25 #include "absl/flags/flag.h"
32 #include "src/proto/grpc/testing/metrics.grpc.pb.h"
33 #include "src/proto/grpc/testing/metrics.pb.h"
46 "The duration (in millisec) between two"
47 " consecutive test calls (per server) issued by the server.");
51 "The length of time (in seconds) to run"
52 " the test. Enter -1 if the test should run continuously until"
53 " forcefully terminated.");
56 "The list of server addresses. The format is: \n"
57 " \"<name_1>:<port_1>,<name_2>:<port_1>...<name_N>:<port_N>\"\n"
58 " Note: <name> can be servername or IP address.");
61 "Number of channels for each server");
64 "Number of stubs per each channels to server. This number also "
65 "indicates the max number of parallel RPC calls on each channel "
66 "at any given time.");
70 "List of test cases to call along with the"
71 " relative weights in the following format:\n"
72 " \"<testcase_1:w_1>,<testcase_2:w_2>...<testcase_n:w_n>\"\n"
73 " The following testcases are currently supported:\n"
76 " large_compressed_unary\n"
79 " server_compressed_streaming\n"
83 " cancel_after_begin\n"
84 " cancel_after_first_response\n"
85 " timeout_on_sleeping_server\n"
87 " status_code_and_message\n"
89 " Example: \"empty_unary:20,large_unary:10,empty_stream:70\"\n"
90 " The above will execute 'empty_unary', 20% of the time,"
91 " 'large_unary', 10% of the time and 'empty_stream' the remaining"
95 "Severity level of messages that should be logged. Any messages "
96 "greater than or equal to the level set here will be logged. "
97 "The choices are: 0 (GPR_LOG_SEVERITY_DEBUG), 1 "
98 "(GPR_LOG_SEVERITY_INFO) and 2 (GPR_LOG_SEVERITY_ERROR)");
100 ABSL_FLAG(
bool, do_not_abort_on_transient_failures,
true,
101 "If set to 'true', abort() is not called in case of transient "
102 "failures like temporary connection failures.");
107 "Whether to use alts. Enable alts will disable tls.");
108 ABSL_FLAG(
bool, use_tls,
false,
"Whether to use tls.");
109 ABSL_FLAG(
bool, use_test_ca,
false,
"False to use SSL roots for google");
111 "Override the server host which is sent in HTTP header");
138 if (test_name ==
it->second) {
139 test_case =
it->first;
149 std::vector<std::string>& tokens) {
151 size_t epos = std::string::npos;
153 while ((epos = comma_delimited_str.find(
',', bpos)) != std::string::npos) {
154 tokens.emplace_back(comma_delimited_str.substr(bpos, epos - bpos));
158 tokens.emplace_back(comma_delimited_str.substr(bpos));
167 std::vector<std::pair<TestCaseType, int>>&
tests) {
168 bool is_success =
true;
170 std::vector<std::string> tokens;
173 for (
auto it = tokens.begin();
it != tokens.end();
it++) {
175 size_t colon_pos =
it->find(
':');
176 if (colon_pos == std::string::npos) {
183 int weight = std::stoi(
it->substr(colon_pos + 1));
191 tests.emplace_back(std::make_pair(test_case,
weight));
199 const std::vector<std::pair<TestCaseType, int>>&
tests) {
213 absl::GetFlag(FLAGS_do_not_abort_on_transient_failures) ?
"true"
217 for (
auto it = addresses.begin();
it != addresses.end();
it++) {
230 int main(
int argc,
char** argv) {
245 srand(time(
nullptr));
258 std::vector<std::pair<TestCaseType, int>>
tests;
272 std::vector<std::thread> test_threads;
273 std::vector<std::unique_ptr<StressTestInteropClient>>
clients;
293 for (
int channel_idx = 0;
299 std::bind(
static_cast<std::shared_ptr<grpc::Channel> (*)(
307 for (
int stub_idx = 0;
308 stub_idx <
absl::GetFlag(FLAGS_num_stubs_per_channel); stub_idx++) {
310 ++thread_idx, *
it, channel_creation_func, test_selector,
315 bool is_already_created =
false;
318 "/stress_test/server_%d/channel_%d/stub_%d/qps",
319 server_idx, channel_idx, stub_idx);
322 &StressTestInteropClient::MainLoop,
clients.back().get(),
332 std::unique_ptr<grpc::Server> metrics_server;
339 for (
auto it = test_threads.begin();
it != test_threads.end();
it++) {