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
c8667056
Commit
c8667056
authored
9 years ago
by
Craig Tiller
Browse files
Options
Downloads
Plain Diff
Merge pull request #1367 from yang-g/interop
Add two scenarios in interop test
parents
6eda2d7c
68d61573
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/cpp/interop/client.cc
+9
-0
9 additions, 0 deletions
test/cpp/interop/client.cc
test/cpp/interop/interop_client.cc
+44
-0
44 additions, 0 deletions
test/cpp/interop/interop_client.cc
test/cpp/interop/interop_client.h
+2
-0
2 additions, 0 deletions
test/cpp/interop/interop_client.h
with
55 additions
and
0 deletions
test/cpp/interop/client.cc
+
9
−
0
View file @
c8667056
...
...
@@ -62,6 +62,8 @@ DEFINE_string(test_case, "large_unary",
" streaming with slow client consumer; "
"half_duplex : half-duplex streaming; "
"ping_pong : full-duplex streaming; "
"cancel_after_begin : cancel stream after starting it; "
"cancel_after_first_response: cancel on first response; "
"service_account_creds : large_unary with service_account auth; "
"compute_engine_creds: large_unary with compute engine auth; "
"jwt_token_creds: large_unary with JWT token auth; "
...
...
@@ -95,6 +97,10 @@ int main(int argc, char** argv) {
client
.
DoHalfDuplex
();
}
else
if
(
FLAGS_test_case
==
"ping_pong"
)
{
client
.
DoPingPong
();
}
else
if
(
FLAGS_test_case
==
"cancel_after_begin"
)
{
client
.
DoCancelAfterBegin
();
}
else
if
(
FLAGS_test_case
==
"cancel_after_first_response"
)
{
client
.
DoCancelAfterFirstResponse
();
}
else
if
(
FLAGS_test_case
==
"service_account_creds"
)
{
grpc
::
string
json_key
=
GetServiceAccountJsonKey
();
client
.
DoServiceAccountCreds
(
json_key
,
FLAGS_oauth_scope
);
...
...
@@ -111,6 +117,8 @@ int main(int argc, char** argv) {
client
.
DoResponseStreaming
();
client
.
DoHalfDuplex
();
client
.
DoPingPong
();
client
.
DoCancelAfterBegin
();
client
.
DoCancelAfterFirstResponse
();
// service_account_creds and jwt_token_creds can only run with ssl.
if
(
FLAGS_enable_ssl
)
{
grpc
::
string
json_key
=
GetServiceAccountJsonKey
();
...
...
@@ -123,6 +131,7 @@ int main(int argc, char** argv) {
GPR_ERROR
,
"Unsupported test case %s. Valid options are all|empty_unary|"
"large_unary|client_streaming|server_streaming|half_duplex|ping_pong|"
"cancel_after_begin|cancel_after_first_response|"
"service_account_creds|compute_engine_creds|jwt_token_creds"
,
FLAGS_test_case
.
c_str
());
ret
=
1
;
...
...
This diff is collapsed.
Click to expand it.
test/cpp/interop/interop_client.cc
+
44
−
0
View file @
c8667056
...
...
@@ -307,5 +307,49 @@ void InteropClient::DoPingPong() {
gpr_log
(
GPR_INFO
,
"Ping pong streaming done."
);
}
void
InteropClient
::
DoCancelAfterBegin
()
{
gpr_log
(
GPR_INFO
,
"Sending request steaming rpc ..."
);
std
::
unique_ptr
<
TestService
::
Stub
>
stub
(
TestService
::
NewStub
(
channel_
));
ClientContext
context
;
StreamingInputCallRequest
request
;
StreamingInputCallResponse
response
;
std
::
unique_ptr
<
ClientWriter
<
StreamingInputCallRequest
>>
stream
(
stub
->
StreamingInputCall
(
&
context
,
&
response
));
gpr_log
(
GPR_INFO
,
"Trying to cancel..."
);
context
.
TryCancel
();
Status
s
=
stream
->
Finish
();
GPR_ASSERT
(
s
.
code
()
==
StatusCode
::
CANCELLED
);
gpr_log
(
GPR_INFO
,
"Canceling streaming done."
);
}
void
InteropClient
::
DoCancelAfterFirstResponse
()
{
gpr_log
(
GPR_INFO
,
"Sending Ping Pong streaming rpc ..."
);
std
::
unique_ptr
<
TestService
::
Stub
>
stub
(
TestService
::
NewStub
(
channel_
));
ClientContext
context
;
std
::
unique_ptr
<
ClientReaderWriter
<
StreamingOutputCallRequest
,
StreamingOutputCallResponse
>>
stream
(
stub
->
FullDuplexCall
(
&
context
));
StreamingOutputCallRequest
request
;
request
.
set_response_type
(
PayloadType
::
COMPRESSABLE
);
ResponseParameters
*
response_parameter
=
request
.
add_response_parameters
();
response_parameter
->
set_size
(
31415
);
request
.
mutable_payload
()
->
set_body
(
grpc
::
string
(
27182
,
'\0'
));
StreamingOutputCallResponse
response
;
GPR_ASSERT
(
stream
->
Write
(
request
));
GPR_ASSERT
(
stream
->
Read
(
&
response
));
GPR_ASSERT
(
response
.
payload
().
has_body
());
GPR_ASSERT
(
response
.
payload
().
body
()
==
grpc
::
string
(
31415
,
'\0'
));
gpr_log
(
GPR_INFO
,
"Trying to cancel..."
);
context
.
TryCancel
();
Status
s
=
stream
->
Finish
();
gpr_log
(
GPR_INFO
,
"Canceling pingpong streaming done."
);
}
}
// namespace testing
}
// namespace grpc
This diff is collapsed.
Click to expand it.
test/cpp/interop/interop_client.h
+
2
−
0
View file @
c8667056
...
...
@@ -57,6 +57,8 @@ class InteropClient {
void
DoRequestStreaming
();
void
DoResponseStreaming
();
void
DoResponseStreamingWithSlowConsumer
();
void
DoCancelAfterBegin
();
void
DoCancelAfterFirstResponse
();
// Auth tests.
// username is a string containing the user email
void
DoJwtTokenCreds
(
const
grpc
::
string
&
username
);
...
...
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