|
|
|
@ -375,11 +375,10 @@ class ClientStats { |
|
|
|
|
class AdsServiceImpl : public AggregatedDiscoveryService::Service, |
|
|
|
|
public std::enable_shared_from_this<AdsServiceImpl> { |
|
|
|
|
public: |
|
|
|
|
enum ResponseState { |
|
|
|
|
NOT_SENT, |
|
|
|
|
SENT, |
|
|
|
|
ACKED, |
|
|
|
|
NACKED, |
|
|
|
|
struct ResponseState { |
|
|
|
|
enum State { NOT_SENT, SENT, ACKED, NACKED }; |
|
|
|
|
State state = NOT_SENT; |
|
|
|
|
std::string error_message; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct EdsResourceArgs { |
|
|
|
@ -487,11 +486,15 @@ class AdsServiceImpl : public AggregatedDiscoveryService::Service, |
|
|
|
|
// comparing it to nonce (this server ensures they are always set to
|
|
|
|
|
// the same in a response.)
|
|
|
|
|
if (!request.response_nonce().empty()) { |
|
|
|
|
resource_type_response_state_[request.type_url()] = |
|
|
|
|
resource_type_response_state_[request.type_url()].state = |
|
|
|
|
(!request.version_info().empty() && |
|
|
|
|
request.version_info() == request.response_nonce()) |
|
|
|
|
? ACKED |
|
|
|
|
: NACKED; |
|
|
|
|
? ResponseState::ACKED |
|
|
|
|
: ResponseState::NACKED; |
|
|
|
|
} |
|
|
|
|
if (request.has_error_detail()) { |
|
|
|
|
resource_type_response_state_[request.type_url()].error_message = |
|
|
|
|
request.error_detail().message(); |
|
|
|
|
} |
|
|
|
|
// As long as the test did not tell us to ignore this type of
|
|
|
|
|
// request, we will loop through all resources to:
|
|
|
|
@ -920,7 +923,7 @@ class AdsServiceImpl : public AggregatedDiscoveryService::Service, |
|
|
|
|
const SubscriptionNameMap& subscription_name_map, |
|
|
|
|
const std::set<std::string>& resources_added_to_response, |
|
|
|
|
DiscoveryResponse* response) { |
|
|
|
|
resource_type_response_state_[resource_type] = SENT; |
|
|
|
|
resource_type_response_state_[resource_type].state = ResponseState::SENT; |
|
|
|
|
response->set_type_url(resource_type); |
|
|
|
|
response->set_version_info(absl::StrCat(version)); |
|
|
|
|
response->set_nonce(absl::StrCat(version)); |
|
|
|
@ -949,7 +952,7 @@ class AdsServiceImpl : public AggregatedDiscoveryService::Service, |
|
|
|
|
Listener default_listener_; |
|
|
|
|
RouteConfiguration default_route_config_; |
|
|
|
|
Cluster default_cluster_; |
|
|
|
|
std::map<std::string /*resource type*/, ResponseState> |
|
|
|
|
std::map<std::string /* type_url */, ResponseState> |
|
|
|
|
resource_type_response_state_; |
|
|
|
|
std::set<std::string /*resource_type*/> resource_types_to_ignore_; |
|
|
|
|
// An instance data member containing the current state of all resources.
|
|
|
|
@ -1904,8 +1907,8 @@ TEST_P(XdsResolverOnlyTest, ClusterRemoved) { |
|
|
|
|
// Make sure RPCs are still succeeding.
|
|
|
|
|
CheckRpcSendOk(100 * num_backends_); |
|
|
|
|
// Make sure we ACK'ed the update.
|
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->cds_response_state(), |
|
|
|
|
AdsServiceImpl::ACKED); |
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->cds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::ACKED); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that we restart all xDS requests when we reestablish the ADS call.
|
|
|
|
@ -2163,8 +2166,10 @@ TEST_P(LdsTest, NoApiListener) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->lds_response_state(), |
|
|
|
|
AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = |
|
|
|
|
balancers_[0]->ads_service()->lds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "Listener has no ApiListener."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if the route_specifier in the
|
|
|
|
@ -2179,8 +2184,11 @@ TEST_P(LdsTest, WrongRouteSpecifier) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->lds_response_state(), |
|
|
|
|
AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = |
|
|
|
|
balancers_[0]->ads_service()->lds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, |
|
|
|
|
"HttpConnectionManager neither has inlined route_config nor RDS."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using LdsRdsTest = BasicTest; |
|
|
|
@ -2191,7 +2199,8 @@ TEST_P(LdsRdsTest, Vanilla) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
(void)SendRpc(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::ACKED); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0).state, |
|
|
|
|
AdsServiceImpl::ResponseState::ACKED); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if matching domain can't be found in
|
|
|
|
@ -2205,7 +2214,10 @@ TEST_P(LdsRdsTest, NoMatchedDomain) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, |
|
|
|
|
"No matched virtual host found in the route config."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should choose the virtual host with matching domain if
|
|
|
|
@ -2224,7 +2236,8 @@ TEST_P(LdsRdsTest, ChooseMatchedDomain) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
(void)SendRpc(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::ACKED); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0).state, |
|
|
|
|
AdsServiceImpl::ResponseState::ACKED); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should choose the last route in the virtual host if
|
|
|
|
@ -2242,7 +2255,8 @@ TEST_P(LdsRdsTest, ChooseLastRoute) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
(void)SendRpc(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::ACKED); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0).state, |
|
|
|
|
AdsServiceImpl::ResponseState::ACKED); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route match has non-empty prefix
|
|
|
|
@ -2253,12 +2267,16 @@ TEST_P(LdsRdsTest, RouteMatchHasNonemptyPrefix) { |
|
|
|
|
route_config.mutable_virtual_hosts(0) |
|
|
|
|
->mutable_routes(0) |
|
|
|
|
->mutable_match() |
|
|
|
|
->set_prefix("nonempty_prefix"); |
|
|
|
|
->set_prefix("/nonempty_prefix/"); |
|
|
|
|
SetRouteConfiguration(0, route_config); |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
balancers_[0]->ads_service()->lds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, |
|
|
|
|
"Default route must have empty service and method"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route match has a prefix
|
|
|
|
@ -2279,7 +2297,9 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixNonEmptyNoSlash) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "Prefix does not start with a /"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route match has a prefix
|
|
|
|
@ -2297,7 +2317,10 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixNoEndingSlash) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, |
|
|
|
|
"Prefix not in the required format of /service/"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route match has a prefix
|
|
|
|
@ -2315,7 +2338,9 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixNoLeadingSlash) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "Prefix does not start with a /"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route match has a prefix
|
|
|
|
@ -2333,7 +2358,9 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixExtraContent) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "Prefix does not end with a /"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route match has a prefix
|
|
|
|
@ -2351,7 +2378,9 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixNoContent) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "Prefix contains empty service name"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route match has path
|
|
|
|
@ -2372,7 +2401,9 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathEmptyPath) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "Path if set cannot be empty"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route match has path
|
|
|
|
@ -2393,7 +2424,9 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathNoLeadingSlash) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "Path does not start with a /"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route match has path
|
|
|
|
@ -2414,7 +2447,10 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathEndsWithSlash) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, |
|
|
|
|
"Path not in the required format of /service/method"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route match has path
|
|
|
|
@ -2435,7 +2471,10 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathMissingMiddleSlash) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, |
|
|
|
|
"Path not in the required format of /service/method"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route match has path
|
|
|
|
@ -2456,7 +2495,9 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathMissingService) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "Path contains empty service name"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route match has path
|
|
|
|
@ -2477,7 +2518,9 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathMissingMethod) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "Path contains empty method name"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if route has an action other than
|
|
|
|
@ -2490,12 +2533,11 @@ TEST_P(LdsRdsTest, RouteHasNoRouteAction) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "No RouteAction found in route."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO@donnadionne: Add more invalid config tests to cover all errors in
|
|
|
|
|
// xds_api.cc
|
|
|
|
|
|
|
|
|
|
// Tests that LDS client should send a NACK if RouteAction has a
|
|
|
|
|
// cluster_specifier other than cluster in the LDS response.
|
|
|
|
|
TEST_P(LdsRdsTest, RouteActionHasNoCluster) { |
|
|
|
@ -2509,7 +2551,9 @@ TEST_P(LdsRdsTest, RouteActionHasNoCluster) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(RouteConfigurationResponseState(0), AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = RouteConfigurationResponseState(0); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "No cluster found in RouteAction."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that LDS client times out when no response received.
|
|
|
|
@ -2685,8 +2729,8 @@ TEST_P(CdsTest, Vanilla) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
(void)SendRpc(); |
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->cds_response_state(), |
|
|
|
|
AdsServiceImpl::ACKED); |
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->cds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::ACKED); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that CDS client should send a NACK if the cluster type in CDS response
|
|
|
|
@ -2698,8 +2742,10 @@ TEST_P(CdsTest, WrongClusterType) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->cds_response_state(), |
|
|
|
|
AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = |
|
|
|
|
balancers_[0]->ads_service()->cds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "DiscoveryType is not EDS."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that CDS client should send a NACK if the eds_config in CDS response is
|
|
|
|
@ -2711,8 +2757,10 @@ TEST_P(CdsTest, WrongEdsConfig) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->cds_response_state(), |
|
|
|
|
AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = |
|
|
|
|
balancers_[0]->ads_service()->cds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "EDS ConfigSource is not ADS."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that CDS client should send a NACK if the lb_policy in CDS response is
|
|
|
|
@ -2724,8 +2772,10 @@ TEST_P(CdsTest, WrongLbPolicy) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->cds_response_state(), |
|
|
|
|
AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = |
|
|
|
|
balancers_[0]->ads_service()->cds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "LB policy is not ROUND_ROBIN."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that CDS client should send a NACK if the lrs_server in CDS response is
|
|
|
|
@ -2737,8 +2787,10 @@ TEST_P(CdsTest, WrongLrsServer) { |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->cds_response_state(), |
|
|
|
|
AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = |
|
|
|
|
balancers_[0]->ads_service()->cds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, "LRS ConfigSource is not self."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that CDS client times out when no response received.
|
|
|
|
@ -2771,8 +2823,11 @@ TEST_P(EdsTest, NacksSparsePriorityList) { |
|
|
|
|
balancers_[0]->ads_service()->SetEdsResource( |
|
|
|
|
AdsServiceImpl::BuildEdsResource(args), kDefaultResourceName); |
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NACKED); |
|
|
|
|
const auto& response_state = |
|
|
|
|
balancers_[0]->ads_service()->eds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_EQ(response_state.error_message, |
|
|
|
|
"EDS update includes sparse priority list"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using LocalityMapTest = BasicTest; |
|
|
|
@ -3221,8 +3276,8 @@ TEST_P(FailoverTest, MoveAllLocalitiesInCurrentPriorityToHigherPriority) { |
|
|
|
|
// When backend 3 gets traffic, we know the second update has been seen.
|
|
|
|
|
WaitForBackend(3); |
|
|
|
|
// The ADS service of balancer 0 got at least 1 response.
|
|
|
|
|
EXPECT_GT(balancers_[0]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_GT(balancers_[0]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
delayed_resource_setter.join(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -3495,12 +3550,12 @@ TEST_P(BalancerUpdateTest, UpdateBalancersButKeepUsingOriginalBalancer) { |
|
|
|
|
// All 10 requests should have gone to the first backend.
|
|
|
|
|
EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); |
|
|
|
|
// The ADS service of balancer 0 sent at least 1 response.
|
|
|
|
|
EXPECT_GT(balancers_[0]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[1]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[2]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_GT(balancers_[0]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[1]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[2]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); |
|
|
|
|
SetNextResolutionForLbChannel({balancers_[1]->port()}); |
|
|
|
|
gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); |
|
|
|
@ -3515,12 +3570,12 @@ TEST_P(BalancerUpdateTest, UpdateBalancersButKeepUsingOriginalBalancer) { |
|
|
|
|
// first balancer, which doesn't assign the second backend.
|
|
|
|
|
EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); |
|
|
|
|
// The ADS service of balancer 0 sent at least 1 response.
|
|
|
|
|
EXPECT_GT(balancers_[0]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[1]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[2]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_GT(balancers_[0]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[1]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[2]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that the old LB call is still used after multiple balancer address
|
|
|
|
@ -3550,12 +3605,12 @@ TEST_P(BalancerUpdateTest, Repeated) { |
|
|
|
|
// All 10 requests should have gone to the first backend.
|
|
|
|
|
EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); |
|
|
|
|
// The ADS service of balancer 0 sent at least 1 response.
|
|
|
|
|
EXPECT_GT(balancers_[0]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[1]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[2]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_GT(balancers_[0]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[1]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[2]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
std::vector<int> ports; |
|
|
|
|
ports.emplace_back(balancers_[0]->port()); |
|
|
|
|
ports.emplace_back(balancers_[1]->port()); |
|
|
|
@ -3614,12 +3669,12 @@ TEST_P(BalancerUpdateTest, DeadUpdate) { |
|
|
|
|
// All 10 requests should have gone to the first backend.
|
|
|
|
|
EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); |
|
|
|
|
// The ADS service of balancer 0 sent at least 1 response.
|
|
|
|
|
EXPECT_GT(balancers_[0]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[1]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[2]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_GT(balancers_[0]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[1]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[2]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
// Kill balancer 0
|
|
|
|
|
gpr_log(GPR_INFO, "********** ABOUT TO KILL BALANCER 0 *************"); |
|
|
|
|
balancers_[0]->Shutdown(); |
|
|
|
@ -3632,12 +3687,12 @@ TEST_P(BalancerUpdateTest, DeadUpdate) { |
|
|
|
|
EXPECT_EQ(20U, backends_[0]->backend_service()->request_count()); |
|
|
|
|
EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); |
|
|
|
|
// The ADS service of no balancers sent anything
|
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[1]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[2]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[1]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[2]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); |
|
|
|
|
SetNextResolutionForLbChannel({balancers_[1]->port()}); |
|
|
|
|
gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); |
|
|
|
@ -3654,12 +3709,12 @@ TEST_P(BalancerUpdateTest, DeadUpdate) { |
|
|
|
|
// All 10 requests should have gone to the second backend.
|
|
|
|
|
EXPECT_EQ(10U, backends_[1]->backend_service()->request_count()); |
|
|
|
|
// The ADS service of balancer 1 sent at least 1 response.
|
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_GT(balancers_[1]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[2]->ads_service()->eds_response_state(), |
|
|
|
|
AdsServiceImpl::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[0]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
EXPECT_GT(balancers_[1]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
EXPECT_EQ(balancers_[2]->ads_service()->eds_response_state().state, |
|
|
|
|
AdsServiceImpl::ResponseState::NOT_SENT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// The re-resolution tests are deferred because they rely on the fallback mode,
|
|
|
|
|