|
|
|
@ -246,53 +246,6 @@ void TestScenario::Log() const { |
|
|
|
|
|
|
|
|
|
class HealthCheck : public health::v1::Health::Service {}; |
|
|
|
|
|
|
|
|
|
/* This interceptor does nothing. Just keeps a global count on the number of
|
|
|
|
|
* times it was invoked. */ |
|
|
|
|
class DummyInterceptor : public experimental::Interceptor { |
|
|
|
|
public: |
|
|
|
|
DummyInterceptor(experimental::ClientRpcInfo* info) {} |
|
|
|
|
|
|
|
|
|
virtual void Intercept(experimental::InterceptorBatchMethods* methods) { |
|
|
|
|
if (methods->QueryInterceptionHookPoint( |
|
|
|
|
experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) { |
|
|
|
|
num_times_run_++; |
|
|
|
|
} else if (methods->QueryInterceptionHookPoint( |
|
|
|
|
experimental::InterceptionHookPoints:: |
|
|
|
|
POST_RECV_INITIAL_METADATA)) { |
|
|
|
|
num_times_run_reverse_++; |
|
|
|
|
} |
|
|
|
|
methods->Proceed(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void Reset() { |
|
|
|
|
num_times_run_.store(0); |
|
|
|
|
num_times_run_reverse_.store(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int GetNumTimesRun() { |
|
|
|
|
EXPECT_EQ(num_times_run_.load(), num_times_run_reverse_.load()); |
|
|
|
|
return num_times_run_.load(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static const int kNumInterceptorsRegistered = 5; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
static std::atomic<int> num_times_run_; |
|
|
|
|
static std::atomic<int> num_times_run_reverse_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
std::atomic<int> DummyInterceptor::num_times_run_; |
|
|
|
|
std::atomic<int> DummyInterceptor::num_times_run_reverse_; |
|
|
|
|
|
|
|
|
|
class DummyInterceptorFactory |
|
|
|
|
: public experimental::ClientInterceptorFactoryInterface { |
|
|
|
|
public: |
|
|
|
|
virtual experimental::Interceptor* CreateClientInterceptor( |
|
|
|
|
experimental::ClientRpcInfo* info) override { |
|
|
|
|
return new DummyInterceptor(info); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class AsyncEnd2endTest : public ::testing::TestWithParam<TestScenario> { |
|
|
|
|
protected: |
|
|
|
|
AsyncEnd2endTest() { GetParam().Log(); } |
|
|
|
@ -340,22 +293,10 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<TestScenario> { |
|
|
|
|
ChannelArguments args; |
|
|
|
|
auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( |
|
|
|
|
GetParam().credentials_type, &args); |
|
|
|
|
auto creators = std::unique_ptr<std::vector< |
|
|
|
|
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>( |
|
|
|
|
new std::vector<std::unique_ptr< |
|
|
|
|
experimental::ClientInterceptorFactoryInterface>>()); |
|
|
|
|
// Add dummy interceptors
|
|
|
|
|
for (auto i = 0; i < DummyInterceptor::kNumInterceptorsRegistered; i++) { |
|
|
|
|
creators->push_back(std::unique_ptr<DummyInterceptorFactory>( |
|
|
|
|
new DummyInterceptorFactory())); |
|
|
|
|
} |
|
|
|
|
std::shared_ptr<Channel> channel = |
|
|
|
|
!(GetParam().inproc) |
|
|
|
|
? CreateCustomChannelWithInterceptors(server_address_.str(), |
|
|
|
|
channel_creds, args, |
|
|
|
|
std::move(creators)) |
|
|
|
|
: server_->experimental().InProcessChannelWithInterceptors( |
|
|
|
|
args, std::move(creators)); |
|
|
|
|
? CreateCustomChannel(server_address_.str(), channel_creds, args) |
|
|
|
|
: server_->InProcessChannel(args); |
|
|
|
|
stub_ = grpc::testing::EchoTestService::NewStub(channel); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|