aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/end2end/tests/max_message_length.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/end2end/tests/max_message_length.c')
-rw-r--r--test/core/end2end/tests/max_message_length.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c
index 43f71f51d1..cdca3e6748 100644
--- a/test/core/end2end/tests/max_message_length.c
+++ b/test/core/end2end/tests/max_message_length.c
@@ -98,19 +98,22 @@ static void end_test(grpc_end2end_test_fixture *f) {
grpc_completion_queue_destroy(f->cq);
}
-static void test_max_message_length(grpc_end2end_test_config config) {
+static void test_max_message_length(grpc_end2end_test_config config,
+ bool send_limit) {
+ gpr_log(GPR_INFO, "testing with send_limit=%d", send_limit);
+
grpc_end2end_test_fixture f;
- grpc_arg server_arg;
- grpc_channel_args server_args;
- grpc_call *c;
- grpc_call *s;
+ grpc_arg channel_arg;
+ grpc_channel_args channel_args;
+ grpc_call *c = NULL;
+ grpc_call *s = NULL;
cq_verifier *cqv;
grpc_op ops[6];
grpc_op *op;
gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
grpc_byte_buffer *request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *recv_payload;
+ grpc_byte_buffer *recv_payload = NULL;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -121,14 +124,17 @@ static void test_max_message_length(grpc_end2end_test_config config) {
size_t details_capacity = 0;
int was_cancelled = 2;
- server_arg.key = GRPC_ARG_MAX_MESSAGE_LENGTH;
- server_arg.type = GRPC_ARG_INTEGER;
- server_arg.value.integer = 5;
+ 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;
- server_args.num_args = 1;
- server_args.args = &server_arg;
+ channel_args.num_args = 1;
+ channel_args.args = &channel_arg;
- f = begin_test(config, "test_max_message_length", NULL, &server_args);
+ f = begin_test(config, "test_max_message_length",
+ send_limit ? &channel_args : NULL,
+ send_limit ? NULL : &channel_args);
cqv = cq_verifier_create(f.cq);
c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
@@ -173,6 +179,12 @@ static void test_max_message_length(grpc_end2end_test_config config) {
error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
+ if (send_limit) {
+ CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
+ cq_verify(cqv);
+ goto done;
+ }
+
error =
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101));
@@ -199,11 +211,16 @@ static void test_max_message_length(grpc_end2end_test_config config) {
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
cq_verify(cqv);
- GPR_ASSERT(status != GRPC_STATUS_OK);
GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234"));
GPR_ASSERT(was_cancelled == 1);
- GPR_ASSERT(recv_payload == NULL);
+
+done:
+ GPR_ASSERT(status == GRPC_STATUS_INVALID_ARGUMENT);
+ GPR_ASSERT(strcmp(details,
+ send_limit
+ ? "Sent message larger than max (11 vs. 5)"
+ : "Received message larger than max (11 vs. 5)") == 0);
gpr_free(details);
grpc_metadata_array_destroy(&initial_metadata_recv);
@@ -211,9 +228,10 @@ static void test_max_message_length(grpc_end2end_test_config config) {
grpc_metadata_array_destroy(&request_metadata_recv);
grpc_call_details_destroy(&call_details);
grpc_byte_buffer_destroy(request_payload);
+ grpc_byte_buffer_destroy(recv_payload);
grpc_call_destroy(c);
- grpc_call_destroy(s);
+ if (s != NULL) grpc_call_destroy(s);
cq_verifier_destroy(cqv);
@@ -222,7 +240,8 @@ static void test_max_message_length(grpc_end2end_test_config config) {
}
void max_message_length(grpc_end2end_test_config config) {
- test_max_message_length(config);
+ test_max_message_length(config, true);
+ test_max_message_length(config, false);
}
void max_message_length_pre_init(void) {}