Move Channel also to impl for now

pull/18444/head
Karthik Ravi Shankar 6 years ago
parent e57182ab61
commit 60bdeef9f4
  1. 2
      include/grpcpp/create_channel.h
  2. 3
      include/grpcpp/impl/codegen/client_context.h
  3. 41
      include/grpcpp/security/credentials.h
  4. 12
      include/grpcpp/security/credentials_impl.h
  5. 2
      src/cpp/client/create_channel.cc
  6. 2
      src/cpp/client/create_channel_posix.cc
  7. 2
      src/cpp/client/credentials_cc.cc
  8. 11
      src/cpp/client/insecure_credentials.cc
  9. 10
      src/cpp/client/secure_credentials.cc
  10. 8
      src/cpp/client/secure_credentials.h
  11. 33
      test/cpp/end2end/end2end_test.cc
  12. 4
      test/cpp/end2end/filter_end2end_test.cc
  13. 4
      test/cpp/end2end/generic_end2end_test.cc
  14. 4
      test/cpp/end2end/health_service_end2end_test.cc
  15. 10
      test/cpp/end2end/hybrid_end2end_test.cc
  16. 4
      test/cpp/end2end/mock_test.cc
  17. 4
      test/cpp/end2end/server_early_return_test.cc
  18. 21
      test/cpp/end2end/server_interceptors_end2end_test.cc
  19. 4
      test/cpp/end2end/streaming_throughput_test.cc
  20. 4
      test/cpp/end2end/thread_stress_test.cc
  21. 4
      test/cpp/util/cli_call_test.cc

@ -19,8 +19,8 @@
#ifndef GRPCPP_CREATE_CHANNEL_H #ifndef GRPCPP_CREATE_CHANNEL_H
#define GRPCPP_CREATE_CHANNEL_H #define GRPCPP_CREATE_CHANNEL_H
#include <grpcpp/support/channel_arguments.h>
#include <grpcpp/create_channel_impl.h> #include <grpcpp/create_channel_impl.h>
#include <grpcpp/support/channel_arguments.h>
namespace grpc { namespace grpc {

@ -309,7 +309,8 @@ class ClientContext {
/// call. /// call.
/// ///
/// \see https://grpc.io/docs/guides/auth.html /// \see https://grpc.io/docs/guides/auth.html
void set_credentials(const std::shared_ptr<grpc_impl::CallCredentials>& creds) { void set_credentials(
const std::shared_ptr<grpc_impl::CallCredentials>& creds) {
creds_ = creds; creds_ = creds;
} }

@ -30,7 +30,8 @@ typedef ::grpc_impl::SslCredentialsOptions SslCredentialsOptions;
typedef ::grpc_impl::SecureCallCredentials SecureCallCredentials; typedef ::grpc_impl::SecureCallCredentials SecureCallCredentials;
typedef ::grpc_impl::SecureChannelCredentials SecureChannelCredentials; typedef ::grpc_impl::SecureChannelCredentials SecureChannelCredentials;
static inline std::shared_ptr<grpc_impl::ChannelCredentials> GoogleDefaultCredentials() { static inline std::shared_ptr<grpc_impl::ChannelCredentials>
GoogleDefaultCredentials() {
return ::grpc_impl::GoogleDefaultCredentials(); return ::grpc_impl::GoogleDefaultCredentials();
} }
@ -39,30 +40,34 @@ static inline std::shared_ptr<ChannelCredentials> SslCredentials(
return ::grpc_impl::SslCredentials(options); return ::grpc_impl::SslCredentials(options);
} }
static inline std::shared_ptr<grpc_impl::CallCredentials> GoogleComputeEngineCredentials() { static inline std::shared_ptr<grpc_impl::CallCredentials>
GoogleComputeEngineCredentials() {
return ::grpc_impl::GoogleComputeEngineCredentials(); return ::grpc_impl::GoogleComputeEngineCredentials();
} }
static inline std::shared_ptr<grpc_impl::CallCredentials> ServiceAccountJWTAccessCredentials( static inline std::shared_ptr<grpc_impl::CallCredentials>
ServiceAccountJWTAccessCredentials(
const grpc::string& json_key, const grpc::string& json_key,
long token_lifetime_seconds = ::grpc_impl::kMaxAuthTokenLifetimeSecs) { long token_lifetime_seconds = ::grpc_impl::kMaxAuthTokenLifetimeSecs) {
return ::grpc_impl::ServiceAccountJWTAccessCredentials(json_key, token_lifetime_seconds); return ::grpc_impl::ServiceAccountJWTAccessCredentials(
json_key, token_lifetime_seconds);
} }
static inline std::shared_ptr<grpc_impl::CallCredentials> GoogleRefreshTokenCredentials( static inline std::shared_ptr<grpc_impl::CallCredentials>
const grpc::string& json_refresh_token) { GoogleRefreshTokenCredentials(const grpc::string& json_refresh_token) {
return ::grpc_impl::GoogleRefreshTokenCredentials(json_refresh_token); return ::grpc_impl::GoogleRefreshTokenCredentials(json_refresh_token);
} }
static inline std::shared_ptr<grpc_impl::CallCredentials> AccessTokenCredentials( static inline std::shared_ptr<grpc_impl::CallCredentials>
const grpc::string& access_token) { AccessTokenCredentials(const grpc::string& access_token) {
return ::grpc_impl::AccessTokenCredentials(access_token); return ::grpc_impl::AccessTokenCredentials(access_token);
} }
static inline std::shared_ptr<grpc_impl::CallCredentials> GoogleIAMCredentials( static inline std::shared_ptr<grpc_impl::CallCredentials> GoogleIAMCredentials(
const grpc::string& authorization_token, const grpc::string& authorization_token,
const grpc::string& authority_selector) { const grpc::string& authority_selector) {
return ::grpc_impl::GoogleIAMCredentials(authorization_token, authority_selector); return ::grpc_impl::GoogleIAMCredentials(authorization_token,
authority_selector);
} }
static inline std::shared_ptr<ChannelCredentials> CompositeChannelCredentials( static inline std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
@ -71,30 +76,34 @@ static inline std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
return ::grpc_impl::CompositeChannelCredentials(channel_creds, call_creds); return ::grpc_impl::CompositeChannelCredentials(channel_creds, call_creds);
} }
static inline std::shared_ptr<grpc_impl::CallCredentials> CompositeCallCredentials( static inline std::shared_ptr<grpc_impl::CallCredentials>
const std::shared_ptr<CallCredentials>& creds1, CompositeCallCredentials(const std::shared_ptr<CallCredentials>& creds1,
const std::shared_ptr<CallCredentials>& creds2) { const std::shared_ptr<CallCredentials>& creds2) {
return ::grpc_impl::CompositeCallCredentials(creds1, creds2); return ::grpc_impl::CompositeCallCredentials(creds1, creds2);
} }
static inline std::shared_ptr<grpc_impl::ChannelCredentials> InsecureChannelCredentials() { static inline std::shared_ptr<grpc_impl::ChannelCredentials>
InsecureChannelCredentials() {
return ::grpc_impl::InsecureChannelCredentials(); return ::grpc_impl::InsecureChannelCredentials();
} }
static inline std::shared_ptr<grpc_impl::ChannelCredentials> CronetChannelCredentials(void* engine) { static inline std::shared_ptr<grpc_impl::ChannelCredentials>
CronetChannelCredentials(void* engine) {
return ::grpc_impl::CronetChannelCredentials(engine); return ::grpc_impl::CronetChannelCredentials(engine);
} }
typedef ::grpc_impl::MetadataCredentialsPlugin MetadataCredentialsPlugin; typedef ::grpc_impl::MetadataCredentialsPlugin MetadataCredentialsPlugin;
static inline std::shared_ptr<grpc_impl::CallCredentials> MetadataCredentialsFromPlugin( static inline std::shared_ptr<grpc_impl::CallCredentials>
MetadataCredentialsFromPlugin(
std::unique_ptr<MetadataCredentialsPlugin> plugin) { std::unique_ptr<MetadataCredentialsPlugin> plugin) {
return ::grpc_impl::MetadataCredentialsFromPlugin(std::move(plugin)); return ::grpc_impl::MetadataCredentialsFromPlugin(std::move(plugin));
} }
namespace experimental { namespace experimental {
typedef ::grpc_impl::experimental::AltsCredentialsOptions AltsCredentialsOptions; typedef ::grpc_impl::experimental::AltsCredentialsOptions
AltsCredentialsOptions;
static inline std::shared_ptr<grpc_impl::ChannelCredentials> AltsCredentials( static inline std::shared_ptr<grpc_impl::ChannelCredentials> AltsCredentials(
const AltsCredentialsOptions& options) { const AltsCredentialsOptions& options) {

@ -88,19 +88,19 @@ class ChannelCredentials : private grpc::GrpcLibraryCodegen {
const grpc::string& target, const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds, const std::shared_ptr<ChannelCredentials>& creds,
const grpc::ChannelArguments& args, const grpc::ChannelArguments& args,
std::vector< std::vector<std::unique_ptr<
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>> grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators); interceptor_creators);
virtual std::shared_ptr<grpc::Channel> CreateChannel( virtual std::shared_ptr<grpc::Channel> CreateChannelImpl(
const grpc::string& target, const grpc::ChannelArguments& args) = 0; const grpc::string& target, const grpc::ChannelArguments& args) = 0;
// This function should have been a pure virtual function, but it is // This function should have been a pure virtual function, but it is
// implemented as a virtual function so that it does not break API. // implemented as a virtual function so that it does not break API.
virtual std::shared_ptr<grpc::Channel> CreateChannelWithInterceptors( virtual std::shared_ptr<grpc::Channel> CreateChannelWithInterceptors(
const grpc::string& target, const grpc::ChannelArguments& args, const grpc::string& target, const grpc::ChannelArguments& args,
std::vector< std::vector<std::unique_ptr<
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>> grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators) { interceptor_creators) {
return nullptr; return nullptr;
} }
@ -280,6 +280,6 @@ std::shared_ptr<ChannelCredentials> LocalCredentials(
grpc_local_connect_type type); grpc_local_connect_type type);
} // namespace experimental } // namespace experimental
} // namespace grpc } // namespace grpc_impl
#endif // GRPCPP_SECURITY_CREDENTIALS_H #endif // GRPCPP_SECURITY_CREDENTIALS_H

@ -20,8 +20,8 @@
#include <grpcpp/channel.h> #include <grpcpp/channel.h>
#include <grpcpp/create_channel.h> #include <grpcpp/create_channel.h>
#include <grpcpp/security/credentials.h>
#include <grpcpp/impl/grpc_library.h> #include <grpcpp/impl/grpc_library.h>
#include <grpcpp/security/credentials.h>
#include <grpcpp/support/channel_arguments.h> #include <grpcpp/support/channel_arguments.h>
#include "src/cpp/client/create_channel_internal.h" #include "src/cpp/client/create_channel_internal.h"

@ -19,8 +19,8 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_posix.h> #include <grpc/grpc_posix.h>
#include <grpcpp/channel.h> #include <grpcpp/channel.h>
#include <grpcpp/support/channel_arguments.h>
#include <grpcpp/impl/grpc_library.h> #include <grpcpp/impl/grpc_library.h>
#include <grpcpp/support/channel_arguments.h>
#include "src/cpp/client/create_channel_internal.h" #include "src/cpp/client/create_channel_internal.h"

@ -30,4 +30,4 @@ CallCredentials::CallCredentials() { g_gli_initializer.summon(); }
CallCredentials::~CallCredentials() {} CallCredentials::~CallCredentials() {}
} // namespace grpc } // namespace grpc_impl

@ -31,13 +31,8 @@ namespace grpc_impl {
namespace { namespace {
class InsecureChannelCredentialsImpl final : public ChannelCredentials { class InsecureChannelCredentialsImpl final : public ChannelCredentials {
public: public:
<<<<<<< HEAD
std::shared_ptr<grpc::Channel> CreateChannelImpl( std::shared_ptr<grpc::Channel> CreateChannelImpl(
const string& target, const grpc::ChannelArguments& args) override {
=======
std::shared_ptr<grpc::Channel> CreateChannel(
const grpc::string& target, const grpc::ChannelArguments& args) override { const grpc::string& target, const grpc::ChannelArguments& args) override {
>>>>>>> Changes to fold credentials into grpc_impl from grpc
return CreateChannelWithInterceptors( return CreateChannelWithInterceptors(
target, args, target, args,
std::vector<std::unique_ptr< std::vector<std::unique_ptr<
@ -46,8 +41,8 @@ class InsecureChannelCredentialsImpl final : public ChannelCredentials {
std::shared_ptr<grpc::Channel> CreateChannelWithInterceptors( std::shared_ptr<grpc::Channel> CreateChannelWithInterceptors(
const grpc::string& target, const grpc::ChannelArguments& args, const grpc::string& target, const grpc::ChannelArguments& args,
std::vector< std::vector<std::unique_ptr<
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>> grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators) override { interceptor_creators) override {
grpc_channel_args channel_args; grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args); args.SetChannelArgs(&channel_args);
@ -66,4 +61,4 @@ std::shared_ptr<ChannelCredentials> InsecureChannelCredentials() {
new InsecureChannelCredentialsImpl()); new InsecureChannelCredentialsImpl());
} }
} // namespace grpc } // namespace grpc_impl

@ -35,11 +35,11 @@ SecureChannelCredentials::SecureChannelCredentials(
} }
std::shared_ptr<grpc::Channel> SecureChannelCredentials::CreateChannelImpl( std::shared_ptr<grpc::Channel> SecureChannelCredentials::CreateChannelImpl(
const string& target, const grpc::ChannelArguments& args) { const grpc::string& target, const grpc::ChannelArguments& args) {
return CreateChannelWithInterceptors( return CreateChannelWithInterceptors(
target, args, target, args,
std::vector< std::vector<std::unique_ptr<
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>()); grpc::experimental::ClientInterceptorFactoryInterface>>());
} }
std::shared_ptr<grpc::Channel> std::shared_ptr<grpc::Channel>
@ -220,7 +220,7 @@ std::shared_ptr<grpc_impl::CallCredentials> MetadataCredentialsFromPlugin(
grpc_metadata_credentials_create_from_plugin(c_plugin, nullptr)); grpc_metadata_credentials_create_from_plugin(c_plugin, nullptr));
} }
} // namespace grpc_impl } // namespace grpc_impl
namespace grpc { namespace grpc {
@ -325,4 +325,4 @@ MetadataCredentialsPluginWrapper::MetadataCredentialsPluginWrapper(
std::unique_ptr<MetadataCredentialsPlugin> plugin) std::unique_ptr<MetadataCredentialsPlugin> plugin)
: thread_pool_(CreateDefaultThreadPool()), plugin_(std::move(plugin)) {} : thread_pool_(CreateDefaultThreadPool()), plugin_(std::move(plugin)) {}
} // namespace grpc_impl } // namespace grpc

@ -38,15 +38,15 @@ class SecureChannelCredentials final : public ChannelCredentials {
grpc_channel_credentials* GetRawCreds() { return c_creds_; } grpc_channel_credentials* GetRawCreds() { return c_creds_; }
std::shared_ptr<grpc::Channel> CreateChannelImpl( std::shared_ptr<grpc::Channel> CreateChannelImpl(
const string& target, const grpc::ChannelArguments& args) override; const grpc::string& target, const grpc::ChannelArguments& args) override;
SecureChannelCredentials* AsSecureCredentials() override { return this; } SecureChannelCredentials* AsSecureCredentials() override { return this; }
private: private:
std::shared_ptr<grpc::Channel> CreateChannelWithInterceptors( std::shared_ptr<grpc::Channel> CreateChannelWithInterceptors(
const grpc::string& target, const grpc::ChannelArguments& args, const grpc::string& target, const grpc::ChannelArguments& args,
std::vector< std::vector<std::unique_ptr<
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>> grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators) override; interceptor_creators) override;
grpc_channel_credentials* const c_creds_; grpc_channel_credentials* const c_creds_;
}; };
@ -66,7 +66,7 @@ class SecureCallCredentials final : public CallCredentials {
grpc_call_credentials* const c_creds_; grpc_call_credentials* const c_creds_;
}; };
} // namespace grpc_impl } // namespace grpc_impl
namespace grpc { namespace grpc {

@ -374,7 +374,8 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
proxy_server_ = builder.BuildAndStart(); proxy_server_ = builder.BuildAndStart();
channel_ = grpc::CreateChannel(proxyaddr.str(), InsecureChannelCredentials()); channel_ =
grpc::CreateChannel(proxyaddr.str(), InsecureChannelCredentials());
} }
stub_ = grpc::testing::EchoTestService::NewStub(channel_); stub_ = grpc::testing::EchoTestService::NewStub(channel_);
@ -1825,8 +1826,8 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginKeyFailure) {
EchoRequest request; EchoRequest request;
EchoResponse response; EchoResponse response;
ClientContext context; ClientContext context;
context.set_credentials( context.set_credentials(grpc::MetadataCredentialsFromPlugin(
grpc::MetadataCredentialsFromPlugin(std::unique_ptr<MetadataCredentialsPlugin>( std::unique_ptr<MetadataCredentialsPlugin>(
new TestMetadataCredentialsPlugin( new TestMetadataCredentialsPlugin(
TestMetadataCredentialsPlugin::kBadMetadataKey, TestMetadataCredentialsPlugin::kBadMetadataKey,
"Does not matter, will fail the key is invalid.", false, true)))); "Does not matter, will fail the key is invalid.", false, true))));
@ -1843,8 +1844,8 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) {
EchoRequest request; EchoRequest request;
EchoResponse response; EchoResponse response;
ClientContext context; ClientContext context;
context.set_credentials( context.set_credentials(grpc::MetadataCredentialsFromPlugin(
grpc::MetadataCredentialsFromPlugin(std::unique_ptr<MetadataCredentialsPlugin>( std::unique_ptr<MetadataCredentialsPlugin>(
new TestMetadataCredentialsPlugin( new TestMetadataCredentialsPlugin(
TestMetadataCredentialsPlugin::kGoodMetadataKey, TestMetadataCredentialsPlugin::kGoodMetadataKey,
"With illegal \n value.", false, true)))); "With illegal \n value.", false, true))));
@ -1861,8 +1862,8 @@ TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) {
EchoRequest request; EchoRequest request;
EchoResponse response; EchoResponse response;
ClientContext context; ClientContext context;
context.set_credentials( context.set_credentials(grpc::MetadataCredentialsFromPlugin(
grpc::MetadataCredentialsFromPlugin(std::unique_ptr<MetadataCredentialsPlugin>( std::unique_ptr<MetadataCredentialsPlugin>(
new TestMetadataCredentialsPlugin( new TestMetadataCredentialsPlugin(
TestMetadataCredentialsPlugin::kGoodMetadataKey, TestMetadataCredentialsPlugin::kGoodMetadataKey,
"Does not matter, will fail anyway (see 3rd param)", false, "Does not matter, will fail anyway (see 3rd param)", false,
@ -1925,8 +1926,8 @@ TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginFailure) {
EchoRequest request; EchoRequest request;
EchoResponse response; EchoResponse response;
ClientContext context; ClientContext context;
context.set_credentials( context.set_credentials(grpc::MetadataCredentialsFromPlugin(
grpc::MetadataCredentialsFromPlugin(std::unique_ptr<MetadataCredentialsPlugin>( std::unique_ptr<MetadataCredentialsPlugin>(
new TestMetadataCredentialsPlugin( new TestMetadataCredentialsPlugin(
TestMetadataCredentialsPlugin::kGoodMetadataKey, TestMetadataCredentialsPlugin::kGoodMetadataKey,
"Does not matter, will fail anyway (see 3rd param)", true, "Does not matter, will fail anyway (see 3rd param)", true,
@ -1953,12 +1954,14 @@ TEST_P(SecureEnd2endTest, CompositeCallCreds) {
const char kMetadataVal2[] = "call-creds-val2"; const char kMetadataVal2[] = "call-creds-val2";
context.set_credentials(grpc::CompositeCallCredentials( context.set_credentials(grpc::CompositeCallCredentials(
grpc::MetadataCredentialsFromPlugin(std::unique_ptr<MetadataCredentialsPlugin>( grpc::MetadataCredentialsFromPlugin(
new TestMetadataCredentialsPlugin(kMetadataKey1, kMetadataVal1, true, std::unique_ptr<MetadataCredentialsPlugin>(
true))), new TestMetadataCredentialsPlugin(kMetadataKey1, kMetadataVal1,
grpc::MetadataCredentialsFromPlugin(std::unique_ptr<MetadataCredentialsPlugin>( true, true))),
new TestMetadataCredentialsPlugin(kMetadataKey2, kMetadataVal2, true, grpc::MetadataCredentialsFromPlugin(
true))))); std::unique_ptr<MetadataCredentialsPlugin>(
new TestMetadataCredentialsPlugin(kMetadataKey2, kMetadataVal2,
true, true)))));
request.set_message("Hello"); request.set_message("Hello");
request.mutable_param()->set_echo_metadata(true); request.mutable_param()->set_echo_metadata(true);

@ -146,8 +146,8 @@ class FilterEnd2endTest : public ::testing::Test {
} }
void ResetStub() { void ResetStub() {
std::shared_ptr<Channel> channel = std::shared_ptr<Channel> channel = grpc::CreateChannel(
grpc::CreateChannel(server_address_.str(), InsecureChannelCredentials()); server_address_.str(), InsecureChannelCredentials());
generic_stub_.reset(new GenericStub(channel)); generic_stub_.reset(new GenericStub(channel));
ResetConnectionCounter(); ResetConnectionCounter();
ResetCallCounter(); ResetCallCounter();

@ -90,8 +90,8 @@ class GenericEnd2endTest : public ::testing::Test {
} }
void ResetStub() { void ResetStub() {
std::shared_ptr<Channel> channel = std::shared_ptr<Channel> channel = grpc::CreateChannel(
grpc::CreateChannel(server_address_.str(), InsecureChannelCredentials()); server_address_.str(), InsecureChannelCredentials());
generic_stub_.reset(new GenericStub(channel)); generic_stub_.reset(new GenericStub(channel));
} }

@ -124,8 +124,8 @@ class HealthServiceEnd2endTest : public ::testing::Test {
} }
void ResetStubs() { void ResetStubs() {
std::shared_ptr<Channel> channel = std::shared_ptr<Channel> channel = grpc::CreateChannel(
grpc::CreateChannel(server_address_.str(), InsecureChannelCredentials()); server_address_.str(), InsecureChannelCredentials());
hc_stub_ = grpc::health::v1::Health::NewStub(channel); hc_stub_ = grpc::health::v1::Health::NewStub(channel);
} }

@ -297,7 +297,7 @@ class HybridEnd2endTest : public ::testing::TestWithParam<bool> {
std::shared_ptr<Channel> channel = std::shared_ptr<Channel> channel =
inproc_ ? server_->InProcessChannel(ChannelArguments()) inproc_ ? server_->InProcessChannel(ChannelArguments())
: grpc::CreateChannel(server_address_.str(), : grpc::CreateChannel(server_address_.str(),
InsecureChannelCredentials()); InsecureChannelCredentials());
stub_ = grpc::testing::EchoTestService::NewStub(channel); stub_ = grpc::testing::EchoTestService::NewStub(channel);
} }
@ -321,8 +321,8 @@ class HybridEnd2endTest : public ::testing::TestWithParam<bool> {
} }
void SendEchoToDupService() { void SendEchoToDupService() {
std::shared_ptr<Channel> channel = std::shared_ptr<Channel> channel = grpc::CreateChannel(
grpc::CreateChannel(server_address_.str(), InsecureChannelCredentials()); server_address_.str(), InsecureChannelCredentials());
auto stub = grpc::testing::duplicate::EchoTestService::NewStub(channel); auto stub = grpc::testing::duplicate::EchoTestService::NewStub(channel);
EchoRequest send_request; EchoRequest send_request;
EchoResponse recv_response; EchoResponse recv_response;
@ -373,8 +373,8 @@ class HybridEnd2endTest : public ::testing::TestWithParam<bool> {
} }
void SendSimpleServerStreamingToDupService() { void SendSimpleServerStreamingToDupService() {
std::shared_ptr<Channel> channel = std::shared_ptr<Channel> channel = grpc::CreateChannel(
grpc::CreateChannel(server_address_.str(), InsecureChannelCredentials()); server_address_.str(), InsecureChannelCredentials());
auto stub = grpc::testing::duplicate::EchoTestService::NewStub(channel); auto stub = grpc::testing::duplicate::EchoTestService::NewStub(channel);
EchoRequest request; EchoRequest request;
EchoResponse response; EchoResponse response;

@ -244,8 +244,8 @@ class MockTest : public ::testing::Test {
void TearDown() override { server_->Shutdown(); } void TearDown() override { server_->Shutdown(); }
void ResetStub() { void ResetStub() {
std::shared_ptr<Channel> channel = std::shared_ptr<Channel> channel = grpc::CreateChannel(
grpc::CreateChannel(server_address_.str(), InsecureChannelCredentials()); server_address_.str(), InsecureChannelCredentials());
stub_ = grpc::testing::EchoTestService::NewStub(channel); stub_ = grpc::testing::EchoTestService::NewStub(channel);
} }

@ -122,8 +122,8 @@ class ServerEarlyReturnTest : public ::testing::Test {
builder.RegisterService(&service_); builder.RegisterService(&service_);
server_ = builder.BuildAndStart(); server_ = builder.BuildAndStart();
channel_ = channel_ = grpc::CreateChannel(server_address_.str(),
grpc::CreateChannel(server_address_.str(), InsecureChannelCredentials()); InsecureChannelCredentials());
stub_ = grpc::testing::EchoTestService::NewStub(channel_); stub_ = grpc::testing::EchoTestService::NewStub(channel_);
} }

@ -265,7 +265,8 @@ class ServerInterceptorsEnd2endSyncUnaryTest : public ::testing::Test {
TEST_F(ServerInterceptorsEnd2endSyncUnaryTest, UnaryTest) { TEST_F(ServerInterceptorsEnd2endSyncUnaryTest, UnaryTest) {
ChannelArguments args; ChannelArguments args;
DummyInterceptor::Reset(); DummyInterceptor::Reset();
auto channel = grpc::CreateChannel(server_address_, InsecureChannelCredentials()); auto channel =
grpc::CreateChannel(server_address_, InsecureChannelCredentials());
MakeCall(channel); MakeCall(channel);
// Make sure all 20 dummy interceptors were run // Make sure all 20 dummy interceptors were run
EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20); EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20);
@ -308,7 +309,8 @@ class ServerInterceptorsEnd2endSyncStreamingTest : public ::testing::Test {
TEST_F(ServerInterceptorsEnd2endSyncStreamingTest, ClientStreamingTest) { TEST_F(ServerInterceptorsEnd2endSyncStreamingTest, ClientStreamingTest) {
ChannelArguments args; ChannelArguments args;
DummyInterceptor::Reset(); DummyInterceptor::Reset();
auto channel = grpc::CreateChannel(server_address_, InsecureChannelCredentials()); auto channel =
grpc::CreateChannel(server_address_, InsecureChannelCredentials());
MakeClientStreamingCall(channel); MakeClientStreamingCall(channel);
// Make sure all 20 dummy interceptors were run // Make sure all 20 dummy interceptors were run
EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20); EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20);
@ -317,7 +319,8 @@ TEST_F(ServerInterceptorsEnd2endSyncStreamingTest, ClientStreamingTest) {
TEST_F(ServerInterceptorsEnd2endSyncStreamingTest, ServerStreamingTest) { TEST_F(ServerInterceptorsEnd2endSyncStreamingTest, ServerStreamingTest) {
ChannelArguments args; ChannelArguments args;
DummyInterceptor::Reset(); DummyInterceptor::Reset();
auto channel = grpc::CreateChannel(server_address_, InsecureChannelCredentials()); auto channel =
grpc::CreateChannel(server_address_, InsecureChannelCredentials());
MakeServerStreamingCall(channel); MakeServerStreamingCall(channel);
// Make sure all 20 dummy interceptors were run // Make sure all 20 dummy interceptors were run
EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20); EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20);
@ -326,7 +329,8 @@ TEST_F(ServerInterceptorsEnd2endSyncStreamingTest, ServerStreamingTest) {
TEST_F(ServerInterceptorsEnd2endSyncStreamingTest, BidiStreamingTest) { TEST_F(ServerInterceptorsEnd2endSyncStreamingTest, BidiStreamingTest) {
ChannelArguments args; ChannelArguments args;
DummyInterceptor::Reset(); DummyInterceptor::Reset();
auto channel = grpc::CreateChannel(server_address_, InsecureChannelCredentials()); auto channel =
grpc::CreateChannel(server_address_, InsecureChannelCredentials());
MakeBidiStreamingCall(channel); MakeBidiStreamingCall(channel);
// Make sure all 20 dummy interceptors were run // Make sure all 20 dummy interceptors were run
EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20); EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20);
@ -356,7 +360,8 @@ TEST_F(ServerInterceptorsAsyncEnd2endTest, UnaryTest) {
auto server = builder.BuildAndStart(); auto server = builder.BuildAndStart();
ChannelArguments args; ChannelArguments args;
auto channel = grpc::CreateChannel(server_address, InsecureChannelCredentials()); auto channel =
grpc::CreateChannel(server_address, InsecureChannelCredentials());
auto stub = grpc::testing::EchoTestService::NewStub(channel); auto stub = grpc::testing::EchoTestService::NewStub(channel);
EchoRequest send_request; EchoRequest send_request;
@ -428,7 +433,8 @@ TEST_F(ServerInterceptorsAsyncEnd2endTest, BidiStreamingTest) {
auto server = builder.BuildAndStart(); auto server = builder.BuildAndStart();
ChannelArguments args; ChannelArguments args;
auto channel = grpc::CreateChannel(server_address, InsecureChannelCredentials()); auto channel =
grpc::CreateChannel(server_address, InsecureChannelCredentials());
auto stub = grpc::testing::EchoTestService::NewStub(channel); auto stub = grpc::testing::EchoTestService::NewStub(channel);
EchoRequest send_request; EchoRequest send_request;
@ -509,7 +515,8 @@ TEST_F(ServerInterceptorsAsyncEnd2endTest, GenericRPCTest) {
auto server = builder.BuildAndStart(); auto server = builder.BuildAndStart();
ChannelArguments args; ChannelArguments args;
auto channel = grpc::CreateChannel(server_address, InsecureChannelCredentials()); auto channel =
grpc::CreateChannel(server_address, InsecureChannelCredentials());
GenericStub generic_stub(channel); GenericStub generic_stub(channel);
const grpc::string kMethodName("/grpc.cpp.test.util.EchoTestService/Echo"); const grpc::string kMethodName("/grpc.cpp.test.util.EchoTestService/Echo");

@ -145,8 +145,8 @@ class End2endTest : public ::testing::Test {
void TearDown() override { server_->Shutdown(); } void TearDown() override { server_->Shutdown(); }
void ResetStub() { void ResetStub() {
std::shared_ptr<Channel> channel = std::shared_ptr<Channel> channel = grpc::CreateChannel(
grpc::CreateChannel(server_address_.str(), InsecureChannelCredentials()); server_address_.str(), InsecureChannelCredentials());
stub_ = grpc::testing::EchoTestService::NewStub(channel); stub_ = grpc::testing::EchoTestService::NewStub(channel);
} }

@ -96,8 +96,8 @@ template <class Service>
class CommonStressTestInsecure : public CommonStressTest<Service> { class CommonStressTestInsecure : public CommonStressTest<Service> {
public: public:
void ResetStub() override { void ResetStub() override {
std::shared_ptr<Channel> channel = std::shared_ptr<Channel> channel = grpc::CreateChannel(
grpc::CreateChannel(server_address_.str(), InsecureChannelCredentials()); server_address_.str(), InsecureChannelCredentials());
this->stub_ = grpc::testing::EchoTestService::NewStub(channel); this->stub_ = grpc::testing::EchoTestService::NewStub(channel);
} }
bool AllowExhaustion() override { return false; } bool AllowExhaustion() override { return false; }

@ -74,8 +74,8 @@ class CliCallTest : public ::testing::Test {
void TearDown() override { server_->Shutdown(); } void TearDown() override { server_->Shutdown(); }
void ResetStub() { void ResetStub() {
channel_ = channel_ = grpc::CreateChannel(server_address_.str(),
grpc::CreateChannel(server_address_.str(), InsecureChannelCredentials()); InsecureChannelCredentials());
stub_ = grpc::testing::EchoTestService::NewStub(channel_); stub_ = grpc::testing::EchoTestService::NewStub(channel_);
} }

Loading…
Cancel
Save