diff options
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/end2end/cq_verifier.c | 8 | ||||
-rw-r--r-- | test/core/end2end/cq_verifier.h | 1 | ||||
-rw-r--r-- | test/core/end2end/tests/large_metadata.c | 29 |
3 files changed, 31 insertions, 7 deletions
diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 77afe588d7..5f1a33242e 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -107,6 +107,14 @@ int contains_metadata(grpc_metadata_array *array, const char *key, return has_metadata(array->metadata, array->count, key, value); } +int contains_metadata_key(grpc_metadata_array *array, const char *key) { + for (size_t i = 0; i < array->count; ++i) { + if (strcmp(array->metadata[i].key, key) == 0) + return 1; + } + return 0; +} + static gpr_slice merge_slices(gpr_slice *slices, size_t nslices) { size_t i; size_t len = 0; diff --git a/test/core/end2end/cq_verifier.h b/test/core/end2end/cq_verifier.h index b3e07c45a5..a54065950d 100644 --- a/test/core/end2end/cq_verifier.h +++ b/test/core/end2end/cq_verifier.h @@ -62,5 +62,6 @@ void cq_expect_completion(cq_verifier *v, void *tag, int success); int byte_buffer_eq_string(grpc_byte_buffer *byte_buffer, const char *string); int contains_metadata(grpc_metadata_array *array, const char *key, const char *value); +int contains_metadata_key(grpc_metadata_array *array, const char *key); #endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_H */ diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index 0e5d6b4fe0..f09b55a2c0 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -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) {} |