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

Commit 0bf76b19 authored by Mike Yu's avatar Mike Yu Committed by Automerger Merge Worker
Browse files

Test: Deflake RepeatedSetup_NoRedundantPrivateDnsValidation am: 8447354f

parents 8cedaf56 8447354f
Loading
Loading
Loading
Loading
+10 −4
Original line number Original line Diff line number Diff line
@@ -5600,7 +5600,6 @@ TEST_F(ResolverTest, RepeatedSetup_NoRedundantPrivateDnsValidation) {
    StartDns(dns2, {});
    StartDns(dns2, {});
    test::DnsTlsFrontend workableTls(addr1, "853", addr1, "53");
    test::DnsTlsFrontend workableTls(addr1, "853", addr1, "53");
    test::DnsTlsFrontend unresponsiveTls(addr2, "853", addr2, "53");
    test::DnsTlsFrontend unresponsiveTls(addr2, "853", addr2, "53");
    int validationAttemptsToUnresponsiveTls = 1;
    unresponsiveTls.setHangOnHandshakeForTesting(true);
    unresponsiveTls.setHangOnHandshakeForTesting(true);
    ASSERT_TRUE(workableTls.startServer());
    ASSERT_TRUE(workableTls.startServer());
    ASSERT_TRUE(unresponsiveTls.startServer());
    ASSERT_TRUE(unresponsiveTls.startServer());
@@ -5616,7 +5615,8 @@ TEST_F(ResolverTest, RepeatedSetup_NoRedundantPrivateDnsValidation) {
    EXPECT_TRUE(WaitForPrivateDnsValidation(unusable_addr, false));
    EXPECT_TRUE(WaitForPrivateDnsValidation(unusable_addr, false));


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


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


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


        waitForPrivateDnsStateUpdated();
        waitForPrivateDnsStateUpdated();
        ASSERT_TRUE(mDnsClient.SetResolversFromParcel(parcel));
        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
                    // Despite the identical IP address, the server is regarded as a different
                    // server when DnsTlsServer.name is different. The resolver treats it as a
                    // server when DnsTlsServer.name is different. The resolver treats it as a
                    // different object and begins the validation process.
                    // different object and begins the validation process.
                    validationAttemptsToUnresponsiveTls++;
                    validationAttemptToUnresponsiveTls = true;


                    // This is the limitation from DnsTlsFrontend. DnsTlsFrontend can't operate
                    // This is the limitation from DnsTlsFrontend. DnsTlsFrontend can't operate
                    // concurrently. As soon as there's another connection request,
                    // 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_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;
        TlsNameLastTime = config.tlsName;
        unresponsiveTls.clearConnectionsCount();
    }
    }


    // Check that all the validation results are caught.
    // Check that all the validation results are caught.