Merge pull request #23537 from markdroth/xds_routing_env

Remove env var protection of new xds routing code.
reviewable/pr23539/r3
Mark D. Roth 4 years ago committed by GitHub
commit 94a2b5d40c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 65
      src/core/ext/filters/client_channel/xds/xds_api.cc
  2. 1
      src/core/ext/filters/client_channel/xds/xds_api.h
  3. 135
      test/cpp/end2end/xds_end2end_test.cc
  4. 1
      test/cpp/interop/xds_interop_client.cc

@ -134,18 +134,6 @@ const char* XdsApi::kCdsTypeUrl = "type.googleapis.com/envoy.api.v2.Cluster";
const char* XdsApi::kEdsTypeUrl =
"type.googleapis.com/envoy.api.v2.ClusterLoadAssignment";
namespace {
bool XdsRoutingEnabled() {
char* value = gpr_getenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
bool parsed_value;
bool parse_succeeded = gpr_parse_bool_value(value, &parsed_value);
gpr_free(value);
return parse_succeeded && parsed_value;
}
} // namespace
std::string XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::ToString()
const {
std::string path_type_string;
@ -238,7 +226,6 @@ XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
const XdsBootstrap::Node* node)
: client_(client),
tracer_(tracer),
xds_routing_enabled_(XdsRoutingEnabled()),
node_(node),
build_version_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING, " ",
grpc_version_string())),
@ -1270,8 +1257,7 @@ grpc_error* RouteActionParse(const envoy_api_v2_route_Route* route,
grpc_error* RouteConfigParse(
XdsClient* client, TraceFlag* tracer,
const envoy_api_v2_RouteConfiguration* route_config,
const std::string& expected_server_name, const bool xds_routing_enabled,
XdsApi::RdsUpdate* rds_update) {
const std::string& expected_server_name, XdsApi::RdsUpdate* rds_update) {
MaybeLogRouteConfiguration(client, tracer, route_config);
// Get the virtual hosts.
size_t size;
@ -1331,37 +1317,6 @@ grpc_error* RouteConfigParse(
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"No route found in the virtual host.");
}
// If xds_routing is not configured, only look at the last one in the route
// list (the default route)
if (!xds_routing_enabled) {
const envoy_api_v2_route_Route* route = routes[size - 1];
const envoy_api_v2_route_RouteMatch* match =
envoy_api_v2_route_Route_match(route);
XdsApi::RdsUpdate::RdsRoute rds_route;
rds_route.matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute::
Matchers::PathMatcher::PathMatcherType::PREFIX;
// if xds routing is not enabled, we must be working on the default route;
// in this case, we must have an empty or single slash prefix.
if (!envoy_api_v2_route_RouteMatch_has_prefix(match)) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"No prefix field found in Default RouteMatch.");
}
const upb_strview prefix = envoy_api_v2_route_RouteMatch_prefix(match);
if (!upb_strview_eql(prefix, upb_strview_makez("")) &&
!upb_strview_eql(prefix, upb_strview_makez("/"))) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Default route must have empty prefix.");
}
bool ignore_route = false;
grpc_error* error = RouteActionParse(route, &rds_route, &ignore_route);
if (error != GRPC_ERROR_NONE) return error;
if (ignore_route) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Default route action is ignored.");
}
rds_update->routes.emplace_back(std::move(rds_route));
return GRPC_ERROR_NONE;
}
// Loop over the whole list of routes
for (size_t i = 0; i < size; ++i) {
const envoy_api_v2_route_Route* route = routes[i];
@ -1403,7 +1358,6 @@ grpc_error* RouteConfigParse(
grpc_error* LdsResponseParse(XdsClient* client, TraceFlag* tracer,
const envoy_api_v2_DiscoveryResponse* response,
const std::string& expected_server_name,
const bool xds_routing_enabled,
absl::optional<XdsApi::LdsUpdate>* lds_update,
upb_arena* arena) {
// Get the resources from the response.
@ -1449,9 +1403,8 @@ grpc_error* LdsResponseParse(XdsClient* client, TraceFlag* tracer,
envoy_config_filter_network_http_connection_manager_v2_HttpConnectionManager_route_config(
http_connection_manager);
XdsApi::RdsUpdate rds_update;
grpc_error* error =
RouteConfigParse(client, tracer, route_config, expected_server_name,
xds_routing_enabled, &rds_update);
grpc_error* error = RouteConfigParse(client, tracer, route_config,
expected_server_name, &rds_update);
if (error != GRPC_ERROR_NONE) return error;
lds_update->emplace();
(*lds_update)->rds_update.emplace(std::move(rds_update));
@ -1493,7 +1446,6 @@ grpc_error* RdsResponseParse(
const envoy_api_v2_DiscoveryResponse* response,
const std::string& expected_server_name,
const std::set<absl::string_view>& expected_route_configuration_names,
const bool xds_routing_enabled,
absl::optional<XdsApi::RdsUpdate>* rds_update, upb_arena* arena) {
// Get the resources from the response.
size_t size;
@ -1525,9 +1477,8 @@ grpc_error* RdsResponseParse(
}
// Parse the route_config.
XdsApi::RdsUpdate local_rds_update;
grpc_error* error =
RouteConfigParse(client, tracer, route_config, expected_server_name,
xds_routing_enabled, &local_rds_update);
grpc_error* error = RouteConfigParse(
client, tracer, route_config, expected_server_name, &local_rds_update);
if (error != GRPC_ERROR_NONE) return error;
rds_update->emplace(std::move(local_rds_update));
return GRPC_ERROR_NONE;
@ -1839,11 +1790,11 @@ grpc_error* XdsApi::ParseAdsResponse(
// Parse the response according to the resource type.
if (*type_url == kLdsTypeUrl) {
return LdsResponseParse(client_, tracer_, response, expected_server_name,
xds_routing_enabled_, lds_update, arena.ptr());
lds_update, arena.ptr());
} else if (*type_url == kRdsTypeUrl) {
return RdsResponseParse(client_, tracer_, response, expected_server_name,
expected_route_configuration_names,
xds_routing_enabled_, rds_update, arena.ptr());
expected_route_configuration_names, rds_update,
arena.ptr());
} else if (*type_url == kCdsTypeUrl) {
return CdsResponseParse(client_, tracer_, response, expected_cluster_names,
cds_update_map, arena.ptr());

@ -335,7 +335,6 @@ class XdsApi {
private:
XdsClient* client_;
TraceFlag* tracer_;
const bool xds_routing_enabled_;
const XdsBootstrap::Node* node_;
const std::string build_version_;
const std::string user_agent_name_;

@ -2013,26 +2013,6 @@ TEST_P(XdsResolverOnlyTest, DefaultRouteSpecifiesSlashPrefix) {
WaitForAllBackends();
}
TEST_P(XdsResolverOnlyTest, DefaultRouteCaseInsensitive) {
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
route_config.mutable_virtual_hosts(0)
->mutable_routes(0)
->mutable_match()
->mutable_case_sensitive()
->set_value(false);
balancers_[0]->ads_service()->SetLdsResource(
AdsServiceImpl::BuildListener(route_config));
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
AdsServiceImpl::EdsResourceArgs args({
{"locality0", GetBackendPorts()},
});
balancers_[0]->ads_service()->SetEdsResource(
AdsServiceImpl::BuildEdsResource(args));
CheckRpcSendOk(5, RpcOptions().set_wait_for_ready(true));
}
class XdsResolverLoadReportingOnlyTest : public XdsEnd2endTest {
public:
XdsResolverLoadReportingOnlyTest() : XdsEnd2endTest(4, 1, 3) {}
@ -2379,50 +2359,9 @@ TEST_P(LdsRdsTest, ChooseLastRoute) {
AdsServiceImpl::ResponseState::ACKED);
}
// Tests that LDS client should send a NACK if route match has non-empty prefix
// as the only route (default) in the LDS response.
TEST_P(LdsRdsTest, RouteMatchHasNonemptyPrefix) {
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
route_config.mutable_virtual_hosts(0)
->mutable_routes(0)
->mutable_match()
->set_prefix("/nonempty_prefix/");
SetRouteConfiguration(0, route_config);
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
CheckRpcSendFailure();
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 prefix.");
}
// Tests that LDS client should send a NACK if route match has path specifier
// besides prefix as the only route (default) in the LDS response.
TEST_P(LdsRdsTest, RouteMatchHasUnsupportedSpecifier) {
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
route_config.mutable_virtual_hosts(0)
->mutable_routes(0)
->mutable_match()
->set_path("");
SetRouteConfiguration(0, route_config);
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
CheckRpcSendFailure();
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,
"No prefix field found in Default RouteMatch.");
}
// Tests that LDS client should send a NACK if route match has a case_sensitive
// set to false.
TEST_P(LdsRdsTest, RouteMatchHasCaseSensitiveFalse) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2435,12 +2374,10 @@ TEST_P(LdsRdsTest, RouteMatchHasCaseSensitiveFalse) {
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message,
"case_sensitive if set must be set to true.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client should ignore route which has query_parameters.
TEST_P(LdsRdsTest, RouteMatchHasQueryParameters) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2453,13 +2390,11 @@ TEST_P(LdsRdsTest, RouteMatchHasQueryParameters) {
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message, "No valid routes specified.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client should send a ACK if route match has a prefix
// that is either empty or a single slash
TEST_P(LdsRdsTest, RouteMatchHasValidPrefixEmptyOrSingleSlash) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2473,13 +2408,11 @@ TEST_P(LdsRdsTest, RouteMatchHasValidPrefixEmptyOrSingleSlash) {
(void)SendRpc();
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::ACKED);
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client should ignore route which has a path
// prefix string does not start with "/".
TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixNoLeadingSlash) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2491,13 +2424,11 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixNoLeadingSlash) {
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message, "No valid routes specified.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client should ignore route which has a prefix
// string with more than 2 slashes.
TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixExtraContent) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2509,13 +2440,11 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixExtraContent) {
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message, "No valid routes specified.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client should ignore route which has a prefix
// string "//".
TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixDoubleSlash) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2527,13 +2456,11 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixDoubleSlash) {
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message, "No valid routes specified.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client should ignore route which has path
// but it's empty.
TEST_P(LdsRdsTest, RouteMatchHasInvalidPathEmptyPath) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2545,13 +2472,11 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathEmptyPath) {
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message, "No valid routes specified.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client should ignore route which has path
// string does not start with "/".
TEST_P(LdsRdsTest, RouteMatchHasInvalidPathNoLeadingSlash) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2563,13 +2488,11 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathNoLeadingSlash) {
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message, "No valid routes specified.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client should ignore route which has path
// string that has too many slashes; for example, ends with "/".
TEST_P(LdsRdsTest, RouteMatchHasInvalidPathTooManySlashes) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2581,13 +2504,11 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathTooManySlashes) {
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message, "No valid routes specified.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client should ignore route which has path
// string that has only 1 slash: missing "/" between service and method.
TEST_P(LdsRdsTest, RouteMatchHasInvalidPathOnlyOneSlash) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2599,13 +2520,11 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathOnlyOneSlash) {
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message, "No valid routes specified.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client should ignore route which has path
// string that is missing service.
TEST_P(LdsRdsTest, RouteMatchHasInvalidPathMissingService) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2617,13 +2536,11 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathMissingService) {
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message, "No valid routes specified.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client should ignore route which has path
// string that is missing method.
TEST_P(LdsRdsTest, RouteMatchHasInvalidPathMissingMethod) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2635,12 +2552,10 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathMissingMethod) {
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message, "No valid routes specified.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Test that LDS client should reject route which has invalid path regex.
TEST_P(LdsRdsTest, RouteMatchHasInvalidPathRegex) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const char* kNewCluster1Name = "new_cluster_1";
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
@ -2655,7 +2570,6 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathRegex) {
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message,
"Invalid regex string specified in path matcher.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client should send a NACK if route has an action other than
@ -2673,27 +2587,7 @@ TEST_P(LdsRdsTest, RouteHasNoRouteAction) {
EXPECT_EQ(response_state.error_message, "No RouteAction found in route.");
}
// Tests that LDS client should send a NACK if route has a
// cluster_specifier other than cluster or weighted_clusters in the LDS
// response.
TEST_P(LdsRdsTest, RouteActionUnsupportedClusterSpecifier) {
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
route_config.mutable_virtual_hosts(0)
->mutable_routes(0)
->mutable_route()
->mutable_cluster_header();
SetRouteConfiguration(0, route_config);
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
CheckRpcSendFailure();
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message, "Default route action is ignored.");
}
TEST_P(LdsRdsTest, RouteActionClusterHasEmptyClusterName) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
@ -2710,11 +2604,9 @@ TEST_P(LdsRdsTest, RouteActionClusterHasEmptyClusterName) {
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message,
"RouteAction cluster contains empty cluster name.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, RouteActionWeightedTargetHasIncorrectTotalWeightSet) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const size_t kWeight75 = 75;
const char* kNewCluster1Name = "new_cluster_1";
RouteConfiguration route_config =
@ -2740,11 +2632,9 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetHasIncorrectTotalWeightSet) {
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message,
"RouteAction weighted_cluster has incorrect total weight");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, RouteActionWeightedTargetClusterHasEmptyClusterName) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const size_t kWeight75 = 75;
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
@ -2770,11 +2660,9 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetClusterHasEmptyClusterName) {
EXPECT_EQ(
response_state.error_message,
"RouteAction weighted_cluster cluster contains empty cluster name.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, RouteActionWeightedTargetClusterHasNoWeight) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const size_t kWeight75 = 75;
const char* kNewCluster1Name = "new_cluster_1";
RouteConfiguration route_config =
@ -2799,11 +2687,9 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetClusterHasNoWeight) {
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message,
"RouteAction weighted_cluster cluster missing weight");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, RouteHeaderMatchInvalidRegex) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const char* kNewCluster1Name = "new_cluster_1";
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
@ -2821,11 +2707,9 @@ TEST_P(LdsRdsTest, RouteHeaderMatchInvalidRegex) {
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED);
EXPECT_EQ(response_state.error_message,
"Invalid regex string specified in header matcher.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, RouteHeaderMatchInvalidRange) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const char* kNewCluster1Name = "new_cluster_1";
RouteConfiguration route_config =
balancers_[0]->ads_service()->default_route_config();
@ -2845,7 +2729,6 @@ TEST_P(LdsRdsTest, RouteHeaderMatchInvalidRange) {
EXPECT_EQ(response_state.error_message,
"Invalid range header matcher specifier specified: end "
"cannot be smaller than start.");
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
// Tests that LDS client times out when no response received.
@ -2864,7 +2747,6 @@ TEST_P(LdsRdsTest, Timeout) {
// Tests that LDS client should choose the default route (with no matching
// specified) after unable to find a match with previous routes.
TEST_P(LdsRdsTest, XdsRoutingPathMatching) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const char* kNewCluster1Name = "new_cluster_1";
const char* kNewCluster2Name = "new_cluster_2";
const size_t kNumEcho1Rpcs = 10;
@ -2934,11 +2816,9 @@ TEST_P(LdsRdsTest, XdsRoutingPathMatching) {
EXPECT_EQ(0, backends_[3]->backend_service()->request_count());
EXPECT_EQ(0, backends_[3]->backend_service1()->request_count());
EXPECT_EQ(kNumEcho2Rpcs, backends_[3]->backend_service2()->request_count());
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, XdsRoutingPrefixMatching) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const char* kNewCluster1Name = "new_cluster_1";
const char* kNewCluster2Name = "new_cluster_2";
const size_t kNumEcho1Rpcs = 10;
@ -3003,11 +2883,9 @@ TEST_P(LdsRdsTest, XdsRoutingPrefixMatching) {
EXPECT_EQ(0, backends_[3]->backend_service()->request_count());
EXPECT_EQ(0, backends_[3]->backend_service1()->request_count());
EXPECT_EQ(kNumEcho2Rpcs, backends_[3]->backend_service2()->request_count());
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, XdsRoutingPathRegexMatching) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const char* kNewCluster1Name = "new_cluster_1";
const char* kNewCluster2Name = "new_cluster_2";
const size_t kNumEcho1Rpcs = 10;
@ -3074,11 +2952,9 @@ TEST_P(LdsRdsTest, XdsRoutingPathRegexMatching) {
EXPECT_EQ(0, backends_[3]->backend_service()->request_count());
EXPECT_EQ(0, backends_[3]->backend_service1()->request_count());
EXPECT_EQ(kNumEcho2Rpcs, backends_[3]->backend_service2()->request_count());
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, XdsRoutingWeightedCluster) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const char* kNewCluster1Name = "new_cluster_1";
const char* kNewCluster2Name = "new_cluster_2";
const size_t kNumEcho1Rpcs = 1000;
@ -3160,7 +3036,6 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedCluster) {
(1 - kErrorToleranceSmallLoad)),
::testing::Le(kNumEcho1Rpcs * kWeight25 / 100 *
(1 + kErrorToleranceSmallLoad))));
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, RouteActionWeightedTargetDefaultRoute) {
@ -3239,7 +3114,6 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetDefaultRoute) {
}
TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateWeights) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const char* kNewCluster1Name = "new_cluster_1";
const char* kNewCluster2Name = "anew_cluster_2";
const char* kNewCluster3Name = "new_cluster_3";
@ -3366,11 +3240,9 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateWeights) {
(1 - kErrorTolerance)),
::testing::Le(kNumEcho1Rpcs * kWeight50 / 100 *
(1 + kErrorTolerance))));
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateClusters) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const char* kNewCluster1Name = "new_cluster_1";
const char* kNewCluster2Name = "anew_cluster_2";
const char* kNewCluster3Name = "new_cluster_3";
@ -3526,11 +3398,9 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateClusters) {
(1 - kErrorToleranceSmallLoad)),
::testing::Le(kNumEcho1Rpcs * kWeight25 / 100 *
(1 + kErrorToleranceSmallLoad))));
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, XdsRoutingHeadersMatching) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const char* kNewCluster1Name = "new_cluster_1";
const size_t kNumEcho1Rpcs = 100;
const size_t kNumEchoRpcs = 5;
@ -3605,11 +3475,9 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatching) {
EXPECT_EQ(0, backends_[1]->backend_service2()->request_count());
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::ACKED);
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, XdsRoutingRuntimeFractionMatching) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const char* kNewCluster1Name = "new_cluster_1";
const size_t kNumRpcs = 1000;
SetNextResolution({});
@ -3659,11 +3527,9 @@ TEST_P(LdsRdsTest, XdsRoutingRuntimeFractionMatching) {
::testing::Le(kNumRpcs * 25 / 100 * (1 + kErrorTolerance))));
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::ACKED);
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingUnmatchCases) {
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
const char* kNewCluster1Name = "new_cluster_1";
const char* kNewCluster2Name = "new_cluster_2";
const char* kNewCluster3Name = "new_cluster_3";
@ -3753,7 +3619,6 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingUnmatchCases) {
EXPECT_EQ(0, backends_[0]->backend_service2()->request_count());
const auto& response_state = RouteConfigurationResponseState(0);
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::ACKED);
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
}
using CdsTest = BasicTest;

@ -358,7 +358,6 @@ void RunServer(const int port) {
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(argc, argv);
grpc::testing::InitTest(&argc, &argv, true);
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ROUTING", "true");
std::chrono::duration<double> duration_per_query =
std::chrono::nanoseconds(std::chrono::seconds(1)) / FLAGS_qps;

Loading…
Cancel
Save