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

Commit 8447354f authored by Mike Yu's avatar Mike Yu
Browse files

Test: Deflake RepeatedSetup_NoRedundantPrivateDnsValidation

Fix the test to pass when the flag dot_async_handshake is 1

Bug: 261327438
Test: run the test with dot_async_handshake=1
Test: run the test with dot_async_handshake=0
Change-Id: I7e1592d765e9a7428e2eda81d26c9e42fb4628b2
parent d93ed608
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -5600,7 +5600,6 @@ TEST_F(ResolverTest, RepeatedSetup_NoRedundantPrivateDnsValidation) {
    StartDns(dns2, {});
    test::DnsTlsFrontend workableTls(addr1, "853", addr1, "53");
    test::DnsTlsFrontend unresponsiveTls(addr2, "853", addr2, "53");
    int validationAttemptsToUnresponsiveTls = 1;
    unresponsiveTls.setHangOnHandshakeForTesting(true);
    ASSERT_TRUE(workableTls.startServer());
    ASSERT_TRUE(unresponsiveTls.startServer());
@@ -5616,7 +5615,8 @@ TEST_F(ResolverTest, RepeatedSetup_NoRedundantPrivateDnsValidation) {
    EXPECT_TRUE(WaitForPrivateDnsValidation(unusable_addr, false));

    // The validation is still in progress.
    EXPECT_EQ(unresponsiveTls.acceptConnectionsCount(), validationAttemptsToUnresponsiveTls);
    EXPECT_EQ(unresponsiveTls.acceptConnectionsCount(), 1);
    unresponsiveTls.clearConnectionsCount();

    static const struct TestConfig {
        std::vector<std::string> tlsServers;
@@ -5638,6 +5638,7 @@ TEST_F(ResolverTest, RepeatedSetup_NoRedundantPrivateDnsValidation) {
        parcel.caCertificate = config.tlsName.empty() ? "" : kCaCert;

        const bool dnsModeChanged = (TlsNameLastTime != config.tlsName);
        bool validationAttemptToUnresponsiveTls = false;

        waitForPrivateDnsStateUpdated();
        ASSERT_TRUE(mDnsClient.SetResolversFromParcel(parcel));
@@ -5656,7 +5657,7 @@ TEST_F(ResolverTest, RepeatedSetup_NoRedundantPrivateDnsValidation) {
                    // Despite the identical IP address, the server is regarded as a different
                    // server when DnsTlsServer.name is different. The resolver treats it as a
                    // different object and begins the validation process.
                    validationAttemptsToUnresponsiveTls++;
                    validationAttemptToUnresponsiveTls = true;

                    // This is the limitation from DnsTlsFrontend. DnsTlsFrontend can't operate
                    // concurrently. As soon as there's another connection request,
@@ -5689,9 +5690,14 @@ TEST_F(ResolverTest, RepeatedSetup_NoRedundantPrivateDnsValidation) {
            EXPECT_TRUE(WaitForPrivateDnsValidation(unusable_addr, false));
        }

        EXPECT_EQ(unresponsiveTls.acceptConnectionsCount(), validationAttemptsToUnresponsiveTls);
        if (validationAttemptToUnresponsiveTls) {
            EXPECT_GT(unresponsiveTls.acceptConnectionsCount(), 0);
        } else {
            EXPECT_EQ(unresponsiveTls.acceptConnectionsCount(), 0);
        }

        TlsNameLastTime = config.tlsName;
        unresponsiveTls.clearConnectionsCount();
    }

    // Check that all the validation results are caught.