Add test for retry code path.

pull/17577/head
Mark D. Roth 6 years ago
parent 08f94b1623
commit e8cd36924e
  1. 1
      src/core/lib/transport/service_config.h
  2. 34
      test/cpp/end2end/client_lb_end2end_test.cc

@ -240,6 +240,7 @@ RefCountedPtr<T> ServiceConfig::MethodConfigTableLookup(
value = table.Get(wildcard_path);
grpc_slice_unref_internal(wildcard_path);
gpr_free(path_str);
if (value == nullptr) return nullptr;
}
return RefCountedPtr<T>(*value);
}

@ -1251,7 +1251,7 @@ class ClientLbInterceptTrailingMetadataTest : public ClientLbEnd2endTest {
int trailers_intercepted_ = 0;
};
TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetries) {
TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetriesDisabled) {
const int kNumServers = 1;
const int kNumRpcs = 10;
StartServers(kNumServers);
@ -1267,6 +1267,38 @@ TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetries) {
EXPECT_EQ(kNumRpcs, trailers_intercepted());
}
TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetriesEnabled) {
const int kNumServers = 1;
const int kNumRpcs = 10;
StartServers(kNumServers);
ChannelArguments args;
args.SetServiceConfigJSON(
"{\n"
" \"methodConfig\": [ {\n"
" \"name\": [\n"
" { \"service\": \"grpc.testing.EchoTestService\" }\n"
" ],\n"
" \"retryPolicy\": {\n"
" \"maxAttempts\": 3,\n"
" \"initialBackoff\": \"1s\",\n"
" \"maxBackoff\": \"120s\",\n"
" \"backoffMultiplier\": 1.6,\n"
" \"retryableStatusCodes\": [ \"ABORTED\" ]\n"
" }\n"
" } ]\n"
"}");
auto channel = BuildChannel("intercept_trailing_metadata_lb", args);
auto stub = BuildStub(channel);
SetNextResolution(GetServersPorts());
for (size_t i = 0; i < kNumRpcs; ++i) {
CheckRpcSendOk(stub, DEBUG_LOCATION);
}
// Check LB policy name for the channel.
EXPECT_EQ("intercept_trailing_metadata_lb",
channel->GetLoadBalancingPolicyName());
EXPECT_EQ(kNumRpcs, trailers_intercepted());
}
} // namespace
} // namespace testing
} // namespace grpc

Loading…
Cancel
Save