|
|
|
@ -43,7 +43,13 @@ |
|
|
|
|
using grpc::testing::EchoRequest; |
|
|
|
|
using grpc::testing::EchoResponse; |
|
|
|
|
|
|
|
|
|
#if defined(__APPLE__) |
|
|
|
|
// Use less # of threads on Mac because its test machines are less powerful
|
|
|
|
|
// to finish the test on time. (context: b/185231823)
|
|
|
|
|
const int kNumThreads = 100; // Number of threads
|
|
|
|
|
#else |
|
|
|
|
const int kNumThreads = 300; // Number of threads
|
|
|
|
|
#endif |
|
|
|
|
const int kNumAsyncSendThreads = 2; |
|
|
|
|
const int kNumAsyncReceiveThreads = 50; |
|
|
|
|
const int kNumAsyncServerThreads = 50; |
|
|
|
@ -314,12 +320,15 @@ TYPED_TEST(End2endTest, ThreadStress) { |
|
|
|
|
std::vector<std::thread> threads; |
|
|
|
|
gpr_atm errors; |
|
|
|
|
gpr_atm_rel_store(&errors, static_cast<gpr_atm>(0)); |
|
|
|
|
threads.reserve(kNumThreads); |
|
|
|
|
for (int i = 0; i < kNumThreads; ++i) { |
|
|
|
|
int num_threads = kNumThreads / grpc_test_slowdown_factor(); |
|
|
|
|
// The number of threads should be > 10 to be able to catch errors
|
|
|
|
|
ASSERT_GT(num_threads, 10); |
|
|
|
|
threads.reserve(num_threads); |
|
|
|
|
for (int i = 0; i < num_threads; ++i) { |
|
|
|
|
threads.emplace_back(SendRpc, this->common_.GetStub(), kNumRpcs, |
|
|
|
|
this->common_.AllowExhaustion(), &errors); |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < kNumThreads; ++i) { |
|
|
|
|
for (int i = 0; i < num_threads; ++i) { |
|
|
|
|
threads[i].join(); |
|
|
|
|
} |
|
|
|
|
uint64_t error_cnt = static_cast<uint64_t>(gpr_atm_no_barrier_load(&errors)); |
|
|
|
|