|
|
|
@ -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, |
|
|
|
|
const char *test_name, |
|
|
|
|
grpc_channel_args *client_args, |
|
|
|
|
grpc_channel_args *server_args) { |
|
|
|
|
grpc_channel_args *server_args, |
|
|
|
|
const char *query_args) { |
|
|
|
|
grpc_end2end_test_fixture f; |
|
|
|
|
gpr_log(GPR_INFO, "%s/%s", test_name, config.name); |
|
|
|
|
// 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, |
|
|
|
|
// proxy, only on the backend server.
|
|
|
|
|
f = config.create_fixture(NULL, NULL); |
|
|
|
|
config.init_server(&f, server_args); |
|
|
|
|
config.init_client(&f, client_args, NULL); |
|
|
|
|
config.init_client(&f, client_args, query_args); |
|
|
|
|
return 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
|
|
|
|
|
// recv limit on server.
|
|
|
|
|
static void test_max_message_length_on_request(grpc_end2end_test_config config, |
|
|
|
|
bool send_limit) { |
|
|
|
|
gpr_log(GPR_INFO, "testing request with send_limit=%d", send_limit); |
|
|
|
|
bool 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_arg channel_arg; |
|
|
|
@ -127,21 +130,35 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, |
|
|
|
|
size_t details_capacity = 0; |
|
|
|
|
int was_cancelled = 2; |
|
|
|
|
|
|
|
|
|
char *query_args = NULL; |
|
|
|
|
grpc_channel_args *client_args = NULL; |
|
|
|
|
grpc_channel_args *server_args = NULL; |
|
|
|
|
if (use_service_config) { |
|
|
|
|
// We don't currently support service configs on the server side.
|
|
|
|
|
GPR_ASSERT(send_limit); |
|
|
|
|
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", |
|
|
|
|
send_limit ? &channel_args : NULL, |
|
|
|
|
send_limit ? NULL : &channel_args); |
|
|
|
|
f = begin_test(config, "test_max_request_message_length", client_args, |
|
|
|
|
server_args, query_args); |
|
|
|
|
cqv = cq_verifier_create(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_ASSERT(c); |
|
|
|
|
|
|
|
|
@ -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_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(was_cancelled == 1); |
|
|
|
|
|
|
|
|
@ -246,8 +263,10 @@ done: |
|
|
|
|
// If send_limit is true, applies send limit on server; otherwise, applies
|
|
|
|
|
// recv limit on client.
|
|
|
|
|
static void test_max_message_length_on_response(grpc_end2end_test_config config, |
|
|
|
|
bool send_limit) { |
|
|
|
|
gpr_log(GPR_INFO, "testing response with send_limit=%d", send_limit); |
|
|
|
|
bool 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_arg channel_arg; |
|
|
|
@ -272,21 +291,35 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, |
|
|
|
|
size_t details_capacity = 0; |
|
|
|
|
int was_cancelled = 2; |
|
|
|
|
|
|
|
|
|
char *query_args = NULL; |
|
|
|
|
grpc_channel_args *client_args = NULL; |
|
|
|
|
grpc_channel_args *server_args = NULL; |
|
|
|
|
if (use_service_config) { |
|
|
|
|
// We don't currently support service configs on the server side.
|
|
|
|
|
GPR_ASSERT(!send_limit); |
|
|
|
|
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", |
|
|
|
|
send_limit ? NULL : &channel_args, |
|
|
|
|
send_limit ? &channel_args : NULL); |
|
|
|
|
f = begin_test(config, "test_max_response_message_length", client_args, |
|
|
|
|
server_args, query_args); |
|
|
|
|
cqv = cq_verifier_create(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_ASSERT(c); |
|
|
|
|
|
|
|
|
@ -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_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(was_cancelled == 0); |
|
|
|
|
|
|
|
|
@ -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) { |
|
|
|
|
test_max_message_length_on_request(config, false /* send_limit */); |
|
|
|
|
test_max_message_length_on_request(config, true /* send_limit */); |
|
|
|
|
test_max_message_length_on_response(config, false /* send_limit */); |
|
|
|
|
test_max_message_length_on_response(config, true /* send_limit */); |
|
|
|
|
test_max_message_length_on_request(config, false /* send_limit */, |
|
|
|
|
false /* use_service_config */); |
|
|
|
|
test_max_message_length_on_request(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) {} |
|
|
|
|