|
|
@ -18,7 +18,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "test/cpp/util/grpc_tool.h" |
|
|
|
#include "test/cpp/util/grpc_tool.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <gflags/gflags.h> |
|
|
|
|
|
|
|
#include <grpc/grpc.h> |
|
|
|
#include <grpc/grpc.h> |
|
|
|
#include <grpc/support/alloc.h> |
|
|
|
#include <grpc/support/alloc.h> |
|
|
|
#include <grpcpp/channel.h> |
|
|
|
#include <grpcpp/channel.h> |
|
|
@ -33,6 +32,7 @@ |
|
|
|
#include <chrono> |
|
|
|
#include <chrono> |
|
|
|
#include <sstream> |
|
|
|
#include <sstream> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "absl/flags/flag.h" |
|
|
|
#include "src/core/lib/gpr/env.h" |
|
|
|
#include "src/core/lib/gpr/env.h" |
|
|
|
#include "src/core/lib/iomgr/load_file.h" |
|
|
|
#include "src/core/lib/iomgr/load_file.h" |
|
|
|
#include "src/proto/grpc/testing/echo.grpc.pb.h" |
|
|
|
#include "src/proto/grpc/testing/echo.grpc.pb.h" |
|
|
@ -110,24 +110,22 @@ using grpc::testing::EchoResponse; |
|
|
|
" }\n" \
|
|
|
|
" }\n" \
|
|
|
|
"}\n\n" |
|
|
|
"}\n\n" |
|
|
|
|
|
|
|
|
|
|
|
DECLARE_string(channel_creds_type); |
|
|
|
ABSL_DECLARE_FLAG(std::string, channel_creds_type); |
|
|
|
DECLARE_string(ssl_target); |
|
|
|
ABSL_DECLARE_FLAG(std::string, ssl_target); |
|
|
|
|
|
|
|
ABSL_DECLARE_FLAG(bool, binary_input); |
|
|
|
|
|
|
|
ABSL_DECLARE_FLAG(bool, binary_output); |
|
|
|
|
|
|
|
ABSL_DECLARE_FLAG(bool, json_input); |
|
|
|
|
|
|
|
ABSL_DECLARE_FLAG(bool, json_output); |
|
|
|
|
|
|
|
ABSL_DECLARE_FLAG(bool, l); |
|
|
|
|
|
|
|
ABSL_DECLARE_FLAG(bool, batch); |
|
|
|
|
|
|
|
ABSL_DECLARE_FLAG(std::string, metadata); |
|
|
|
|
|
|
|
ABSL_DECLARE_FLAG(std::string, protofiles); |
|
|
|
|
|
|
|
ABSL_DECLARE_FLAG(std::string, proto_path); |
|
|
|
|
|
|
|
ABSL_DECLARE_FLAG(std::string, default_service_config); |
|
|
|
|
|
|
|
ABSL_DECLARE_FLAG(double, timeout); |
|
|
|
|
|
|
|
|
|
|
|
namespace grpc { |
|
|
|
namespace grpc { |
|
|
|
namespace testing { |
|
|
|
namespace testing { |
|
|
|
|
|
|
|
|
|
|
|
DECLARE_bool(binary_input); |
|
|
|
|
|
|
|
DECLARE_bool(binary_output); |
|
|
|
|
|
|
|
DECLARE_bool(json_input); |
|
|
|
|
|
|
|
DECLARE_bool(json_output); |
|
|
|
|
|
|
|
DECLARE_bool(l); |
|
|
|
|
|
|
|
DECLARE_bool(batch); |
|
|
|
|
|
|
|
DECLARE_string(metadata); |
|
|
|
|
|
|
|
DECLARE_string(protofiles); |
|
|
|
|
|
|
|
DECLARE_string(proto_path); |
|
|
|
|
|
|
|
DECLARE_string(default_service_config); |
|
|
|
|
|
|
|
DECLARE_double(timeout); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
namespace { |
|
|
|
|
|
|
|
|
|
|
|
const int kServerDefaultResponseStreamsToSend = 3; |
|
|
|
const int kServerDefaultResponseStreamsToSend = 3; |
|
|
@ -204,7 +202,8 @@ class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { |
|
|
|
|
|
|
|
|
|
|
|
// Returning string instead of bool to avoid using embedded messages in
|
|
|
|
// Returning string instead of bool to avoid using embedded messages in
|
|
|
|
// proto3
|
|
|
|
// proto3
|
|
|
|
response->set_message(seconds.count() <= FLAGS_timeout ? "true" : "false"); |
|
|
|
response->set_message( |
|
|
|
|
|
|
|
seconds.count() <= absl::GetFlag(FLAGS_timeout) ? "true" : "false"); |
|
|
|
return Status::OK; |
|
|
|
return Status::OK; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -372,7 +371,7 @@ TEST_F(GrpcToolTest, ListCommand) { |
|
|
|
const std::string server_address = SetUpServer(); |
|
|
|
const std::string server_address = SetUpServer(); |
|
|
|
const char* argv[] = {"grpc_cli", "ls", server_address.c_str()}; |
|
|
|
const char* argv[] = {"grpc_cli", "ls", server_address.c_str()}; |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_l = false; |
|
|
|
absl::SetFlag(&FLAGS_l, false); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
@ -391,7 +390,7 @@ TEST_F(GrpcToolTest, ListOneService) { |
|
|
|
const char* argv[] = {"grpc_cli", "ls", server_address.c_str(), |
|
|
|
const char* argv[] = {"grpc_cli", "ls", server_address.c_str(), |
|
|
|
"grpc.testing.EchoTestService"}; |
|
|
|
"grpc.testing.EchoTestService"}; |
|
|
|
// without -l flag
|
|
|
|
// without -l flag
|
|
|
|
FLAGS_l = false; |
|
|
|
absl::SetFlag(&FLAGS_l, false); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
@ -402,7 +401,7 @@ TEST_F(GrpcToolTest, ListOneService) { |
|
|
|
// with -l flag
|
|
|
|
// with -l flag
|
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.clear(); |
|
|
|
output_stream.clear(); |
|
|
|
FLAGS_l = true; |
|
|
|
absl::SetFlag(&FLAGS_l, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
@ -442,7 +441,7 @@ TEST_F(GrpcToolTest, ListOneMethod) { |
|
|
|
const char* argv[] = {"grpc_cli", "ls", server_address.c_str(), |
|
|
|
const char* argv[] = {"grpc_cli", "ls", server_address.c_str(), |
|
|
|
"grpc.testing.EchoTestService.Echo"}; |
|
|
|
"grpc.testing.EchoTestService.Echo"}; |
|
|
|
// without -l flag
|
|
|
|
// without -l flag
|
|
|
|
FLAGS_l = false; |
|
|
|
absl::SetFlag(&FLAGS_l, false); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
@ -452,7 +451,7 @@ TEST_F(GrpcToolTest, ListOneMethod) { |
|
|
|
// with -l flag
|
|
|
|
// with -l flag
|
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.clear(); |
|
|
|
output_stream.clear(); |
|
|
|
FLAGS_l = true; |
|
|
|
absl::SetFlag(&FLAGS_l, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
@ -496,11 +495,12 @@ TEST_F(GrpcToolTest, CallCommand) { |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.clear(); |
|
|
|
output_stream.clear(); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_json_output = true; |
|
|
|
// TODO(Capstan): Consider using absl::FlagSaver
|
|
|
|
|
|
|
|
absl::SetFlag(&FLAGS_json_output, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_json_output = false; |
|
|
|
absl::SetFlag(&FLAGS_json_output, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output:
|
|
|
|
// Expected output:
|
|
|
|
// {
|
|
|
|
// {
|
|
|
@ -520,7 +520,7 @@ TEST_F(GrpcToolTest, CallCommandJsonInput) { |
|
|
|
const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo", |
|
|
|
const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo", |
|
|
|
"{ \"message\": \"Hello\"}"}; |
|
|
|
"{ \"message\": \"Hello\"}"}; |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_json_input = true; |
|
|
|
absl::SetFlag(&FLAGS_json_input, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
@ -532,12 +532,12 @@ TEST_F(GrpcToolTest, CallCommandJsonInput) { |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.clear(); |
|
|
|
output_stream.clear(); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_json_output = true; |
|
|
|
absl::SetFlag(&FLAGS_json_output, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_json_output = false; |
|
|
|
absl::SetFlag(&FLAGS_json_output, false); |
|
|
|
FLAGS_json_input = false; |
|
|
|
absl::SetFlag(&FLAGS_json_input, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output:
|
|
|
|
// Expected output:
|
|
|
|
// {
|
|
|
|
// {
|
|
|
@ -562,11 +562,11 @@ TEST_F(GrpcToolTest, CallCommandBatch) { |
|
|
|
std::istringstream ss("message: 'Hello1'\n\n message: 'Hello2'\n\n"); |
|
|
|
std::istringstream ss("message: 'Hello1'\n\n message: 'Hello2'\n\n"); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_batch = true; |
|
|
|
absl::SetFlag(&FLAGS_batch, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_batch = false; |
|
|
|
absl::SetFlag(&FLAGS_batch, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
|
|
|
|
// Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
|
|
|
|
// "Hello2"\n"
|
|
|
|
// "Hello2"\n"
|
|
|
@ -580,13 +580,13 @@ TEST_F(GrpcToolTest, CallCommandBatch) { |
|
|
|
ss.seekg(0); |
|
|
|
ss.seekg(0); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_batch = true; |
|
|
|
absl::SetFlag(&FLAGS_batch, true); |
|
|
|
FLAGS_json_output = true; |
|
|
|
absl::SetFlag(&FLAGS_json_output, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_json_output = false; |
|
|
|
absl::SetFlag(&FLAGS_json_output, false); |
|
|
|
FLAGS_batch = false; |
|
|
|
absl::SetFlag(&FLAGS_batch, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output:
|
|
|
|
// Expected output:
|
|
|
|
// {
|
|
|
|
// {
|
|
|
@ -623,12 +623,12 @@ TEST_F(GrpcToolTest, CallCommandBatchJsonInput) { |
|
|
|
"{\"message\": \"Hello1\"}\n\n{\"message\": \"Hello2\" }\n\n"); |
|
|
|
"{\"message\": \"Hello1\"}\n\n{\"message\": \"Hello2\" }\n\n"); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_json_input = true; |
|
|
|
absl::SetFlag(&FLAGS_json_input, true); |
|
|
|
FLAGS_batch = true; |
|
|
|
absl::SetFlag(&FLAGS_batch, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_batch = false; |
|
|
|
absl::SetFlag(&FLAGS_batch, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
|
|
|
|
// Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
|
|
|
|
// "Hello2"\n"
|
|
|
|
// "Hello2"\n"
|
|
|
@ -642,14 +642,14 @@ TEST_F(GrpcToolTest, CallCommandBatchJsonInput) { |
|
|
|
ss.seekg(0); |
|
|
|
ss.seekg(0); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_batch = true; |
|
|
|
absl::SetFlag(&FLAGS_batch, true); |
|
|
|
FLAGS_json_output = true; |
|
|
|
absl::SetFlag(&FLAGS_json_output, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_json_output = false; |
|
|
|
absl::SetFlag(&FLAGS_json_output, false); |
|
|
|
FLAGS_batch = false; |
|
|
|
absl::SetFlag(&FLAGS_batch, false); |
|
|
|
FLAGS_json_input = false; |
|
|
|
absl::SetFlag(&FLAGS_json_input, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output:
|
|
|
|
// Expected output:
|
|
|
|
// {
|
|
|
|
// {
|
|
|
@ -685,11 +685,11 @@ TEST_F(GrpcToolTest, CallCommandBatchWithBadRequest) { |
|
|
|
std::istringstream ss("message: 1\n\n message: 'Hello2'\n\n"); |
|
|
|
std::istringstream ss("message: 1\n\n message: 'Hello2'\n\n"); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_batch = true; |
|
|
|
absl::SetFlag(&FLAGS_batch, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_batch = false; |
|
|
|
absl::SetFlag(&FLAGS_batch, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output: "message: "Hello0"\nmessage: "Hello2"\n"
|
|
|
|
// Expected output: "message: "Hello0"\nmessage: "Hello2"\n"
|
|
|
|
EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), |
|
|
|
EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), |
|
|
@ -702,13 +702,13 @@ TEST_F(GrpcToolTest, CallCommandBatchWithBadRequest) { |
|
|
|
ss.seekg(0); |
|
|
|
ss.seekg(0); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_batch = true; |
|
|
|
absl::SetFlag(&FLAGS_batch, true); |
|
|
|
FLAGS_json_output = true; |
|
|
|
absl::SetFlag(&FLAGS_json_output, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_json_output = false; |
|
|
|
absl::SetFlag(&FLAGS_json_output, false); |
|
|
|
FLAGS_batch = false; |
|
|
|
absl::SetFlag(&FLAGS_batch, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output:
|
|
|
|
// Expected output:
|
|
|
|
// {
|
|
|
|
// {
|
|
|
@ -741,13 +741,13 @@ TEST_F(GrpcToolTest, CallCommandBatchJsonInputWithBadRequest) { |
|
|
|
"{ \"message\": 1 }\n\n { \"message\": \"Hello2\" }\n\n"); |
|
|
|
"{ \"message\": 1 }\n\n { \"message\": \"Hello2\" }\n\n"); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_batch = true; |
|
|
|
absl::SetFlag(&FLAGS_batch, true); |
|
|
|
FLAGS_json_input = true; |
|
|
|
absl::SetFlag(&FLAGS_json_input, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_json_input = false; |
|
|
|
absl::SetFlag(&FLAGS_json_input, false); |
|
|
|
FLAGS_batch = false; |
|
|
|
absl::SetFlag(&FLAGS_batch, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output: "message: "Hello0"\nmessage: "Hello2"\n"
|
|
|
|
// Expected output: "message: "Hello0"\nmessage: "Hello2"\n"
|
|
|
|
EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), |
|
|
|
EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), |
|
|
@ -760,15 +760,15 @@ TEST_F(GrpcToolTest, CallCommandBatchJsonInputWithBadRequest) { |
|
|
|
ss.seekg(0); |
|
|
|
ss.seekg(0); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_batch = true; |
|
|
|
absl::SetFlag(&FLAGS_batch, true); |
|
|
|
FLAGS_json_input = true; |
|
|
|
absl::SetFlag(&FLAGS_json_input, true); |
|
|
|
FLAGS_json_output = true; |
|
|
|
absl::SetFlag(&FLAGS_json_output, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_json_output = false; |
|
|
|
absl::SetFlag(&FLAGS_json_output, false); |
|
|
|
FLAGS_json_input = false; |
|
|
|
absl::SetFlag(&FLAGS_json_input, false); |
|
|
|
FLAGS_batch = false; |
|
|
|
absl::SetFlag(&FLAGS_batch, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output:
|
|
|
|
// Expected output:
|
|
|
|
// {
|
|
|
|
// {
|
|
|
@ -827,11 +827,11 @@ TEST_F(GrpcToolTest, CallCommandRequestStreamJsonInput) { |
|
|
|
"{ \"message\": \"Hello1\" }\n\n{ \"message\": \"Hello2\" }\n\n"); |
|
|
|
"{ \"message\": \"Hello1\" }\n\n{ \"message\": \"Hello2\" }\n\n"); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_json_input = true; |
|
|
|
absl::SetFlag(&FLAGS_json_input, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_json_input = false; |
|
|
|
absl::SetFlag(&FLAGS_json_input, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output: "message: \"Hello0Hello1Hello2\""
|
|
|
|
// Expected output: "message: \"Hello0Hello1Hello2\""
|
|
|
|
EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), |
|
|
|
EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), |
|
|
@ -880,11 +880,11 @@ TEST_F(GrpcToolTest, CallCommandRequestStreamWithBadRequestJsonInput) { |
|
|
|
"{ \"bad_field\": \"Hello1\" }\n\n{ \"message\": \"Hello2\" }\n\n"); |
|
|
|
"{ \"bad_field\": \"Hello1\" }\n\n{ \"message\": \"Hello2\" }\n\n"); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
std::cin.rdbuf(ss.rdbuf()); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_json_input = true; |
|
|
|
absl::SetFlag(&FLAGS_json_input, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_json_input = false; |
|
|
|
absl::SetFlag(&FLAGS_json_input, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output: "message: \"Hello0Hello2\""
|
|
|
|
// Expected output: "message: \"Hello0Hello2\""
|
|
|
|
EXPECT_TRUE(nullptr != |
|
|
|
EXPECT_TRUE(nullptr != |
|
|
@ -902,7 +902,7 @@ TEST_F(GrpcToolTest, CallCommandWithTimeoutDeadlineSet) { |
|
|
|
"CheckDeadlineSet"}; |
|
|
|
"CheckDeadlineSet"}; |
|
|
|
|
|
|
|
|
|
|
|
// Set timeout to 5000.25 seconds
|
|
|
|
// Set timeout to 5000.25 seconds
|
|
|
|
FLAGS_timeout = 5000.25; |
|
|
|
absl::SetFlag(&FLAGS_timeout, 5000.25); |
|
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
@ -923,7 +923,7 @@ TEST_F(GrpcToolTest, CallCommandWithTimeoutDeadlineUpperBound) { |
|
|
|
"CheckDeadlineUpperBound"}; |
|
|
|
"CheckDeadlineUpperBound"}; |
|
|
|
|
|
|
|
|
|
|
|
// Set timeout to 900 seconds
|
|
|
|
// Set timeout to 900 seconds
|
|
|
|
FLAGS_timeout = 900; |
|
|
|
absl::SetFlag(&FLAGS_timeout, 900); |
|
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
@ -945,7 +945,7 @@ TEST_F(GrpcToolTest, CallCommandWithNegativeTimeoutValue) { |
|
|
|
"CheckDeadlineSet"}; |
|
|
|
"CheckDeadlineSet"}; |
|
|
|
|
|
|
|
|
|
|
|
// Set timeout to -5 (deadline not set)
|
|
|
|
// Set timeout to -5 (deadline not set)
|
|
|
|
FLAGS_timeout = -5; |
|
|
|
absl::SetFlag(&FLAGS_timeout, -5); |
|
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
@ -967,7 +967,7 @@ TEST_F(GrpcToolTest, CallCommandWithDefaultTimeoutValue) { |
|
|
|
"CheckDeadlineSet"}; |
|
|
|
"CheckDeadlineSet"}; |
|
|
|
|
|
|
|
|
|
|
|
// Set timeout to -1 (default value, deadline not set)
|
|
|
|
// Set timeout to -1 (default value, deadline not set)
|
|
|
|
FLAGS_timeout = -1; |
|
|
|
absl::SetFlag(&FLAGS_timeout, -1); |
|
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
@ -1005,11 +1005,11 @@ TEST_F(GrpcToolTest, CallCommandResponseStream) { |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.clear(); |
|
|
|
output_stream.clear(); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_json_output = true; |
|
|
|
absl::SetFlag(&FLAGS_json_output, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_json_output = false; |
|
|
|
absl::SetFlag(&FLAGS_json_output, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output: "{\n \"message\": \"Hello{n}\"\n}\n"
|
|
|
|
// Expected output: "{\n \"message\": \"Hello{n}\"\n}\n"
|
|
|
|
for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) { |
|
|
|
for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) { |
|
|
@ -1085,8 +1085,8 @@ TEST_F(GrpcToolTest, ParseCommand) { |
|
|
|
"grpc.testing.EchoResponse", |
|
|
|
"grpc.testing.EchoResponse", |
|
|
|
ECHO_RESPONSE_MESSAGE_TEXT_FORMAT}; |
|
|
|
ECHO_RESPONSE_MESSAGE_TEXT_FORMAT}; |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_binary_input = false; |
|
|
|
absl::SetFlag(&FLAGS_binary_input, false); |
|
|
|
FLAGS_binary_output = false; |
|
|
|
absl::SetFlag(&FLAGS_binary_output, false); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
@ -1098,11 +1098,11 @@ TEST_F(GrpcToolTest, ParseCommand) { |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.clear(); |
|
|
|
output_stream.clear(); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_json_output = true; |
|
|
|
absl::SetFlag(&FLAGS_json_output, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_json_output = false; |
|
|
|
absl::SetFlag(&FLAGS_json_output, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output: ECHO_RESPONSE_MESSAGE_JSON_FORMAT
|
|
|
|
// Expected output: ECHO_RESPONSE_MESSAGE_JSON_FORMAT
|
|
|
|
EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), |
|
|
|
EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), |
|
|
@ -1111,7 +1111,7 @@ TEST_F(GrpcToolTest, ParseCommand) { |
|
|
|
// Parse text message to binary message and then parse it back to text message
|
|
|
|
// Parse text message to binary message and then parse it back to text message
|
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.clear(); |
|
|
|
output_stream.clear(); |
|
|
|
FLAGS_binary_output = true; |
|
|
|
absl::SetFlag(&FLAGS_binary_output, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
@ -1119,8 +1119,8 @@ TEST_F(GrpcToolTest, ParseCommand) { |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.clear(); |
|
|
|
output_stream.clear(); |
|
|
|
argv[4] = binary_data.c_str(); |
|
|
|
argv[4] = binary_data.c_str(); |
|
|
|
FLAGS_binary_input = true; |
|
|
|
absl::SetFlag(&FLAGS_binary_input, true); |
|
|
|
FLAGS_binary_output = false; |
|
|
|
absl::SetFlag(&FLAGS_binary_output, false); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(5, argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(5, argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
@ -1129,8 +1129,8 @@ TEST_F(GrpcToolTest, ParseCommand) { |
|
|
|
EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), |
|
|
|
EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), |
|
|
|
ECHO_RESPONSE_MESSAGE_TEXT_FORMAT)); |
|
|
|
ECHO_RESPONSE_MESSAGE_TEXT_FORMAT)); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_binary_input = false; |
|
|
|
absl::SetFlag(&FLAGS_binary_input, false); |
|
|
|
FLAGS_binary_output = false; |
|
|
|
absl::SetFlag(&FLAGS_binary_output, false); |
|
|
|
ShutdownServer(); |
|
|
|
ShutdownServer(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1145,7 +1145,7 @@ TEST_F(GrpcToolTest, ParseCommandJsonFormat) { |
|
|
|
"grpc.testing.EchoResponse", |
|
|
|
"grpc.testing.EchoResponse", |
|
|
|
ECHO_RESPONSE_MESSAGE_JSON_FORMAT}; |
|
|
|
ECHO_RESPONSE_MESSAGE_JSON_FORMAT}; |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_json_input = true; |
|
|
|
absl::SetFlag(&FLAGS_json_input, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
@ -1158,12 +1158,12 @@ TEST_F(GrpcToolTest, ParseCommandJsonFormat) { |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.str(std::string()); |
|
|
|
output_stream.clear(); |
|
|
|
output_stream.clear(); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_json_output = true; |
|
|
|
absl::SetFlag(&FLAGS_json_output, true); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_json_output = false; |
|
|
|
absl::SetFlag(&FLAGS_json_output, false); |
|
|
|
FLAGS_json_input = false; |
|
|
|
absl::SetFlag(&FLAGS_json_input, false); |
|
|
|
|
|
|
|
|
|
|
|
// Expected output: ECHO_RESPONSE_MESSAGE_JSON_FORMAT
|
|
|
|
// Expected output: ECHO_RESPONSE_MESSAGE_JSON_FORMAT
|
|
|
|
EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), |
|
|
|
EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), |
|
|
@ -1211,7 +1211,7 @@ TEST_F(GrpcToolTest, CallCommandWithMetadata) { |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
std::stringstream output_stream; |
|
|
|
std::stringstream output_stream; |
|
|
|
FLAGS_metadata = "key0:val0:key1:valq:key2:val2"; |
|
|
|
absl::SetFlag(&FLAGS_metadata, "key0:val0:key1:valq:key2:val2"); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, |
|
|
|
TestCliCredentials(), |
|
|
|
TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
@ -1223,7 +1223,7 @@ TEST_F(GrpcToolTest, CallCommandWithMetadata) { |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
std::stringstream output_stream; |
|
|
|
std::stringstream output_stream; |
|
|
|
FLAGS_metadata = "key:val\\:val"; |
|
|
|
absl::SetFlag(&FLAGS_metadata, "key:val\\:val"); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, |
|
|
|
TestCliCredentials(), |
|
|
|
TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
@ -1235,7 +1235,7 @@ TEST_F(GrpcToolTest, CallCommandWithMetadata) { |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
std::stringstream output_stream; |
|
|
|
std::stringstream output_stream; |
|
|
|
FLAGS_metadata = "key:val\\\\val"; |
|
|
|
absl::SetFlag(&FLAGS_metadata, "key:val\\\\val"); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, |
|
|
|
TestCliCredentials(), |
|
|
|
TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
@ -1245,7 +1245,7 @@ TEST_F(GrpcToolTest, CallCommandWithMetadata) { |
|
|
|
strstr(output_stream.str().c_str(), "message: \"Hello\"")); |
|
|
|
strstr(output_stream.str().c_str(), "message: \"Hello\"")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_metadata = ""; |
|
|
|
absl::SetFlag(&FLAGS_metadata, ""); |
|
|
|
ShutdownServer(); |
|
|
|
ShutdownServer(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1254,15 +1254,16 @@ TEST_F(GrpcToolTest, CallCommandWithBadMetadata) { |
|
|
|
const char* argv[] = {"grpc_cli", "call", "localhost:10000", |
|
|
|
const char* argv[] = {"grpc_cli", "call", "localhost:10000", |
|
|
|
"grpc.testing.EchoTestService.Echo", |
|
|
|
"grpc.testing.EchoTestService.Echo", |
|
|
|
"message: 'Hello'"}; |
|
|
|
"message: 'Hello'"}; |
|
|
|
FLAGS_protofiles = "src/proto/grpc/testing/echo.proto"; |
|
|
|
absl::SetFlag(&FLAGS_protofiles, "src/proto/grpc/testing/echo.proto"); |
|
|
|
char* test_srcdir = gpr_getenv("TEST_SRCDIR"); |
|
|
|
char* test_srcdir = gpr_getenv("TEST_SRCDIR"); |
|
|
|
if (test_srcdir != nullptr) { |
|
|
|
if (test_srcdir != nullptr) { |
|
|
|
FLAGS_proto_path = test_srcdir + std::string("/com_github_grpc_grpc"); |
|
|
|
absl::SetFlag(&FLAGS_proto_path, |
|
|
|
|
|
|
|
test_srcdir + std::string("/com_github_grpc_grpc")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
std::stringstream output_stream; |
|
|
|
std::stringstream output_stream; |
|
|
|
FLAGS_metadata = "key0:val0:key1"; |
|
|
|
absl::SetFlag(&FLAGS_metadata, "key0:val0:key1"); |
|
|
|
// Exit with 1
|
|
|
|
// Exit with 1
|
|
|
|
EXPECT_EXIT( |
|
|
|
EXPECT_EXIT( |
|
|
|
GrpcToolMainLib( |
|
|
|
GrpcToolMainLib( |
|
|
@ -1273,7 +1274,7 @@ TEST_F(GrpcToolTest, CallCommandWithBadMetadata) { |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
std::stringstream output_stream; |
|
|
|
std::stringstream output_stream; |
|
|
|
FLAGS_metadata = "key:val\\val"; |
|
|
|
absl::SetFlag(&FLAGS_metadata, "key:val\\val"); |
|
|
|
// Exit with 1
|
|
|
|
// Exit with 1
|
|
|
|
EXPECT_EXIT( |
|
|
|
EXPECT_EXIT( |
|
|
|
GrpcToolMainLib( |
|
|
|
GrpcToolMainLib( |
|
|
@ -1282,8 +1283,8 @@ TEST_F(GrpcToolTest, CallCommandWithBadMetadata) { |
|
|
|
::testing::ExitedWithCode(1), ".*Failed to parse metadata flag.*"); |
|
|
|
::testing::ExitedWithCode(1), ".*Failed to parse metadata flag.*"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_metadata = ""; |
|
|
|
absl::SetFlag(&FLAGS_metadata, ""); |
|
|
|
FLAGS_protofiles = ""; |
|
|
|
absl::SetFlag(&FLAGS_protofiles, ""); |
|
|
|
|
|
|
|
|
|
|
|
gpr_free(test_srcdir); |
|
|
|
gpr_free(test_srcdir); |
|
|
|
} |
|
|
|
} |
|
|
@ -1295,9 +1296,9 @@ TEST_F(GrpcToolTest, ListCommand_OverrideSslHostName) { |
|
|
|
// --ssl_target=z.test.google.fr"
|
|
|
|
// --ssl_target=z.test.google.fr"
|
|
|
|
std::stringstream output_stream; |
|
|
|
std::stringstream output_stream; |
|
|
|
const char* argv[] = {"grpc_cli", "ls", server_address.c_str()}; |
|
|
|
const char* argv[] = {"grpc_cli", "ls", server_address.c_str()}; |
|
|
|
FLAGS_l = false; |
|
|
|
absl::SetFlag(&FLAGS_l, false); |
|
|
|
FLAGS_channel_creds_type = "ssl"; |
|
|
|
absl::SetFlag(&FLAGS_channel_creds_type, "ssl"); |
|
|
|
FLAGS_ssl_target = "z.test.google.fr"; |
|
|
|
absl::SetFlag(&FLAGS_ssl_target, "z.test.google.fr"); |
|
|
|
EXPECT_TRUE( |
|
|
|
EXPECT_TRUE( |
|
|
|
0 == GrpcToolMainLib( |
|
|
|
0 == GrpcToolMainLib( |
|
|
|
ArraySize(argv), argv, TestCliCredentials(true), |
|
|
|
ArraySize(argv), argv, TestCliCredentials(true), |
|
|
@ -1306,8 +1307,8 @@ TEST_F(GrpcToolTest, ListCommand_OverrideSslHostName) { |
|
|
|
"grpc.testing.EchoTestService\n" |
|
|
|
"grpc.testing.EchoTestService\n" |
|
|
|
"grpc.reflection.v1alpha.ServerReflection\n")); |
|
|
|
"grpc.reflection.v1alpha.ServerReflection\n")); |
|
|
|
|
|
|
|
|
|
|
|
FLAGS_channel_creds_type = ""; |
|
|
|
absl::SetFlag(&FLAGS_channel_creds_type, ""); |
|
|
|
FLAGS_ssl_target = ""; |
|
|
|
absl::SetFlag(&FLAGS_ssl_target, ""); |
|
|
|
ShutdownServer(); |
|
|
|
ShutdownServer(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1320,13 +1321,13 @@ TEST_F(GrpcToolTest, ConfiguringDefaultServiceConfig) { |
|
|
|
// Just check that the tool is still operational when --default_service_config
|
|
|
|
// Just check that the tool is still operational when --default_service_config
|
|
|
|
// is configured. This particular service config is in reality redundant with
|
|
|
|
// is configured. This particular service config is in reality redundant with
|
|
|
|
// the channel's default configuration.
|
|
|
|
// the channel's default configuration.
|
|
|
|
FLAGS_l = false; |
|
|
|
absl::SetFlag(&FLAGS_l, false); |
|
|
|
FLAGS_default_service_config = |
|
|
|
absl::SetFlag(&FLAGS_default_service_config, |
|
|
|
"{\"loadBalancingConfig\":[{\"pick_first\":{}}]}"; |
|
|
|
"{\"loadBalancingConfig\":[{\"pick_first\":{}}]}"); |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::bind(PrintStream, &output_stream, |
|
|
|
std::placeholders::_1))); |
|
|
|
std::placeholders::_1))); |
|
|
|
FLAGS_default_service_config = ""; |
|
|
|
absl::SetFlag(&FLAGS_default_service_config, ""); |
|
|
|
EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), |
|
|
|
EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), |
|
|
|
"grpc.testing.EchoTestService\n" |
|
|
|
"grpc.testing.EchoTestService\n" |
|
|
|
"grpc.reflection.v1alpha.ServerReflection\n")); |
|
|
|
"grpc.reflection.v1alpha.ServerReflection\n")); |
|
|
|