summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2020-04-26 04:49:56 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-04-26 04:49:56 +0000
commit966fef81e77d0d226b937ebae722b26ed6132534 (patch)
tree8cdfd21508364dcdae0c60342475d94fe70f1953
parent96ae81c65988eab65d6fefdba88b53ce2c34bc67 (diff)
parent23013b08caa51f26606ad7b90c321b243e7c5e83 (diff)
Speed up IpClientIntegrationTest. am: 23013b08ca
Change-Id: I6d7fd8f10a55e7911997575d4e7f26fa91bf4c1f
-rw-r--r--tests/integration/src/android/net/ip/IpClientIntegrationTest.java28
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();