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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
02ce8605
Commit
02ce8605
authored
Feb 27, 2018
by
Alexander Polcyn
Committed by
Alex Polcyn
Feb 28, 2018
Browse files
Options
Downloads
Patches
Plain Diff
Add a flag to the resolver_component_test that permits extra addresses
parent
a90d718c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cpp/naming/resolver_component_test.cc
+23
-9
23 additions, 9 deletions
test/cpp/naming/resolver_component_test.cc
with
23 additions
and
9 deletions
test/cpp/naming/resolver_component_test.cc
+
23
−
9
View file @
02ce8605
...
@@ -65,6 +65,11 @@ DEFINE_string(expected_addrs, "",
...
@@ -65,6 +65,11 @@ DEFINE_string(expected_addrs, "",
"List of expected backend or balancer addresses in the form "
"List of expected backend or balancer addresses in the form "
"'<ip0:port0>,<is_balancer0>;<ip1:port1>,<is_balancer1>;...'. "
"'<ip0:port0>,<is_balancer0>;<ip1:port1>,<is_balancer1>;...'. "
"'is_balancer' should be bool, i.e. true or false."
);
"'is_balancer' should be bool, i.e. true or false."
);
DEFINE_bool
(
allow_extra_addrs
,
false
,
"Permit extra resolved addresses in the final list of "
"resolved addresses. This is useful in certain integration "
"test environments in which DNS responses are not fully "
"deterministic."
);
DEFINE_string
(
expected_chosen_service_config
,
""
,
DEFINE_string
(
expected_chosen_service_config
,
""
,
"Expected service config json string that gets chosen (no "
"Expected service config json string that gets chosen (no "
"whitespace). Empty for none."
);
"whitespace). Empty for none."
);
...
@@ -240,9 +245,11 @@ void CheckResolverResultLocked(void* argsp, grpc_error* err) {
...
@@ -240,9 +245,11 @@ void CheckResolverResultLocked(void* argsp, grpc_error* err) {
GPR_ASSERT
(
channel_arg
->
type
==
GRPC_ARG_POINTER
);
GPR_ASSERT
(
channel_arg
->
type
==
GRPC_ARG_POINTER
);
grpc_lb_addresses
*
addresses
=
grpc_lb_addresses
*
addresses
=
(
grpc_lb_addresses
*
)
channel_arg
->
value
.
pointer
.
p
;
(
grpc_lb_addresses
*
)
channel_arg
->
value
.
pointer
.
p
;
gpr_log
(
GPR_INFO
,
"num addrs found: %"
PRIdPTR
". expected %"
PRIdPTR
,
gpr_log
(
GPR_INFO
,
addresses
->
num_addresses
,
args
->
expected_addrs
.
size
());
"num addrs found: %"
PRIdPTR
". expected %"
PRIdPTR
GPR_ASSERT
(
addresses
->
num_addresses
==
args
->
expected_addrs
.
size
());
". Allow extra addresses:%d."
,
addresses
->
num_addresses
,
args
->
expected_addrs
.
size
(),
FLAGS_allow_extra_addrs
);
std
::
vector
<
GrpcLBAddress
>
found_lb_addrs
;
std
::
vector
<
GrpcLBAddress
>
found_lb_addrs
;
for
(
size_t
i
=
0
;
i
<
addresses
->
num_addresses
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
addresses
->
num_addresses
;
i
++
)
{
grpc_lb_address
addr
=
addresses
->
addresses
[
i
];
grpc_lb_address
addr
=
addresses
->
addresses
[
i
];
...
@@ -254,13 +261,20 @@ void CheckResolverResultLocked(void* argsp, grpc_error* err) {
...
@@ -254,13 +261,20 @@ void CheckResolverResultLocked(void* argsp, grpc_error* err) {
gpr_free
(
str
);
gpr_free
(
str
);
}
}
if
(
args
->
expected_addrs
.
size
()
!=
found_lb_addrs
.
size
())
{
if
(
args
->
expected_addrs
.
size
()
!=
found_lb_addrs
.
size
())
{
// Permit extra resolved addresses if "--allow_extra_addrs" was set.
if
(
!
(
FLAGS_allow_extra_addrs
&&
found_lb_addrs
.
size
()
>
args
->
expected_addrs
.
size
()))
{
gpr_log
(
GPR_DEBUG
,
gpr_log
(
GPR_DEBUG
,
"found lb addrs size is: %"
PRIdPTR
"found lb addrs size is: %"
PRIdPTR
". expected addrs size is %"
PRIdPTR
,
". expected addrs size is %"
PRIdPTR
". --allow_extra_addrs=%d."
,
found_lb_addrs
.
size
(),
args
->
expected_addrs
.
size
());
found_lb_addrs
.
size
(),
args
->
expected_addrs
.
size
(),
FLAGS_allow_extra_addrs
);
abort
();
abort
();
}
}
EXPECT_THAT
(
args
->
expected_addrs
,
UnorderedElementsAreArray
(
found_lb_addrs
));
}
for
(
size_t
i
=
0
;
i
<
args
->
expected_addrs
.
size
();
i
++
)
{
EXPECT_THAT
(
found_lb_addrs
,
::
testing
::
Contains
(
args
->
expected_addrs
[
i
]));
}
CheckServiceConfigResultLocked
(
channel_args
,
args
);
CheckServiceConfigResultLocked
(
channel_args
,
args
);
if
(
args
->
expected_service_config_string
==
""
)
{
if
(
args
->
expected_service_config_string
==
""
)
{
CheckLBPolicyResultLocked
(
channel_args
,
args
);
CheckLBPolicyResultLocked
(
channel_args
,
args
);
...
...
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
sign in
to comment