Skip to content
Snippets Groups Projects
Commit 9033477a authored by Chalard Jean's avatar Chalard Jean
Browse files

Fix flake : testVpnSetUnderlyingNetworks

When the device is very slow to run this test, cell might end
its lingering period in the middle of the test while wifi is
the default. VPN will then ignore it as an underlying network,
causing the test to fail.

Test: testVpnSetUnderlyingNetworks
      Added sleep in a strategic place to make sure the problem
      was correctly identified, and observed the test failing.
      After the fix, the test passes with the sleep.
Fixes: 280627836
Fixes: 293844384
Change-Id: Iaf56de963eb17845c1d76a0310b55f7f9321f7e4
parent 50f07be9
No related branches found
No related tags found
No related merge requests found
......@@ -9053,6 +9053,18 @@ public class ConnectivityServiceTest {
mCm.registerNetworkCallback(vpnNetworkRequest, vpnNetworkCallback);
vpnNetworkCallback.assertNoCallback();
 
// Lingering timer is short and cell might be disconnected if the device is particularly
// slow running the test, unless it's requested. Make sure the networks the test needs
// are all requested.
final NetworkCallback cellCallback = new NetworkCallback() {};
final NetworkCallback wifiCallback = new NetworkCallback() {};
mCm.requestNetwork(
new NetworkRequest.Builder().addTransportType(TRANSPORT_CELLULAR).build(),
cellCallback);
mCm.requestNetwork(
new NetworkRequest.Builder().addTransportType(TRANSPORT_WIFI).build(),
wifiCallback);
mMockVpn.establishForMyUid(true /* validated */, false /* hasInternet */,
false /* privateDnsProbeSent */);
assertUidRangesUpdatedForMyUid(true);
......@@ -9209,6 +9221,8 @@ public class ConnectivityServiceTest {
assertDefaultNetworkCapabilities(userId /* no networks */);
 
mMockVpn.disconnect();
mCm.unregisterNetworkCallback(cellCallback);
mCm.unregisterNetworkCallback(wifiCallback);
}
 
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment