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
b5bcca44
Commit
b5bcca44
authored
9 years ago
by
Tim Emiola
Browse files
Options
Downloads
Patches
Plain Diff
Adds interop cancellation tests
parent
a10a8432
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/bin/interop/interop_client.rb
+29
-3
29 additions, 3 deletions
src/ruby/bin/interop/interop_client.rb
with
29 additions
and
3 deletions
src/ruby/bin/interop/interop_client.rb
+
29
−
3
View file @
b5bcca44
...
@@ -136,12 +136,14 @@ class PingPongPlayer
...
@@ -136,12 +136,14 @@ class PingPongPlayer
include
Grpc
::
Testing
::
PayloadType
include
Grpc
::
Testing
::
PayloadType
attr_accessor
:assertions
# required by Minitest::Assertions
attr_accessor
:assertions
# required by Minitest::Assertions
attr_accessor
:queue
attr_accessor
:queue
attr_accessor
:canceller_op
# reqs is the enumerator over the requests
# reqs is the enumerator over the requests
def
initialize
(
msg_sizes
)
def
initialize
(
msg_sizes
)
@queue
=
Queue
.
new
@queue
=
Queue
.
new
@msg_sizes
=
msg_sizes
@msg_sizes
=
msg_sizes
@assertions
=
0
# required by Minitest::Assertions
@assertions
=
0
# required by Minitest::Assertions
@canceller_op
=
nil
# used to cancel after the first response
end
end
def
each_item
def
each_item
...
@@ -155,12 +157,15 @@ class PingPongPlayer
...
@@ -155,12 +157,15 @@ class PingPongPlayer
response_parameters:
[
p_cls
.
new
(
size:
resp_size
)])
response_parameters:
[
p_cls
.
new
(
size:
resp_size
)])
yield
req
yield
req
resp
=
@queue
.
pop
resp
=
@queue
.
pop
assert_equal
(
:COMPRESSABLE
,
resp
.
payload
.
type
,
assert_equal
(
:COMPRESSABLE
,
resp
.
payload
.
type
,
'payload type is wrong'
)
'payload type is wrong'
)
assert_equal
(
resp_size
,
resp
.
payload
.
body
.
length
,
assert_equal
(
resp_size
,
resp
.
payload
.
body
.
length
,
'
payload body #{
i
} has the wrong length
'
)
"
payload body
#{
count
}
has the wrong length
"
)
p
"OK: ping_pong
#{
count
}
"
p
"OK: ping_pong
#{
count
}
"
count
+=
1
count
+=
1
unless
@canceller_op
.
nil?
canceller_op
.
cancel
break
end
end
end
end
end
end
end
...
@@ -260,6 +265,27 @@ class NamedTests
...
@@ -260,6 +265,27 @@ class NamedTests
p
'OK: ping_pong'
p
'OK: ping_pong'
end
end
def
cancel_after_begin
msg_sizes
=
[
27_182
,
8
,
1828
,
45_904
]
reqs
=
msg_sizes
.
map
do
|
x
|
req
=
Payload
.
new
(
body:
nulls
(
x
))
StreamingInputCallRequest
.
new
(
payload:
req
)
end
op
=
@stub
.
streaming_input_call
(
reqs
,
return_op:
true
)
op
.
cancel
assert_raises
(
GRPC
::
Cancelled
)
{
op
.
execute
}
p
'OK: cancel_after_begin'
end
def
cancel_after_first
msg_sizes
=
[[
27_182
,
31_415
],
[
8
,
9
],
[
1828
,
2653
],
[
45_904
,
58_979
]]
ppp
=
PingPongPlayer
.
new
(
msg_sizes
)
op
=
@stub
.
full_duplex_call
(
ppp
.
each_item
,
return_op:
true
)
ppp
.
canceller_op
=
op
# causes ppp to cancel after the 1st message
assert_raises
(
GRPC
::
Cancelled
)
{
op
.
execute
.
each
{
|
r
|
ppp
.
queue
.
push
(
r
)
}
}
p
'OK: cancel_after_first'
end
def
all
def
all
all_methods
=
NamedTests
.
instance_methods
(
false
).
map
(
&
:to_s
)
all_methods
=
NamedTests
.
instance_methods
(
false
).
map
(
&
:to_s
)
all_methods
.
each
do
|
m
|
all_methods
.
each
do
|
m
|
...
...
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