Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
0fa95eab
Commit
0fa95eab
authored
9 years ago
by
Sree Kuchibhotla
Browse files
Options
Downloads
Patches
Plain Diff
Ability to filter log messages based on log level
parent
64f10281
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cpp/interop/stress_test.cc
+33
-2
33 additions, 2 deletions
test/cpp/interop/stress_test.cc
with
33 additions
and
2 deletions
test/cpp/interop/stress_test.cc
+
33
−
2
View file @
0fa95eab
...
@@ -50,6 +50,10 @@
...
@@ -50,6 +50,10 @@
#include
"test/proto/metrics.grpc.pb.h"
#include
"test/proto/metrics.grpc.pb.h"
#include
"test/proto/metrics.pb.h"
#include
"test/proto/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_port
,
8081
,
"The metrics server port."
);
DEFINE_int32
(
metrics_collection_interval_secs
,
5
,
DEFINE_int32
(
metrics_collection_interval_secs
,
5
,
...
@@ -94,6 +98,12 @@ DEFINE_string(test_cases, "",
...
@@ -94,6 +98,12 @@ DEFINE_string(test_cases, "",
" 'large_unary', 10% of the time and 'empty_stream' the remaining"
" 'large_unary', 10% of the time and 'empty_stream' the remaining"
" 70% of the time"
);
" 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
::
kTestCaseList
;
using
grpc
::
testing
::
MetricsService
;
using
grpc
::
testing
::
MetricsService
;
using
grpc
::
testing
::
MetricsServiceImpl
;
using
grpc
::
testing
::
MetricsServiceImpl
;
...
@@ -102,6 +112,16 @@ using grpc::testing::TestCaseType;
...
@@ -102,6 +112,16 @@ using grpc::testing::TestCaseType;
using
grpc
::
testing
::
UNKNOWN_TEST
;
using
grpc
::
testing
::
UNKNOWN_TEST
;
using
grpc
::
testing
::
WeightedRandomTestSelector
;
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
GetTestTypeFromName
(
const
grpc
::
string
&
test_name
)
{
TestCaseType
test_case
=
UNKNOWN_TEST
;
TestCaseType
test_case
=
UNKNOWN_TEST
;
...
@@ -190,6 +210,18 @@ void LogParameterInfo(const std::vector<grpc::string>& addresses,
...
@@ -190,6 +210,18 @@ void LogParameterInfo(const std::vector<grpc::string>& addresses,
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
grpc
::
testing
::
InitTest
(
&
argc
,
&
argv
,
true
);
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
));
srand
(
time
(
NULL
));
// Parse the server addresses
// Parse the server addresses
...
@@ -198,7 +230,7 @@ int main(int argc, char** argv) {
...
@@ -198,7 +230,7 @@ int main(int argc, char** argv) {
// Parse test cases and weights
// Parse test cases and weights
if
(
FLAGS_test_cases
.
length
()
==
0
)
{
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
;
return
1
;
}
}
...
@@ -270,6 +302,5 @@ int main(int argc, char** argv) {
...
@@ -270,6 +302,5 @@ int main(int argc, char** argv) {
it
->
join
();
it
->
join
();
}
}
metrics_server
->
Wait
();
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment