Merge "Extend tethering enable/disable timeout to 30 seconds" into main
This commit is contained in:
@@ -366,6 +366,11 @@ public abstract class EthernetTetheringTestBase {
|
|||||||
private volatile Collection<TetheredClient> mClients = null;
|
private volatile Collection<TetheredClient> mClients = null;
|
||||||
private volatile Network mUpstream = 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) {
|
MyTetheringEventCallback(TetheringManager tm, String iface) {
|
||||||
this(tm, iface, null);
|
this(tm, iface, null);
|
||||||
mAcceptAnyUpstream = true;
|
mAcceptAnyUpstream = true;
|
||||||
@@ -424,13 +429,13 @@ public abstract class EthernetTetheringTestBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void awaitInterfaceTethered() throws Exception {
|
public void awaitInterfaceTethered() throws Exception {
|
||||||
assertTrue("Ethernet not tethered after " + TIMEOUT_MS + "ms",
|
assertTrue("Ethernet not tethered after " + EXPANDED_TIMEOUT_MS + "ms",
|
||||||
mTetheringStartedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
|
mTetheringStartedLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void awaitInterfaceLocalOnly() throws Exception {
|
public void awaitInterfaceLocalOnly() throws Exception {
|
||||||
assertTrue("Ethernet not local-only after " + TIMEOUT_MS + "ms",
|
assertTrue("Ethernet not local-only after " + EXPANDED_TIMEOUT_MS + "ms",
|
||||||
mLocalOnlyStartedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
|
mLocalOnlyStartedLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to check if the callback has registered. When the callback is registered,
|
// 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 {
|
public void awaitCallbackRegistered() throws Exception {
|
||||||
if (!mCallbackRegisteredLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
|
if (!mCallbackRegisteredLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
|
||||||
fail("Did not receive callback registered signal after " + TIMEOUT_MS + "ms");
|
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 && !mInterfaceWasLocalOnly) return;
|
||||||
|
|
||||||
if (mInterfaceWasTethered) {
|
if (mInterfaceWasTethered) {
|
||||||
assertTrue(mIface + " not untethered after " + TIMEOUT_MS + "ms",
|
assertTrue(mIface + " not untethered after " + EXPANDED_TIMEOUT_MS + "ms",
|
||||||
mTetheringStoppedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
|
mTetheringStoppedLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS));
|
||||||
} else if (mInterfaceWasLocalOnly) {
|
} else if (mInterfaceWasLocalOnly) {
|
||||||
assertTrue(mIface + " not untethered after " + TIMEOUT_MS + "ms",
|
assertTrue(mIface + " not untethered after " + EXPANDED_TIMEOUT_MS + "ms",
|
||||||
mLocalOnlyStoppedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
|
mLocalOnlyStoppedLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS));
|
||||||
} else {
|
} else {
|
||||||
fail(mIface + " cannot be both tethered and local-only. Update this test class.");
|
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 {
|
public Collection<TetheredClient> awaitClientConnected() throws Exception {
|
||||||
assertTrue("Did not receive client connected callback after " + TIMEOUT_MS + "ms",
|
assertTrue("Did not receive client connected callback after "
|
||||||
mClientConnectedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
|
+ EXPANDED_TIMEOUT_MS + "ms",
|
||||||
|
mClientConnectedLatch.await(EXPANDED_TIMEOUT_MS, TimeUnit.MILLISECONDS));
|
||||||
return mClients;
|
return mClients;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,10 +513,10 @@ public abstract class EthernetTetheringTestBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Network awaitUpstreamChanged(boolean throwTimeoutException) throws Exception {
|
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 "
|
final String errorMessage = "Did not receive upstream "
|
||||||
+ (mAcceptAnyUpstream ? "any" : mExpectedUpstream)
|
+ (mAcceptAnyUpstream ? "any" : mExpectedUpstream)
|
||||||
+ " callback after " + TIMEOUT_MS + "ms";
|
+ " callback after " + EXPANDED_TIMEOUT_MS + "ms";
|
||||||
|
|
||||||
if (throwTimeoutException) {
|
if (throwTimeoutException) {
|
||||||
throw new TimeoutException(errorMessage);
|
throw new TimeoutException(errorMessage);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ import android.os.SystemProperties;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.test.filters.MediumTest;
|
import androidx.test.filters.LargeTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import com.android.net.module.util.Ipv6Utils;
|
import com.android.net.module.util.Ipv6Utils;
|
||||||
@@ -79,7 +79,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@MediumTest
|
@LargeTest
|
||||||
public class EthernetTetheringTest extends EthernetTetheringTestBase {
|
public class EthernetTetheringTest extends EthernetTetheringTestBase {
|
||||||
@Rule
|
@Rule
|
||||||
public final DevSdkIgnoreRule mIgnoreRule = new DevSdkIgnoreRule();
|
public final DevSdkIgnoreRule mIgnoreRule = new DevSdkIgnoreRule();
|
||||||
|
|||||||
Reference in New Issue
Block a user