|
|
|
@ -5650,7 +5650,6 @@ TEST_P(LdsRdsTest, XdsRoutingWithOnlyApplicationTimeout) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(LdsRdsTest, XdsRetryPolicyNumRetries) { |
|
|
|
|
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY", "true"); |
|
|
|
|
const size_t kNumRetries = 3; |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
@ -5711,11 +5710,9 @@ TEST_P(LdsRdsTest, XdsRetryPolicyNumRetries) { |
|
|
|
|
StatusCode::UNAUTHENTICATED)) |
|
|
|
|
.set_expected_error_code(StatusCode::UNAUTHENTICATED)); |
|
|
|
|
EXPECT_EQ(1, backends_[0]->backend_service()->request_count()); |
|
|
|
|
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(LdsRdsTest, XdsRetryPolicyAtVirtualHostLevel) { |
|
|
|
|
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY", "true"); |
|
|
|
|
const size_t kNumRetries = 3; |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
@ -5739,11 +5736,9 @@ TEST_P(LdsRdsTest, XdsRetryPolicyAtVirtualHostLevel) { |
|
|
|
|
StatusCode::DEADLINE_EXCEEDED)) |
|
|
|
|
.set_expected_error_code(StatusCode::DEADLINE_EXCEEDED)); |
|
|
|
|
EXPECT_EQ(kNumRetries + 1, backends_[0]->backend_service()->request_count()); |
|
|
|
|
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(LdsRdsTest, XdsRetryPolicyLongBackOff) { |
|
|
|
|
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY", "true"); |
|
|
|
|
// Set num retries to 3, but due to longer back off, we expect only 1 retry
|
|
|
|
|
// will take place.
|
|
|
|
|
const size_t kNumRetries = 3; |
|
|
|
@ -5777,11 +5772,9 @@ TEST_P(LdsRdsTest, XdsRetryPolicyLongBackOff) { |
|
|
|
|
StatusCode::CANCELLED)) |
|
|
|
|
.set_expected_error_code(StatusCode::DEADLINE_EXCEEDED)); |
|
|
|
|
EXPECT_EQ(1 + 1, backends_[0]->backend_service()->request_count()); |
|
|
|
|
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(LdsRdsTest, XdsRetryPolicyMaxBackOff) { |
|
|
|
|
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY", "true"); |
|
|
|
|
// Set num retries to 3, but due to longer back off, we expect only 2 retry
|
|
|
|
|
// will take place, while the 2nd one will obey the max backoff.
|
|
|
|
|
const size_t kNumRetries = 3; |
|
|
|
@ -5822,11 +5815,9 @@ TEST_P(LdsRdsTest, XdsRetryPolicyMaxBackOff) { |
|
|
|
|
StatusCode::CANCELLED)) |
|
|
|
|
.set_expected_error_code(StatusCode::DEADLINE_EXCEEDED)); |
|
|
|
|
EXPECT_EQ(2 + 1, backends_[0]->backend_service()->request_count()); |
|
|
|
|
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(LdsRdsTest, XdsRetryPolicyUnsupportedStatusCode) { |
|
|
|
|
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY", "true"); |
|
|
|
|
const size_t kNumRetries = 3; |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
@ -5849,11 +5840,9 @@ TEST_P(LdsRdsTest, XdsRetryPolicyUnsupportedStatusCode) { |
|
|
|
|
StatusCode::DEADLINE_EXCEEDED)) |
|
|
|
|
.set_expected_error_code(StatusCode::DEADLINE_EXCEEDED)); |
|
|
|
|
EXPECT_EQ(1, backends_[0]->backend_service()->request_count()); |
|
|
|
|
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(LdsRdsTest, XdsRetryPolicyInvalidNumRetriesZero) { |
|
|
|
|
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY", "true"); |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
// Populate new EDS resources.
|
|
|
|
@ -5876,11 +5865,9 @@ TEST_P(LdsRdsTest, XdsRetryPolicyInvalidNumRetriesZero) { |
|
|
|
|
response_state.error_message, |
|
|
|
|
::testing::HasSubstr( |
|
|
|
|
"RouteAction RetryPolicy num_retries set to invalid value 0.")); |
|
|
|
|
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(LdsRdsTest, XdsRetryPolicyRetryBackOffMissingBaseInterval) { |
|
|
|
|
gpr_setenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY", "true"); |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
// Populate new EDS resources.
|
|
|
|
@ -5907,70 +5894,6 @@ TEST_P(LdsRdsTest, XdsRetryPolicyRetryBackOffMissingBaseInterval) { |
|
|
|
|
response_state.error_message, |
|
|
|
|
::testing::HasSubstr( |
|
|
|
|
"RouteAction RetryPolicy RetryBackoff missing base interval.")); |
|
|
|
|
gpr_unsetenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(LdsRdsTest, XdsRetryPolicyDisabled) { |
|
|
|
|
const size_t kNumRetries = 3; |
|
|
|
|
SetNextResolution({}); |
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
// Populate new EDS resources.
|
|
|
|
|
AdsServiceImpl::EdsResourceArgs args({ |
|
|
|
|
{"locality0", CreateEndpointsForBackends(0, 1)}, |
|
|
|
|
}); |
|
|
|
|
balancers_[0]->ads_service()->SetEdsResource(BuildEdsResource(args)); |
|
|
|
|
// Construct route config to set retry policy.
|
|
|
|
|
RouteConfiguration new_route_config = default_route_config_; |
|
|
|
|
auto* route1 = new_route_config.mutable_virtual_hosts(0)->mutable_routes(0); |
|
|
|
|
auto* retry_policy = route1->mutable_route()->mutable_retry_policy(); |
|
|
|
|
retry_policy->set_retry_on( |
|
|
|
|
"5xx,cancelled,deadline-exceeded,internal,resource-exhausted," |
|
|
|
|
"unavailable"); |
|
|
|
|
retry_policy->mutable_num_retries()->set_value(kNumRetries); |
|
|
|
|
SetRouteConfiguration(0, new_route_config); |
|
|
|
|
// Ensure we don't retry on supported statuses.
|
|
|
|
|
CheckRpcSendFailure( |
|
|
|
|
CheckRpcSendFailureOptions() |
|
|
|
|
.set_rpc_options( |
|
|
|
|
RpcOptions().set_server_expected_error(StatusCode::CANCELLED)) |
|
|
|
|
.set_expected_error_code(StatusCode::CANCELLED)); |
|
|
|
|
EXPECT_EQ(1, backends_[0]->backend_service()->request_count()); |
|
|
|
|
ResetBackendCounters(); |
|
|
|
|
CheckRpcSendFailure( |
|
|
|
|
CheckRpcSendFailureOptions() |
|
|
|
|
.set_rpc_options(RpcOptions().set_server_expected_error( |
|
|
|
|
StatusCode::DEADLINE_EXCEEDED)) |
|
|
|
|
.set_expected_error_code(StatusCode::DEADLINE_EXCEEDED)); |
|
|
|
|
EXPECT_EQ(1, backends_[0]->backend_service()->request_count()); |
|
|
|
|
ResetBackendCounters(); |
|
|
|
|
CheckRpcSendFailure( |
|
|
|
|
CheckRpcSendFailureOptions() |
|
|
|
|
.set_rpc_options( |
|
|
|
|
RpcOptions().set_server_expected_error(StatusCode::INTERNAL)) |
|
|
|
|
.set_expected_error_code(StatusCode::INTERNAL)); |
|
|
|
|
EXPECT_EQ(1, backends_[0]->backend_service()->request_count()); |
|
|
|
|
ResetBackendCounters(); |
|
|
|
|
CheckRpcSendFailure( |
|
|
|
|
CheckRpcSendFailureOptions() |
|
|
|
|
.set_rpc_options(RpcOptions().set_server_expected_error( |
|
|
|
|
StatusCode::RESOURCE_EXHAUSTED)) |
|
|
|
|
.set_expected_error_code(StatusCode::RESOURCE_EXHAUSTED)); |
|
|
|
|
EXPECT_EQ(1, backends_[0]->backend_service()->request_count()); |
|
|
|
|
ResetBackendCounters(); |
|
|
|
|
CheckRpcSendFailure( |
|
|
|
|
CheckRpcSendFailureOptions() |
|
|
|
|
.set_rpc_options( |
|
|
|
|
RpcOptions().set_server_expected_error(StatusCode::UNAVAILABLE)) |
|
|
|
|
.set_expected_error_code(StatusCode::UNAVAILABLE)); |
|
|
|
|
EXPECT_EQ(1, backends_[0]->backend_service()->request_count()); |
|
|
|
|
ResetBackendCounters(); |
|
|
|
|
// Ensure we don't retry on an unsupported status.
|
|
|
|
|
CheckRpcSendFailure( |
|
|
|
|
CheckRpcSendFailureOptions() |
|
|
|
|
.set_rpc_options(RpcOptions().set_server_expected_error( |
|
|
|
|
StatusCode::UNAUTHENTICATED)) |
|
|
|
|
.set_expected_error_code(StatusCode::UNAUTHENTICATED)); |
|
|
|
|
EXPECT_EQ(1, backends_[0]->backend_service()->request_count()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(LdsRdsTest, XdsRoutingHeadersMatching) { |
|
|
|
|