aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/interop/stress_test.cc
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2016-01-07 16:37:03 -0800
committerGravatar Craig Tiller <craig.tiller@gmail.com>2016-01-07 16:37:03 -0800
commit7cc0f464d12696b0f5c26d3ad248215c9ff63c27 (patch)
treec572b7fc730350ebd7ff3201ded323cfee9dad3f /test/cpp/interop/stress_test.cc
parent54ed674d406e43a9c54ad103b5ea454d73a64c3b (diff)
parentabf85d96481a35d26ecfd16575f0a13846d3b8e5 (diff)
Merge github.com:grpc/grpc into proto_names
Diffstat (limited to 'test/cpp/interop/stress_test.cc')
-rw-r--r--test/cpp/interop/stress_test.cc35
1 files changed, 33 insertions, 2 deletions
diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc
index ce72febaaa..05d5f2e339 100644
--- a/test/cpp/interop/stress_test.cc
+++ b/test/cpp/interop/stress_test.cc
@@ -50,6 +50,10 @@
#include "src/proto/grpc/testing/metrics.grpc.pb.h"
#include "src/proto/grpc/testing/metrics.pb.h"
+extern "C" {
+extern void gpr_default_log(gpr_log_func_args* args);
+}
+
DEFINE_int32(metrics_port, 8081, "The metrics server port.");
DEFINE_int32(metrics_collection_interval_secs, 5,
@@ -94,6 +98,12 @@ DEFINE_string(test_cases, "",
" 'large_unary', 10% of the time and 'empty_stream' the remaining"
" 70% of the time");
+DEFINE_int32(log_level, GPR_LOG_SEVERITY_DEBUG,
+ "Severity level of messages that should be logged. Any messages "
+ "greater than or equal to the level set here will be logged. "
+ "The choices are: 0 (GPR_LOG_SEVERITY_DEBUG), 1 "
+ "(GPR_LOG_SEVERITY_INFO) and 2 (GPR_LOG_SEVERITY_ERROR.");
+
using grpc::testing::kTestCaseList;
using grpc::testing::MetricsService;
using grpc::testing::MetricsServiceImpl;
@@ -102,6 +112,16 @@ using grpc::testing::TestCaseType;
using grpc::testing::UNKNOWN_TEST;
using grpc::testing::WeightedRandomTestSelector;
+static int log_level = GPR_LOG_SEVERITY_DEBUG;
+
+// A simple wrapper to grp_default_log() function. This only logs messages at or
+// above the current log level (set in 'log_level' variable)
+void TestLogFunction(gpr_log_func_args* args) {
+ if (args->severity >= log_level) {
+ gpr_default_log(args);
+ }
+}
+
TestCaseType GetTestTypeFromName(const grpc::string& test_name) {
TestCaseType test_case = UNKNOWN_TEST;
@@ -190,6 +210,18 @@ void LogParameterInfo(const std::vector<grpc::string>& addresses,
int main(int argc, char** argv) {
grpc::testing::InitTest(&argc, &argv, true);
+ if (FLAGS_log_level > GPR_LOG_SEVERITY_ERROR ||
+ FLAGS_log_level < GPR_LOG_SEVERITY_DEBUG) {
+ gpr_log(GPR_ERROR, "log_level should be an integer between %d and %d",
+ GPR_LOG_SEVERITY_DEBUG, GPR_LOG_SEVERITY_ERROR);
+ return 1;
+ }
+
+ // Change the default log function to TestLogFunction which respects the
+ // log_level setting.
+ log_level = FLAGS_log_level;
+ gpr_set_log_function(TestLogFunction);
+
srand(time(NULL));
// Parse the server addresses
@@ -198,7 +230,7 @@ int main(int argc, char** argv) {
// Parse test cases and weights
if (FLAGS_test_cases.length() == 0) {
- gpr_log(GPR_INFO, "Not running tests. The 'test_cases' string is empty");
+ gpr_log(GPR_ERROR, "Not running tests. The 'test_cases' string is empty");
return 1;
}
@@ -270,6 +302,5 @@ int main(int argc, char** argv) {
it->join();
}
- metrics_server->Wait();
return 0;
}