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
da091f7f
Commit
da091f7f
authored
8 years ago
by
Mark D. Roth
Browse files
Options
Downloads
Patches
Plain Diff
Test setting max message size limits via service config.
parent
928a5941
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/tests/max_message_length.c
+77
-34
77 additions, 34 deletions
test/core/end2end/tests/max_message_length.c
with
77 additions
and
34 deletions
test/core/end2end/tests/max_message_length.c
+
77
−
34
View file @
da091f7f
...
@@ -48,7 +48,8 @@ static void *tag(intptr_t t) { return (void *)t; }
...
@@ -48,7 +48,8 @@ static void *tag(intptr_t t) { return (void *)t; }
static
grpc_end2end_test_fixture
begin_test
(
grpc_end2end_test_config
config
,
static
grpc_end2end_test_fixture
begin_test
(
grpc_end2end_test_config
config
,
const
char
*
test_name
,
const
char
*
test_name
,
grpc_channel_args
*
client_args
,
grpc_channel_args
*
client_args
,
grpc_channel_args
*
server_args
)
{
grpc_channel_args
*
server_args
,
const
char
*
query_args
)
{
grpc_end2end_test_fixture
f
;
grpc_end2end_test_fixture
f
;
gpr_log
(
GPR_INFO
,
"%s/%s"
,
test_name
,
config
.
name
);
gpr_log
(
GPR_INFO
,
"%s/%s"
,
test_name
,
config
.
name
);
// We intentionally do not pass the client and server args to
// We intentionally do not pass the client and server args to
...
@@ -56,7 +57,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
...
@@ -56,7 +57,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
// proxy, only on the backend server.
// proxy, only on the backend server.
f
=
config
.
create_fixture
(
NULL
,
NULL
);
f
=
config
.
create_fixture
(
NULL
,
NULL
);
config
.
init_server
(
&
f
,
server_args
);
config
.
init_server
(
&
f
,
server_args
);
config
.
init_client
(
&
f
,
client_args
,
NULL
);
config
.
init_client
(
&
f
,
client_args
,
query_args
);
return
f
;
return
f
;
}
}
...
@@ -102,8 +103,10 @@ static void end_test(grpc_end2end_test_fixture *f) {
...
@@ -102,8 +103,10 @@ static void end_test(grpc_end2end_test_fixture *f) {
// If send_limit is true, applies send limit on client; otherwise, applies
// If send_limit is true, applies send limit on client; otherwise, applies
// recv limit on server.
// recv limit on server.
static
void
test_max_message_length_on_request
(
grpc_end2end_test_config
config
,
static
void
test_max_message_length_on_request
(
grpc_end2end_test_config
config
,
bool
send_limit
)
{
bool
send_limit
,
gpr_log
(
GPR_INFO
,
"testing request with send_limit=%d"
,
send_limit
);
bool
use_service_config
)
{
gpr_log
(
GPR_INFO
,
"testing request with send_limit=%d use_service_config=%d"
,
send_limit
,
use_service_config
);
grpc_end2end_test_fixture
f
;
grpc_end2end_test_fixture
f
;
grpc_arg
channel_arg
;
grpc_arg
channel_arg
;
...
@@ -127,21 +130,35 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
...
@@ -127,21 +130,35 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
size_t
details_capacity
=
0
;
size_t
details_capacity
=
0
;
int
was_cancelled
=
2
;
int
was_cancelled
=
2
;
channel_arg
.
key
=
send_limit
?
GRPC_ARG_MAX_SEND_MESSAGE_LENGTH
char
*
query_args
=
NULL
;
:
GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH
;
grpc_channel_args
*
client_args
=
NULL
;
channel_arg
.
type
=
GRPC_ARG_INTEGER
;
grpc_channel_args
*
server_args
=
NULL
;
channel_arg
.
value
.
integer
=
5
;
if
(
use_service_config
)
{
// We don't currently support service configs on the server side.
channel_args
.
num_args
=
1
;
GPR_ASSERT
(
send_limit
);
channel_args
.
args
=
&
channel_arg
;
query_args
=
"method_name=/service/method"
"&max_request_message_bytes=5"
;
}
else
{
// Set limit via channel args.
channel_arg
.
key
=
send_limit
?
GRPC_ARG_MAX_SEND_MESSAGE_LENGTH
:
GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH
;
channel_arg
.
type
=
GRPC_ARG_INTEGER
;
channel_arg
.
value
.
integer
=
5
;
channel_args
.
num_args
=
1
;
channel_args
.
args
=
&
channel_arg
;
if
(
send_limit
)
{
client_args
=
&
channel_args
;
}
else
{
server_args
=
&
channel_args
;
}
}
f
=
begin_test
(
config
,
"test_max_message_length"
,
f
=
begin_test
(
config
,
"test_max_request_message_length"
,
client_args
,
send_limit
?
&
channel_args
:
NULL
,
server_args
,
query_args
);
send_limit
?
NULL
:
&
channel_args
);
cqv
=
cq_verifier_create
(
f
.
cq
);
cqv
=
cq_verifier_create
(
f
.
cq
);
c
=
grpc_channel_create_call
(
f
.
client
,
NULL
,
GRPC_PROPAGATE_DEFAULTS
,
f
.
cq
,
c
=
grpc_channel_create_call
(
f
.
client
,
NULL
,
GRPC_PROPAGATE_DEFAULTS
,
f
.
cq
,
"/
foo
"
,
"foo.test.google.fr:1234"
,
"/
service/method
"
,
"foo.test.google.fr:1234"
,
gpr_inf_future
(
GPR_CLOCK_REALTIME
),
NULL
);
gpr_inf_future
(
GPR_CLOCK_REALTIME
),
NULL
);
GPR_ASSERT
(
c
);
GPR_ASSERT
(
c
);
...
@@ -214,7 +231,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
...
@@ -214,7 +231,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
CQ_EXPECT_COMPLETION
(
cqv
,
tag
(
1
),
1
);
CQ_EXPECT_COMPLETION
(
cqv
,
tag
(
1
),
1
);
cq_verify
(
cqv
);
cq_verify
(
cqv
);
GPR_ASSERT
(
0
==
strcmp
(
call_details
.
method
,
"/
foo
"
));
GPR_ASSERT
(
0
==
strcmp
(
call_details
.
method
,
"/
service/method
"
));
GPR_ASSERT
(
0
==
strcmp
(
call_details
.
host
,
"foo.test.google.fr:1234"
));
GPR_ASSERT
(
0
==
strcmp
(
call_details
.
host
,
"foo.test.google.fr:1234"
));
GPR_ASSERT
(
was_cancelled
==
1
);
GPR_ASSERT
(
was_cancelled
==
1
);
...
@@ -246,8 +263,10 @@ done:
...
@@ -246,8 +263,10 @@ done:
// If send_limit is true, applies send limit on server; otherwise, applies
// If send_limit is true, applies send limit on server; otherwise, applies
// recv limit on client.
// recv limit on client.
static
void
test_max_message_length_on_response
(
grpc_end2end_test_config
config
,
static
void
test_max_message_length_on_response
(
grpc_end2end_test_config
config
,
bool
send_limit
)
{
bool
send_limit
,
gpr_log
(
GPR_INFO
,
"testing response with send_limit=%d"
,
send_limit
);
bool
use_service_config
)
{
gpr_log
(
GPR_INFO
,
"testing response with send_limit=%d use_service_config=%d"
,
send_limit
,
use_service_config
);
grpc_end2end_test_fixture
f
;
grpc_end2end_test_fixture
f
;
grpc_arg
channel_arg
;
grpc_arg
channel_arg
;
...
@@ -272,21 +291,35 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
...
@@ -272,21 +291,35 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
size_t
details_capacity
=
0
;
size_t
details_capacity
=
0
;
int
was_cancelled
=
2
;
int
was_cancelled
=
2
;
channel_arg
.
key
=
send_limit
?
GRPC_ARG_MAX_SEND_MESSAGE_LENGTH
char
*
query_args
=
NULL
;
:
GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH
;
grpc_channel_args
*
client_args
=
NULL
;
channel_arg
.
type
=
GRPC_ARG_INTEGER
;
grpc_channel_args
*
server_args
=
NULL
;
channel_arg
.
value
.
integer
=
5
;
if
(
use_service_config
)
{
// We don't currently support service configs on the server side.
channel_args
.
num_args
=
1
;
GPR_ASSERT
(
!
send_limit
);
channel_args
.
args
=
&
channel_arg
;
query_args
=
"method_name=/service/method"
"&max_response_message_bytes=5"
;
}
else
{
// Set limit via channel args.
channel_arg
.
key
=
send_limit
?
GRPC_ARG_MAX_SEND_MESSAGE_LENGTH
:
GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH
;
channel_arg
.
type
=
GRPC_ARG_INTEGER
;
channel_arg
.
value
.
integer
=
5
;
channel_args
.
num_args
=
1
;
channel_args
.
args
=
&
channel_arg
;
if
(
send_limit
)
{
server_args
=
&
channel_args
;
}
else
{
client_args
=
&
channel_args
;
}
}
f
=
begin_test
(
config
,
"test_max_message_length"
,
f
=
begin_test
(
config
,
"test_max_response_message_length"
,
client_args
,
send_limit
?
NULL
:
&
channel_args
,
server_args
,
query_args
);
send_limit
?
&
channel_args
:
NULL
);
cqv
=
cq_verifier_create
(
f
.
cq
);
cqv
=
cq_verifier_create
(
f
.
cq
);
c
=
grpc_channel_create_call
(
f
.
client
,
NULL
,
GRPC_PROPAGATE_DEFAULTS
,
f
.
cq
,
c
=
grpc_channel_create_call
(
f
.
client
,
NULL
,
GRPC_PROPAGATE_DEFAULTS
,
f
.
cq
,
"/
foo
"
,
"foo.test.google.fr:1234"
,
"/
service/method
"
,
"foo.test.google.fr:1234"
,
gpr_inf_future
(
GPR_CLOCK_REALTIME
),
NULL
);
gpr_inf_future
(
GPR_CLOCK_REALTIME
),
NULL
);
GPR_ASSERT
(
c
);
GPR_ASSERT
(
c
);
...
@@ -365,7 +398,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
...
@@ -365,7 +398,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
CQ_EXPECT_COMPLETION
(
cqv
,
tag
(
1
),
1
);
CQ_EXPECT_COMPLETION
(
cqv
,
tag
(
1
),
1
);
cq_verify
(
cqv
);
cq_verify
(
cqv
);
GPR_ASSERT
(
0
==
strcmp
(
call_details
.
method
,
"/
foo
"
));
GPR_ASSERT
(
0
==
strcmp
(
call_details
.
method
,
"/
service/method
"
));
GPR_ASSERT
(
0
==
strcmp
(
call_details
.
host
,
"foo.test.google.fr:1234"
));
GPR_ASSERT
(
0
==
strcmp
(
call_details
.
host
,
"foo.test.google.fr:1234"
));
GPR_ASSERT
(
was_cancelled
==
0
);
GPR_ASSERT
(
was_cancelled
==
0
);
...
@@ -393,10 +426,20 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
...
@@ -393,10 +426,20 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
}
}
void
max_message_length
(
grpc_end2end_test_config
config
)
{
void
max_message_length
(
grpc_end2end_test_config
config
)
{
test_max_message_length_on_request
(
config
,
false
/* send_limit */
);
test_max_message_length_on_request
(
config
,
false
/* send_limit */
,
test_max_message_length_on_request
(
config
,
true
/* send_limit */
);
false
/* use_service_config */
);
test_max_message_length_on_response
(
config
,
false
/* send_limit */
);
test_max_message_length_on_request
(
config
,
true
/* send_limit */
,
test_max_message_length_on_response
(
config
,
true
/* send_limit */
);
false
/* use_service_config */
);
test_max_message_length_on_response
(
config
,
false
/* send_limit */
,
false
/* use_service_config */
);
test_max_message_length_on_response
(
config
,
true
/* send_limit */
,
false
/* use_service_config */
);
if
(
config
.
feature_mask
&
FEATURE_MASK_SUPPORTS_QUERY_ARGS
)
{
test_max_message_length_on_request
(
config
,
true
/* send_limit */
,
true
/* use_service_config */
);
test_max_message_length_on_response
(
config
,
false
/* send_limit */
,
true
/* use_service_config */
);
}
}
}
void
max_message_length_pre_init
(
void
)
{}
void
max_message_length_pre_init
(
void
)
{}
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