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
a3960b98
Commit
a3960b98
authored
8 years ago
by
Noah Eisen
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #9244 from ncteisen/ruby_advanced_interop_client_side
Ruby Advanced Interop Client Side
parents
428e409a
e81d96da
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb
+7
-0
7 additions, 0 deletions
src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb
src/ruby/pb/test/client.rb
+165
-6
165 additions, 6 deletions
src/ruby/pb/test/client.rb
with
172 additions
and
6 deletions
src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb
+
7
−
0
View file @
a3960b98
...
@@ -54,6 +54,10 @@ module Grpc
...
@@ -54,6 +54,10 @@ module Grpc
rpc
:EmptyCall
,
Empty
,
Empty
rpc
:EmptyCall
,
Empty
,
Empty
# One request followed by one response.
# One request followed by one response.
rpc
:UnaryCall
,
SimpleRequest
,
SimpleResponse
rpc
:UnaryCall
,
SimpleRequest
,
SimpleResponse
# One request followed by one response. Response has cache control
# headers set such that a caching HTTP proxy (such as GFE) can
# satisfy subsequent requests.
rpc
:CacheableUnaryCall
,
SimpleRequest
,
SimpleResponse
# One request followed by a sequence of responses (streamed download).
# One request followed by a sequence of responses (streamed download).
# The server returns the payload with client desired type and sizes.
# The server returns the payload with client desired type and sizes.
rpc
:StreamingOutputCall
,
StreamingOutputCallRequest
,
stream
(
StreamingOutputCallResponse
)
rpc
:StreamingOutputCall
,
StreamingOutputCallRequest
,
stream
(
StreamingOutputCallResponse
)
...
@@ -69,6 +73,9 @@ module Grpc
...
@@ -69,6 +73,9 @@ module Grpc
# stream of responses are returned to the client when the server starts with
# stream of responses are returned to the client when the server starts with
# first request.
# first request.
rpc
:HalfDuplexCall
,
stream
(
StreamingOutputCallRequest
),
stream
(
StreamingOutputCallResponse
)
rpc
:HalfDuplexCall
,
stream
(
StreamingOutputCallRequest
),
stream
(
StreamingOutputCallResponse
)
# The test server will not implement this method. It will be used
# to test the behavior when clients call unimplemented methods.
rpc
:UnimplementedCall
,
Empty
,
Empty
end
end
Stub
=
Service
.
rpc_stub_class
Stub
=
Service
.
rpc_stub_class
...
...
This diff is collapsed.
Click to expand it.
src/ruby/pb/test/client.rb
+
165
−
6
View file @
a3960b98
...
@@ -158,14 +158,26 @@ def create_stub(opts)
...
@@ -158,14 +158,26 @@ def create_stub(opts)
GRPC
.
logger
.
info
(
"... connecting securely to
#{
address
}
"
)
GRPC
.
logger
.
info
(
"... connecting securely to
#{
address
}
"
)
stub_opts
[
:channel_args
].
merge!
(
compression_channel_args
)
stub_opts
[
:channel_args
].
merge!
(
compression_channel_args
)
Grpc
::
Testing
::
TestService
::
Stub
.
new
(
address
,
creds
,
**
stub_opts
)
if
opts
.
test_case
==
"unimplemented_service"
Grpc
::
Testing
::
UnimplementedService
::
Stub
.
new
(
address
,
creds
,
**
stub_opts
)
else
Grpc
::
Testing
::
TestService
::
Stub
.
new
(
address
,
creds
,
**
stub_opts
)
end
else
else
GRPC
.
logger
.
info
(
"... connecting insecurely to
#{
address
}
"
)
GRPC
.
logger
.
info
(
"... connecting insecurely to
#{
address
}
"
)
Grpc
::
Testing
::
TestService
::
Stub
.
new
(
if
opts
.
test_case
==
"unimplemented_service"
address
,
Grpc
::
Testing
::
UnimplementedService
::
Stub
.
new
(
:this_channel_is_insecure
,
address
,
channel_args:
compression_channel_args
:this_channel_is_insecure
,
)
channel_args:
compression_channel_args
)
else
Grpc
::
Testing
::
TestService
::
Stub
.
new
(
address
,
:this_channel_is_insecure
,
channel_args:
compression_channel_args
)
end
end
end
end
end
...
@@ -502,6 +514,153 @@ class NamedTests
...
@@ -502,6 +514,153 @@ class NamedTests
op
.
wait
op
.
wait
end
end
def
unimplemented_method
begin
resp
=
@stub
.
unimplemented_call
(
Empty
.
new
)
rescue
GRPC
::
Unimplemented
=>
e
return
rescue
Exception
=>
e
fail
AssertionError
,
"Expected BadStatus. Received:
#{
e
.
inspect
}
"
end
fail
AssertionError
,
"GRPC::Unimplemented should have been raised. Was not."
end
def
unimplemented_service
begin
resp
=
@stub
.
unimplemented_call
(
Empty
.
new
)
rescue
GRPC
::
Unimplemented
=>
e
return
rescue
Exception
=>
e
fail
AssertionError
,
"Expected BadStatus. Received:
#{
e
.
inspect
}
"
end
fail
AssertionError
,
"GRPC::Unimplemented should have been raised. Was not."
end
def
status_code_and_message
# Function wide constants.
message
=
"test status method"
code
=
GRPC
::
Core
::
StatusCodes
::
UNKNOWN
# Testing with UnaryCall.
payload
=
Payload
.
new
(
type: :COMPRESSABLE
,
body:
nulls
(
1
))
echo_status
=
EchoStatus
.
new
(
code:
code
,
message:
message
)
req
=
SimpleRequest
.
new
(
response_type: :COMPRESSABLE
,
response_size:
1
,
payload:
payload
,
response_status:
echo_status
)
seen_correct_exception
=
false
begin
resp
=
@stub
.
unary_call
(
req
)
rescue
GRPC
::
Unknown
=>
e
if
e
.
details
!=
message
fail
AssertionError
,
"Expected message
#{
message
}
. Received:
#{
e
.
details
}
"
end
seen_correct_exception
=
true
rescue
Exception
=>
e
fail
AssertionError
,
"Expected BadStatus. Received:
#{
e
.
inspect
}
"
end
if
not
seen_correct_exception
fail
AssertionError
,
"Did not see expected status from UnaryCall"
end
# testing with FullDuplex
req_cls
,
p_cls
=
StreamingOutputCallRequest
,
ResponseParameters
duplex_req
=
req_cls
.
new
(
payload:
Payload
.
new
(
body:
nulls
(
1
)),
response_type: :COMPRESSABLE
,
response_parameters:
[
p_cls
.
new
(
size:
1
)],
response_status:
echo_status
)
seen_correct_exception
=
false
begin
resp
=
@stub
.
full_duplex_call
([
duplex_req
])
resp
.
next
# triggers initial req to be sent
rescue
GRPC
::
Unknown
=>
e
if
e
.
details
!=
message
fail
AssertionError
,
"Expected message
#{
message
}
. Received:
#{
e
.
details
}
"
end
seen_correct_exception
=
true
rescue
Exception
=>
e
fail
AssertionError
,
"Expected BadStatus. Received:
#{
e
.
inspect
}
"
end
if
not
seen_correct_exception
fail
AssertionError
,
"Did not see expected status from FullDuplexCall"
end
end
def
custom_metadata
# Function wide constants
req_size
,
wanted_response_size
=
271_828
,
314_159
initial_metadata_key
=
"x-grpc-test-echo-initial"
initial_metadata_value
=
"test_initial_metadata_value"
trailing_metadata_key
=
"x-grpc-test-echo-trailing-bin"
trailing_metadata_value
=
"
\x0a\x0b\x0a\x0b\x0a\x0b
"
metadata
=
{
initial_metadata_key
=>
initial_metadata_value
,
trailing_metadata_key
=>
trailing_metadata_value
}
# Testing with UnaryCall
payload
=
Payload
.
new
(
type: :COMPRESSABLE
,
body:
nulls
(
req_size
))
req
=
SimpleRequest
.
new
(
response_type: :COMPRESSABLE
,
response_size:
wanted_response_size
,
payload:
payload
)
op
=
@stub
.
unary_call
(
req
,
metadata:
metadata
,
return_op:
true
)
op
.
execute
if
not
op
.
metadata
.
has_key?
(
initial_metadata_key
)
fail
AssertionError
,
"Expected initial metadata. None received"
elsif
op
.
metadata
[
initial_metadata_key
]
!=
metadata
[
initial_metadata_key
]
fail
AssertionError
,
"Expected initial metadata:
#{
metadata
[
initial_metadata_key
]
}
. "
\
"Received:
#{
op
.
metadata
[
initial_metadata_key
]
}
"
end
if
not
op
.
trailing_metadata
.
has_key?
(
trailing_metadata_key
)
fail
AssertionError
,
"Expected trailing metadata. None received"
elsif
op
.
trailing_metadata
[
trailing_metadata_key
]
!=
metadata
[
trailing_metadata_key
]
fail
AssertionError
,
"Expected trailing metadata:
#{
metadata
[
trailing_metadata_key
]
}
. "
\
"Received:
#{
op
.
trailing_metadata
[
trailing_metadata_key
]
}
"
end
# Testing with FullDuplex
req_cls
,
p_cls
=
StreamingOutputCallRequest
,
ResponseParameters
duplex_req
=
req_cls
.
new
(
payload:
Payload
.
new
(
body:
nulls
(
req_size
)),
response_type: :COMPRESSABLE
,
response_parameters:
[
p_cls
.
new
(
size:
wanted_response_size
)])
duplex_op
=
@stub
.
full_duplex_call
([
duplex_req
],
metadata:
metadata
,
return_op:
true
)
resp
=
duplex_op
.
execute
resp
.
each
{
|
r
|
}
# ensures that the server sends trailing data
duplex_op
.
wait
if
not
duplex_op
.
metadata
.
has_key?
(
initial_metadata_key
)
fail
AssertionError
,
"Expected initial metadata. None received"
elsif
duplex_op
.
metadata
[
initial_metadata_key
]
!=
metadata
[
initial_metadata_key
]
fail
AssertionError
,
"Expected initial metadata:
#{
metadata
[
initial_metadata_key
]
}
. "
\
"Received:
#{
duplex_op
.
metadata
[
initial_metadata_key
]
}
"
end
if
not
duplex_op
.
trailing_metadata
[
trailing_metadata_key
]
fail
AssertionError
,
"Expected trailing metadata. None received"
elsif
duplex_op
.
trailing_metadata
[
trailing_metadata_key
]
!=
metadata
[
trailing_metadata_key
]
fail
AssertionError
,
"Expected trailing metadata:
#{
metadata
[
trailing_metadata_key
]
}
. "
\
"Received:
#{
duplex_op
.
trailing_metadata
[
trailing_metadata_key
]
}
"
end
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