|
|
|
@ -562,7 +562,17 @@ TEST_F(XdsEndpointTest, DuplicateLocalityName) { |
|
|
|
|
socket_address->set_address("127.0.0.1"); |
|
|
|
|
socket_address->set_port_value(443); |
|
|
|
|
locality = cla.add_endpoints(); |
|
|
|
|
*locality = cla.endpoints(0); |
|
|
|
|
locality->mutable_load_balancing_weight()->set_value(1); |
|
|
|
|
locality_name = locality->mutable_locality(); |
|
|
|
|
locality_name->set_region("myregion"); |
|
|
|
|
locality_name->set_zone("myzone"); |
|
|
|
|
locality_name->set_sub_zone("mysubzone"); |
|
|
|
|
socket_address = locality->add_lb_endpoints() |
|
|
|
|
->mutable_endpoint() |
|
|
|
|
->mutable_address() |
|
|
|
|
->mutable_socket_address(); |
|
|
|
|
socket_address->set_address("127.0.0.2"); |
|
|
|
|
socket_address->set_port_value(443); |
|
|
|
|
std::string serialized_resource; |
|
|
|
|
ASSERT_TRUE(cla.SerializeToString(&serialized_resource)); |
|
|
|
|
auto* resource_type = XdsEndpointResourceType::Get(); |
|
|
|
@ -596,7 +606,17 @@ TEST_F(XdsEndpointTest, SparsePriorityList) { |
|
|
|
|
socket_address->set_port_value(443); |
|
|
|
|
locality->set_priority(1); |
|
|
|
|
locality = cla.add_endpoints(); |
|
|
|
|
*locality = cla.endpoints(0); |
|
|
|
|
locality->mutable_load_balancing_weight()->set_value(1); |
|
|
|
|
locality_name = locality->mutable_locality(); |
|
|
|
|
locality_name->set_region("myregion2"); |
|
|
|
|
locality_name->set_zone("myzone"); |
|
|
|
|
locality_name->set_sub_zone("mysubzone"); |
|
|
|
|
socket_address = locality->add_lb_endpoints() |
|
|
|
|
->mutable_endpoint() |
|
|
|
|
->mutable_address() |
|
|
|
|
->mutable_socket_address(); |
|
|
|
|
socket_address->set_address("127.0.0.2"); |
|
|
|
|
socket_address->set_port_value(443); |
|
|
|
|
locality->set_priority(3); |
|
|
|
|
std::string serialized_resource; |
|
|
|
|
ASSERT_TRUE(cla.SerializeToString(&serialized_resource)); |
|
|
|
@ -632,10 +652,19 @@ TEST_F(XdsEndpointTest, LocalityWeightsWithinPriorityExceedUint32Max) { |
|
|
|
|
locality->set_priority(0); |
|
|
|
|
// Second locality has weight of uint32 max.
|
|
|
|
|
locality = cla.add_endpoints(); |
|
|
|
|
*locality = cla.endpoints(0); // Copy first locality.
|
|
|
|
|
locality->mutable_locality()->set_region("myregion2"); |
|
|
|
|
locality->mutable_load_balancing_weight()->set_value( |
|
|
|
|
std::numeric_limits<uint32_t>::max()); |
|
|
|
|
locality_name = locality->mutable_locality(); |
|
|
|
|
locality_name->set_region("myregion2"); |
|
|
|
|
locality_name->set_zone("myzone"); |
|
|
|
|
locality_name->set_sub_zone("mysubzone"); |
|
|
|
|
socket_address = locality->add_lb_endpoints() |
|
|
|
|
->mutable_endpoint() |
|
|
|
|
->mutable_address() |
|
|
|
|
->mutable_socket_address(); |
|
|
|
|
socket_address->set_address("127.0.0.2"); |
|
|
|
|
socket_address->set_port_value(443); |
|
|
|
|
locality->set_priority(0); |
|
|
|
|
std::string serialized_resource; |
|
|
|
|
ASSERT_TRUE(cla.SerializeToString(&serialized_resource)); |
|
|
|
|
auto* resource_type = XdsEndpointResourceType::Get(); |
|
|
|
@ -652,6 +681,51 @@ TEST_F(XdsEndpointTest, LocalityWeightsWithinPriorityExceedUint32Max) { |
|
|
|
|
<< decode_result.resource.status(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(XdsEndpointTest, DuplicateAddresses) { |
|
|
|
|
ClusterLoadAssignment cla; |
|
|
|
|
cla.set_cluster_name("foo"); |
|
|
|
|
auto* locality = cla.add_endpoints(); |
|
|
|
|
locality->mutable_load_balancing_weight()->set_value(1); |
|
|
|
|
auto* locality_name = locality->mutable_locality(); |
|
|
|
|
locality_name->set_region("myregion"); |
|
|
|
|
locality_name->set_zone("myzone"); |
|
|
|
|
locality_name->set_sub_zone("mysubzone"); |
|
|
|
|
auto* socket_address = locality->add_lb_endpoints() |
|
|
|
|
->mutable_endpoint() |
|
|
|
|
->mutable_address() |
|
|
|
|
->mutable_socket_address(); |
|
|
|
|
socket_address->set_address("127.0.0.1"); |
|
|
|
|
socket_address->set_port_value(443); |
|
|
|
|
locality->set_priority(0); |
|
|
|
|
locality = cla.add_endpoints(); |
|
|
|
|
locality->mutable_load_balancing_weight()->set_value(1); |
|
|
|
|
locality_name = locality->mutable_locality(); |
|
|
|
|
locality_name->set_region("myregion2"); |
|
|
|
|
locality_name->set_zone("myzone"); |
|
|
|
|
locality_name->set_sub_zone("mysubzone"); |
|
|
|
|
socket_address = locality->add_lb_endpoints() |
|
|
|
|
->mutable_endpoint() |
|
|
|
|
->mutable_address() |
|
|
|
|
->mutable_socket_address(); |
|
|
|
|
socket_address->set_address("127.0.0.1"); |
|
|
|
|
socket_address->set_port_value(443); |
|
|
|
|
locality->set_priority(0); |
|
|
|
|
std::string serialized_resource; |
|
|
|
|
ASSERT_TRUE(cla.SerializeToString(&serialized_resource)); |
|
|
|
|
auto* resource_type = XdsEndpointResourceType::Get(); |
|
|
|
|
auto decode_result = resource_type->Decode( |
|
|
|
|
decode_context_, serialized_resource, /*is_v2=*/false); |
|
|
|
|
ASSERT_TRUE(decode_result.name.has_value()); |
|
|
|
|
EXPECT_EQ(*decode_result.name, "foo"); |
|
|
|
|
EXPECT_EQ(decode_result.resource.status().code(), |
|
|
|
|
absl::StatusCode::kInvalidArgument); |
|
|
|
|
EXPECT_EQ(decode_result.resource.status().message(), |
|
|
|
|
"errors parsing EDS resource: [" |
|
|
|
|
"field:endpoints[1].lb_endpoints[0] " |
|
|
|
|
"error:duplicate endpoint address \"ipv4:127.0.0.1:443\"]") |
|
|
|
|
<< decode_result.resource.status(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(XdsEndpointTest, DropConfig) { |
|
|
|
|
ClusterLoadAssignment cla; |
|
|
|
|
cla.set_cluster_name("foo"); |
|
|
|
|