From b76f9ee4e6699bf9b816a4a0b0239624d64c9450 Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Fri, 8 Feb 2019 17:10:50 +0900 Subject: [PATCH] Fix flaky testNattSocketKeepalives The test did not wait for the WifiNetworkAgent to disconnect, and there are reports of flakes where it is still connected in connectKeepaliveNetwork. Test: atest FrameworksNetTests Bug: 124319553 Change-Id: I85968806885c8853ec4f4dbea356366c1af0ea1c --- .../java/com/android/server/ConnectivityServiceTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java index 1548a76cc4..a19174448d 100644 --- a/tests/net/java/com/android/server/ConnectivityServiceTest.java +++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java @@ -3791,11 +3791,14 @@ public class ConnectivityServiceTest { } @Test - public void testNattSocketKeepalives() throws Exception { + public void testNattSocketKeepalives_SingleThreadExecutor() throws Exception { final ExecutorService executorSingleThread = Executors.newSingleThreadExecutor(); doTestNattSocketKeepalivesWithExecutor(executorSingleThread); executorSingleThread.shutdown(); + } + @Test + public void testNattSocketKeepalives_InlineExecutor() throws Exception { final Executor executorInline = (Runnable r) -> r.run(); doTestNattSocketKeepalivesWithExecutor(executorInline); } @@ -3937,6 +3940,7 @@ public class ConnectivityServiceTest { testSocket2.close(); mWiFiNetworkAgent.disconnect(); + waitFor(mWiFiNetworkAgent.getDisconnectedCV()); } @Test