diff options
Diffstat (limited to 'test/cpp/end2end/client_interceptors_end2end_test.cc')
-rw-r--r-- | test/cpp/end2end/client_interceptors_end2end_test.cc | 116 |
1 files changed, 50 insertions, 66 deletions
diff --git a/test/cpp/end2end/client_interceptors_end2end_test.cc b/test/cpp/end2end/client_interceptors_end2end_test.cc index 3708c11235..33773e3b3b 100644 --- a/test/cpp/end2end/client_interceptors_end2end_test.cc +++ b/test/cpp/end2end/client_interceptors_end2end_test.cc @@ -50,6 +50,7 @@ class HijackingInterceptor : public experimental::Interceptor { info_ = info; // Make sure it is the right method EXPECT_EQ(strcmp("/grpc.testing.EchoTestService/Echo", info->method()), 0); + EXPECT_EQ(info->type(), experimental::ClientRpcInfo::Type::UNARY); } virtual void Intercept(experimental::InterceptorBatchMethods* methods) { @@ -415,15 +416,13 @@ class ClientInterceptorsEnd2endTest : public ::testing::Test { TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorLoggingTest) { ChannelArguments args; DummyInterceptor::Reset(); - auto creators = std::unique_ptr<std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>( - new std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); - creators->push_back(std::unique_ptr<LoggingInterceptorFactory>( + std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> + creators; + creators.push_back(std::unique_ptr<LoggingInterceptorFactory>( new LoggingInterceptorFactory())); // Add 20 dummy interceptors for (auto i = 0; i < 20; i++) { - creators->push_back(std::unique_ptr<DummyInterceptorFactory>( + creators.push_back(std::unique_ptr<DummyInterceptorFactory>( new DummyInterceptorFactory())); } auto channel = experimental::CreateCustomChannelWithInterceptors( @@ -436,20 +435,19 @@ TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorLoggingTest) { TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorHijackingTest) { ChannelArguments args; DummyInterceptor::Reset(); - auto creators = std::unique_ptr<std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>( - new std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); + std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> + creators; // Add 20 dummy interceptors before hijacking interceptor + creators.reserve(20); for (auto i = 0; i < 20; i++) { - creators->push_back(std::unique_ptr<DummyInterceptorFactory>( + creators.push_back(std::unique_ptr<DummyInterceptorFactory>( new DummyInterceptorFactory())); } - creators->push_back(std::unique_ptr<HijackingInterceptorFactory>( + creators.push_back(std::unique_ptr<HijackingInterceptorFactory>( new HijackingInterceptorFactory())); // Add 20 dummy interceptors after hijacking interceptor for (auto i = 0; i < 20; i++) { - creators->push_back(std::unique_ptr<DummyInterceptorFactory>( + creators.push_back(std::unique_ptr<DummyInterceptorFactory>( new DummyInterceptorFactory())); } auto channel = experimental::CreateCustomChannelWithInterceptors( @@ -462,13 +460,11 @@ TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorHijackingTest) { TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorLogThenHijackTest) { ChannelArguments args; - auto creators = std::unique_ptr<std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>( - new std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); - creators->push_back(std::unique_ptr<LoggingInterceptorFactory>( + std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> + creators; + creators.push_back(std::unique_ptr<LoggingInterceptorFactory>( new LoggingInterceptorFactory())); - creators->push_back(std::unique_ptr<HijackingInterceptorFactory>( + creators.push_back(std::unique_ptr<HijackingInterceptorFactory>( new HijackingInterceptorFactory())); auto channel = experimental::CreateCustomChannelWithInterceptors( server_address_, InsecureChannelCredentials(), args, std::move(creators)); @@ -480,21 +476,20 @@ TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorHijackingMakesAnotherCallTest) { ChannelArguments args; DummyInterceptor::Reset(); - auto creators = std::unique_ptr<std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>( - new std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); + std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> + creators; // Add 5 dummy interceptors before hijacking interceptor + creators.reserve(5); for (auto i = 0; i < 5; i++) { - creators->push_back(std::unique_ptr<DummyInterceptorFactory>( + creators.push_back(std::unique_ptr<DummyInterceptorFactory>( new DummyInterceptorFactory())); } - creators->push_back( + creators.push_back( std::unique_ptr<experimental::ClientInterceptorFactoryInterface>( new HijackingInterceptorMakesAnotherCallFactory())); // Add 7 dummy interceptors after hijacking interceptor for (auto i = 0; i < 7; i++) { - creators->push_back(std::unique_ptr<DummyInterceptorFactory>( + creators.push_back(std::unique_ptr<DummyInterceptorFactory>( new DummyInterceptorFactory())); } auto channel = server_->experimental().InProcessChannelWithInterceptors( @@ -510,15 +505,13 @@ TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorLoggingTestWithCallback) { ChannelArguments args; DummyInterceptor::Reset(); - auto creators = std::unique_ptr<std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>( - new std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); - creators->push_back(std::unique_ptr<LoggingInterceptorFactory>( + std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> + creators; + creators.push_back(std::unique_ptr<LoggingInterceptorFactory>( new LoggingInterceptorFactory())); // Add 20 dummy interceptors for (auto i = 0; i < 20; i++) { - creators->push_back(std::unique_ptr<DummyInterceptorFactory>( + creators.push_back(std::unique_ptr<DummyInterceptorFactory>( new DummyInterceptorFactory())); } auto channel = server_->experimental().InProcessChannelWithInterceptors( @@ -550,15 +543,13 @@ class ClientInterceptorsStreamingEnd2endTest : public ::testing::Test { TEST_F(ClientInterceptorsStreamingEnd2endTest, ClientStreamingTest) { ChannelArguments args; DummyInterceptor::Reset(); - auto creators = std::unique_ptr<std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>( - new std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); - creators->push_back(std::unique_ptr<LoggingInterceptorFactory>( + std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> + creators; + creators.push_back(std::unique_ptr<LoggingInterceptorFactory>( new LoggingInterceptorFactory())); // Add 20 dummy interceptors for (auto i = 0; i < 20; i++) { - creators->push_back(std::unique_ptr<DummyInterceptorFactory>( + creators.push_back(std::unique_ptr<DummyInterceptorFactory>( new DummyInterceptorFactory())); } auto channel = experimental::CreateCustomChannelWithInterceptors( @@ -571,15 +562,13 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest, ClientStreamingTest) { TEST_F(ClientInterceptorsStreamingEnd2endTest, ServerStreamingTest) { ChannelArguments args; DummyInterceptor::Reset(); - auto creators = std::unique_ptr<std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>( - new std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); - creators->push_back(std::unique_ptr<LoggingInterceptorFactory>( + std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> + creators; + creators.push_back(std::unique_ptr<LoggingInterceptorFactory>( new LoggingInterceptorFactory())); // Add 20 dummy interceptors for (auto i = 0; i < 20; i++) { - creators->push_back(std::unique_ptr<DummyInterceptorFactory>( + creators.push_back(std::unique_ptr<DummyInterceptorFactory>( new DummyInterceptorFactory())); } auto channel = experimental::CreateCustomChannelWithInterceptors( @@ -623,15 +612,13 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest, ClientStreamingHijackingTest) { TEST_F(ClientInterceptorsStreamingEnd2endTest, BidiStreamingTest) { ChannelArguments args; DummyInterceptor::Reset(); - auto creators = std::unique_ptr<std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>( - new std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); - creators->push_back(std::unique_ptr<LoggingInterceptorFactory>( + std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> + creators; + creators.push_back(std::unique_ptr<LoggingInterceptorFactory>( new LoggingInterceptorFactory())); // Add 20 dummy interceptors for (auto i = 0; i < 20; i++) { - creators->push_back(std::unique_ptr<DummyInterceptorFactory>( + creators.push_back(std::unique_ptr<DummyInterceptorFactory>( new DummyInterceptorFactory())); } auto channel = experimental::CreateCustomChannelWithInterceptors( @@ -668,13 +655,12 @@ TEST_F(ClientGlobalInterceptorEnd2endTest, DummyGlobalInterceptor) { experimental::RegisterGlobalClientInterceptorFactory(&global_factory); ChannelArguments args; DummyInterceptor::Reset(); - auto creators = std::unique_ptr<std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>( - new std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); + std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> + creators; // Add 20 dummy interceptors + creators.reserve(20); for (auto i = 0; i < 20; i++) { - creators->push_back(std::unique_ptr<DummyInterceptorFactory>( + creators.push_back(std::unique_ptr<DummyInterceptorFactory>( new DummyInterceptorFactory())); } auto channel = experimental::CreateCustomChannelWithInterceptors( @@ -695,13 +681,12 @@ TEST_F(ClientGlobalInterceptorEnd2endTest, LoggingGlobalInterceptor) { experimental::RegisterGlobalClientInterceptorFactory(&global_factory); ChannelArguments args; DummyInterceptor::Reset(); - auto creators = std::unique_ptr<std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>( - new std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); + std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> + creators; // Add 20 dummy interceptors + creators.reserve(20); for (auto i = 0; i < 20; i++) { - creators->push_back(std::unique_ptr<DummyInterceptorFactory>( + creators.push_back(std::unique_ptr<DummyInterceptorFactory>( new DummyInterceptorFactory())); } auto channel = experimental::CreateCustomChannelWithInterceptors( @@ -722,13 +707,12 @@ TEST_F(ClientGlobalInterceptorEnd2endTest, HijackingGlobalInterceptor) { experimental::RegisterGlobalClientInterceptorFactory(&global_factory); ChannelArguments args; DummyInterceptor::Reset(); - auto creators = std::unique_ptr<std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>( - new std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); + std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> + creators; // Add 20 dummy interceptors + creators.reserve(20); for (auto i = 0; i < 20; i++) { - creators->push_back(std::unique_ptr<DummyInterceptorFactory>( + creators.push_back(std::unique_ptr<DummyInterceptorFactory>( new DummyInterceptorFactory())); } auto channel = experimental::CreateCustomChannelWithInterceptors( @@ -746,7 +730,7 @@ TEST_F(ClientGlobalInterceptorEnd2endTest, HijackingGlobalInterceptor) { } // namespace grpc int main(int argc, char** argv) { - grpc_test_init(argc, argv); + grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } |