20 #include <unordered_map>
22 #include "absl/flags/flag.h"
37 "Whether to use alts. Enable alts will disable tls.");
38 ABSL_FLAG(
bool, use_tls,
false,
"Whether to use tls.");
40 "User provided credentials type.");
41 ABSL_FLAG(
bool, use_test_ca,
false,
"False to use SSL roots for google");
45 "Override the server host which is sent in HTTP header");
48 "Configure different test cases. Valid options are:\n\n"
49 "all : all test cases;\n"
87 "Email of GCE default service account");
89 "Path to service account json key file.");
91 ABSL_FLAG(
bool, do_not_abort_on_transient_failures,
false,
92 "If set to 'true', abort() is not called in case of transient "
93 "failures (i.e failures that are temporary and will likely go away "
94 "on retrying; like a temporary connection failure) and an error "
95 "message is printed instead. Note that this flag just controls "
96 "whether abort() is called or not. It does not control whether the "
97 "test is retried in case of transient failures (and currently the "
98 "interop tests are not retried even if this flag is set to true)");
100 "The number of iterations to use for the two soak tests; rpc_soak "
101 "and channel_soak.");
103 "The number of iterations in soak tests that are allowed to fail "
104 "(either due to non-OK status code or exceeding the "
105 "per-iteration max acceptable latency).");
107 "The number of milliseconds a single iteration in the two soak "
108 "tests (rpc_soak and channel_soak) should take.");
110 "The overall number of seconds after which a soak test should "
111 "stop and fail, if the desired number of iterations have not yet "
114 "The minimum time in milliseconds between consecutive RPCs in a "
115 "soak test (rpc_soak or channel_soak), useful for limiting QPS");
117 "The interval in seconds between rpcs. This is used by "
118 "long_connection test");
120 "Additional metadata to send in each request, as a "
121 "semicolon-separated list of key:value pairs.");
123 bool, log_metadata_and_status,
false,
124 "If set to 'true', will print received initial and trailing metadata, "
125 "grpc-status and error message to the console, in a stable format.");
137 bool ParseAdditionalMetadataFlag(
139 std::multimap<std::string, std::string>* additional_metadata) {
140 size_t start_pos = 0;
141 while (start_pos <
flag.length()) {
142 size_t colon_pos =
flag.find(
':', start_pos);
143 if (colon_pos == std::string::npos) {
145 "Couldn't parse metadata flag: extra characters at end of flag");
148 size_t semicolon_pos =
flag.find(
';', colon_pos);
152 flag.substr(colon_pos + 1, semicolon_pos - colon_pos - 1);
154 constexpr
char alphanum_and_hyphen[] =
156 "abcdefghijklmnopqrstuvwxyz"
157 "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
158 if (
key.find_first_not_of(alphanum_and_hyphen) != std::string::npos) {
160 "Couldn't parse metadata flag: key contains characters other "
161 "than alphanumeric and hyphens: %s",
167 for (
char&
c :
key) {
168 if (
c >=
'A' &&
c <=
'Z') {
173 gpr_log(
GPR_INFO,
"Adding additional metadata with key %s and value %s",
175 additional_metadata->insert({
key,
value});
177 if (semicolon_pos == std::string::npos) {
180 start_pos = semicolon_pos + 1;
189 int main(
int argc,
char** argv) {
199 channel_creation_func = [test_case]() {
200 std::vector<std::unique_ptr<
204 factories.emplace_back(
210 std::multimap<std::string, std::string> additional_metadata;
211 if (!ParseAdditionalMetadataFlag(
absl::GetFlag(FLAGS_additional_metadata),
212 &additional_metadata)) {
216 channel_creation_func = [test_case, additional_metadata]() {
217 std::vector<std::unique_ptr<
220 factories.emplace_back(
222 additional_metadata));
224 factories.emplace_back(
232 channel_creation_func,
true,
236 actions[
"empty_unary"] =
238 actions[
"large_unary"] =
240 actions[
"server_compressed_unary"] = std::bind(
242 actions[
"client_compressed_unary"] = std::bind(
244 actions[
"client_streaming"] =
246 actions[
"server_streaming"] =
248 actions[
"server_compressed_streaming"] = std::bind(
250 actions[
"client_compressed_streaming"] = std::bind(
252 actions[
"slow_consumer"] = std::bind(
255 actions[
"half_duplex"] =
257 actions[
"ping_pong"] =
259 actions[
"cancel_after_begin"] =
261 actions[
"cancel_after_first_response"] = std::bind(
263 actions[
"timeout_on_sleeping_server"] = std::bind(
265 actions[
"empty_stream"] =
267 actions[
"pick_first_unary"] =
270 actions[
"compute_engine_creds"] =
274 actions[
"jwt_token_creds"] =
277 actions[
"oauth2_auth_token"] =
281 actions[
"per_rpc_creds"] =
286 "google_default_credentials") {
287 actions[
"google_default_credentials"] =
291 actions[
"status_code_and_message"] =
293 actions[
"special_status_message"] =
295 actions[
"custom_metadata"] =
297 actions[
"unimplemented_method"] =
299 actions[
"unimplemented_service"] =
301 actions[
"channel_soak"] = std::bind(
305 absl::GetFlag(FLAGS_soak_per_iteration_max_acceptable_latency_ms),
308 actions[
"rpc_soak"] = std::bind(
312 absl::GetFlag(FLAGS_soak_per_iteration_max_acceptable_latency_ms),
315 actions[
"long_lived_channel"] =
323 for (
const auto&
action : actions) {
326 }
else if (actions.find(
absl::GetFlag(FLAGS_test_case)) != actions.end()) {
330 for (
const auto&
action : actions) {