aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/end2end
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp/end2end')
-rw-r--r--test/cpp/end2end/async_end2end_test.cc67
-rw-r--r--test/cpp/end2end/end2end_test.cc14
2 files changed, 33 insertions, 48 deletions
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 248e054e49..85b4ff8120 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -65,9 +65,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;
@@ -104,23 +102,15 @@ class AsyncEnd2endTest : public ::testing::Test {
}
void ResetStub() {
- std::shared_ptr<ChannelInterface> channel =
- CreateChannel(server_address_.str(), ChannelArguments());
+ std::shared_ptr<ChannelInterface> channel = CreateChannel(
+ server_address_.str(), InsecureCredentials(), ChannelArguments());
stub_.reset(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 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++) {
@@ -135,12 +125,11 @@ class AsyncEnd2endTest : public ::testing::Test {
grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx);
send_request.set_message("Hello");
- std::unique_ptr<ClientAsyncResponseReader<EchoResponse> >
- response_reader(stub_->Echo(
- &cli_ctx, send_request, &cli_cq_, tag(1)));
+ std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
+ stub_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1)));
- service_.RequestEcho(
- &srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2));
+ service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_,
+ tag(2));
server_ok(2);
EXPECT_EQ(send_request.message(), recv_request.message());
@@ -193,8 +182,7 @@ TEST_F(AsyncEnd2endTest, SimpleClientStreaming) {
std::unique_ptr<ClientAsyncWriter<EchoRequest> > cli_stream(
stub_->RequestStream(&cli_ctx, &recv_response, &cli_cq_, tag(1)));
- service_.RequestRequestStream(
- &srv_ctx, &srv_stream, &srv_cq_, tag(2));
+ service_.RequestRequestStream(&srv_ctx, &srv_stream, &srv_cq_, tag(2));
server_ok(2);
client_ok(1);
@@ -247,8 +235,8 @@ TEST_F(AsyncEnd2endTest, SimpleServerStreaming) {
std::unique_ptr<ClientAsyncReader<EchoResponse> > cli_stream(
stub_->ResponseStream(&cli_ctx, send_request, &cli_cq_, tag(1)));
- service_.RequestResponseStream(
- &srv_ctx, &recv_request, &srv_stream, &srv_cq_, tag(2));
+ service_.RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, &srv_cq_,
+ tag(2));
server_ok(2);
client_ok(1);
@@ -298,8 +286,7 @@ TEST_F(AsyncEnd2endTest, SimpleBidiStreaming) {
std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse> >
cli_stream(stub_->BidiStream(&cli_ctx, &cli_cq_, tag(1)));
- service_.RequestBidiStream(
- &srv_ctx, &srv_stream, &srv_cq_, tag(2));
+ service_.RequestBidiStream(&srv_ctx, &srv_stream, &srv_cq_, tag(2));
server_ok(2);
client_ok(1);
@@ -357,8 +344,8 @@ TEST_F(AsyncEnd2endTest, ClientInitialMetadataRpc) {
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
stub_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1)));
- service_.RequestEcho(
- &srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2));
+ service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_,
+ tag(2));
server_ok(2);
EXPECT_EQ(send_request.message(), recv_request.message());
auto client_initial_metadata = srv_ctx.client_metadata();
@@ -399,8 +386,8 @@ TEST_F(AsyncEnd2endTest, ServerInitialMetadataRpc) {
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
stub_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1)));
- service_.RequestEcho(
- &srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2));
+ service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_,
+ tag(2));
server_ok(2);
EXPECT_EQ(send_request.message(), recv_request.message());
srv_ctx.AddInitialMetadata(meta1.first, meta1.second);
@@ -447,8 +434,8 @@ TEST_F(AsyncEnd2endTest, ServerTrailingMetadataRpc) {
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
stub_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1)));
- service_.RequestEcho(
- &srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2));
+ service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_,
+ tag(2));
server_ok(2);
EXPECT_EQ(send_request.message(), recv_request.message());
response_writer.SendInitialMetadata(tag(3));
@@ -462,7 +449,6 @@ TEST_F(AsyncEnd2endTest, ServerTrailingMetadataRpc) {
server_ok(4);
-
response_reader->Finish(&recv_response, &recv_status, tag(5));
client_ok(5);
EXPECT_EQ(send_response.message(), recv_response.message());
@@ -491,10 +477,12 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) {
std::pair<grpc::string, grpc::string> meta2(
"key2-bin", {"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc", 13});
std::pair<grpc::string, grpc::string> meta3("key3", "val3");
- std::pair<grpc::string, grpc::string> meta6("key4-bin",
+ std::pair<grpc::string, grpc::string> meta6(
+ "key4-bin",
{"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d", 14});
std::pair<grpc::string, grpc::string> meta5("key5", "val5");
- std::pair<grpc::string, grpc::string> meta4("key6-bin",
+ std::pair<grpc::string, grpc::string> meta4(
+ "key6-bin",
{"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee", 15});
cli_ctx.AddMetadata(meta1.first, meta1.second);
@@ -503,8 +491,8 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) {
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
stub_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1)));
- service_.RequestEcho(
- &srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2));
+ service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_,
+ tag(2));
server_ok(2);
EXPECT_EQ(send_request.message(), recv_request.message());
auto client_initial_metadata = srv_ctx.client_metadata();
@@ -531,7 +519,6 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) {
server_ok(5);
-
response_reader->Finish(&recv_response, &recv_status, tag(6));
client_ok(6);
EXPECT_EQ(send_response.message(), recv_response.message());
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index d4ca3ef49e..f5ecd1a20c 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -160,8 +160,8 @@ class End2endTest : public ::testing::Test {
void TearDown() override { server_->Shutdown(); }
void ResetStub() {
- std::shared_ptr<ChannelInterface> channel =
- CreateChannel(server_address_.str(), ChannelArguments());
+ std::shared_ptr<ChannelInterface> channel = CreateChannel(
+ server_address_.str(), InsecureCredentials(), ChannelArguments());
stub_.reset(grpc::cpp::test::util::TestService::NewStub(channel));
}
@@ -328,8 +328,7 @@ TEST_F(End2endTest, ResponseStream) {
ClientContext context;
request.set_message("hello");
- ClientReader<EchoResponse>* stream =
- stub_->ResponseStream(&context, request);
+ ClientReader<EchoResponse>* stream = stub_->ResponseStream(&context, request);
EXPECT_TRUE(stream->Read(&response));
EXPECT_EQ(response.message(), request.message() + "0");
EXPECT_TRUE(stream->Read(&response));
@@ -381,8 +380,8 @@ TEST_F(End2endTest, BidiStream) {
// Talk to the two services with the same name but different package names.
// The two stubs are created on the same channel.
TEST_F(End2endTest, DiffPackageServices) {
- std::shared_ptr<ChannelInterface> channel =
- CreateChannel(server_address_.str(), ChannelArguments());
+ std::shared_ptr<ChannelInterface> channel = CreateChannel(
+ server_address_.str(), InsecureCredentials(), ChannelArguments());
EchoRequest request;
EchoResponse response;
@@ -407,8 +406,7 @@ TEST_F(End2endTest, DiffPackageServices) {
// rpc and stream should fail on bad credentials.
TEST_F(End2endTest, BadCredentials) {
std::unique_ptr<Credentials> bad_creds =
- CredentialsFactory::ServiceAccountCredentials("", "",
- std::chrono::seconds(1));
+ ServiceAccountCredentials("", "", std::chrono::seconds(1));
EXPECT_EQ(nullptr, bad_creds.get());
std::shared_ptr<ChannelInterface> channel =
CreateChannel(server_address_.str(), bad_creds, ChannelArguments());