diff options
| author | 2018-07-24 22:50:56 -0700 | |
|---|---|---|
| committer | 2018-07-24 22:50:56 -0700 | |
| commit | 12ba6bcc73280a852fc91908f2795102f565a285 (patch) | |
| tree | b999e0922e64a02d72778118a106857c04ecda46 | |
| parent | d673f4f271670fc5dd1e73d85b9a6009e052605e (diff) | |
| parent | 43b12f57f787ca2755b16bda3abb85a2eba251ab (diff) | |
Merge "Increase TEST_LINGER_DELAY_MS" am: 9a783699cc am: 93c22129e2 am: d2339214eb
am: 43b12f57f7
Change-Id: Iffd1ea689a9cedee4252836de208b506290c067b
| -rw-r--r-- | tests/net/java/com/android/server/ConnectivityServiceTest.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java index dbf81d69e50c..6fb36513a8ed 100644 --- a/tests/net/java/com/android/server/ConnectivityServiceTest.java +++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java @@ -1465,9 +1465,11 @@ public class ConnectivityServiceTest { * received. assertNoCallback may be called at any time. */ private class TestNetworkCallback extends NetworkCallback { - // Chosen to be much less than the linger timeout. This ensures that we can distinguish + // Chosen to be less than the linger timeout. This ensures that we can distinguish // between a LOST callback that arrives immediately and a LOST callback that arrives after - // the linger timeout. + // the linger timeout. For this, our assertions should run fast enough to leave less than + // (mService.mLingerDelayMs - TIMEOUT_MS) between the time callbacks are supposedly fired, + // and the time we call expectCallback. private final static int TIMEOUT_MS = 100; private final LinkedBlockingQueue<CallbackInfo> mCallbacks = new LinkedBlockingQueue<>(); @@ -1545,9 +1547,9 @@ public class ConnectivityServiceTest { if (state == CallbackState.LOSING) { String msg = String.format( "Invalid linger time value %d, must be between %d and %d", - actual.arg, 0, TEST_LINGER_DELAY_MS); + actual.arg, 0, mService.mLingerDelayMs); int maxMsToLive = (Integer) actual.arg; - assertTrue(msg, 0 <= maxMsToLive && maxMsToLive <= TEST_LINGER_DELAY_MS); + assertTrue(msg, 0 <= maxMsToLive && maxMsToLive <= mService.mLingerDelayMs); } return actual; @@ -1769,6 +1771,12 @@ public class ConnectivityServiceTest { @Test public void testMultipleLingering() { + // This test would be flaky with the default 120ms timer: that is short enough that + // lingered networks are torn down before assertions can be run. We don't want to mock the + // lingering timer to keep the WakeupMessage logic realistic: this has already proven useful + // in detecting races. + mService.mLingerDelayMs = 300; + NetworkRequest request = new NetworkRequest.Builder() .clearCapabilities().addCapability(NET_CAPABILITY_NOT_METERED) .build(); @@ -1986,7 +1994,7 @@ public class ConnectivityServiceTest { // Let linger run its course. callback.assertNoCallback(); - final int lingerTimeoutMs = TEST_LINGER_DELAY_MS + TEST_LINGER_DELAY_MS / 4; + final int lingerTimeoutMs = mService.mLingerDelayMs + mService.mLingerDelayMs / 4; callback.expectCallback(CallbackState.LOST, mCellNetworkAgent, lingerTimeoutMs); // Register a TRACK_DEFAULT request and check that it does not affect lingering. |