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
98f2f754
Commit
98f2f754
authored
8 years ago
by
Vijay Pai
Browse files
Options
Downloads
Patches
Plain Diff
Used TYPED_TEST to parametrize
Include all 4 sync/async client/server combos
parent
40d1a2cb
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/end2end/thread_stress_test.cc
+21
-34
21 additions, 34 deletions
test/cpp/end2end/thread_stress_test.cc
with
21 additions
and
34 deletions
test/cpp/end2end/thread_stress_test.cc
+
21
−
34
View file @
98f2f754
...
...
@@ -318,6 +318,7 @@ class CommonStressTestAsyncServer
std
::
vector
<
std
::
thread
*>
server_threads_
;
};
template
<
class
Common
>
class
End2endTest
:
public
::
testing
::
Test
{
protected:
End2endTest
()
{}
...
...
@@ -325,17 +326,7 @@ class End2endTest : public ::testing::Test {
void
TearDown
()
GRPC_OVERRIDE
{
common_
.
TearDown
();
}
void
ResetStub
()
{
common_
.
ResetStub
();
}
CommonStressTestSyncServer
common_
;
};
class
End2endTestAsyncServer
:
public
::
testing
::
Test
{
protected:
End2endTestAsyncServer
()
{}
void
SetUp
()
GRPC_OVERRIDE
{
common_
.
SetUp
();
}
void
TearDown
()
GRPC_OVERRIDE
{
common_
.
TearDown
();
}
void
ResetStub
()
{
common_
.
ResetStub
();
}
CommonStressTestAsyncServer
common_
;
Common
common_
;
};
static
void
SendRpc
(
grpc
::
testing
::
EchoTestService
::
Stub
*
stub
,
int
num_rpcs
)
{
...
...
@@ -351,23 +342,16 @@ static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs) {
}
}
TEST_F
(
End2endTest
,
ThreadStress
)
{
common_
.
ResetStub
();
std
::
vector
<
std
::
thread
*>
threads
;
for
(
int
i
=
0
;
i
<
kNumThreads
;
++
i
)
{
threads
.
push_back
(
new
std
::
thread
(
SendRpc
,
common_
.
GetStub
(),
kNumRpcs
));
}
for
(
int
i
=
0
;
i
<
kNumThreads
;
++
i
)
{
threads
[
i
]
->
join
();
delete
threads
[
i
];
}
}
TEST_F
(
End2endTestAsyncServer
,
ThreadStress
)
{
common_
.
ResetStub
();
typedef
::
testing
::
Types
<
CommonStressTestSyncServer
,
CommonStressTestAsyncServer
>
CommonTypes
;
TYPED_TEST_CASE
(
End2endTest
,
CommonTypes
);
TYPED_TEST
(
End2endTest
,
ThreadStress
)
{
this
->
common_
.
ResetStub
();
std
::
vector
<
std
::
thread
*>
threads
;
for
(
int
i
=
0
;
i
<
kNumThreads
;
++
i
)
{
threads
.
push_back
(
new
std
::
thread
(
SendRpc
,
common_
.
GetStub
(),
kNumRpcs
));
threads
.
push_back
(
new
std
::
thread
(
SendRpc
,
this
->
common_
.
GetStub
(),
kNumRpcs
));
}
for
(
int
i
=
0
;
i
<
kNumThreads
;
++
i
)
{
threads
[
i
]
->
join
();
...
...
@@ -375,6 +359,7 @@ TEST_F(End2endTestAsyncServer, ThreadStress) {
}
}
template
<
class
Common
>
class
AsyncClientEnd2endTest
:
public
::
testing
::
Test
{
protected:
AsyncClientEnd2endTest
()
:
rpcs_outstanding_
(
0
)
{}
...
...
@@ -442,31 +427,33 @@ class AsyncClientEnd2endTest : public ::testing::Test {
}
}
Common
StressTestSyncServer
common_
;
Common
common_
;
CompletionQueue
cq_
;
mutex
mu_
;
condition_variable
cv_
;
int
rpcs_outstanding_
;
};
TEST_F
(
AsyncClientEnd2endTest
,
ThreadStress
)
{
common_
.
ResetStub
();
TYPED_TEST_CASE
(
AsyncClientEnd2endTest
,
CommonTypes
);
TYPED_TEST
(
AsyncClientEnd2endTest
,
ThreadStress
)
{
this
->
common_
.
ResetStub
();
std
::
vector
<
std
::
thread
*>
send_threads
,
completion_threads
;
for
(
int
i
=
0
;
i
<
kNumAsyncReceiveThreads
;
++
i
)
{
completion_threads
.
push_back
(
new
std
::
thread
(
&
AsyncClientEnd2endTest_ThreadStress_Test
::
AsyncCompleteRpc
,
this
));
&
AsyncClientEnd2endTest_ThreadStress_Test
<
TypeParam
>::
AsyncCompleteRpc
,
this
));
}
for
(
int
i
=
0
;
i
<
kNumAsyncSendThreads
;
++
i
)
{
send_threads
.
push_back
(
new
std
::
thread
(
&
AsyncClientEnd2endTest_ThreadStress_Test
::
AsyncSendRpc
,
this
,
kNumRpcs
));
send_threads
.
push_back
(
new
std
::
thread
(
&
AsyncClientEnd2endTest_ThreadStress_Test
<
TypeParam
>
::
AsyncSendRpc
,
this
,
kNumRpcs
));
}
for
(
int
i
=
0
;
i
<
kNumAsyncSendThreads
;
++
i
)
{
send_threads
[
i
]
->
join
();
delete
send_threads
[
i
];
}
Wait
();
this
->
Wait
();
for
(
int
i
=
0
;
i
<
kNumAsyncReceiveThreads
;
++
i
)
{
completion_threads
[
i
]
->
join
();
delete
completion_threads
[
i
];
...
...
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