Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19b5229f authored by Mike Yu's avatar Mike Yu
Browse files

Test: Deflake RepeatedSetup_KeepChangingPrivateDnsServers

The test fails if the flag dot_async_handshake is 1. If the
flag is 0, DnsResolver doesn't retry when DoT connection
establishement fails; if the flag is 1, DnsResolver does retry
when DoT connection establishment fails. To fix the test to not
fail when the flag is 1, we check whether |connectCountsAfter|
is greater than |connectCountsBefore| rather than check the exact
value returned by tls.acceptConnectionsCount().

Bug: 261327438
Test: run the test with dot_async_handshake=1
Test: run the test with dot_async_handshake=0
Change-Id: I729e5a91d97bd57dbbe5670de2305bc7f8a09200
parent 8447354f
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -5795,17 +5795,17 @@ TEST_F(ResolverTest, RepeatedSetup_KeepChangingPrivateDnsServers) {
                // Must be UNRESPONSIVE.
                // DnsTlsFrontend is the only signal for checking whether or not the resolver starts
                // another validation when the server is unresponsive.
                const int expectCountDiff =
                        config.expectNothingHappenWhenServerUnresponsive ? 0 : 1;
                if (expectCountDiff == 0) {
                    // It's possible that the resolver hasn't yet started to
                    // connect. Wait a while.
                    std::this_thread::sleep_for(100ms);
                } else {

                // Wait for a while to avoid running the checker code too early.
                std::this_thread::sleep_for(200ms);
                if (!config.expectNothingHappenWhenServerUnresponsive) {
                    EXPECT_TRUE(WaitForPrivateDnsValidation(config.tlsServer, false));
                }
                const auto condition = [&]() {
                    return tls.acceptConnectionsCount() == connectCountsBefore + expectCountDiff;
                    const int connectCountsAfter = tls.acceptConnectionsCount();
                    return config.expectNothingHappenWhenServerUnresponsive
                                   ? (connectCountsAfter == connectCountsBefore)
                                   : (connectCountsAfter > connectCountsBefore);
                };
                EXPECT_TRUE(PollForCondition(condition));
            }