summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRemi NGUYEN VAN <reminv@google.com>2020-05-26 00:25:52 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-05-26 00:25:52 +0000
commitf9aa3eb62823c22122e56b44ebcc2b8a11ff8f64 (patch)
treeb69082a2064b066d25b0bf4de8237dac647b7e45
parentc44e086024adc06ebb2500e9f9aa8c5143cb9606 (diff)
parentc0816168ec24b1eea73543d2ee398f4cc30bee05 (diff)
Merge "Fix flakes in testMultipleProbes" into rvc-dev am: c0816168ec
Change-Id: Iedbfbcc4363c6285da5348c38daa30dafd16d9d3
-rw-r--r--tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
index dace986..dda7f08 100644
--- a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
+++ b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
@@ -69,6 +69,8 @@ import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -1895,7 +1897,6 @@ public class NetworkMonitorTest {
setStatus(mHttpConnection, 500);
setStatus(mFallbackConnection, 204);
nm.forceReevaluation(Process.myUid());
- final ArgumentCaptor<Integer> intCaptor = ArgumentCaptor.forClass(Integer.class);
// Expect to send HTTP, HTTPs, FALLBACK and evaluation results.
verifyNetworkTested(NETWORK_VALIDATION_RESULT_PARTIAL,
NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_FALLBACK);
@@ -2085,8 +2086,11 @@ public class NetworkMonitorTest {
setPortal302(mOtherHttpConnection1);
runPortalNetworkTest();
// Get conclusive result from one of the HTTP probe. Expect to create 2 HTTP and 2 HTTPS
- // probes as resource configuration.
- verify(mCleartextDnsNetwork, times(4)).openConnection(any());
+ // probes as resource configuration, but the portal can be detected before other probes
+ // start.
+ verify(mCleartextDnsNetwork, atMost(4)).openConnection(any());
+ verify(mCleartextDnsNetwork, atLeastOnce()).openConnection(any());
+ verify(mOtherHttpConnection1).getResponseCode();
}
@Test
@@ -2096,12 +2100,15 @@ public class NetworkMonitorTest {
setStatus(mOtherHttpsConnection2, 204);
runValidatedNetworkTest();
// Get conclusive result from one of the HTTPS probe. Expect to create 2 HTTP and 2 HTTPS
- // probes as resource configuration.
- verify(mCleartextDnsNetwork, times(4)).openConnection(any());
+ // probes as resource configuration, but the network may validate from the HTTPS probe
+ // before other probes start.
+ verify(mCleartextDnsNetwork, atMost(4)).openConnection(any());
+ verify(mCleartextDnsNetwork, atLeastOnce()).openConnection(any());
+ verify(mOtherHttpsConnection2).getResponseCode();
}
@Test
- public void testMultipleProbesOnInValiadNetworkForPrioritizedResource() throws Exception {
+ public void testMultipleProbesOnInValidNetworkForPrioritizedResource() throws Exception {
setupResourceForMultipleProbes();
// The configuration resource is prioritized. Only use configurations from resource.(i.e
// Only configuration for mOtherHttpsConnection2, mOtherHttpsConnection2,
@@ -2110,8 +2117,11 @@ public class NetworkMonitorTest {
setStatus(mHttpsConnection, 204);
runFailedNetworkTest();
// No conclusive result from both HTTP and HTTPS probes. Expect to create 2 HTTP and 2 HTTPS
- // probes as resource configuration.
+ // probes as resource configuration. All probes are expected to have been run because this
+ // network is set to never validate (no probe has a success or portal result), so NM tests
+ // all probes to completion.
verify(mCleartextDnsNetwork, times(4)).openConnection(any());
+ verify(mHttpsConnection, never()).getResponseCode();
}
@Test