diff options
author | Vijay Pai <vpai@google.com> | 2016-02-08 11:48:36 -0800 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2016-02-08 11:48:36 -0800 |
commit | 81b780b84b77a093ac2273865cd1af8a0f6f69bf (patch) | |
tree | 956d843a4a262159caa98afd9bf8df7fdc2ca9d5 /test/cpp/end2end | |
parent | e4333fa1d3e2ff10f69f261b9c31bf39a4837b9c (diff) | |
parent | 001db590ffb68c8e7051273f7fe9ccd6a9572e10 (diff) |
Merge pull request #5126 from sreecha/thread_stress_test
Modify thread stress test. Receive threads >> send threads
Diffstat (limited to 'test/cpp/end2end')
-rw-r--r-- | test/cpp/end2end/thread_stress_test.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc index 4c7caa9b87..dd7a8e5ed2 100644 --- a/test/cpp/end2end/thread_stress_test.cc +++ b/test/cpp/end2end/thread_stress_test.cc @@ -55,7 +55,9 @@ using grpc::testing::EchoRequest; using grpc::testing::EchoResponse; using std::chrono::system_clock; -const int kNumThreads = 100; // Number of threads +const int kNumThreads = 100; // Number of threads +const int kNumAsyncSendThreads = 2; +const int kNumAsyncReceiveThreads = 50; const int kNumRpcs = 1000; // Number of RPCs per thread namespace grpc { @@ -273,7 +275,7 @@ class AsyncClientEnd2endTest : public ::testing::Test { for (int i = 0; i < num_rpcs; ++i) { AsyncClientCall* call = new AsyncClientCall; EchoRequest request; - request.set_message("Hello"); + request.set_message("Hello: " + std::to_string(i)); call->response_reader = common_.GetStub()->AsyncEcho(&call->context, request, &cq_); call->response_reader->Finish(&call->response, &call->status, @@ -290,7 +292,9 @@ class AsyncClientEnd2endTest : public ::testing::Test { bool ok = false; if (!cq_.Next(&got_tag, &ok)) break; AsyncClientCall* call = static_cast<AsyncClientCall*>(got_tag); - GPR_ASSERT(ok); + if (!ok) { + gpr_log(GPR_DEBUG, "Error: %d", call->status.error_code()); + } delete call; bool notify; @@ -315,22 +319,22 @@ class AsyncClientEnd2endTest : public ::testing::Test { TEST_F(AsyncClientEnd2endTest, ThreadStress) { common_.ResetStub(); std::vector<std::thread*> send_threads, completion_threads; - for (int i = 0; i < kNumThreads / 2; ++i) { + for (int i = 0; i < kNumAsyncReceiveThreads; ++i) { completion_threads.push_back(new std::thread( &AsyncClientEnd2endTest_ThreadStress_Test::AsyncCompleteRpc, this)); } - for (int i = 0; i < kNumThreads / 2; ++i) { + for (int i = 0; i < kNumAsyncSendThreads; ++i) { send_threads.push_back( new std::thread(&AsyncClientEnd2endTest_ThreadStress_Test::AsyncSendRpc, this, kNumRpcs)); } - for (int i = 0; i < kNumThreads / 2; ++i) { + for (int i = 0; i < kNumAsyncSendThreads; ++i) { send_threads[i]->join(); delete send_threads[i]; } Wait(); - for (int i = 0; i < kNumThreads / 2; ++i) { + for (int i = 0; i < kNumAsyncReceiveThreads; ++i) { completion_threads[i]->join(); delete completion_threads[i]; } |