diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2020-04-26 15:02:40 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-04-26 15:02:40 +0000 |
commit | 8129d8f145f86eb98b8f1e5ae5fa88cdb2b46e91 (patch) | |
tree | 798ce0e7d00f53133ef7a2726ab4505c353487f8 | |
parent | 966fef81e77d0d226b937ebae722b26ed6132534 (diff) | |
parent | 60422b52f80154447b25987f13517427d8f6e5b2 (diff) |
Deflake testRaRdnss. am: 60422b52f8
Change-Id: I0dc62bda526e72c23e53f15f2547030933a07fc3
-rw-r--r-- | tests/integration/src/android/net/ip/IpClientIntegrationTest.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/integration/src/android/net/ip/IpClientIntegrationTest.java b/tests/integration/src/android/net/ip/IpClientIntegrationTest.java index 5ae4470..59bebb1 100644 --- a/tests/integration/src/android/net/ip/IpClientIntegrationTest.java +++ b/tests/integration/src/android/net/ip/IpClientIntegrationTest.java @@ -1370,27 +1370,37 @@ public class IpClientIntegrationTest { waitForRouterSolicitation(); mPacketReader.sendResponse(ra); + InOrder inOrder = inOrder(mCb); + ArgumentCaptor<LinkProperties> captor = ArgumentCaptor.forClass(LinkProperties.class); - verify(mCb, timeout(TEST_TIMEOUT_MS)).onProvisioningSuccess(captor.capture()); + inOrder.verify(mCb, timeout(TEST_TIMEOUT_MS)).onProvisioningSuccess(captor.capture()); LinkProperties lp = captor.getValue(); + // Sometimes provisioning completes as soon as the link-local and the stable address appear, + // before the privacy address appears. If so, wait here for the LinkProperties update that + // contains the privacy address. Otherwise, future calls to verify() might get confused. + // TODO: move this code to a more general startIpv6Provisioning method so we can write more + // IPv6 tests without duplicating this complexity. + if (lp.getLinkAddresses().size() == 2) { + inOrder.verify(mCb, timeout(TEST_TIMEOUT_MS)).onLinkPropertiesChange( + argThat(x -> x.getLinkAddresses().size() == 3)); + } + // Expect that DNS servers with lifetimes below CONFIG_MIN_RDNSS_LIFETIME are not accepted. assertNotNull(lp); assertEquals(1, lp.getDnsServers().size()); assertTrue(lp.getDnsServers().contains(InetAddress.getByName(dnsServer))); - reset(mCb); // If the RDNSS lifetime is above the minimum, the DNS server is accepted. rdnss1 = buildRdnssOption(68, lowlifeDnsServer); ra = buildRaPacket(pio, rdnss1, rdnss2); mPacketReader.sendResponse(ra); - verify(mCb, timeout(TEST_TIMEOUT_MS)).onLinkPropertiesChange(captor.capture()); + inOrder.verify(mCb, timeout(TEST_TIMEOUT_MS)).onLinkPropertiesChange(captor.capture()); lp = captor.getValue(); assertNotNull(lp); assertEquals(2, lp.getDnsServers().size()); assertTrue(lp.getDnsServers().contains(InetAddress.getByName(dnsServer))); assertTrue(lp.getDnsServers().contains(InetAddress.getByName(lowlifeDnsServer))); - reset(mCb); // Expect that setting RDNSS lifetime of 0 causes loss of provisioning. rdnss1 = buildRdnssOption(0, dnsServer); @@ -1398,7 +1408,7 @@ public class IpClientIntegrationTest { ra = buildRaPacket(pio, rdnss1, rdnss2); mPacketReader.sendResponse(ra); - verify(mCb, timeout(TEST_TIMEOUT_MS)).onProvisioningFailure(captor.capture()); + inOrder.verify(mCb, timeout(TEST_TIMEOUT_MS)).onProvisioningFailure(captor.capture()); lp = captor.getValue(); assertNotNull(lp); assertEquals(0, lp.getDnsServers().size()); |