stress_interop_client.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *is % allowed in string
17  */
18 
19 #ifndef GRPC_TEST_CPP_STRESS_INTEROP_CLIENT_H
20 #define GRPC_TEST_CPP_STRESS_INTEROP_CLIENT_H
21 
22 #include <memory>
23 #include <string>
24 #include <vector>
25 
26 #include <grpcpp/create_channel.h>
27 
30 
31 namespace grpc {
32 namespace testing {
33 
34 using std::pair;
35 using std::vector;
36 
56 };
57 
58 const vector<pair<TestCaseType, std::string>> kTestCaseList = {
59  {EMPTY_UNARY, "empty_unary"},
60  {LARGE_UNARY, "large_unary"},
61  {CLIENT_COMPRESSED_UNARY, "client_compressed_unary"},
62  {CLIENT_COMPRESSED_STREAMING, "client_compressed_streaming"},
63  {CLIENT_STREAMING, "client_streaming"},
64  {SERVER_STREAMING, "server_streaming"},
65  {SERVER_COMPRESSED_UNARY, "server_compressed_unary"},
66  {SERVER_COMPRESSED_STREAMING, "server_compressed_streaming"},
67  {SLOW_CONSUMER, "slow_consumer"},
68  {HALF_DUPLEX, "half_duplex"},
69  {PING_PONG, "ping_pong"},
70  {CANCEL_AFTER_BEGIN, "cancel_after_begin"},
71  {CANCEL_AFTER_FIRST_RESPONSE, "cancel_after_first_response"},
72  {TIMEOUT_ON_SLEEPING_SERVER, "timeout_on_sleeping_server"},
73  {EMPTY_STREAM, "empty_stream"},
74  {STATUS_CODE_AND_MESSAGE, "status_code_and_message"},
75  {CUSTOM_METADATA, "custom_metadata"}};
76 
78  public:
79  // Takes a vector of <test_case, weight> pairs as the input
81  const vector<pair<TestCaseType, int>>& tests);
82 
83  // Returns a weighted-randomly chosen test case based on the test cases and
84  // weights passed in the constructor
85  TestCaseType GetNextTest() const;
86 
87  private:
88  const vector<pair<TestCaseType, int>> tests_;
90 };
91 
93  public:
95  ChannelCreationFunc channel_creation_func,
96  const WeightedRandomTestSelector& test_selector,
97  long test_duration_secs, long sleep_duration_ms,
98  bool do_not_abort_on_transient_failures);
99 
100  // The main function. Use this as the thread entry point.
101  // qps_gauge is the QpsGauge to record the requests per second metric
102  void MainLoop(const std::shared_ptr<QpsGauge>& qps_gauge);
103 
104  private:
105  bool RunTest(TestCaseType test_case);
106 
107  int test_id_;
110  std::unique_ptr<InteropClient> interop_client_;
114 };
115 
116 } // namespace testing
117 } // namespace grpc
118 
119 #endif // GRPC_TEST_CPP_STRESS_INTEROP_CLIENT_H
testing
Definition: aws_request_signer_test.cc:25
grpc
Definition: grpcpp/alarm.h:33
grpc::testing::WeightedRandomTestSelector::GetNextTest
TestCaseType GetNextTest() const
Definition: stress_interop_client.cc:48
grpc::testing::SERVER_COMPRESSED_STREAMING
@ SERVER_COMPRESSED_STREAMING
Definition: stress_interop_client.h:46
grpc::testing::EMPTY_STREAM
@ EMPTY_STREAM
Definition: stress_interop_client.h:53
grpc::testing::kTestCaseList
const vector< pair< TestCaseType, std::string > > kTestCaseList
Definition: stress_interop_client.h:58
grpc::testing::SLOW_CONSUMER
@ SLOW_CONSUMER
Definition: stress_interop_client.h:47
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc::testing::CLIENT_STREAMING
@ CLIENT_STREAMING
Definition: stress_interop_client.h:43
grpc::testing::CLIENT_COMPRESSED_UNARY
@ CLIENT_COMPRESSED_UNARY
Definition: stress_interop_client.h:41
grpc::testing::TIMEOUT_ON_SLEEPING_SERVER
@ TIMEOUT_ON_SLEEPING_SERVER
Definition: stress_interop_client.h:52
grpc::testing::StressTestInteropClient::test_selector_
const WeightedRandomTestSelector & test_selector_
Definition: stress_interop_client.h:111
server_address
std::string server_address("0.0.0.0:10000")
grpc::testing::StressTestInteropClient::test_duration_secs_
long test_duration_secs_
Definition: stress_interop_client.h:112
grpc::testing::SERVER_STREAMING
@ SERVER_STREAMING
Definition: stress_interop_client.h:44
metrics_server.h
grpc::testing::StressTestInteropClient::interop_client_
std::unique_ptr< InteropClient > interop_client_
Definition: stress_interop_client.h:110
grpc::testing::WeightedRandomTestSelector
Definition: stress_interop_client.h:77
grpc::testing::CUSTOM_METADATA
@ CUSTOM_METADATA
Definition: stress_interop_client.h:55
grpc::testing::StressTestInteropClient::channel_creation_func_
ChannelCreationFunc channel_creation_func_
Definition: stress_interop_client.h:109
grpc::testing::EMPTY_UNARY
@ EMPTY_UNARY
Definition: stress_interop_client.h:39
grpc::testing::StressTestInteropClient::StressTestInteropClient
StressTestInteropClient(int test_id, const std::string &server_address, ChannelCreationFunc channel_creation_func, const WeightedRandomTestSelector &test_selector, long test_duration_secs, long sleep_duration_ms, bool do_not_abort_on_transient_failures)
Definition: stress_interop_client.cc:69
grpc::testing::PING_PONG
@ PING_PONG
Definition: stress_interop_client.h:49
grpc::testing::StressTestInteropClient::MainLoop
void MainLoop(const std::shared_ptr< QpsGauge > &qps_gauge)
Definition: stress_interop_client.cc:83
interop_client.h
grpc::testing::SERVER_COMPRESSED_UNARY
@ SERVER_COMPRESSED_UNARY
Definition: stress_interop_client.h:45
grpc::testing::WeightedRandomTestSelector::total_weight_
int total_weight_
Definition: stress_interop_client.h:89
grpc::testing::StressTestInteropClient
Definition: stress_interop_client.h:92
grpc::testing::StressTestInteropClient::RunTest
bool RunTest(TestCaseType test_case)
Definition: stress_interop_client.cc:117
grpc::testing::ChannelCreationFunc
std::function< std::shared_ptr< Channel >void)> ChannelCreationFunc
Definition: interop_client.h:38
grpc::testing::STATUS_CODE_AND_MESSAGE
@ STATUS_CODE_AND_MESSAGE
Definition: stress_interop_client.h:54
grpc::testing::UNKNOWN_TEST
@ UNKNOWN_TEST
Definition: stress_interop_client.h:38
grpc::testing::StressTestInteropClient::test_id_
int test_id_
Definition: stress_interop_client.h:107
grpc::testing::WeightedRandomTestSelector::WeightedRandomTestSelector
WeightedRandomTestSelector(const vector< pair< TestCaseType, int >> &tests)
Definition: stress_interop_client.cc:37
grpc::testing::LARGE_UNARY
@ LARGE_UNARY
Definition: stress_interop_client.h:40
tests
Definition: src/python/grpcio_tests/tests/__init__.py:1
grpc::testing::TestCaseType
TestCaseType
Definition: stress_interop_client.h:37
grpc::testing::HALF_DUPLEX
@ HALF_DUPLEX
Definition: stress_interop_client.h:48
grpc::testing::StressTestInteropClient::sleep_duration_ms_
long sleep_duration_ms_
Definition: stress_interop_client.h:113
grpc::testing::WeightedRandomTestSelector::tests_
const vector< pair< TestCaseType, int > > tests_
Definition: stress_interop_client.h:88
grpc::testing::CLIENT_COMPRESSED_STREAMING
@ CLIENT_COMPRESSED_STREAMING
Definition: stress_interop_client.h:42
pair
std::pair< std::string, std::string > pair
Definition: abseil-cpp/absl/container/internal/raw_hash_set_benchmark.cc:78
grpc::testing::CANCEL_AFTER_BEGIN
@ CANCEL_AFTER_BEGIN
Definition: stress_interop_client.h:50
create_channel.h
grpc::testing::CANCEL_AFTER_FIRST_RESPONSE
@ CANCEL_AFTER_FIRST_RESPONSE
Definition: stress_interop_client.h:51
grpc::testing::StressTestInteropClient::server_address_
const std::string & server_address_
Definition: stress_interop_client.h:108


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:21