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

Commit 398b9419 authored by Mike Yu's avatar Mike Yu Committed by Automerger Merge Worker
Browse files

Fix PrivateDnsDohTest.ExcessDnsRequests not to interfere other tests am: a4d7bb98

Original change: https://android-review.googlesource.com/c/platform/packages/modules/DnsResolver/+/2005392

Change-Id: I06fdad3d0bedf4ccbbd0b85fa56792f49cd026c5
parents d5e561f4 a4d7bb98
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -744,6 +744,7 @@ TEST_F(PrivateDnsDohTest, ExcessDnsRequests) {
    for (const auto& fd : fds) {
        expectAnswersValid(fd, AF_INET6, kQueryAnswerAAAA);
    }
    EXPECT_TRUE(doh.block_sending(false));

    // There are some queries that fall back to DoT rather than UDP since the DoH client rejects
    // any new DNS requests when the capacity is full.
@@ -780,6 +781,21 @@ TEST_F(PrivateDnsDohTest, ExcessDnsRequests) {
    // Expect two queries: one for DoH probe and the other one for kQueryHostname.
    EXPECT_EQ(doh_ipv6.queries(), 2);
    mDnsClient.TearDownOemNetwork(TEST_NETID_2);

    // The DnsResolver will reconnect to the DoH server for the query that gets blocked at
    // dispatcher sending channel. However, there's no way to know when the reconnection will start.
    // We have to periodically send a DNS request to check it. After the reconnection starts, the
    // DNS query will be sent to the Doh server instead of the cleartext DNS server. Then, we
    // are safe to end the test. Otherwise, the reconnection will interfere other tests.
    EXPECT_EQ(doh.queries(), 0);
    for (int i = 0; i < 50; i++) {
        sleep_for(milliseconds(100));
        int fd = resNetworkQuery(TEST_NETID, kQueryHostname, ns_c_in, ns_t_aaaa,
                                 ANDROID_RESOLV_NO_CACHE_LOOKUP);
        expectAnswersValid(fd, AF_INET6, kQueryAnswerAAAA);
        if (doh.queries() > 0) break;
    }
    EXPECT_GT(doh.queries(), 0);
}

// Tests the scenario where the DnsResolver runs out of QUIC connection data limit.