[Feature sync] Fix flaky test in MdnsSocketClientTests
The interface index is only propagated if there is an A/AAAA
record in the response. Since the responses here are not entirely
controlled in the test, we just want to verify that we get a
response with the target we expect.
Verified by running the test 1400 times via --runs_per_test flag.
Bug: 254155029
Fix: 255922416
Test: atest MdnsSocketClientTests#startDiscovery_andPropagate\
InterfaceIndex_includesInterfaceIndex --iteration 100
Change-Id: Icb0fe7a58a1e626b7f781ff24c2389a3095d4dc6
This commit is contained in:
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -513,11 +514,8 @@ public class MdnsSocketClientTests {
|
||||
mdnsClient.setCallback(mockCallback);
|
||||
mdnsClient.startDiscovery();
|
||||
|
||||
ArgumentCaptor<MdnsResponse> mdnsResponseCaptor =
|
||||
ArgumentCaptor.forClass(MdnsResponse.class);
|
||||
verify(mockCallback, timeout(TIMEOUT).atLeast(1))
|
||||
.onResponseReceived(mdnsResponseCaptor.capture());
|
||||
assertEquals(21, mdnsResponseCaptor.getValue().getInterfaceIndex());
|
||||
verify(mockCallback, timeout(TIMEOUT).atLeastOnce())
|
||||
.onResponseReceived(argThat(response -> response.getInterfaceIndex() == 21));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user