|
|
|
@ -98,7 +98,8 @@ static void end_test(grpc_end2end_test_fixture *f) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Request with a large amount of metadata.*/ |
|
|
|
|
static void test_request_with_large_metadata(grpc_end2end_test_config config) { |
|
|
|
|
static void test_request_with_large_metadata(grpc_end2end_test_config config, |
|
|
|
|
int allow_large_metadata) { |
|
|
|
|
grpc_call *c; |
|
|
|
|
grpc_call *s; |
|
|
|
|
gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); |
|
|
|
@ -106,8 +107,16 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { |
|
|
|
|
grpc_raw_byte_buffer_create(&request_payload_slice, 1); |
|
|
|
|
gpr_timespec deadline = five_seconds_time(); |
|
|
|
|
grpc_metadata meta; |
|
|
|
|
grpc_end2end_test_fixture f = |
|
|
|
|
begin_test(config, "test_request_with_large_metadata", NULL, NULL); |
|
|
|
|
const char *test_name = allow_large_metadata |
|
|
|
|
? "test_request_with_large_metadata_allowed" |
|
|
|
|
: "test_request_with_large_metadata_not_allowed"; |
|
|
|
|
const size_t large_size = 64 * 1024; |
|
|
|
|
grpc_arg arg = { GRPC_ARG_INTEGER, GRPC_ARG_MAX_METADATA_SIZE, |
|
|
|
|
{ .integer=(int)large_size + 1024 } }; |
|
|
|
|
grpc_channel_args args = { 1, &arg }; |
|
|
|
|
grpc_channel_args* use_args = allow_large_metadata ? &args : NULL; |
|
|
|
|
grpc_end2end_test_fixture f = begin_test( |
|
|
|
|
config, test_name, use_args, use_args); |
|
|
|
|
cq_verifier *cqv = cq_verifier_create(f.cq); |
|
|
|
|
grpc_op ops[6]; |
|
|
|
|
grpc_op *op; |
|
|
|
@ -121,7 +130,6 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { |
|
|
|
|
char *details = NULL; |
|
|
|
|
size_t details_capacity = 0; |
|
|
|
|
int was_cancelled = 2; |
|
|
|
|
const size_t large_size = 64 * 1024; |
|
|
|
|
|
|
|
|
|
c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, |
|
|
|
|
"/foo", "foo.test.google.fr", deadline, NULL); |
|
|
|
@ -214,13 +222,19 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { |
|
|
|
|
cq_expect_completion(cqv, tag(1), 1); |
|
|
|
|
cq_verify(cqv); |
|
|
|
|
|
|
|
|
|
// FIXME: why is this assert passing with allow_large_metadata=false?
|
|
|
|
|
GPR_ASSERT(status == GRPC_STATUS_OK); |
|
|
|
|
GPR_ASSERT(0 == strcmp(details, "xyz")); |
|
|
|
|
GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); |
|
|
|
|
GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); |
|
|
|
|
GPR_ASSERT(was_cancelled == 0); |
|
|
|
|
GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); |
|
|
|
|
GPR_ASSERT(contains_metadata(&request_metadata_recv, "key", meta.value)); |
|
|
|
|
if (allow_large_metadata) { |
|
|
|
|
GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); |
|
|
|
|
GPR_ASSERT(contains_metadata(&request_metadata_recv, "key", meta.value)); |
|
|
|
|
} else { |
|
|
|
|
GPR_ASSERT(request_payload_recv == NULL); |
|
|
|
|
GPR_ASSERT(!contains_metadata_key(&request_metadata_recv, "key")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gpr_free(details); |
|
|
|
|
grpc_metadata_array_destroy(&initial_metadata_recv); |
|
|
|
@ -243,7 +257,8 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void large_metadata(grpc_end2end_test_config config) { |
|
|
|
|
test_request_with_large_metadata(config); |
|
|
|
|
test_request_with_large_metadata(config, 1); |
|
|
|
|
test_request_with_large_metadata(config, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void large_metadata_pre_init(void) {} |
|
|
|
|