summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-05-14 11:23:12 -0700
committerNate Jiang <qiangjiang@google.com>2020-05-15 16:16:32 -0700
commit7b4125f23cb847b53f6cacbe67050a16c688c6a4 (patch)
tree751893967e5a5613b946cf0d64718d0a8a676cdd /tests
parent38facc3b2590107a404f2e824fca867afbdd2b92 (diff)
[Metrics] Add Rtt measurement duration metrics
Updated-PDD: TRUE Bug: 131708995 Test: atest com.android.server.wifi Change-Id: Ib12fd6c730df726df7b3c80dd8f685df4e245922
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/rtt/RttMetricsTest.java60
-rw-r--r--tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java45
2 files changed, 68 insertions, 37 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/rtt/RttMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/rtt/RttMetricsTest.java
index a989f0903..937585610 100644
--- a/tests/wifitests/src/com/android/server/wifi/rtt/RttMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/rtt/RttMetricsTest.java
@@ -77,7 +77,7 @@ public class RttMetricsTest extends WifiBaseTest {
// no requests
log = mDut.consolidateProto();
- checkMainStats("No requests", log, 0, 0);
+ checkMainStats("No requests", log, 0, 0, 0, 0);
checkPeerStats("No requests: AP", log.rttToAp, 0, 0, 0, 0, 0, 0, 0, 0);
checkPeerStats("No requests: Aware", log.rttToAware, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -110,7 +110,7 @@ public class RttMetricsTest extends WifiBaseTest {
mDut.recordRequest(ws2, requestAp5);
log = mDut.consolidateProto();
- checkMainStats("Sequence AP-only", log, 10, 0);
+ checkMainStats("Sequence AP-only", log, 10, 0, 0, 0);
checkPeerStats("Sequence AP-only: AP", log.rttToAp, 10, 41, 2, 2, 4, 0, 0, 5);
@@ -162,7 +162,7 @@ public class RttMetricsTest extends WifiBaseTest {
mDut.recordRequest(ws3, requestMixed08);
log = mDut.consolidateProto();
- checkMainStats("Sequence Mixed AP/Aware", log, 4, 0);
+ checkMainStats("Sequence Mixed AP/Aware", log, 4, 0, 0, 0);
checkPeerStats("Sequence Mixed AP/Aware: AP", log.rttToAp, 2, 7, 3, 1, 2, 0, 0, 1);
@@ -205,7 +205,7 @@ public class RttMetricsTest extends WifiBaseTest {
// no requests
log = mDut.consolidateProto();
- checkMainStats("No requests", log, 0, 0);
+ checkMainStats("No requests", log, 0, 0, 0, 0);
checkPeerStats("No requests: AP", log.rttToAp, 0, 0, 0, 0, 0, 0, 0, 0);
checkPeerStats("No requests: Aware", log.rttToAware, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -217,19 +217,23 @@ public class RttMetricsTest extends WifiBaseTest {
mDut.clear();
mDut.recordResult(requestAp1, getDummyRangingResults(RttNative.FRAMEWORK_RTT_STATUS_SUCCESS,
- requestAp1, 5, 0));
+ requestAp1, 5, 0), 500);
mDut.recordResult(requestAp2, getDummyRangingResults(RttNative.FRAMEWORK_RTT_STATUS_SUCCESS,
- requestAp2, 10, 30));
+ requestAp2, 10, 30), 1500);
mDut.recordResult(requestAp5, getDummyRangingResults(RttNative.FRAMEWORK_RTT_STATUS_SUCCESS,
- requestAp5, 0.3, -0.2));
+ requestAp5, 0.3, -0.2), 700);
mDut.recordResult(requestAp6, getDummyRangingResults(RttNative.FRAMEWORK_RTT_STATUS_SUCCESS,
- requestAp6, 40, 30));
+ requestAp6, 40, 30), 1800);
log = mDut.consolidateProto();
- checkMainStats("Sequence AP-only", log, 0, 0);
-
+ checkMainStats("Sequence AP-only", log, 0, 0, 2, 0);
checkPeerStats("Sequence AP-only: AP", log.rttToAp, 0, 0, 0, 0, 0, 1, 6, 0);
+ validateProtoHistBucket("Sequence AP-only: histogramMeasurementDurationApOnly[0]",
+ log.histogramMeasurementDurationApOnly[0], Integer.MIN_VALUE, 1 * 1000, 2);
+ validateProtoHistBucket("Sequence AP-only: histogramMeasurementDurationApOnly[1]",
+ log.histogramMeasurementDurationApOnly[1], 1 * 1000, 2 * 1000, 2);
+
validateProtoIndividualStatusHistBucket(
"Sequence AP-only: rttToAp.histogramIndividualStatus[0]",
log.rttToAp.histogramIndividualStatus[0], WifiMetricsProto.WifiRttLog.SUCCESS, 14);
@@ -257,19 +261,26 @@ public class RttMetricsTest extends WifiBaseTest {
mDut.clear();
mDut.recordResult(requestMixed03, getDummyRangingResults(
- RttNative.FRAMEWORK_RTT_STATUS_SUCCESS, requestMixed03, 5, 0));
+ RttNative.FRAMEWORK_RTT_STATUS_SUCCESS, requestMixed03, 5, 0), 6400);
mDut.recordResult(requestMixed25, getDummyRangingResults(
- RttNative.FRAMEWORK_RTT_STATUS_SUCCESS, requestMixed25, 10, 30));
+ RttNative.FRAMEWORK_RTT_STATUS_SUCCESS, requestMixed25, 10, 30), 7800);
mDut.recordResult(requestMixed50, getDummyRangingResults(
- RttNative.FRAMEWORK_RTT_STATUS_SUCCESS, requestMixed50, 0.3, -0.2));
+ RttNative.FRAMEWORK_RTT_STATUS_SUCCESS, requestMixed50, 0.3, -0.2), 3100);
mDut.recordResult(requestMixed08, getDummyRangingResults(
- RttNative.FRAMEWORK_RTT_STATUS_SUCCESS, requestMixed08, 40, 30));
+ RttNative.FRAMEWORK_RTT_STATUS_SUCCESS, requestMixed08, 40, 30), 9500);
log = mDut.consolidateProto();
- checkMainStats("Sequence Mixed AP/Aware", log, 0, 0);
+ checkMainStats("Sequence Mixed AP/Aware", log, 0, 0, 1, 2);
checkPeerStats("Sequence Mixed AP/Aware: AP", log.rttToAp, 0, 0, 0, 0, 0, 1, 4, 0);
+ validateProtoHistBucket("Sequence Mixed AP/Aware: histogramMeasurementDurationApOnly[0]",
+ log.histogramMeasurementDurationApOnly[0], 3 * 1000, 4 * 1000, 1);
+ validateProtoHistBucket("Sequence Mixed AP/Aware: histogramMeasurementDurationWithAware[0]",
+ log.histogramMeasurementDurationWithAware[0], 6 * 1000, 8 * 1000, 2);
+ validateProtoHistBucket("Sequence Mixed AP/Aware: histogramMeasurementDurationWithAware[1]",
+ log.histogramMeasurementDurationWithAware[1], 8 * 1000, Integer.MAX_VALUE, 1);
+
validateProtoIndividualStatusHistBucket(
"Sequence Mixed AP/Aware: rttToAp.histogramIndividualStatus[0]",
log.rttToAp.histogramIndividualStatus[0], WifiMetricsProto.WifiRttLog.SUCCESS, 7);
@@ -315,11 +326,11 @@ public class RttMetricsTest extends WifiBaseTest {
resultMixed25.remove(3); // Second Aware result: distance = 100
resultMixed25.remove(0); // First AP result: distance = 10
resultMixed25.add(null);
- mDut.recordResult(requestMixed25, resultMixed25);
+ mDut.recordResult(requestMixed25, resultMixed25, 0);
log = mDut.consolidateProto();
- checkMainStats("Sequence Mixed AP/Aware", log, 0, 0);
+ checkMainStats("Sequence Mixed AP/Aware", log, 0, 0, 0, 1);
checkPeerStats("Sequence Mixed AP/Aware: AP", log.rttToAp, 0, 0, 0, 0, 0, 2, 1, 0);
@@ -360,11 +371,11 @@ public class RttMetricsTest extends WifiBaseTest {
mDut.clear();
RangingRequest requestMixed25 = getDummyRangingRequest(2, 5);
- mDut.recordResult(requestMixed25, null);
+ mDut.recordResult(requestMixed25, null, 0);
log = mDut.consolidateProto();
- checkMainStats("Sequence Mixed AP/Aware", log, 0, 0);
+ checkMainStats("Sequence Mixed AP/Aware", log, 0, 0, 0, 0);
checkPeerStats("Sequence Mixed AP/Aware: AP", log.rttToAp, 0, 0, 0, 0, 0, 1, 0, 0);
@@ -538,11 +549,18 @@ public class RttMetricsTest extends WifiBaseTest {
}
private void checkMainStats(String msgPrefix, WifiMetricsProto.WifiRttLog log, int numRequests,
- int histogramOverallStatusLength) {
+ int histogramOverallStatusLength, int histogramMeasurementDurationApOnlyLength,
+ int histogramMeasurementDurationWithAwareLength) {
collector.checkThat(msgPrefix + ": numRequests", log.numRequests, equalTo(numRequests));
collector.checkThat(msgPrefix + ": histogramOverallStatus.length",
log.histogramOverallStatus.length,
equalTo(histogramOverallStatusLength));
+ collector.checkThat(msgPrefix + ": histogramMeasurementDurationApOnly.length",
+ log.histogramMeasurementDurationApOnly.length,
+ equalTo(histogramMeasurementDurationApOnlyLength));
+ collector.checkThat(msgPrefix + ": histogramMeasurementDurationWithAware.length",
+ log.histogramMeasurementDurationWithAware.length,
+ equalTo(histogramMeasurementDurationWithAwareLength));
}
private void checkPeerStats(String msgPrefix, WifiMetricsProto.WifiRttLog.RttToPeerLog log,
@@ -605,7 +623,7 @@ public class RttMetricsTest extends WifiBaseTest {
List<RangingResult> results = getDummyRangingResults(status, request, 0, 0);
for (int i = 0; i < n; ++i) {
- mDut.recordResult(request, results);
+ mDut.recordResult(request, results, 0);
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java
index 437f46a75..687c24f52 100644
--- a/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java
@@ -103,6 +103,7 @@ import java.util.Set;
public class RttServiceImplTest extends WifiBaseTest {
private static final int BACKGROUND_PROCESS_EXEC_GAP_MS = 10 * 60 * 1000; // 10 minutes.
+ private static final int MEASUREMENT_DURATION = 1000;
private RttServiceImplSpy mDut;
private TestLooper mMockLooper;
@@ -265,6 +266,9 @@ public class RttServiceImplTest extends WifiBaseTest {
results.add(RttTestUtils.getDummyRangingResults(requests[i]));
}
+ ClockAnswer clock = new ClockAnswer();
+ doAnswer(clock).when(mockClock).getWallClockMillis();
+ clock.time = 100;
// (1) request 10 ranging operations
for (int i = 0; i < numIter; ++i) {
mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, requests[i],
@@ -273,6 +277,7 @@ public class RttServiceImplTest extends WifiBaseTest {
mMockLooper.dispatchAll();
for (int i = 0; i < numIter; ++i) {
+ clock.time += MEASUREMENT_DURATION;
// (2) verify that request issued to native
verify(mockNative).rangeRequest(mIntCaptor.capture(), eq(requests[i]), eq(true));
verifyWakeupSet(i % 2 != 0, 0);
@@ -293,7 +298,8 @@ public class RttServiceImplTest extends WifiBaseTest {
// verify metrics
for (int i = 0; i < numIter; ++i) {
verify(mockMetrics).recordRequest(eq(mDefaultWs), eq(requests[i]));
- verify(mockMetrics).recordResult(eq(requests[i]), eq(results.get(i).second));
+ verify(mockMetrics).recordResult(eq(requests[i]), eq(results.get(i).second),
+ eq(MEASUREMENT_DURATION));
}
verify(mockMetrics, times(numIter)).recordOverallStatus(
WifiMetricsProto.WifiRttLog.OVERALL_SUCCESS);
@@ -327,6 +333,9 @@ public class RttServiceImplTest extends WifiBaseTest {
doAnswer(answer).when(mockAwareManager).requestMacAddresses(anyInt(), any(), any());
// issue request
+ ClockAnswer clock = new ClockAnswer();
+ doAnswer(clock).when(mockClock).getWallClockMillis();
+ clock.time = 100;
mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request, mockCallback);
mMockLooper.dispatchAll();
@@ -351,6 +360,7 @@ public class RttServiceImplTest extends WifiBaseTest {
results.second.add(
new RangingResult(RangingResult.STATUS_FAIL, removed.getPeerHandle(), 0, 0, 0, 0, 0,
null, null, null, 0));
+ clock.time += MEASUREMENT_DURATION;
mDut.onRangingResults(mIntCaptor.getValue(), results.first);
mMockLooper.dispatchAll();
@@ -364,7 +374,8 @@ public class RttServiceImplTest extends WifiBaseTest {
// verify metrics
verify(mockMetrics).recordRequest(eq(mDefaultWs), eq(request));
- verify(mockMetrics).recordResult(eq(finalRequest), eq(results.first));
+ verify(mockMetrics).recordResult(eq(finalRequest), eq(results.first),
+ eq(MEASUREMENT_DURATION));
verify(mockMetrics).recordOverallStatus(WifiMetricsProto.WifiRttLog.OVERALL_SUCCESS);
verify(mockNative, atLeastOnce()).isReady();
@@ -426,7 +437,8 @@ public class RttServiceImplTest extends WifiBaseTest {
for (int i = 0; i < numIter; ++i) {
verify(mockMetrics).recordRequest(eq(mDefaultWs), eq(requests[i]));
if (i != 0) {
- verify(mockMetrics).recordResult(eq(requests[i]), eq(results.get(i).second));
+ verify(mockMetrics).recordResult(eq(requests[i]), eq(results.get(i).second),
+ anyInt());
}
}
verify(mockMetrics).recordOverallStatus(WifiMetricsProto.WifiRttLog.OVERALL_HAL_FAILURE);
@@ -545,7 +557,8 @@ public class RttServiceImplTest extends WifiBaseTest {
verify(mockMetrics).recordRequest(eq((i % 2) == 0 ? mDefaultWs : oddWs),
eq(requests[i]));
if (i % 2 == 1) {
- verify(mockMetrics).recordResult(eq(requests[i]), eq(results.get(i).second));
+ verify(mockMetrics).recordResult(eq(requests[i]), eq(results.get(i).second),
+ anyInt());
}
}
verify(mockMetrics, times(numIter / 2)).recordOverallStatus(
@@ -688,7 +701,7 @@ public class RttServiceImplTest extends WifiBaseTest {
verifyWakeupCancelled();
// verify metrics
- verify(mockMetrics).recordResult(eq(request), eq(results.second));
+ verify(mockMetrics).recordResult(eq(request), eq(results.second), anyInt());
verify(mockMetrics).recordOverallStatus(WifiMetricsProto.WifiRttLog.OVERALL_SUCCESS);
verify(mockNative, atLeastOnce()).isReady();
@@ -729,7 +742,7 @@ public class RttServiceImplTest extends WifiBaseTest {
// verify metrics
verify(mockMetrics).recordRequest(eq(mDefaultWs), eq(request));
- verify(mockMetrics).recordResult(eq(request), eq(results.second));
+ verify(mockMetrics).recordResult(eq(request), eq(results.second), anyInt());
verify(mockMetrics).recordOverallStatus(WifiMetricsProto.WifiRttLog.OVERALL_SUCCESS);
verify(mockNative, atLeastOnce()).isReady();
@@ -776,7 +789,7 @@ public class RttServiceImplTest extends WifiBaseTest {
// verify metrics
verify(mockMetrics).recordRequest(eq(mDefaultWs), eq(request));
- verify(mockMetrics).recordResult(eq(request), eq(results.second));
+ verify(mockMetrics).recordResult(eq(request), eq(results.second), anyInt());
verify(mockMetrics).recordOverallStatus(WifiMetricsProto.WifiRttLog.OVERALL_SUCCESS);
verify(mockNative, atLeastOnce()).isReady();
@@ -819,7 +832,7 @@ public class RttServiceImplTest extends WifiBaseTest {
// verify metrics
verify(mockMetrics).recordRequest(eq(mDefaultWs), eq(request));
- verify(mockMetrics).recordResult(eq(request), eq(new ArrayList<>()));
+ verify(mockMetrics).recordResult(eq(request), eq(new ArrayList<>()), anyInt());
verify(mockMetrics).recordOverallStatus(WifiMetricsProto.WifiRttLog.OVERALL_SUCCESS);
verify(mockNative, atLeastOnce()).isReady();
@@ -872,7 +885,7 @@ public class RttServiceImplTest extends WifiBaseTest {
// verify metrics
verify(mockMetrics).recordRequest(eq(mDefaultWs), eq(request));
- verify(mockMetrics).recordResult(eq(request), eq(results.second));
+ verify(mockMetrics).recordResult(eq(request), eq(results.second), anyInt());
verify(mockMetrics).recordOverallStatus(WifiMetricsProto.WifiRttLog.OVERALL_SUCCESS);
verify(mockNative, atLeastOnce()).isReady();
@@ -925,7 +938,7 @@ public class RttServiceImplTest extends WifiBaseTest {
// verify metrics
verify(mockMetrics).recordRequest(eq(mDefaultWs), eq(request1));
verify(mockMetrics).recordRequest(eq(mDefaultWs), eq(request2));
- verify(mockMetrics).recordResult(eq(request2), eq(result2.second));
+ verify(mockMetrics).recordResult(eq(request2), eq(result2.second), anyInt());
verify(mockMetrics).recordOverallStatus(WifiMetricsProto.WifiRttLog.OVERALL_TIMEOUT);
verify(mockMetrics).recordOverallStatus(WifiMetricsProto.WifiRttLog.OVERALL_SUCCESS);
@@ -1035,9 +1048,9 @@ public class RttServiceImplTest extends WifiBaseTest {
verify(mockMetrics).recordRequest(eq(mDefaultWs), eq(request3));
verify(mockMetrics).recordRequest(eq(mDefaultWs), eq(request4));
verify(mockMetrics).recordRequest(eq(mDefaultWs), eq(request5));
- verify(mockMetrics).recordResult(eq(request1), eq(result1.second));
- verify(mockMetrics).recordResult(eq(request3), eq(result3.second));
- verify(mockMetrics).recordResult(eq(request4), eq(result4.second));
+ verify(mockMetrics).recordResult(eq(request1), eq(result1.second), anyInt());
+ verify(mockMetrics).recordResult(eq(request3), eq(result3.second), anyInt());
+ verify(mockMetrics).recordResult(eq(request4), eq(result4.second), anyInt());
verify(mockMetrics, times(2)).recordOverallStatus(
WifiMetricsProto.WifiRttLog.OVERALL_THROTTLE);
verify(mockMetrics, times(3)).recordOverallStatus(
@@ -1137,8 +1150,8 @@ public class RttServiceImplTest extends WifiBaseTest {
verify(mockMetrics).recordRequest(eq(wsReq1), eq(request1));
verify(mockMetrics).recordRequest(eq(wsReq2), eq(request2));
verify(mockMetrics).recordRequest(eq(wsReq1), eq(request3));
- verify(mockMetrics).recordResult(eq(request1), eq(result1.second));
- verify(mockMetrics).recordResult(eq(request2), eq(result2.second));
+ verify(mockMetrics).recordResult(eq(request1), eq(result1.second), anyInt());
+ verify(mockMetrics).recordResult(eq(request2), eq(result2.second), anyInt());
verify(mockMetrics).recordOverallStatus(WifiMetricsProto.WifiRttLog.OVERALL_THROTTLE);
verify(mockMetrics, times(2)).recordOverallStatus(
WifiMetricsProto.WifiRttLog.OVERALL_SUCCESS);
@@ -1293,7 +1306,7 @@ public class RttServiceImplTest extends WifiBaseTest {
// verify metrics
verify(mockMetrics, times(RttServiceImpl.MAX_QUEUED_PER_UID + 12)).recordRequest(
eq(useUids ? mDefaultWs : ws), eq(request));
- verify(mockMetrics).recordResult(eq(request), eq(result.second));
+ verify(mockMetrics).recordResult(eq(request), eq(result.second), anyInt());
verify(mockMetrics, times(11)).recordOverallStatus(
WifiMetricsProto.WifiRttLog.OVERALL_THROTTLE);
verify(mockMetrics, times(RttServiceImpl.MAX_QUEUED_PER_UID)).recordOverallStatus(