diff --git a/Tethering/tests/integration/base/android/net/EthernetTetheringTestBase.java b/Tethering/tests/integration/base/android/net/EthernetTetheringTestBase.java index 0702aa75dacb017a122d00e0bbd2c5c9c7ef2e31..1c4a6629d1ed4145036f35d113512b8274e32de6 100644 --- a/Tethering/tests/integration/base/android/net/EthernetTetheringTestBase.java +++ b/Tethering/tests/integration/base/android/net/EthernetTetheringTestBase.java @@ -366,6 +366,11 @@ public abstract class EthernetTetheringTestBase { private volatile Collection<TetheredClient> mClients = null; private volatile Network mUpstream = null; + // The dnsmasq in R might block netd for 20 seconds, which can also block tethering + // enable/disable for 20 seconds. To fix this, changing the timeouts from 5 seconds to 30 + // seconds. See b/289881008. + private static final int EXPANDED_TIMEOUT_MS = 30000; + MyTetheringEventCallback(TetheringManager tm, String iface) { this(tm, iface, null); mAcceptAnyUpstream = true; @@ -424,13 +429,13 @@ public abstract class EthernetTetheringTestBase { } public void awaitInterfaceTethered() throws Exception { - assertTrue("Ethernet not tethered after " + TIMEOUT_MS + "ms", - mTetheringStartedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)); + assertTrue("Ethernet not tethered after " + EXPANDED_TIMEOUT_MS + "ms", + mTetheringStartedLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS)); } public void awaitInterfaceLocalOnly() throws Exception { - assertTrue("Ethernet not local-only after " + TIMEOUT_MS + "ms", - mLocalOnlyStartedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)); + assertTrue("Ethernet not local-only after " + EXPANDED_TIMEOUT_MS + "ms", + mLocalOnlyStartedLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS)); } // Used to check if the callback has registered. When the callback is registered, @@ -444,8 +449,9 @@ public abstract class EthernetTetheringTestBase { } public void awaitCallbackRegistered() throws Exception { - if (!mCallbackRegisteredLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)) { - fail("Did not receive callback registered signal after " + TIMEOUT_MS + "ms"); + if (!mCallbackRegisteredLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS)) { + fail("Did not receive callback registered signal after " + EXPANDED_TIMEOUT_MS + + "ms"); } } @@ -457,11 +463,11 @@ public abstract class EthernetTetheringTestBase { if (!mInterfaceWasTethered && !mInterfaceWasLocalOnly) return; if (mInterfaceWasTethered) { - assertTrue(mIface + " not untethered after " + TIMEOUT_MS + "ms", - mTetheringStoppedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)); + assertTrue(mIface + " not untethered after " + EXPANDED_TIMEOUT_MS + "ms", + mTetheringStoppedLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS)); } else if (mInterfaceWasLocalOnly) { - assertTrue(mIface + " not untethered after " + TIMEOUT_MS + "ms", - mLocalOnlyStoppedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)); + assertTrue(mIface + " not untethered after " + EXPANDED_TIMEOUT_MS + "ms", + mLocalOnlyStoppedLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS)); } else { fail(mIface + " cannot be both tethered and local-only. Update this test class."); } @@ -488,8 +494,9 @@ public abstract class EthernetTetheringTestBase { } public Collection<TetheredClient> awaitClientConnected() throws Exception { - assertTrue("Did not receive client connected callback after " + TIMEOUT_MS + "ms", - mClientConnectedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)); + assertTrue("Did not receive client connected callback after " + + EXPANDED_TIMEOUT_MS + "ms", + mClientConnectedLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS)); return mClients; } @@ -506,10 +513,10 @@ public abstract class EthernetTetheringTestBase { } public Network awaitUpstreamChanged(boolean throwTimeoutException) throws Exception { - if (!mUpstreamLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)) { + if (!mUpstreamLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS)) { final String errorMessage = "Did not receive upstream " + (mAcceptAnyUpstream ? "any" : mExpectedUpstream) - + " callback after " + TIMEOUT_MS + "ms"; + + " callback after " + EXPANDED_TIMEOUT_MS + "ms"; if (throwTimeoutException) { throw new TimeoutException(errorMessage); diff --git a/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java b/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java index 076fde3829b9c02aca76869a15775e01c5e5477c..4949eaa9e2ae317f6f75f747ba723e14c1d92144 100644 --- a/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java +++ b/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java @@ -47,7 +47,7 @@ import android.os.SystemProperties; import android.util.Log; import androidx.annotation.NonNull; -import androidx.test.filters.MediumTest; +import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import com.android.net.module.util.Ipv6Utils; @@ -79,7 +79,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @RunWith(AndroidJUnit4.class) -@MediumTest +@LargeTest public class EthernetTetheringTest extends EthernetTetheringTestBase { @Rule public final DevSdkIgnoreRule mIgnoreRule = new DevSdkIgnoreRule();