diff options
-rw-r--r-- | tests/integration/src/android/net/ip/IpClientIntegrationTest.java | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/tests/integration/src/android/net/ip/IpClientIntegrationTest.java b/tests/integration/src/android/net/ip/IpClientIntegrationTest.java index 79264a8..5ae4470 100644 --- a/tests/integration/src/android/net/ip/IpClientIntegrationTest.java +++ b/tests/integration/src/android/net/ip/IpClientIntegrationTest.java @@ -449,6 +449,21 @@ public class IpClientIntegrationTest { mNetworkObserverRegistry.register(mNetd); mIpc = new IpClient(mContext, mIfaceName, mCb, mNetworkObserverRegistry, mNetworkStackServiceManager, mDependencies); + + // Tell the IpMemoryStore immediately to answer any question about network attributes with a + // null response. Otherwise, the DHCP client will wait for two seconds before starting, + // while its query to the IpMemoryStore times out. + // This does not affect any test that makes the mock memory store return results, because + // unlike when(), it is documented that doAnswer() can be called more than once, to change + // the behaviour of a mock in the middle of a test. + doAnswer(invocation -> { + final String l2Key = invocation.getArgument(0); + ((OnNetworkAttributesRetrievedListener) invocation.getArgument(1)) + .onNetworkAttributesRetrieved(new Status(SUCCESS), l2Key, null); + return null; + }).when(mIpMemoryStore).retrieveNetworkAttributes(any(), any()); + + disableIpv6ProvisioningDelays(); } private void expectAlarmCancelled(InOrder inOrder, OnAlarmListener listener) { @@ -1328,17 +1343,16 @@ public class IpClientIntegrationTest { return packet; } - private void disableRouterSolicitationDelay() throws Exception { - // Speed up the test by removing router_solicitation_delay. + private void disableIpv6ProvisioningDelays() throws Exception { + // Speed up the test by disabling DAD and removing router_solicitation_delay. // We don't need to restore the default value because the interface is removed in tearDown. - // TODO: speed up further by not waiting for RA but keying off first IPv6 packet. + // TODO: speed up further by not waiting for RS but keying off first IPv6 packet. mNetd.setProcSysNet(INetd.IPV6, INetd.CONF, mIfaceName, "router_solicitation_delay", "0"); + mNetd.setProcSysNet(INetd.IPV6, INetd.CONF, mIfaceName, "dad_transmits", "0"); } @Test public void testRaRdnss() throws Exception { - disableRouterSolicitationDelay(); - ProvisioningConfiguration config = new ProvisioningConfiguration.Builder() .withoutIpReachabilityMonitor() .withoutIPv4() @@ -1407,8 +1421,6 @@ public class IpClientIntegrationTest { public void testPref64Option() throws Exception { assumeTrue(ConstantsShim.VERSION > Build.VERSION_CODES.Q); - disableRouterSolicitationDelay(); - ProvisioningConfiguration config = new ProvisioningConfiguration.Builder() .withoutIpReachabilityMonitor() .withoutIPv4() @@ -1563,8 +1575,6 @@ public class IpClientIntegrationTest { // may be sufficient to call waitForIdle to see if IpClient has seen the address. addIpAddressAndWaitForIt(mIfaceName); - disableRouterSolicitationDelay(); - ProvisioningConfiguration config = new ProvisioningConfiguration.Builder() .withoutIpReachabilityMonitor() .build(); |