Merge "Add some timeout for waiting proxy being updated" am: 8c0cefc928 am: df4badea3b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2628997
Change-Id: I55e9d3f81c75cc038f8f10a669643471e1f7fad8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/VpnTest.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/VpnTest.java
index cd3b650..454940f 100755
--- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/VpnTest.java
+++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/VpnTest.java
@@ -1726,10 +1726,21 @@
assertEquals(VpnManager.TYPE_VPN_SERVICE, ((VpnTransportInfo) ti).getType());
}
- private void assertDefaultProxy(ProxyInfo expected) {
+ private void assertDefaultProxy(ProxyInfo expected) throws Exception {
assertEquals("Incorrect proxy config.", expected, mCM.getDefaultProxy());
String expectedHost = expected == null ? null : expected.getHost();
String expectedPort = expected == null ? null : String.valueOf(expected.getPort());
+
+ // ActivityThread may not have time to set it in the properties yet which will cause flakes.
+ // Wait for some time to deflake the test.
+ int attempt = 0;
+ while (!(Objects.equals(expectedHost, System.getProperty("http.proxyHost"))
+ && Objects.equals(expectedPort, System.getProperty("http.proxyPort")))
+ && attempt < 300) {
+ attempt++;
+ Log.d(TAG, "Wait for proxy being updated, attempt=" + attempt);
+ Thread.sleep(100);
+ }
assertEquals("Incorrect proxy host system property.", expectedHost,
System.getProperty("http.proxyHost"));
assertEquals("Incorrect proxy port system property.", expectedPort,