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
f200f25d
Commit
f200f25d
authored
7 years ago
by
apolcyn
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #10564 from apolcyn/deflake_ruby_test
fix flakey race in ruby tests
parents
c3f49455
9b020019
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
src/ruby/spec/generic/rpc_server_pool_spec.rb
+27
-17
27 additions, 17 deletions
src/ruby/spec/generic/rpc_server_pool_spec.rb
with
27 additions
and
17 deletions
src/ruby/spec/generic/rpc_server_pool_spec.rb
+
27
−
17
View file @
f200f25d
...
...
@@ -52,28 +52,31 @@ describe GRPC::Pool do
expect
(
p
.
ready_for_work?
).
to
be
(
false
)
end
it
'it stops being ready after all workers
jobs waiting or running
'
do
it
'it stops being ready after all workers
are busy
'
do
p
=
Pool
.
new
(
5
)
p
.
start
job
=
proc
{
sleep
(
3
)
}
# sleep so workers busy when done scheduling
5
.
times
do
expect
(
p
.
ready_for_work?
).
to
be
(
true
)
p
.
schedule
(
&
job
)
wait_mu
=
Mutex
.
new
wait_cv
=
ConditionVariable
.
new
wait
=
true
job
=
proc
do
wait_mu
.
synchronize
do
wait_cv
.
wait
(
wait_mu
)
while
wait
end
end
expect
(
p
.
ready_for_work?
).
to
be
(
false
)
end
it
'it becomes ready again after jobs complete'
do
p
=
Pool
.
new
(
5
)
p
.
start
job
=
proc
{}
5
.
times
do
expect
(
p
.
ready_for_work?
).
to
be
(
true
)
p
.
schedule
(
&
job
)
end
expect
(
p
.
ready_for_work?
).
to
be
(
false
)
sleep
5
# give the pool time do get at least one task done
expect
(
p
.
ready_for_work?
).
to
be
(
true
)
wait_mu
.
synchronize
do
wait
=
false
wait_cv
.
broadcast
end
end
end
...
...
@@ -105,13 +108,20 @@ describe GRPC::Pool do
it
'stops jobs when there are long running jobs'
do
p
=
Pool
.
new
(
1
)
p
.
start
o
,
q
=
Object
.
new
,
Queue
.
new
wait_forever_mu
=
Mutex
.
new
wait_forever_cv
=
ConditionVariable
.
new
wait_forever
=
true
job_running
=
Queue
.
new
job
=
proc
do
sleep
(
5
)
# long running
q
.
push
(
o
)
job_running
.
push
(
Object
.
new
)
wait_forever_mu
.
synchronize
do
wait_forever_cv
.
wait
while
wait_forever
end
end
p
.
schedule
(
&
job
)
sleep
(
1
)
# should ensure the long job gets scheduled
job_running
.
pop
expect
{
p
.
stop
}.
not_to
raise_error
end
end
...
...
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