From 0dcbb83420e25b657249878606bbef9c53f09ea3 Mon Sep 17 00:00:00 2001 From: Yihua Zhang Date: Fri, 20 Apr 2018 08:50:45 -0700 Subject: add alts to interop tests --- test/cpp/interop/client.cc | 2 ++ test/cpp/interop/client_helper.cc | 5 ++++- test/cpp/interop/http2_client.cc | 2 +- test/cpp/interop/interop_server.cc | 2 ++ test/cpp/interop/reconnect_interop_client.cc | 6 ++++-- test/cpp/interop/server_helper.cc | 3 +++ test/cpp/interop/stress_test.cc | 10 +++++++++- 7 files changed, 25 insertions(+), 5 deletions(-) (limited to 'test/cpp/interop') diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index ca8ee3de06..3eb155ef95 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -31,6 +31,8 @@ #include "test/cpp/interop/interop_client.h" #include "test/cpp/util/test_config.h" +DEFINE_bool(use_alts, false, + "Whether to use alts. Enable alts will disable tls."); DEFINE_bool(use_tls, false, "Whether to use tls."); DEFINE_string(custom_credentials_type, "", "User provided credentials type."); DEFINE_bool(use_test_ca, false, "False to use SSL roots for google"); diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index 4041f95abc..29b5a1ed6c 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -35,6 +35,7 @@ #include "test/cpp/util/create_test_channel.h" #include "test/cpp/util/test_credentials_provider.h" +DECLARE_bool(use_alts); DECLARE_bool(use_tls); DECLARE_string(custom_credentials_type); DECLARE_bool(use_test_ca); @@ -103,8 +104,10 @@ std::shared_ptr CreateChannelForTestCase( GPR_ASSERT(creds); } if (FLAGS_custom_credentials_type.empty()) { + transport_security security_type = + FLAGS_use_alts ? ALTS : (FLAGS_use_tls ? TLS : INSECURE); return CreateTestChannel(host_port, FLAGS_server_host_override, - FLAGS_use_tls, !FLAGS_use_test_ca, creds); + security_type, !FLAGS_use_test_ca, creds); } else { return CreateTestChannel(host_port, FLAGS_custom_credentials_type, creds); } diff --git a/test/cpp/interop/http2_client.cc b/test/cpp/interop/http2_client.cc index 821815c6e8..543f159265 100644 --- a/test/cpp/interop/http2_client.cc +++ b/test/cpp/interop/http2_client.cc @@ -194,7 +194,7 @@ int main(int argc, char** argv) { snprintf(host_port, host_port_buf_size, "%s:%d", FLAGS_server_host.c_str(), FLAGS_server_port); std::shared_ptr channel = - grpc::CreateTestChannel(host_port, false); + grpc::CreateTestChannel(host_port, grpc::testing::INSECURE); GPR_ASSERT(channel->WaitForConnected(gpr_time_add( gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(300, GPR_TIMESPAN)))); grpc::testing::Http2Client client(channel); diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc index 5fa1a336da..6526e0535b 100644 --- a/test/cpp/interop/interop_server.cc +++ b/test/cpp/interop/interop_server.cc @@ -38,6 +38,8 @@ #include "test/cpp/interop/server_helper.h" #include "test/cpp/util/test_config.h" +DEFINE_bool(use_alts, false, + "Whether to use alts. Enable alts will disable tls."); DEFINE_bool(use_tls, false, "Whether to use tls."); DEFINE_string(custom_credentials_type, "", "User provided credentials type."); DEFINE_int32(port, 0, "Server port."); diff --git a/test/cpp/interop/reconnect_interop_client.cc b/test/cpp/interop/reconnect_interop_client.cc index 9a451fa3f2..8a071d417e 100644 --- a/test/cpp/interop/reconnect_interop_client.cc +++ b/test/cpp/interop/reconnect_interop_client.cc @@ -44,9 +44,11 @@ using grpc::ClientContext; using grpc::CreateTestChannel; using grpc::Status; using grpc::testing::Empty; +using grpc::testing::INSECURE; using grpc::testing::ReconnectInfo; using grpc::testing::ReconnectParams; using grpc::testing::ReconnectService; +using grpc::testing::TLS; int main(int argc, char** argv) { grpc::testing::InitTest(&argc, &argv, true); @@ -57,7 +59,7 @@ int main(int argc, char** argv) { server_address << FLAGS_server_host << ':' << FLAGS_server_control_port; std::unique_ptr control_stub( ReconnectService::NewStub( - CreateTestChannel(server_address.str(), false))); + CreateTestChannel(server_address.str(), INSECURE))); ClientContext start_context; ReconnectParams reconnect_params; reconnect_params.set_max_reconnect_backoff_ms(FLAGS_max_reconnect_backoff_ms); @@ -75,7 +77,7 @@ int main(int argc, char** argv) { FLAGS_max_reconnect_backoff_ms); } std::shared_ptr retry_channel = - CreateTestChannel(server_address.str(), "foo.test.google.fr", true, false, + CreateTestChannel(server_address.str(), "foo.test.google.fr", TLS, false, std::shared_ptr(), channel_args); // About 13 retries. diff --git a/test/cpp/interop/server_helper.cc b/test/cpp/interop/server_helper.cc index 93ffd52560..2194521998 100644 --- a/test/cpp/interop/server_helper.cc +++ b/test/cpp/interop/server_helper.cc @@ -26,6 +26,7 @@ #include "src/core/lib/surface/call_test_only.h" #include "test/cpp/util/test_credentials_provider.h" +DECLARE_bool(use_alts); DECLARE_bool(use_tls); DECLARE_string(custom_credentials_type); @@ -36,6 +37,8 @@ std::shared_ptr CreateInteropServerCredentials() { if (!FLAGS_custom_credentials_type.empty()) { return GetCredentialsProvider()->GetServerCredentials( FLAGS_custom_credentials_type); + } else if (FLAGS_use_alts) { + return GetCredentialsProvider()->GetServerCredentials(kAltsCredentialsType); } else if (FLAGS_use_tls) { return GetCredentialsProvider()->GetServerCredentials(kTlsCredentialsType); } else { diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc index 6e8134a83b..023e0c8f0b 100644 --- a/test/cpp/interop/stress_test.cc +++ b/test/cpp/interop/stress_test.cc @@ -99,18 +99,24 @@ DEFINE_bool(do_not_abort_on_transient_failures, true, // Options from client.cc (for compatibility with interop test). // TODO(sreek): Consolidate overlapping options +DEFINE_bool(use_alts, false, + "Whether to use alts. Enable alts will disable tls."); DEFINE_bool(use_tls, false, "Whether to use tls."); DEFINE_bool(use_test_ca, false, "False to use SSL roots for google"); DEFINE_string(server_host_override, "foo.test.google.fr", "Override the server host which is sent in HTTP header"); +using grpc::testing::ALTS; +using grpc::testing::INSECURE; using grpc::testing::MetricsService; using grpc::testing::MetricsServiceImpl; using grpc::testing::StressTestInteropClient; +using grpc::testing::TLS; using grpc::testing::TestCaseType; using grpc::testing::UNKNOWN_TEST; using grpc::testing::WeightedRandomTestSelector; using grpc::testing::kTestCaseList; +using grpc::testing::transport_security; static int log_level = GPR_LOG_SEVERITY_DEBUG; @@ -268,6 +274,8 @@ int main(int argc, char** argv) { int thread_idx = 0; int server_idx = -1; char buffer[256]; + transport_security security_type = + FLAGS_use_alts ? ALTS : (FLAGS_use_tls ? TLS : INSECURE); for (auto it = server_addresses.begin(); it != server_addresses.end(); it++) { ++server_idx; // Create channel(s) for each server @@ -276,7 +284,7 @@ int main(int argc, char** argv) { gpr_log(GPR_INFO, "Starting test with %s channel_idx=%d..", it->c_str(), channel_idx); std::shared_ptr channel = grpc::CreateTestChannel( - *it, FLAGS_server_host_override, FLAGS_use_tls, !FLAGS_use_test_ca); + *it, FLAGS_server_host_override, security_type, !FLAGS_use_test_ca); // Create stub(s) for each channel for (int stub_idx = 0; stub_idx < FLAGS_num_stubs_per_channel; -- cgit v1.2.3