Loading resolver_test.cpp +17 −5 Original line number Diff line number Diff line Loading @@ -886,6 +886,16 @@ TEST_F(ResolverTest, GetAddrInfoV6_nonresponsive) { constexpr char listen_srv[] = "53"; constexpr char host_name1[] = "ohayou.example.com."; constexpr char host_name2[] = "ciao.example.com."; const std::vector<std::string> defaultSearchDomain = {"example.com"}; // The minimal timeout is 1000ms, so we can't decrease timeout // So reduce retry count. const std::vector<int> reduceRetryParams = { 300, // sample validity in seconds 25, // success threshod in percent 8, 8, // {MIN,MAX}_SAMPLES 1000, // BASE_TIMEOUT_MSEC 1, // retry count }; const std::vector<DnsRecord> records0 = { {host_name1, ns_type::ns_t_aaaa, "2001:db8::5"}, {host_name2, ns_type::ns_t_aaaa, "2001:db8::5"}, Loading @@ -902,9 +912,11 @@ TEST_F(ResolverTest, GetAddrInfoV6_nonresponsive) { dns0.setResponseProbability(0.0); StartDns(dns0, records0); StartDns(dns1, records1); ASSERT_TRUE(mDnsClient.SetResolversForNetwork({listen_addr0, listen_addr1})); ASSERT_TRUE(mDnsClient.SetResolversForNetwork({listen_addr0, listen_addr1}, defaultSearchDomain, reduceRetryParams)); const addrinfo hints = {.ai_family = AF_INET6}; // Specify ai_socktype to make getaddrinfo will only query 1 time const addrinfo hints = {.ai_family = AF_INET6, .ai_socktype = SOCK_STREAM}; // dns0 will ignore the request, and we'll fallback to dns1 after the first // retry. Loading @@ -914,13 +926,13 @@ TEST_F(ResolverTest, GetAddrInfoV6_nonresponsive) { EXPECT_EQ(1U, GetNumQueries(dns1, host_name1)); // Now make dns1 also ignore 100% requests... The resolve should alternate // retries between the nameservers and fail after 4 attempts. // queries between the nameservers and fail dns1.setResponseProbability(0.0); addrinfo* result2 = nullptr; EXPECT_EQ(EAI_NODATA, getaddrinfo(host_name2, nullptr, &hints, &result2)); EXPECT_EQ(nullptr, result2); EXPECT_EQ(4U, GetNumQueries(dns0, host_name2)); EXPECT_EQ(4U, GetNumQueries(dns1, host_name2)); EXPECT_EQ(1U, GetNumQueries(dns0, host_name2)); EXPECT_EQ(1U, GetNumQueries(dns1, host_name2)); } TEST_F(ResolverTest, GetAddrInfoV6_concurrent) { Loading Loading
resolver_test.cpp +17 −5 Original line number Diff line number Diff line Loading @@ -886,6 +886,16 @@ TEST_F(ResolverTest, GetAddrInfoV6_nonresponsive) { constexpr char listen_srv[] = "53"; constexpr char host_name1[] = "ohayou.example.com."; constexpr char host_name2[] = "ciao.example.com."; const std::vector<std::string> defaultSearchDomain = {"example.com"}; // The minimal timeout is 1000ms, so we can't decrease timeout // So reduce retry count. const std::vector<int> reduceRetryParams = { 300, // sample validity in seconds 25, // success threshod in percent 8, 8, // {MIN,MAX}_SAMPLES 1000, // BASE_TIMEOUT_MSEC 1, // retry count }; const std::vector<DnsRecord> records0 = { {host_name1, ns_type::ns_t_aaaa, "2001:db8::5"}, {host_name2, ns_type::ns_t_aaaa, "2001:db8::5"}, Loading @@ -902,9 +912,11 @@ TEST_F(ResolverTest, GetAddrInfoV6_nonresponsive) { dns0.setResponseProbability(0.0); StartDns(dns0, records0); StartDns(dns1, records1); ASSERT_TRUE(mDnsClient.SetResolversForNetwork({listen_addr0, listen_addr1})); ASSERT_TRUE(mDnsClient.SetResolversForNetwork({listen_addr0, listen_addr1}, defaultSearchDomain, reduceRetryParams)); const addrinfo hints = {.ai_family = AF_INET6}; // Specify ai_socktype to make getaddrinfo will only query 1 time const addrinfo hints = {.ai_family = AF_INET6, .ai_socktype = SOCK_STREAM}; // dns0 will ignore the request, and we'll fallback to dns1 after the first // retry. Loading @@ -914,13 +926,13 @@ TEST_F(ResolverTest, GetAddrInfoV6_nonresponsive) { EXPECT_EQ(1U, GetNumQueries(dns1, host_name1)); // Now make dns1 also ignore 100% requests... The resolve should alternate // retries between the nameservers and fail after 4 attempts. // queries between the nameservers and fail dns1.setResponseProbability(0.0); addrinfo* result2 = nullptr; EXPECT_EQ(EAI_NODATA, getaddrinfo(host_name2, nullptr, &hints, &result2)); EXPECT_EQ(nullptr, result2); EXPECT_EQ(4U, GetNumQueries(dns0, host_name2)); EXPECT_EQ(4U, GetNumQueries(dns1, host_name2)); EXPECT_EQ(1U, GetNumQueries(dns0, host_name2)); EXPECT_EQ(1U, GetNumQueries(dns1, host_name2)); } TEST_F(ResolverTest, GetAddrInfoV6_concurrent) { Loading