Fix flaky test - testPartialConnectivity
This timing issue is happened when test case already verified NetworkMonitor#setAcceptPartialConnectivity() before NetworkAgent send the CONNECTED state to ConnectivityService. This test case expects that the NetworkMonitor#setAcceptPartialConnectivity() will be invoked when network state is CONNECTED in ConnectivityService#updateNetworkInfo(). NetworkAgent communicates with ConnectivityService by AsyncChannel. Before they connect to each other, the thread of NetworkAgent is keeping idle, so waitForIdle cannot handle this kind of case. Although they have connected to each other, but they don't communicate with each other, waitForIdle() still cannot handle this case. It means waitForIdle() can only handle the case that NetworkAgent already connected to ConnectivityService and NetworkAgent is communicating with ConnectivityService. So, that's why waitForIdle() sometimes doesn't work in this case, and the most simplest and right way to fix this case is to wait the available callback then verify the method. Bug: 140306320 Test: atest FrameworksNetTests: \ ConnectivityServiceTest#testPartialConnectivity \ --generate-new-metrics 500 Change-Id: I64bfecbfe3c5776bd5c347a821f9127e79539c48
Loading
Please register or sign in to comment