From 4b9ec936e8fdff247d31754afbc5ef95fd458ef5 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 4 Mar 2021 10:09:25 -0800 Subject: [PATCH] xDS Interop Client changes for PSM security tests (#25613) --- BUILD | 28 +++++++++++++++++--------- test/cpp/interop/xds_interop_client.cc | 12 ++++++++--- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/BUILD b/BUILD index a9ed766c520..eb271dab3f3 100644 --- a/BUILD +++ b/BUILD @@ -357,6 +357,22 @@ grpc_cc_library( grpc_cc_library( name = "grpc++", + language = "c++", + select_deps = { + "grpc_no_xds": [], + "//conditions:default": [ + "grpc++_xds_client", + "grpc++_xds_server", + ], + }, + standalone = True, + deps = [ + "grpc++_internals", + ], +) + +grpc_cc_library( + name = "grpc++_internals", srcs = [ "src/cpp/client/insecure_credentials.cc", "src/cpp/client/secure_credentials.cc", @@ -382,14 +398,6 @@ grpc_cc_library( ], language = "c++", public_hdrs = GRPCXX_PUBLIC_HDRS, - select_deps = { - "grpc_no_xds": [], - "//conditions:default": [ - "grpc++_xds_client", - "grpc++_xds_server", - ], - }, - standalone = True, deps = [ "gpr", "grpc", @@ -411,7 +419,7 @@ grpc_cc_library( ], language = "c++", deps = [ - "grpc++_base", + "grpc++_internals", ], ) @@ -428,7 +436,7 @@ grpc_cc_library( "include/grpcpp/xds_server_builder.h", ], deps = [ - "grpc++_base", + "grpc++_internals", ], ) diff --git a/test/cpp/interop/xds_interop_client.cc b/test/cpp/interop/xds_interop_client.cc index e0dad44b782..5582b4f800a 100644 --- a/test/cpp/interop/xds_interop_client.cc +++ b/test/cpp/interop/xds_interop_client.cc @@ -59,6 +59,8 @@ ABSL_FLAG(std::string, rpc, "UnaryCall", ABSL_FLAG(std::string, metadata, "", "metadata to send with the RPC."); ABSL_FLAG(std::string, expect_status, "OK", "RPC status for the test RPC to be considered successful"); +ABSL_FLAG(std::string, security, "none", + "If set to \"secure\", XdsCredentials are used"); using grpc::Channel; using grpc::ClientAsyncResponseReader; @@ -460,9 +462,13 @@ class XdsUpdateClientConfigureServiceImpl void RunTestLoop(std::chrono::duration duration_per_query, StatsWatchers* stats_watchers, RpcConfigurationsQueue* rpc_configs_queue) { - TestClient client(grpc::CreateChannel(absl::GetFlag(FLAGS_server), - grpc::InsecureChannelCredentials()), - stats_watchers); + TestClient client( + grpc::CreateChannel(absl::GetFlag(FLAGS_server), + absl::GetFlag(FLAGS_security) == "secure" + ? grpc::experimental::XdsCredentials( + grpc::InsecureChannelCredentials()) + : grpc::InsecureChannelCredentials()), + stats_watchers); std::chrono::time_point start = std::chrono::system_clock::now(); std::chrono::duration elapsed;