|
|
|
@ -212,7 +212,7 @@ TEST_F(AddressSortingTest, TestDepriotizesUnreachableAddresses) { |
|
|
|
|
{"1.2.3.4:443", AF_INET}, |
|
|
|
|
{"5.6.7.8:443", AF_INET}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"1.2.3.4:443", |
|
|
|
|
"5.6.7.8:443", |
|
|
|
@ -231,7 +231,7 @@ TEST_F(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv6) { |
|
|
|
|
{"[2607:f8b0:400a:801::1002]:443", AF_INET6}, |
|
|
|
|
{"1.2.3.4:443", AF_INET}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"1.2.3.4:443", |
|
|
|
|
"[2607:f8b0:400a:801::1002]:443", |
|
|
|
@ -251,7 +251,7 @@ TEST_F(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv4) { |
|
|
|
|
{"[2607:f8b0:400a:801::1002]:443", AF_INET6}, |
|
|
|
|
{"1.2.3.4:443", AF_INET}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[2607:f8b0:400a:801::1002]:443", |
|
|
|
|
"1.2.3.4:443", |
|
|
|
@ -275,7 +275,7 @@ TEST_F(AddressSortingTest, TestDepriotizesNonMatchingScope) { |
|
|
|
|
{"[2000:f8b0:400a:801::1002]:443", AF_INET6}, |
|
|
|
|
{"[fec0::5000]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[fec0::5000]:443", |
|
|
|
|
"[2000:f8b0:400a:801::1002]:443", |
|
|
|
@ -298,7 +298,7 @@ TEST_F(AddressSortingTest, TestUsesLabelFromDefaultTable) { |
|
|
|
|
{"[2002::5001]:443", AF_INET6}, |
|
|
|
|
{"[2001::5001]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[2001::5001]:443", |
|
|
|
|
"[2002::5001]:443", |
|
|
|
@ -321,7 +321,7 @@ TEST_F(AddressSortingTest, TestUsesLabelFromDefaultTableInputFlipped) { |
|
|
|
|
{"[2001::5001]:443", AF_INET6}, |
|
|
|
|
{"[2002::5001]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[2001::5001]:443", |
|
|
|
|
"[2002::5001]:443", |
|
|
|
@ -344,7 +344,7 @@ TEST_F(AddressSortingTest, |
|
|
|
|
{"[3ffe::5001]:443", AF_INET6}, |
|
|
|
|
{"1.2.3.4:443", AF_INET}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs( |
|
|
|
|
lb_addrs, { |
|
|
|
|
// The AF_INET address should be IPv4-mapped by the sort,
|
|
|
|
@ -377,7 +377,7 @@ TEST_F(AddressSortingTest, |
|
|
|
|
{v4_compat_dest, AF_INET6}, |
|
|
|
|
{"[::1]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[::1]:443", |
|
|
|
|
v4_compat_dest, |
|
|
|
@ -400,7 +400,7 @@ TEST_F(AddressSortingTest, |
|
|
|
|
{"[1234::2]:443", AF_INET6}, |
|
|
|
|
{"[::1]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs( |
|
|
|
|
lb_addrs, |
|
|
|
|
{ |
|
|
|
@ -424,7 +424,7 @@ TEST_F(AddressSortingTest, |
|
|
|
|
{"[2001::1234]:443", AF_INET6}, |
|
|
|
|
{"[2000::5001]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs( |
|
|
|
|
lb_addrs, { |
|
|
|
|
// The 2000::/16 address should match the ::/0 prefix rule
|
|
|
|
@ -448,7 +448,7 @@ TEST_F( |
|
|
|
|
{"[2001::1231]:443", AF_INET6}, |
|
|
|
|
{"[2000::5001]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[2000::5001]:443", |
|
|
|
|
"[2001::1231]:443", |
|
|
|
@ -469,7 +469,7 @@ TEST_F(AddressSortingTest, |
|
|
|
|
{"[fec0::1234]:443", AF_INET6}, |
|
|
|
|
{"[fc00::5001]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[fc00::5001]:443", |
|
|
|
|
"[fec0::1234]:443", |
|
|
|
@ -494,7 +494,7 @@ TEST_F( |
|
|
|
|
{"[::ffff:1.1.1.2]:443", AF_INET6}, |
|
|
|
|
{"[1234::2]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
// ::ffff:0:2 should match the v4-mapped
|
|
|
|
|
// precedence entry and be deprioritized.
|
|
|
|
@ -521,7 +521,7 @@ TEST_F(AddressSortingTest, TestPrefersSmallerScope) { |
|
|
|
|
{"[3ffe::5001]:443", AF_INET6}, |
|
|
|
|
{"[fec0::1234]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[fec0::1234]:443", |
|
|
|
|
"[3ffe::5001]:443", |
|
|
|
@ -546,7 +546,7 @@ TEST_F(AddressSortingTest, TestPrefersLongestMatchingSrcDstPrefix) { |
|
|
|
|
{"[3ffe:5001::]:443", AF_INET6}, |
|
|
|
|
{"[3ffe:1234::]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[3ffe:1234::]:443", |
|
|
|
|
"[3ffe:5001::]:443", |
|
|
|
@ -567,7 +567,7 @@ TEST_F(AddressSortingTest, |
|
|
|
|
{"[3ffe::5001]:443", AF_INET6}, |
|
|
|
|
{"[3ffe::1234]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[3ffe::1234]:443", |
|
|
|
|
"[3ffe::5001]:443", |
|
|
|
@ -587,7 +587,7 @@ TEST_F(AddressSortingTest, TestPrefersLongestPrefixStressInnerBytePrefix) { |
|
|
|
|
{"[3ffe:8000::]:443", AF_INET6}, |
|
|
|
|
{"[3ffe:2000::]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[3ffe:2000::]:443", |
|
|
|
|
"[3ffe:8000::]:443", |
|
|
|
@ -607,7 +607,7 @@ TEST_F(AddressSortingTest, TestPrefersLongestPrefixDiffersOnHighestBitOfByte) { |
|
|
|
|
{"[3ffe:6::]:443", AF_INET6}, |
|
|
|
|
{"[3ffe:c::]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[3ffe:c::]:443", |
|
|
|
|
"[3ffe:6::]:443", |
|
|
|
@ -629,7 +629,7 @@ TEST_F(AddressSortingTest, TestPrefersLongestPrefixDiffersByLastBit) { |
|
|
|
|
{"[3ffe:1111:1111:1110::]:443", AF_INET6}, |
|
|
|
|
{"[3ffe:1111:1111:1111::]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[3ffe:1111:1111:1111::]:443", |
|
|
|
|
"[3ffe:1111:1111:1110::]:443", |
|
|
|
@ -651,7 +651,7 @@ TEST_F(AddressSortingTest, TestStableSort) { |
|
|
|
|
{"[3ffe::1234]:443", AF_INET6}, |
|
|
|
|
{"[3ffe::1235]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[3ffe::1234]:443", |
|
|
|
|
"[3ffe::1235]:443", |
|
|
|
@ -677,7 +677,7 @@ TEST_F(AddressSortingTest, TestStableSortFiveElements) { |
|
|
|
|
{"[3ffe::1234]:443", AF_INET6}, |
|
|
|
|
{"[3ffe::1235]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[3ffe::1231]:443", |
|
|
|
|
"[3ffe::1232]:443", |
|
|
|
@ -698,7 +698,7 @@ TEST_F(AddressSortingTest, TestStableSortNoSrcAddrsExist) { |
|
|
|
|
{"[3ffe::1234]:443", AF_INET6}, |
|
|
|
|
{"[3ffe::1235]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[3ffe::1231]:443", |
|
|
|
|
"[3ffe::1232]:443", |
|
|
|
@ -716,7 +716,7 @@ TEST_F(AddressSortingTest, TestStableSortNoSrcAddrsExistWithIpv4) { |
|
|
|
|
{"[::ffff:5.6.7.8]:443", AF_INET6}, |
|
|
|
|
{"1.2.3.4:443", AF_INET}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[::ffff:5.6.7.8]:443", |
|
|
|
|
"1.2.3.4:443", |
|
|
|
@ -744,7 +744,7 @@ TEST_F(AddressSortingTest, TestStableSortV4CompatAndSiteLocalAddresses) { |
|
|
|
|
{"[fec0::2000]:443", AF_INET6}, |
|
|
|
|
{v4_compat_dest, AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, |
|
|
|
|
{ |
|
|
|
|
// The sort should be stable since
|
|
|
|
@ -765,7 +765,7 @@ TEST_F(AddressSortingTest, TestPrefersIpv6Loopback) { |
|
|
|
|
{"[::1]:443", AF_INET6}, |
|
|
|
|
{"127.0.0.1:443", AF_INET}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[::1]:443", |
|
|
|
|
"127.0.0.1:443", |
|
|
|
@ -779,7 +779,7 @@ TEST_F(AddressSortingTest, TestPrefersIpv6LoopbackInputsFlipped) { |
|
|
|
|
{"127.0.0.1:443", AF_INET}, |
|
|
|
|
{"[::1]:443", AF_INET6}, |
|
|
|
|
}); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(&lb_addrs); |
|
|
|
|
grpc_cares_wrapper_address_sorting_sort(nullptr, &lb_addrs); |
|
|
|
|
VerifyLbAddrOutputs(lb_addrs, { |
|
|
|
|
"[::1]:443", |
|
|
|
|
"127.0.0.1:443", |
|
|
|
|