From 63b28447e8a3d27e21e72b6ee3b7f0b7dab166ed Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 3 Feb 2016 15:40:06 -0800 Subject: [PATCH] Remove the command-line flags --- test/cpp/end2end/thread_stress_test.cc | 29 +++++++++----------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc index d8780415406..151b754c62a 100644 --- a/test/cpp/end2end/thread_stress_test.cc +++ b/test/cpp/end2end/thread_stress_test.cc @@ -34,7 +34,6 @@ #include #include -#include #include #include #include @@ -56,15 +55,8 @@ using grpc::testing::EchoRequest; using grpc::testing::EchoResponse; using std::chrono::system_clock; -// In some distros, gflags is in the namespace google, and in some others, -// in gflags. This hack is enabling us to find both. -namespace google {} -namespace gflags {} -using namespace google; -using namespace gflags; - -DEFINE_int32(num_threads, 100, "Number of threads"); -DEFINE_int32(num_rpcs, 1000, "Number of RPCs per thread"); +const int kNumThreads = 100; // Number of threads +const int kNumRpcs = 1000; // Number of RPCs per thread namespace grpc { namespace testing { @@ -239,11 +231,11 @@ static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs) { TEST_F(End2endTest, ThreadStress) { common_.ResetStub(); std::vector threads; - for (int i = 0; i < FLAGS_num_threads; ++i) { + for (int i = 0; i < kNumThreads; ++i) { threads.push_back( - new std::thread(SendRpc, common_.GetStub(), FLAGS_num_rpcs)); + new std::thread(SendRpc, common_.GetStub(), kNumRpcs)); } - for (int i = 0; i < FLAGS_num_threads; ++i) { + for (int i = 0; i < kNumThreads; ++i) { threads[i]->join(); delete threads[i]; } @@ -324,22 +316,22 @@ class AsyncClientEnd2endTest : public ::testing::Test { TEST_F(AsyncClientEnd2endTest, ThreadStress) { common_.ResetStub(); std::vector send_threads, completion_threads; - for (int i = 0; i < FLAGS_num_threads; ++i) { + for (int i = 0; i < kNumThreads; ++i) { completion_threads.push_back(new std::thread( &AsyncClientEnd2endTest_ThreadStress_Test::AsyncCompleteRpc, this)); } - for (int i = 0; i < FLAGS_num_threads; ++i) { + for (int i = 0; i < kNumThreads; ++i) { send_threads.push_back( new std::thread(&AsyncClientEnd2endTest_ThreadStress_Test::AsyncSendRpc, - this, FLAGS_num_rpcs)); + this, kNumRpcs)); } - for (int i = 0; i < FLAGS_num_threads; ++i) { + for (int i = 0; i < kNumThreads; ++i) { send_threads[i]->join(); delete send_threads[i]; } Wait(); - for (int i = 0; i < FLAGS_num_threads; ++i) { + for (int i = 0; i < kNumThreads; ++i) { completion_threads[i]->join(); delete completion_threads[i]; } @@ -349,7 +341,6 @@ TEST_F(AsyncClientEnd2endTest, ThreadStress) { } // namespace grpc int main(int argc, char** argv) { - ParseCommandLineFlags(&argc, &argv, true); grpc_test_init(argc, argv); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS();