Fix flaky CtsHostsideNetworkTests.
'set metered-network' adb command is not blocking, it doesn't
wait for the network to be marked as metered. Updated test
to sleep and poll for metered status.
Bug: 64274313
Test: cts-tradefed run singleCommand cts-dev -m CtsHostsideNetworkTests \
-t com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Change-Id: Ide3e1633167979bdca912c1c299ad17d988b537e
This commit is contained in:
@@ -612,11 +612,15 @@ abstract class AbstractRestrictBackgroundNetworkTestCase extends Instrumentation
|
||||
NetworkInfo info = null;
|
||||
for (int i = 1; i <= maxTries; i++) {
|
||||
info = mCm.getActiveNetworkInfo();
|
||||
if (info != null) {
|
||||
if (info == null) {
|
||||
Log.v(TAG, "No active network info on attempt #" + i
|
||||
+ "; sleeping 1s before polling again");
|
||||
} else if (mCm.isActiveNetworkMetered() != expected) {
|
||||
Log.v(TAG, "Wrong metered status for active network " + info + "; expected="
|
||||
+ expected + "; sleeping 1s before polling again");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
Log.v(TAG, "No active network info on attempt #" + i
|
||||
+ "; sleeping 1s before polling again");
|
||||
Thread.sleep(SECOND_IN_MS);
|
||||
}
|
||||
assertNotNull("No active network after " + maxTries + " attempts", info);
|
||||
|
||||
Reference in New Issue
Block a user