summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2018-04-10 16:19:57 -0700
committerxshu <xshu@google.com>2018-04-13 13:15:51 -0700
commit1f2ef2776476457b3eb2df70e39d53770c6b2b77 (patch)
treebac40eb1f8c83835bc2ba3c41755e862d91f68b3 /tests
parent3a2a2a79bce7ce0f8fe4f4f8de6d0ec478532141 (diff)
metrics: count connection failures after watchdog trigger
Sometimes wifi would experience several more connection failures before finally being able to connect after a watchdog restart trigger. Count these failures to get a better understanding of how watchdog is performing. Bug: 75001353 Test: compile, unit test Change-Id: Ibec913c0b2aadfb1aa2390966f4bfd8fff5a2cca
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java40
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java6
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
index 4abc77f91..0cbc06ac2 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
@@ -1810,4 +1810,44 @@ public class WifiLastResortWatchdogTest {
mLooper.dispatchAll();
verify(mWifiStateMachine, times(1)).takeBugReport(anyString(), anyString());
}
+
+
+ /**
+ * Test metrics incrementing connection failure count after watchdog has already been triggered
+ */
+ @Test
+ public void testIncrementingWatchdogConnectionFailuresAfterTrigger() {
+ String[] ssids = {"\"test1\""};
+ String[] bssids = {"6c:f3:7f:ae:8c:f3"};
+ int[] frequencies = {2437};
+ String[] caps = {"[WPA2-EAP-CCMP][ESS]"};
+ int[] levels = {-60};
+ boolean[] isEphemeral = {false};
+ boolean[] hasEverConnected = {true};
+ List<Pair<ScanDetail, WifiConfiguration>> candidates = createFilteredQnsCandidates(ssids,
+ bssids, frequencies, caps, levels, isEphemeral, hasEverConnected);
+ mLastResortWatchdog.updateAvailableNetworks(candidates);
+
+ // Ensure new networks have zero'ed failure counts
+ for (int i = 0; i < ssids.length; i++) {
+ assertFailureCountEquals(bssids[i], 0, 0, 0);
+ }
+
+ //Increment failure counts
+ for (int i = 0; i < WifiLastResortWatchdog.FAILURE_THRESHOLD; i++) {
+ mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded(
+ ssids[0], bssids[0], WifiLastResortWatchdog.FAILURE_CODE_ASSOCIATION);
+ }
+
+ // Verify relevant WifiMetrics calls were made once with appropriate arguments
+ verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogTriggers();
+
+ // Verify that failure count after trigger is not incremented yet
+ verify(mWifiMetrics, never()).incrementWatchdogTotalConnectionFailureCountAfterTrigger();
+
+ // Fail 1 more time and verify this time it's counted
+ mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded(
+ ssids[0], bssids[0], WifiLastResortWatchdog.FAILURE_CODE_ASSOCIATION);
+ verify(mWifiMetrics, times(1)).incrementWatchdogTotalConnectionFailureCountAfterTrigger();
+ }
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index c31ecb03d..c61db7693 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -228,6 +228,7 @@ public class WifiMetricsTest {
private static final int NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_DHCP = 9;
private static final int NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_OTHER = 10;
private static final int NUM_LAST_RESORT_WATCHDOG_SUCCESSES = 5;
+ private static final int WATCHDOG_TOTAL_CONNECTION_FAILURE_COUNT_AFTER_TRIGGER = 6;
private static final int NUM_RSSI_LEVELS_TO_INCREMENT = 20;
private static final int FIRST_RSSI_LEVEL = -80;
private static final int NUM_OPEN_NETWORK_SCAN_RESULTS = 1;
@@ -473,6 +474,9 @@ public class WifiMetricsTest {
for (int i = 0; i < NUM_LAST_RESORT_WATCHDOG_SUCCESSES; i++) {
mWifiMetrics.incrementNumLastResortWatchdogSuccesses();
}
+ for (int i = 0; i < WATCHDOG_TOTAL_CONNECTION_FAILURE_COUNT_AFTER_TRIGGER; i++) {
+ mWifiMetrics.incrementWatchdogTotalConnectionFailureCountAfterTrigger();
+ }
for (int i = 0; i < NUM_RSSI_LEVELS_TO_INCREMENT; i++) {
for (int j = 0; j <= i; j++) {
mWifiMetrics.incrementRssiPollRssiCount(MIN_RSSI_LEVEL + i);
@@ -775,6 +779,8 @@ public class WifiMetricsTest {
mDecodedProto.numLastResortWatchdogTriggersWithBadOther);
assertEquals(NUM_LAST_RESORT_WATCHDOG_SUCCESSES,
mDecodedProto.numLastResortWatchdogSuccesses);
+ assertEquals(WATCHDOG_TOTAL_CONNECTION_FAILURE_COUNT_AFTER_TRIGGER,
+ mDecodedProto.watchdogTotalConnectionFailureCountAfterTrigger);
assertEquals(TEST_RECORD_DURATION_SEC,
mDecodedProto.recordDurationSec);
for (int i = 0; i < NUM_RSSI_LEVELS_TO_INCREMENT; i++) {