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
81ae740e
Commit
81ae740e
authored
8 years ago
by
Mark D. Roth
Browse files
Options
Downloads
Patches
Plain Diff
Test setting wait_for_ready via service config.
parent
fc275138
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/core/end2end/connection_refused_test.c
+24
-7
24 additions, 7 deletions
test/core/end2end/connection_refused_test.c
with
24 additions
and
7 deletions
test/core/end2end/connection_refused_test.c
+
24
−
7
View file @
81ae740e
...
@@ -37,14 +37,16 @@
...
@@ -37,14 +37,16 @@
#include
<grpc/support/alloc.h>
#include
<grpc/support/alloc.h>
#include
<grpc/support/host_port.h>
#include
<grpc/support/host_port.h>
#include
<grpc/support/log.h>
#include
<grpc/support/log.h>
#include
<grpc/support/string_util.h>
#include
"test/core/end2end/cq_verifier.h"
#include
"test/core/end2end/cq_verifier.h"
#include
"test/core/end2end/fake_resolver.h"
#include
"test/core/util/port.h"
#include
"test/core/util/port.h"
#include
"test/core/util/test_config.h"
#include
"test/core/util/test_config.h"
static
void
*
tag
(
intptr_t
i
)
{
return
(
void
*
)
i
;
}
static
void
*
tag
(
intptr_t
i
)
{
return
(
void
*
)
i
;
}
static
void
run_test
(
bool
wait_for_ready
)
{
static
void
run_test
(
bool
wait_for_ready
,
bool
use_service_config
)
{
grpc_channel
*
chan
;
grpc_channel
*
chan
;
grpc_call
*
call
;
grpc_call
*
call
;
gpr_timespec
deadline
=
GRPC_TIMEOUT_SECONDS_TO_DEADLINE
(
2
);
gpr_timespec
deadline
=
GRPC_TIMEOUT_SECONDS_TO_DEADLINE
(
2
);
...
@@ -57,8 +59,10 @@ static void run_test(bool wait_for_ready) {
...
@@ -57,8 +59,10 @@ static void run_test(bool wait_for_ready) {
char
*
details
=
NULL
;
char
*
details
=
NULL
;
size_t
details_capacity
=
0
;
size_t
details_capacity
=
0
;
gpr_log
(
GPR_INFO
,
"TEST: wait_for_ready=%d"
,
wait_for_ready
);
gpr_log
(
GPR_INFO
,
"TEST: wait_for_ready=%d use_service_config=%d"
,
wait_for_ready
,
use_service_config
);
grpc_fake_resolver_init
();
grpc_init
();
grpc_init
();
grpc_metadata_array_init
(
&
trailing_metadata_recv
);
grpc_metadata_array_init
(
&
trailing_metadata_recv
);
...
@@ -69,11 +73,21 @@ static void run_test(bool wait_for_ready) {
...
@@ -69,11 +73,21 @@ static void run_test(bool wait_for_ready) {
/* create a call, channel to a port which will refuse connection */
/* create a call, channel to a port which will refuse connection */
int
port
=
grpc_pick_unused_port_or_die
();
int
port
=
grpc_pick_unused_port_or_die
();
char
*
addr
;
char
*
addr
;
gpr_join_host_port
(
&
addr
,
"localhost"
,
port
);
gpr_join_host_port
(
&
addr
,
"127.0.0.1"
,
port
);
if
(
use_service_config
)
{
GPR_ASSERT
(
wait_for_ready
);
char
*
server_uri
;
gpr_asprintf
(
&
server_uri
,
"test:%s?method_name=/service/method&wait_for_ready=1"
,
addr
);
gpr_free
(
addr
);
addr
=
server_uri
;
}
gpr_log
(
GPR_INFO
,
"server: %s"
,
addr
);
chan
=
grpc_insecure_channel_create
(
addr
,
NULL
,
NULL
);
chan
=
grpc_insecure_channel_create
(
addr
,
NULL
,
NULL
);
call
=
grpc_channel_create_call
(
chan
,
NULL
,
GRPC_PROPAGATE_DEFAULTS
,
cq
,
call
=
grpc_channel_create_call
(
chan
,
NULL
,
GRPC_PROPAGATE_DEFAULTS
,
cq
,
"/Foo"
,
"nonexistant"
,
deadline
,
NULL
);
"/service/method"
,
"nonexistant"
,
deadline
,
NULL
);
gpr_free
(
addr
);
gpr_free
(
addr
);
...
@@ -81,7 +95,9 @@ static void run_test(bool wait_for_ready) {
...
@@ -81,7 +95,9 @@ static void run_test(bool wait_for_ready) {
op
=
ops
;
op
=
ops
;
op
->
op
=
GRPC_OP_SEND_INITIAL_METADATA
;
op
->
op
=
GRPC_OP_SEND_INITIAL_METADATA
;
op
->
data
.
send_initial_metadata
.
count
=
0
;
op
->
data
.
send_initial_metadata
.
count
=
0
;
op
->
flags
=
wait_for_ready
?
GRPC_INITIAL_METADATA_WAIT_FOR_READY
:
0
;
op
->
flags
=
(
wait_for_ready
&&
!
use_service_config
)
?
GRPC_INITIAL_METADATA_WAIT_FOR_READY
:
0
;
op
->
reserved
=
NULL
;
op
->
reserved
=
NULL
;
op
++
;
op
++
;
op
->
op
=
GRPC_OP_RECV_STATUS_ON_CLIENT
;
op
->
op
=
GRPC_OP_RECV_STATUS_ON_CLIENT
;
...
@@ -122,7 +138,8 @@ static void run_test(bool wait_for_ready) {
...
@@ -122,7 +138,8 @@ static void run_test(bool wait_for_ready) {
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
grpc_test_init
(
argc
,
argv
);
grpc_test_init
(
argc
,
argv
);
run_test
(
false
);
run_test
(
false
/* wait_for_ready */
,
false
/* use_service_config */
);
run_test
(
true
);
run_test
(
true
/* wait_for_ready */
,
false
/* use_service_config */
);
run_test
(
true
/* wait_for_ready */
,
true
/* use_service_config */
);
return
0
;
return
0
;
}
}
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