Go to the documentation of this file.
23 #include <gtest/gtest.h>
38 #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
39 #include "src/proto/grpc/testing/echo.grpc.pb.h"
43 using grpc::testing::EchoRequest;
44 using grpc::testing::EchoResponse;
55 class TestServiceImpl :
public grpc::testing::EchoTestService::Service {
66 template <
class Service>
76 virtual void SetUp() = 0;
80 grpc::testing::EchoTestService::Stub*
GetStub() {
return stub_.get(); }
83 std::unique_ptr<grpc::testing::EchoTestService::Stub>
stub_;
100 template <
class Service>
106 this->
stub_ = grpc::testing::EchoTestService::NewStub(
channel);
124 template <
class Service,
bool allow_resource_exhaustion>
129 std::shared_ptr<Channel>
channel = this->
server_->InProcessChannel(args);
130 this->
stub_ = grpc::testing::EchoTestService::NewStub(
channel);
140 template <
class BaseClass>
149 this->TearDownStart();
157 template <
class BaseClass>
165 builder.SetResourceQuota(quota);
169 this->TearDownStart();
177 template <
class BaseClass>
198 this->TearDownStart();
209 while (
cq_->Next(&ignored_tag, &ignored_ok)) {
220 int i =
static_cast<int>(
reinterpret_cast<intptr_t>(
tag));
224 EchoResponse send_response;
225 send_response.set_message(
contexts_[
i].recv_request.message());
248 cq_.get(),
reinterpret_cast<void*
>(
i));
253 std::unique_ptr<grpc::ServerAsyncResponseWriter<EchoResponse>>
259 grpc::testing::EchoTestService::AsyncService
service_;
260 std::unique_ptr<ServerCompletionQueue>
cq_;
266 template <
class Common>
277 static void SendRpc(grpc::testing::EchoTestService::Stub*
stub,
int num_rpcs,
283 for (
int i = 0;
i < num_rpcs; ++
i) {
289 if (!(allow_exhaustion &&
292 s.error_message().c_str());
302 CommonStressTestSyncServer<CommonStressTestInsecure<TestServiceImpl>>,
303 CommonStressTestSyncServer<CommonStressTestInproc<TestServiceImpl, false>>,
304 CommonStressTestSyncServerLowThreadCount<
305 CommonStressTestInproc<TestServiceImpl, true>>,
306 CommonStressTestAsyncServer<
307 CommonStressTestInsecure<grpc::testing::EchoTestService::AsyncService>>,
308 CommonStressTestAsyncServer<CommonStressTestInproc<
309 grpc::testing::EchoTestService::AsyncService,
false>>>
314 std::vector<std::thread>
threads;
320 this->common_.AllowExhaustion(), &
errors);
326 if (error_cnt != 0) {
330 if (this->
common_.AllowExhaustion()) {
335 template <
class Common>
344 while (
cq_.
Next(&ignored_tag, &ignored_ok)) {
366 for (
int i = 0;
i < num_rpcs; ++
i) {
370 call->response_reader =
412 std::vector<std::thread> send_threads, completion_threads;
414 completion_threads.emplace_back(
415 &AsyncClientEnd2endTest_ThreadStress_Test<TypeParam>::AsyncCompleteRpc,
419 send_threads.emplace_back(
420 &AsyncClientEnd2endTest_ThreadStress_Test<TypeParam>::AsyncSendRpc,
424 send_threads[
i].join();
429 completion_threads[
i].join();
436 int main(
int argc,
char** argv) {
std::unique_ptr< grpc::testing::EchoTestService::Stub > stub_
gpr_setenv("STS_CREDENTIALS", creds_file_name)
grpc::internal::CondVar cv_
grpc::internal::Mutex mu_
void ResetStub() override
::testing::Types< CommonStressTestSyncServer< CommonStressTestInsecure< TestServiceImpl > >, CommonStressTestSyncServer< CommonStressTestInproc< TestServiceImpl, false > >, CommonStressTestSyncServerLowThreadCount< CommonStressTestInproc< TestServiceImpl, true > >, CommonStressTestAsyncServer< CommonStressTestInsecure< grpc::testing::EchoTestService::AsyncService > >, CommonStressTestAsyncServer< CommonStressTestInproc< grpc::testing::EchoTestService::AsyncService, false > > > CommonTypes
grpc::testing::EchoTestService::AsyncService service_
std::vector< std::thread > server_threads_
#define gpr_atm_no_barrier_load(p)
void SetUpStart(ServerBuilder *builder, Service *service) override
#define EXPECT_GT(val1, val2)
std::unique_ptr< Server > server_
void ResetStub() override
virtual bool AllowExhaustion()=0
TestMultipleServiceImpl< grpc::testing::EchoTestService::Service > TestServiceImpl
grpc::testing::EchoTestService::Stub * GetStub()
Status Echo(ServerContext *, const EchoRequest *request, EchoResponse *response) override
static uv_thread_t * threads
Desriptor of an RPC service and its various RPC methods.
bool AllowExhaustion() override
internal::ProxyTypeList< Ts... > Types
ServerBuilder & AddListeningPort(const std::string &addr_uri, std::shared_ptr< grpc::ServerCredentials > creds, int *selected_port=nullptr)
wrapped_grpc_channel * channel
A builder class for the creation and startup of grpc::Server instances.
virtual void TearDown()=0
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
void AsyncSendRpc(int num_rpcs)
unsigned __int64 uint64_t
ResourceQuota & SetMaxThreads(int new_max_threads)
virtual void SetUpStart(ServerBuilder *builder, Service *service)=0
#define gpr_atm_rel_store(p, value)
#define gpr_atm_no_barrier_fetch_add(p, delta)
std::ostringstream server_address_
static const Status & OK
An OK pre-defined instance.
virtual ~CommonStressTest()
std::shared_ptr< Channel > CreateChannel(const grpc::string &target, const std::shared_ptr< ChannelCredentials > &creds)
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
int grpc_pick_unused_port_or_die(void)
virtual void ResetStub()=0
std::unique_ptr< ClientAsyncResponseReader< EchoResponse > > response_reader
int main(int argc, char **argv)
static void * tag(intptr_t t)
CommonStressTestAsyncServer()
std::unique_ptr< ServerContext > srv_ctx
bool Next(void **tag, bool *ok)
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
void SetUpEnd(ServerBuilder *builder)
const int kNumAsyncServerThreads
const int kNumAsyncSendThreads
TYPED_TEST(End2endTest, ThreadStress)
EXPECT_EQ(options.token_exchange_service_uri, "https://foo/exchange")
const int kNumAsyncReceiveThreads
std::vector< Context > contexts_
std::shared_ptr< ServerCredentials > InsecureServerCredentials()
grpc::ClientContext context
const int kMaxMessageSize_
EXPECT_TRUE(grpc::experimental::StsCredentialsOptionsFromJson(minimum_valid_json, &options) .ok())
void RefreshContext(int i)
void SetUpStartCommon(ServerBuilder *builder, Service *service)
std::unique_ptr< grpc::ServerAsyncResponseWriter< EchoResponse > > response_writer
std::shared_ptr< ChannelCredentials > InsecureChannelCredentials()
Credentials for an unencrypted, unauthenticated channel.
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod NSString * service
enum grpc::testing::CommonStressTestAsyncServer::Context::@59 state
void SetUpStart(ServerBuilder *builder, Service *service) override
TYPED_TEST_SUITE(End2endTest, CommonTypes)
static bool to_string(zval *from)
static void SendRpc(grpc::testing::EchoTestService::Stub *stub, int num_rpcs, bool allow_exhaustion, gpr_atm *errors)
grpc::internal::Mutex mu_
bool AllowExhaustion() override
std::unique_ptr< ServerCompletionQueue > cq_
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:36