From 801079f25a075d1ea30d625d7fa4df19e954d96b Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 26 Jul 2023 07:56:33 +0000 Subject: [PATCH] Fix EthernetTetheringTest#testLocalOnlyTethering flaky The testLocalOnlyTethering only verifies whether an IPv6 RA with a ULA prefix is sent out. If the test interface is killed after the RA is sent out while the DHCP server is starting, the error callback with exception is raised. RunDhcp verification is used to ensure that DHCP server is started. Bug: 286701571 Test: TH Change-Id: Iccebcedbba7b2f9cd28bb1cc06af928ff8dfaaca --- .../src/android/net/EthernetTetheringTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java b/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java index eed308c164..076fde3829 100644 --- a/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java +++ b/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java @@ -326,6 +326,14 @@ public class EthernetTetheringTest extends EthernetTetheringTestBase { waitForRouterAdvertisement(downstreamReader, iface, WAIT_RA_TIMEOUT_MS); expectLocalOnlyAddresses(iface); + + // After testing the IPv6 local address, the DHCP server may still be in the process + // of being created. If the downstream interface is killed by the test while the + // DHCP server is starting, a DHCP server error may occur. To ensure that the DHCP + // server has started completely before finishing the test, also test the dhcp server + // by calling runDhcp. + final TetheringTester tester = new TetheringTester(downstreamReader); + tester.runDhcp(MacAddress.fromString("1:2:3:4:5:6").toByteArray()); } finally { maybeStopTapPacketReader(downstreamReader); maybeCloseTestInterface(downstreamIface);