diff options
author | Sree Kuchibhotla <sreek@google.com> | 2016-02-08 10:54:57 -0800 |
---|---|---|
committer | Sree Kuchibhotla <sreek@google.com> | 2016-02-08 10:57:41 -0800 |
commit | 001db590ffb68c8e7051273f7fe9ccd6a9572e10 (patch) | |
tree | 0c2610c9eef61ebe0c0ce6f18ca95935acc12347 /test | |
parent | 469e2fd3fb46478173a8604690170486cfaff781 (diff) |
Modify the test to have large number of threads receiving the RPCs and a
smaller number of threads sending the RPCs. This increases the
likelyhood of race-conditions on receiving threads.
Diffstat (limited to 'test')
-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]; } |