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
6df60759
Commit
6df60759
authored
8 years ago
by
Mark D. Roth
Browse files
Options
Downloads
Patches
Plain Diff
Fix portability problems.
parent
fd635add
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/round_robin_end2end_test.cc
+15
-13
15 additions, 13 deletions
test/cpp/end2end/round_robin_end2end_test.cc
with
15 additions
and
13 deletions
test/cpp/end2end/round_robin_end2end_test.cc
+
15
−
13
View file @
6df60759
...
...
@@ -63,6 +63,8 @@ namespace {
// every call to the Echo RPC.
class
MyTestServiceImpl
:
public
TestServiceImpl
{
public:
MyTestServiceImpl
()
:
request_count_
(
0
)
{}
Status
Echo
(
ServerContext
*
context
,
const
EchoRequest
*
request
,
EchoResponse
*
response
)
GRPC_OVERRIDE
{
{
...
...
@@ -79,7 +81,7 @@ class MyTestServiceImpl : public TestServiceImpl {
private
:
mutex
mu_
;
int
request_count_
=
0
;
int
request_count_
;
};
class
RoundRobinEnd2endTest
:
public
::
testing
::
Test
{
...
...
@@ -93,8 +95,8 @@ class RoundRobinEnd2endTest : public ::testing::Test {
}
void
TearDown
()
GRPC_OVERRIDE
{
for
(
const
auto
&
server
:
servers_
)
{
server
->
Shutdown
();
for
(
size_t
i
=
0
;
i
<
servers_
.
size
();
++
i
)
{
server
s_
[
i
]
->
Shutdown
();
}
}
...
...
@@ -135,17 +137,15 @@ class RoundRobinEnd2endTest : public ::testing::Test {
gpr_log
(
GPR_INFO
,
"starting server on port %d"
,
port_
);
std
::
mutex
mu
;
std
::
condition_variable
cond
;
thread_
=
new
std
::
thread
([
this
,
server_host
,
&
mu
,
&
cond
]()
{
Start
(
server_host
);
lock_guard
<
mutex
>
lock
(
mu
);
cond
.
notify_one
();
});
thread_
=
new
std
::
thread
(
std
::
bind
(
&
ServerData
::
Start
,
this
,
server_host
,
&
mu
,
&
cond
));
unique_lock
<
mutex
>
lock
(
mu
);
cond
.
wait
(
lock
);
gpr_log
(
GPR_INFO
,
"server startup complete"
);
}
void
Start
(
const
grpc
::
string
&
server_host
)
{
void
Start
(
const
grpc
::
string
&
server_host
,
std
::
mutex
*
mu
,
std
::
condition_variable
*
cond
)
{
std
::
ostringstream
server_address
;
server_address
<<
server_host
<<
":"
<<
port_
;
ServerBuilder
builder
;
...
...
@@ -153,6 +153,8 @@ class RoundRobinEnd2endTest : public ::testing::Test {
InsecureServerCredentials
());
builder
.
RegisterService
(
&
service_
);
server_
=
builder
.
BuildAndStart
();
lock_guard
<
mutex
>
lock
(
*
mu
);
cond
->
notify_one
();
}
void
Shutdown
()
{
...
...
@@ -175,8 +177,8 @@ TEST_F(RoundRobinEnd2endTest, PickFirst) {
SendRpc
(
kNumServers
);
// All requests should have gone to a single server.
bool
found
=
false
;
for
(
const
auto
&
server
:
servers_
)
{
const
int
request_count
=
server
->
service_
.
request_count
();
for
(
size_t
i
=
0
;
i
<
servers_
.
size
();
++
i
)
{
const
int
request_count
=
server
s_
[
i
]
->
service_
.
request_count
();
if
(
request_count
==
kNumServers
)
{
found
=
true
;
}
else
{
...
...
@@ -193,8 +195,8 @@ TEST_F(RoundRobinEnd2endTest, RoundRobin) {
ResetStub
(
true
/* round_robin */
);
SendRpc
(
kNumServers
);
// One request should have gone to each server.
for
(
const
auto
&
server
:
servers_
)
{
EXPECT_EQ
(
1
,
server
->
service_
.
request_count
());
for
(
size_t
i
=
0
;
i
<
servers_
.
size
();
++
i
)
{
EXPECT_EQ
(
1
,
server
s_
[
i
]
->
service_
.
request_count
());
}
}
...
...
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