aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp')
-rw-r--r--test/cpp/client/credentials_test.cc2
-rw-r--r--test/cpp/end2end/async_end2end_test.cc60
-rw-r--r--test/cpp/end2end/end2end_test.cc2
-rw-r--r--test/cpp/end2end/generic_end2end_test.cc270
-rw-r--r--test/cpp/interop/client.cc53
-rw-r--r--test/cpp/interop/interop_test.cc16
-rw-r--r--test/cpp/interop/server.cc2
-rw-r--r--test/cpp/qps/client_async.cc52
-rw-r--r--test/cpp/qps/qps_driver.cc2
-rw-r--r--test/cpp/qps/server.cc6
-rw-r--r--test/cpp/qps/server_async.cc46
-rw-r--r--test/cpp/qps/server_sync.cc2
-rw-r--r--test/cpp/qps/worker.cc2
-rw-r--r--test/cpp/util/create_test_channel.cc3
-rw-r--r--test/cpp/util/status_test.cc2
15 files changed, 440 insertions, 80 deletions
diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc
index 59ca33cc29..24251f297b 100644
--- a/test/cpp/client/credentials_test.cc
+++ b/test/cpp/client/credentials_test.cc
@@ -54,7 +54,7 @@ TEST_F(CredentialsTest, InvalidServiceAccountCreds) {
} // namespace testing
} // namespace grpc
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
grpc_init();
int ret = RUN_ALL_TESTS();
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 70df9e14b2..4c71831dec 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -66,7 +66,7 @@ namespace testing {
namespace {
-void* tag(int i) { return (void*)(gpr_intptr)i; }
+void* tag(int i) { return (void*)(gpr_intptr) i; }
void verify_ok(CompletionQueue* cq, int i, bool expect_ok) {
bool ok;
@@ -76,6 +76,20 @@ void verify_ok(CompletionQueue* cq, int i, bool expect_ok) {
EXPECT_EQ(tag(i), got_tag);
}
+void verify_timed_ok(
+ CompletionQueue* cq, int i, bool expect_ok,
+ std::chrono::system_clock::time_point deadline =
+ std::chrono::system_clock::time_point::max(),
+ CompletionQueue::NextStatus expected_outcome = CompletionQueue::GOT_EVENT) {
+ bool ok;
+ void* got_tag;
+ EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), expected_outcome);
+ if (expected_outcome == CompletionQueue::GOT_EVENT) {
+ EXPECT_EQ(expect_ok, ok);
+ EXPECT_EQ(tag(i), got_tag);
+ }
+}
+
class AsyncEnd2endTest : public ::testing::Test {
protected:
AsyncEnd2endTest() : service_(&srv_cq_) {}
@@ -85,7 +99,7 @@ class AsyncEnd2endTest : public ::testing::Test {
server_address_ << "localhost:" << port;
// Setup server
ServerBuilder builder;
- builder.AddPort(server_address_.str(), grpc::InsecureServerCredentials());
+ builder.AddListeningPort(server_address_.str(), grpc::InsecureServerCredentials());
builder.RegisterAsyncService(&service_);
server_ = builder.BuildAndStart();
}
@@ -166,6 +180,48 @@ TEST_F(AsyncEnd2endTest, SequentialRpcs) {
SendRpc(10);
}
+// Test a simple RPC using the async version of Next
+TEST_F(AsyncEnd2endTest, AsyncNextRpc) {
+ ResetStub();
+
+ EchoRequest send_request;
+ EchoRequest recv_request;
+ EchoResponse send_response;
+ EchoResponse recv_response;
+ Status recv_status;
+
+ ClientContext cli_ctx;
+ ServerContext srv_ctx;
+ grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx);
+
+ send_request.set_message("Hello");
+ std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
+ stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1)));
+
+ std::chrono::system_clock::time_point time_now(
+ std::chrono::system_clock::now()),
+ time_limit(std::chrono::system_clock::now() + std::chrono::seconds(5));
+ verify_timed_ok(&srv_cq_, -1, true, time_now, CompletionQueue::TIMEOUT);
+ verify_timed_ok(&cli_cq_, -1, true, time_now, CompletionQueue::TIMEOUT);
+
+ service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_,
+ tag(2));
+
+ verify_timed_ok(&srv_cq_, 2, true, time_limit);
+ EXPECT_EQ(send_request.message(), recv_request.message());
+ verify_timed_ok(&cli_cq_, 1, true, time_limit);
+
+ send_response.set_message(recv_request.message());
+ response_writer.Finish(send_response, Status::OK, tag(3));
+ verify_timed_ok(&srv_cq_, 3, true);
+
+ response_reader->Finish(&recv_response, &recv_status, tag(4));
+ verify_timed_ok(&cli_cq_, 4, true);
+
+ EXPECT_EQ(send_response.message(), recv_response.message());
+ EXPECT_TRUE(recv_status.IsOk());
+}
+
// Two pings and a final pong.
TEST_F(AsyncEnd2endTest, SimpleClientStreaming) {
ResetStub();
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index c586849349..41c2669533 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -151,7 +151,7 @@ class End2endTest : public ::testing::Test {
server_address_ << "localhost:" << port;
// Setup server
ServerBuilder builder;
- builder.AddPort(server_address_.str(), InsecureServerCredentials());
+ builder.AddListeningPort(server_address_.str(), InsecureServerCredentials());
builder.RegisterService(&service_);
builder.RegisterService(&dup_pkg_service_);
builder.SetThreadPool(&thread_pool_);
diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc
new file mode 100644
index 0000000000..711f1b9540
--- /dev/null
+++ b/test/cpp/end2end/generic_end2end_test.cc
@@ -0,0 +1,270 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <chrono>
+#include <memory>
+
+#include "src/cpp/proto/proto_utils.h"
+#include "src/cpp/util/time.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+#include "test/cpp/util/echo.pb.h"
+#include <grpc++/async_generic_service.h>
+#include <grpc++/async_unary_call.h>
+#include <grpc++/byte_buffer.h>
+#include <grpc++/channel_arguments.h>
+#include <grpc++/channel_interface.h>
+#include <grpc++/client_context.h>
+#include <grpc++/create_channel.h>
+#include <grpc++/credentials.h>
+#include <grpc++/server.h>
+#include <grpc++/server_builder.h>
+#include <grpc++/server_context.h>
+#include <grpc++/server_credentials.h>
+#include <grpc++/slice.h>
+#include <grpc++/status.h>
+#include <grpc++/stream.h>
+#include <gtest/gtest.h>
+
+#include <grpc/grpc.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/time.h>
+
+using grpc::cpp::test::util::EchoRequest;
+using grpc::cpp::test::util::EchoResponse;
+using std::chrono::system_clock;
+
+namespace grpc {
+namespace testing {
+namespace {
+
+void* tag(int i) { return (void*)(gpr_intptr) i; }
+
+void verify_ok(CompletionQueue* cq, int i, bool expect_ok) {
+ bool ok;
+ void* got_tag;
+ EXPECT_TRUE(cq->Next(&got_tag, &ok));
+ EXPECT_EQ(expect_ok, ok);
+ EXPECT_EQ(tag(i), got_tag);
+}
+
+bool ParseFromByteBuffer(ByteBuffer* buffer, grpc::protobuf::Message* message) {
+ std::vector<Slice> slices;
+ buffer->Dump(&slices);
+ grpc::string buf;
+ buf.reserve(buffer->Length());
+ for (const Slice& s : slices) {
+ buf.append(reinterpret_cast<const char*>(s.begin()), s.size());
+ }
+ return message->ParseFromString(buf);
+}
+
+class GenericEnd2endTest : public ::testing::Test {
+ protected:
+ GenericEnd2endTest() : generic_service_("*") {}
+
+ void SetUp() GRPC_OVERRIDE {
+ int port = grpc_pick_unused_port_or_die();
+ server_address_ << "localhost:" << port;
+ // Setup server
+ ServerBuilder builder;
+ builder.AddListeningPort(server_address_.str(), InsecureServerCredentials());
+ builder.RegisterAsyncGenericService(&generic_service_);
+ server_ = builder.BuildAndStart();
+ }
+
+ void TearDown() GRPC_OVERRIDE {
+ server_->Shutdown();
+ void* ignored_tag;
+ bool ignored_ok;
+ cli_cq_.Shutdown();
+ srv_cq_.Shutdown();
+ while (cli_cq_.Next(&ignored_tag, &ignored_ok))
+ ;
+ while (srv_cq_.Next(&ignored_tag, &ignored_ok))
+ ;
+ }
+
+ void ResetStub() {
+ std::shared_ptr<ChannelInterface> channel = CreateChannel(
+ server_address_.str(), InsecureCredentials(), ChannelArguments());
+ stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel));
+ }
+
+ void server_ok(int i) { verify_ok(&srv_cq_, i, true); }
+ void client_ok(int i) { verify_ok(&cli_cq_, i, true); }
+ void server_fail(int i) { verify_ok(&srv_cq_, i, false); }
+ void client_fail(int i) { verify_ok(&cli_cq_, i, false); }
+
+ void SendRpc(int num_rpcs) {
+ for (int i = 0; i < num_rpcs; i++) {
+ EchoRequest send_request;
+ EchoRequest recv_request;
+ EchoResponse send_response;
+ EchoResponse recv_response;
+ Status recv_status;
+
+ ClientContext cli_ctx;
+ GenericServerContext srv_ctx;
+ GenericServerAsyncReaderWriter stream(&srv_ctx);
+
+ send_request.set_message("Hello");
+ std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
+ stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1)));
+ client_ok(1);
+
+ generic_service_.RequestCall(&srv_ctx, &stream, &srv_cq_, tag(2));
+
+ verify_ok(generic_service_.completion_queue(), 2, true);
+ EXPECT_EQ(server_address_.str(), srv_ctx.host());
+ EXPECT_EQ("/grpc.cpp.test.util.TestService/Echo", srv_ctx.method());
+ ByteBuffer recv_buffer;
+ stream.Read(&recv_buffer, tag(3));
+ server_ok(3);
+ EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request));
+ EXPECT_EQ(send_request.message(), recv_request.message());
+
+ send_response.set_message(recv_request.message());
+ grpc::string buf;
+ send_response.SerializeToString(&buf);
+ gpr_slice s = gpr_slice_from_copied_string(buf.c_str());
+ Slice slice(s, Slice::STEAL_REF);
+ ByteBuffer send_buffer(&slice, 1);
+ stream.Write(send_buffer, tag(4));
+ server_ok(4);
+
+ stream.Finish(Status::OK, tag(5));
+ server_ok(5);
+
+ response_reader->Finish(&recv_response, &recv_status, tag(4));
+ client_ok(4);
+
+ EXPECT_EQ(send_response.message(), recv_response.message());
+ EXPECT_TRUE(recv_status.IsOk());
+ }
+ }
+
+ CompletionQueue cli_cq_;
+ CompletionQueue srv_cq_;
+ std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub_;
+ std::unique_ptr<Server> server_;
+ AsyncGenericService generic_service_;
+ std::ostringstream server_address_;
+};
+
+TEST_F(GenericEnd2endTest, SimpleRpc) {
+ ResetStub();
+ SendRpc(1);
+}
+
+TEST_F(GenericEnd2endTest, SequentialRpcs) {
+ ResetStub();
+ SendRpc(10);
+}
+
+// One ping, one pong.
+TEST_F(GenericEnd2endTest, SimpleBidiStreaming) {
+ ResetStub();
+
+ EchoRequest send_request;
+ EchoRequest recv_request;
+ EchoResponse send_response;
+ EchoResponse recv_response;
+ Status recv_status;
+ ClientContext cli_ctx;
+ GenericServerContext srv_ctx;
+ GenericServerAsyncReaderWriter srv_stream(&srv_ctx);
+
+ send_request.set_message("Hello");
+ std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse> >
+ cli_stream(stub_->AsyncBidiStream(&cli_ctx, &cli_cq_, tag(1)));
+ client_ok(1);
+
+ generic_service_.RequestCall(&srv_ctx, &srv_stream, &srv_cq_, tag(2));
+
+ verify_ok(generic_service_.completion_queue(), 2, true);
+ EXPECT_EQ(server_address_.str(), srv_ctx.host());
+ EXPECT_EQ("/grpc.cpp.test.util.TestService/BidiStream", srv_ctx.method());
+
+ cli_stream->Write(send_request, tag(3));
+ client_ok(3);
+
+ ByteBuffer recv_buffer;
+ srv_stream.Read(&recv_buffer, tag(4));
+ server_ok(4);
+ EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request));
+ EXPECT_EQ(send_request.message(), recv_request.message());
+
+ send_response.set_message(recv_request.message());
+ grpc::string buf;
+ send_response.SerializeToString(&buf);
+ gpr_slice s = gpr_slice_from_copied_string(buf.c_str());
+ Slice slice(s, Slice::STEAL_REF);
+ ByteBuffer send_buffer(&slice, 1);
+ srv_stream.Write(send_buffer, tag(5));
+ server_ok(5);
+
+ cli_stream->Read(&recv_response, tag(6));
+ client_ok(6);
+ EXPECT_EQ(send_response.message(), recv_response.message());
+
+ cli_stream->WritesDone(tag(7));
+ client_ok(7);
+
+ recv_buffer.Clear();
+ srv_stream.Read(&recv_buffer, tag(8));
+ server_fail(8);
+
+ srv_stream.Finish(Status::OK, tag(9));
+ server_ok(9);
+
+ cli_stream->Finish(&recv_status, tag(10));
+ client_ok(10);
+
+ EXPECT_EQ(send_response.message(), recv_response.message());
+ EXPECT_TRUE(recv_status.IsOk());
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+ ::testing::InitGoogleTest(&argc, argv);
+ int result = RUN_ALL_TESTS();
+ grpc_shutdown();
+ google::protobuf::ShutdownProtobufLibrary();
+ return result;
+}
diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc
index ae68f7a556..de6c6b7b77 100644
--- a/test/cpp/interop/client.cc
+++ b/test/cpp/interop/client.cc
@@ -73,6 +73,7 @@ DEFINE_string(test_case, "large_unary",
"ping_pong : full-duplex streaming; "
"service_account_creds : large_unary with service_account auth; "
"compute_engine_creds: large_unary with compute engine auth; "
+ "jwt_token_creds: large_unary with JWT token auth; "
"all : all of above.");
DEFINE_string(default_service_account, "",
"Email of GCE default service account");
@@ -85,6 +86,7 @@ using grpc::ClientContext;
using grpc::ComputeEngineCredentials;
using grpc::CreateTestChannel;
using grpc::Credentials;
+using grpc::JWTCredentials;
using grpc::ServiceAccountCredentials;
using grpc::testing::ResponseParameters;
using grpc::testing::SimpleRequest;
@@ -146,12 +148,28 @@ std::shared_ptr<ChannelInterface> CreateChannelForTestCase(
creds = ComputeEngineCredentials();
return CreateTestChannel(host_port, FLAGS_server_host_override,
FLAGS_enable_ssl, FLAGS_use_prod_roots, creds);
+ } else if (test_case == "jwt_token_creds") {
+ std::unique_ptr<Credentials> creds;
+ GPR_ASSERT(FLAGS_enable_ssl);
+ grpc::string json_key = GetServiceAccountJsonKey();
+ creds = JWTCredentials(json_key, std::chrono::hours(1));
+ return CreateTestChannel(host_port, FLAGS_server_host_override,
+ FLAGS_enable_ssl, FLAGS_use_prod_roots, creds);
} else {
return CreateTestChannel(host_port, FLAGS_server_host_override,
FLAGS_enable_ssl, FLAGS_use_prod_roots);
}
}
+void AssertOkOrPrintErrorStatus(const grpc::Status& s) {
+ if (s.IsOk()) {
+ return;
+ }
+ gpr_log(GPR_INFO, "Error status code: %d, message: %s", s.code(),
+ s.details().c_str());
+ GPR_ASSERT(0);
+}
+
void DoEmpty() {
gpr_log(GPR_INFO, "Sending an empty rpc...");
std::shared_ptr<ChannelInterface> channel =
@@ -163,8 +181,8 @@ void DoEmpty() {
ClientContext context;
grpc::Status s = stub->EmptyCall(&context, request, &response);
+ AssertOkOrPrintErrorStatus(s);
- GPR_ASSERT(s.IsOk());
gpr_log(GPR_INFO, "Empty rpc done.");
}
@@ -181,7 +199,7 @@ void PerformLargeUnary(std::shared_ptr<ChannelInterface> channel,
grpc::Status s = stub->UnaryCall(&context, *request, response);
- GPR_ASSERT(s.IsOk());
+ AssertOkOrPrintErrorStatus(s);
GPR_ASSERT(response->payload().type() ==
grpc::testing::PayloadType::COMPRESSABLE);
GPR_ASSERT(response->payload().body() ==
@@ -227,6 +245,20 @@ void DoServiceAccountCreds() {
gpr_log(GPR_INFO, "Large unary with service account creds done.");
}
+void DoJwtTokenCreds() {
+ gpr_log(GPR_INFO, "Sending a large unary rpc with JWT token credentials ...");
+ std::shared_ptr<ChannelInterface> channel =
+ CreateChannelForTestCase("jwt_token_creds");
+ SimpleRequest request;
+ SimpleResponse response;
+ request.set_fill_username(true);
+ PerformLargeUnary(channel, &request, &response);
+ GPR_ASSERT(!response.username().empty());
+ grpc::string json_key = GetServiceAccountJsonKey();
+ GPR_ASSERT(json_key.find(response.username()) != grpc::string::npos);
+ gpr_log(GPR_INFO, "Large unary with JWT token creds done.");
+}
+
void DoLargeUnary() {
gpr_log(GPR_INFO, "Sending a large unary rpc...");
std::shared_ptr<ChannelInterface> channel =
@@ -261,7 +293,7 @@ void DoRequestStreaming() {
grpc::Status s = stream->Finish();
GPR_ASSERT(response.aggregated_payload_size() == aggregated_payload_size);
- GPR_ASSERT(s.IsOk());
+ AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Request streaming done.");
}
@@ -290,7 +322,7 @@ void DoResponseStreaming() {
GPR_ASSERT(response_stream_sizes.size() == i);
grpc::Status s = stream->Finish();
- GPR_ASSERT(s.IsOk());
+ AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Response streaming done.");
}
@@ -322,7 +354,7 @@ void DoResponseStreamingWithSlowConsumer() {
GPR_ASSERT(kNumResponseMessages == i);
grpc::Status s = stream->Finish();
- GPR_ASSERT(s.IsOk());
+ AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Response streaming done.");
}
@@ -355,7 +387,7 @@ void DoHalfDuplex() {
}
GPR_ASSERT(response_stream_sizes.size() == i);
grpc::Status s = stream->Finish();
- GPR_ASSERT(s.IsOk());
+ AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Half-duplex streaming rpc done.");
}
@@ -388,7 +420,7 @@ void DoPingPong() {
stream->WritesDone();
GPR_ASSERT(!stream->Read(&response));
grpc::Status s = stream->Finish();
- GPR_ASSERT(s.IsOk());
+ AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Ping pong streaming done.");
}
@@ -415,6 +447,8 @@ int main(int argc, char** argv) {
DoServiceAccountCreds();
} else if (FLAGS_test_case == "compute_engine_creds") {
DoComputeEngineCreds();
+ } else if (FLAGS_test_case == "jwt_token_creds") {
+ DoJwtTokenCreds();
} else if (FLAGS_test_case == "all") {
DoEmpty();
DoLargeUnary();
@@ -422,9 +456,10 @@ int main(int argc, char** argv) {
DoResponseStreaming();
DoHalfDuplex();
DoPingPong();
- // service_account_creds can only run with ssl.
+ // service_account_creds and jwt_token_creds can only run with ssl.
if (FLAGS_enable_ssl) {
DoServiceAccountCreds();
+ DoJwtTokenCreds();
}
// compute_engine_creds only runs in GCE.
} else {
@@ -432,7 +467,7 @@ int main(int argc, char** argv) {
GPR_ERROR,
"Unsupported test case %s. Valid options are all|empty_unary|"
"large_unary|client_streaming|server_streaming|half_duplex|ping_pong|"
- "service_account_creds|compute_engine_creds",
+ "service_account_creds|compute_engine_creds|jwt_token_creds",
FLAGS_test_case.c_str());
}
diff --git a/test/cpp/interop/interop_test.cc b/test/cpp/interop/interop_test.cc
index 811e0eb009..a7a5cc0b2c 100644
--- a/test/cpp/interop/interop_test.cc
+++ b/test/cpp/interop/interop_test.cc
@@ -54,13 +54,13 @@ extern "C" {
#include <grpc/support/log.h>
#include "test/core/util/port.h"
-int test_client(const char *root, const char *host, int port) {
+int test_client(const char* root, const char* host, int port) {
int status;
pid_t cli;
cli = fork();
if (cli == 0) {
- char *binary_path;
- char *port_arg;
+ char* binary_path;
+ char* port_arg;
gpr_asprintf(&binary_path, "%s/interop_client", root);
gpr_asprintf(&port_arg, "--server_port=%d", port);
@@ -78,9 +78,9 @@ int test_client(const char *root, const char *host, int port) {
return 0;
}
-int main(int argc, char **argv) {
- char *me = argv[0];
- char *lslash = strrchr(me, '/');
+int main(int argc, char** argv) {
+ char* me = argv[0];
+ char* lslash = strrchr(me, '/');
char root[1024];
int port = grpc_pick_unused_port_or_die();
int status;
@@ -104,8 +104,8 @@ int main(int argc, char **argv) {
/* start the server */
svr = fork();
if (svr == 0) {
- char *binary_path;
- char *port_arg;
+ char* binary_path;
+ char* port_arg;
gpr_asprintf(&binary_path, "%s/interop_server", root);
gpr_asprintf(&port_arg, "--port=%d", port);
diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc
index 743482e967..eceb600d4c 100644
--- a/test/cpp/interop/server.cc
+++ b/test/cpp/interop/server.cc
@@ -217,7 +217,7 @@ void RunServer() {
"", {{test_server1_key, test_server1_cert}}};
creds = grpc::SslServerCredentials(ssl_opts);
}
- builder.AddPort(server_address.str(), creds);
+ builder.AddListeningPort(server_address.str(), creds);
std::unique_ptr<Server> server(builder.BuildAndStart());
gpr_log(GPR_INFO, "Server listening on %s", server_address.str().c_str());
while (!got_sigint) {
diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc
index c6535bebf8..526f37a1fd 100644
--- a/test/cpp/qps/client_async.cc
+++ b/test/cpp/qps/client_async.cc
@@ -61,23 +61,23 @@ class ClientRpcContext {
virtual ~ClientRpcContext() {}
virtual bool RunNextState() = 0; // do next state, return false if steps done
virtual void StartNewClone() = 0;
- static void *tag(ClientRpcContext *c) { return reinterpret_cast<void *>(c); }
- static ClientRpcContext *detag(void *t) {
- return reinterpret_cast<ClientRpcContext *>(t);
+ static void* tag(ClientRpcContext* c) { return reinterpret_cast<void*>(c); }
+ static ClientRpcContext* detag(void* t) {
+ return reinterpret_cast<ClientRpcContext*>(t);
}
- virtual void report_stats(Histogram *hist) = 0;
+ virtual void report_stats(Histogram* hist) = 0;
};
template <class RequestType, class ResponseType>
class ClientRpcContextUnaryImpl : public ClientRpcContext {
public:
ClientRpcContextUnaryImpl(
- TestService::Stub *stub, const RequestType &req,
+ TestService::Stub* stub, const RequestType& req,
std::function<
std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>(
- TestService::Stub *, grpc::ClientContext *, const RequestType &,
- void *)> start_req,
- std::function<void(grpc::Status, ResponseType *)> on_done)
+ TestService::Stub*, grpc::ClientContext*, const RequestType&,
+ void*)> start_req,
+ std::function<void(grpc::Status, ResponseType*)> on_done)
: context_(),
stub_(stub),
req_(req),
@@ -90,7 +90,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext {
start_req(stub_, &context_, req_, ClientRpcContext::tag(this))) {}
~ClientRpcContextUnaryImpl() GRPC_OVERRIDE {}
bool RunNextState() GRPC_OVERRIDE { return (this->*next_state_)(); }
- void report_stats(Histogram *hist) GRPC_OVERRIDE {
+ void report_stats(Histogram* hist) GRPC_OVERRIDE {
hist->Add((Timer::Now() - start_) * 1e9);
}
@@ -113,13 +113,13 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext {
return false;
}
grpc::ClientContext context_;
- TestService::Stub *stub_;
+ TestService::Stub* stub_;
RequestType req_;
ResponseType response_;
bool (ClientRpcContextUnaryImpl::*next_state_)();
- std::function<void(grpc::Status, ResponseType *)> callback_;
+ std::function<void(grpc::Status, ResponseType*)> callback_;
std::function<std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>(
- TestService::Stub *, grpc::ClientContext *, const RequestType &, void *)>
+ TestService::Stub*, grpc::ClientContext*, const RequestType&, void*)>
start_req_;
grpc::Status status_;
double start_;
@@ -129,13 +129,13 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext {
class AsyncClient GRPC_FINAL : public Client {
public:
- explicit AsyncClient(const ClientConfig &config) : Client(config) {
+ explicit AsyncClient(const ClientConfig& config) : Client(config) {
for (int i = 0; i < config.async_client_threads(); i++) {
cli_cqs_.emplace_back(new CompletionQueue);
}
auto payload_size = config.payload_size();
- auto check_done = [payload_size](grpc::Status s, SimpleResponse *response) {
+ auto check_done = [payload_size](grpc::Status s, SimpleResponse* response) {
GPR_ASSERT(s.IsOk() && (response->payload().type() ==
grpc::testing::PayloadType::COMPRESSABLE) &&
(response->payload().body().length() ==
@@ -144,16 +144,16 @@ class AsyncClient GRPC_FINAL : public Client {
int t = 0;
for (int i = 0; i < config.outstanding_rpcs_per_channel(); i++) {
- for (auto &channel : channels_) {
- auto *cq = cli_cqs_[t].get();
+ for (auto& channel : channels_) {
+ auto* cq = cli_cqs_[t].get();
t = (t + 1) % cli_cqs_.size();
- auto start_req = [cq](TestService::Stub *stub, grpc::ClientContext *ctx,
- const SimpleRequest &request, void *tag) {
+ auto start_req = [cq](TestService::Stub* stub, grpc::ClientContext* ctx,
+ const SimpleRequest& request, void* tag) {
return stub->AsyncUnaryCall(ctx, request, cq, tag);
};
- TestService::Stub *stub = channel.get_stub();
- const SimpleRequest &request = request_;
+ TestService::Stub* stub = channel.get_stub();
+ const SimpleRequest& request = request_;
new ClientRpcContextUnaryImpl<SimpleRequest, SimpleResponse>(
stub, request, start_req, check_done);
}
@@ -165,9 +165,9 @@ class AsyncClient GRPC_FINAL : public Client {
~AsyncClient() GRPC_OVERRIDE {
EndThreads();
- for (auto &cq : cli_cqs_) {
+ for (auto& cq : cli_cqs_) {
cq->Shutdown();
- void *got_tag;
+ void* got_tag;
bool ok;
while (cq->Next(&got_tag, &ok)) {
delete ClientRpcContext::detag(got_tag);
@@ -175,12 +175,12 @@ class AsyncClient GRPC_FINAL : public Client {
}
}
- void ThreadFunc(Histogram *histogram, size_t thread_idx) GRPC_OVERRIDE {
- void *got_tag;
+ void ThreadFunc(Histogram* histogram, size_t thread_idx) GRPC_OVERRIDE {
+ void* got_tag;
bool ok;
cli_cqs_[thread_idx]->Next(&got_tag, &ok);
- ClientRpcContext *ctx = ClientRpcContext::detag(got_tag);
+ ClientRpcContext* ctx = ClientRpcContext::detag(got_tag);
if (ctx->RunNextState() == false) {
// call the callback and then delete it
ctx->report_stats(histogram);
@@ -193,7 +193,7 @@ class AsyncClient GRPC_FINAL : public Client {
std::vector<std::unique_ptr<CompletionQueue>> cli_cqs_;
};
-std::unique_ptr<Client> CreateAsyncClient(const ClientConfig &args) {
+std::unique_ptr<Client> CreateAsyncClient(const ClientConfig& args) {
return std::unique_ptr<Client>(new AsyncClient(args));
}
diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc
index bf51e7408e..5e9a577f8e 100644
--- a/test/cpp/qps/qps_driver.cc
+++ b/test/cpp/qps/qps_driver.cc
@@ -69,7 +69,7 @@ namespace gflags {}
using namespace google;
using namespace gflags;
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_init();
ParseCommandLineFlags(&argc, &argv, true);
diff --git a/test/cpp/qps/server.cc b/test/cpp/qps/server.cc
index 005f0f9c5e..e1907b069b 100644
--- a/test/cpp/qps/server.cc
+++ b/test/cpp/qps/server.cc
@@ -73,8 +73,8 @@ using grpc::Status;
// In some distros, gflags is in the namespace google, and in some others,
// in gflags. This hack is enabling us to find both.
-namespace google { }
-namespace gflags { }
+namespace google {}
+namespace gflags {}
using namespace google;
using namespace gflags;
@@ -137,7 +137,7 @@ static void RunServer() {
SimpleResponse response;
ServerBuilder builder;
- builder.AddPort(server_address, grpc::InsecureServerCredentials());
+ builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
builder.RegisterService(&service);
std::unique_ptr<ThreadPool> pool(new ThreadPool(FLAGS_server_threads));
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index 19778e5a7c..586b6e7abe 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -62,13 +62,13 @@ namespace testing {
class AsyncQpsServerTest : public Server {
public:
- AsyncQpsServerTest(const ServerConfig &config, int port)
+ AsyncQpsServerTest(const ServerConfig& config, int port)
: srv_cq_(), async_service_(&srv_cq_), server_(nullptr) {
- char *server_address = NULL;
+ char* server_address = NULL;
gpr_join_host_port(&server_address, "::", port);
ServerBuilder builder;
- builder.AddPort(server_address, InsecureServerCredentials());
+ builder.AddListeningPort(server_address, InsecureServerCredentials());
gpr_free(server_address);
builder.RegisterAsyncService(&async_service_);
@@ -87,10 +87,10 @@ class AsyncQpsServerTest : public Server {
threads_.push_back(std::thread([=]() {
// Wait until work is available or we are shutting down
bool ok;
- void *got_tag;
+ void* got_tag;
while (srv_cq_.Next(&got_tag, &ok)) {
if (ok) {
- ServerRpcContext *ctx = detag(got_tag);
+ ServerRpcContext* ctx = detag(got_tag);
// The tag is a pointer to an RPC context to invoke
if (ctx->RunNextState() == false) {
// this RPC context is done, so refresh it
@@ -105,7 +105,7 @@ class AsyncQpsServerTest : public Server {
~AsyncQpsServerTest() {
server_->Shutdown();
srv_cq_.Shutdown();
- for (auto &thr : threads_) {
+ for (auto& thr : threads_) {
thr.join();
}
while (!contexts_.empty()) {
@@ -122,21 +122,21 @@ class AsyncQpsServerTest : public Server {
virtual bool RunNextState() = 0; // do next state, return false if all done
virtual void Reset() = 0; // start this back at a clean state
};
- static void *tag(ServerRpcContext *func) {
- return reinterpret_cast<void *>(func);
+ static void* tag(ServerRpcContext* func) {
+ return reinterpret_cast<void*>(func);
}
- static ServerRpcContext *detag(void *tag) {
- return reinterpret_cast<ServerRpcContext *>(tag);
+ static ServerRpcContext* detag(void* tag) {
+ return reinterpret_cast<ServerRpcContext*>(tag);
}
template <class RequestType, class ResponseType>
class ServerRpcContextUnaryImpl : public ServerRpcContext {
public:
ServerRpcContextUnaryImpl(
- std::function<void(ServerContext *, RequestType *,
- grpc::ServerAsyncResponseWriter<ResponseType> *,
- void *)> request_method,
- std::function<grpc::Status(const RequestType *, ResponseType *)>
+ std::function<void(ServerContext*, RequestType*,
+ grpc::ServerAsyncResponseWriter<ResponseType>*,
+ void*)> request_method,
+ std::function<grpc::Status(const RequestType*, ResponseType*)>
invoke_method)
: next_state_(&ServerRpcContextUnaryImpl::invoker),
request_method_(request_method),
@@ -175,16 +175,16 @@ class AsyncQpsServerTest : public Server {
ServerContext srv_ctx_;
RequestType req_;
bool (ServerRpcContextUnaryImpl::*next_state_)();
- std::function<void(ServerContext *, RequestType *,
- grpc::ServerAsyncResponseWriter<ResponseType> *, void *)>
+ std::function<void(ServerContext*, RequestType*,
+ grpc::ServerAsyncResponseWriter<ResponseType>*, void*)>
request_method_;
- std::function<grpc::Status(const RequestType *, ResponseType *)>
+ std::function<grpc::Status(const RequestType*, ResponseType*)>
invoke_method_;
grpc::ServerAsyncResponseWriter<ResponseType> response_writer_;
};
- static Status UnaryCall(const SimpleRequest *request,
- SimpleResponse *response) {
+ static Status UnaryCall(const SimpleRequest* request,
+ SimpleResponse* response) {
if (request->has_response_size() && request->response_size() > 0) {
if (!SetPayload(request->response_type(), request->response_size(),
response->mutable_payload())) {
@@ -197,13 +197,13 @@ class AsyncQpsServerTest : public Server {
TestService::AsyncService async_service_;
std::vector<std::thread> threads_;
std::unique_ptr<grpc::Server> server_;
- std::function<void(ServerContext *, SimpleRequest *,
- grpc::ServerAsyncResponseWriter<SimpleResponse> *, void *)>
+ std::function<void(ServerContext*, SimpleRequest*,
+ grpc::ServerAsyncResponseWriter<SimpleResponse>*, void*)>
request_unary_;
- std::forward_list<ServerRpcContext *> contexts_;
+ std::forward_list<ServerRpcContext*> contexts_;
};
-std::unique_ptr<Server> CreateAsyncServer(const ServerConfig &config,
+std::unique_ptr<Server> CreateAsyncServer(const ServerConfig& config,
int port) {
return std::unique_ptr<Server>(new AsyncQpsServerTest(config, port));
}
diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc
index 5c6541989c..3e15fb61c0 100644
--- a/test/cpp/qps/server_sync.cc
+++ b/test/cpp/qps/server_sync.cc
@@ -84,7 +84,7 @@ class SynchronousServer GRPC_FINAL : public grpc::testing::Server {
char* server_address = NULL;
gpr_join_host_port(&server_address, "::", port);
- builder.AddPort(server_address, InsecureServerCredentials());
+ builder.AddListeningPort(server_address, InsecureServerCredentials());
gpr_free(server_address);
builder.RegisterService(&service_);
diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc
index faabfd1147..fdcd9d5069 100644
--- a/test/cpp/qps/worker.cc
+++ b/test/cpp/qps/worker.cc
@@ -210,7 +210,7 @@ static void RunServer() {
WorkerImpl service;
ServerBuilder builder;
- builder.AddPort(server_address, InsecureServerCredentials());
+ builder.AddListeningPort(server_address, InsecureServerCredentials());
builder.RegisterService(&service);
gpr_free(server_address);
diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc
index d3b84b2965..f040acc4b1 100644
--- a/test/cpp/util/create_test_channel.cc
+++ b/test/cpp/util/create_test_channel.cc
@@ -72,8 +72,7 @@ std::shared_ptr<ChannelInterface> CreateTestChannel(
const grpc::string& connect_to =
server.empty() ? override_hostname : server;
if (creds.get()) {
- channel_creds =
- CompositeCredentials(creds, channel_creds);
+ channel_creds = CompositeCredentials(creds, channel_creds);
}
return CreateChannel(connect_to, channel_creds, channel_args);
} else {
diff --git a/test/cpp/util/status_test.cc b/test/cpp/util/status_test.cc
index 8c6a3354fe..17b92ab06a 100644
--- a/test/cpp/util/status_test.cc
+++ b/test/cpp/util/status_test.cc
@@ -36,7 +36,7 @@
#include <grpc/support/log.h>
// Make sure the existing grpc_status_code match with grpc::Code.
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
GPR_ASSERT(grpc::StatusCode::OK ==
static_cast<grpc::StatusCode>(GRPC_STATUS_OK));
GPR_ASSERT(grpc::StatusCode::CANCELLED ==