|
|
|
@ -77,8 +77,8 @@ static void drain_cq(grpc_completion_queue *cq) { |
|
|
|
|
|
|
|
|
|
static void shutdown_server(grpc_end2end_test_fixture *f) { |
|
|
|
|
if (!f->server) return; |
|
|
|
|
grpc_server_shutdown_and_notify(f->server, f->server_cq, tag(1000)); |
|
|
|
|
GPR_ASSERT(grpc_completion_queue_pluck(f->server_cq, tag(1000), |
|
|
|
|
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); |
|
|
|
|
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), |
|
|
|
|
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)) |
|
|
|
|
.type == GRPC_OP_COMPLETE); |
|
|
|
|
grpc_server_destroy(f->server); |
|
|
|
@ -95,12 +95,9 @@ static void end_test(grpc_end2end_test_fixture *f) { |
|
|
|
|
shutdown_server(f); |
|
|
|
|
shutdown_client(f); |
|
|
|
|
|
|
|
|
|
grpc_completion_queue_shutdown(f->server_cq); |
|
|
|
|
drain_cq(f->server_cq); |
|
|
|
|
grpc_completion_queue_destroy(f->server_cq); |
|
|
|
|
grpc_completion_queue_shutdown(f->client_cq); |
|
|
|
|
drain_cq(f->client_cq); |
|
|
|
|
grpc_completion_queue_destroy(f->client_cq); |
|
|
|
|
grpc_completion_queue_shutdown(f->cq); |
|
|
|
|
drain_cq(f->cq); |
|
|
|
|
grpc_completion_queue_destroy(f->cq); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void request_with_payload_template( |
|
|
|
@ -116,8 +113,6 @@ static void request_with_payload_template( |
|
|
|
|
grpc_channel_args *client_args; |
|
|
|
|
grpc_channel_args *server_args; |
|
|
|
|
grpc_end2end_test_fixture f; |
|
|
|
|
cq_verifier *v_client; |
|
|
|
|
cq_verifier *v_server; |
|
|
|
|
grpc_op ops[6]; |
|
|
|
|
grpc_op *op; |
|
|
|
|
grpc_metadata_array initial_metadata_recv; |
|
|
|
@ -129,6 +124,7 @@ static void request_with_payload_template( |
|
|
|
|
char *details = NULL; |
|
|
|
|
size_t details_capacity = 0; |
|
|
|
|
int was_cancelled = 2; |
|
|
|
|
cq_verifier *cqv; |
|
|
|
|
|
|
|
|
|
char str[1024]; memset(&str[0], 1023, 'x'); str[1023] = '\0'; |
|
|
|
|
request_payload_slice = gpr_slice_from_copied_string(str); |
|
|
|
@ -140,10 +136,9 @@ static void request_with_payload_template( |
|
|
|
|
NULL, requested_compression_level); |
|
|
|
|
|
|
|
|
|
f = begin_test(config, test_name, client_args, server_args); |
|
|
|
|
v_client = cq_verifier_create(f.client_cq); |
|
|
|
|
v_server = cq_verifier_create(f.server_cq); |
|
|
|
|
cqv = cq_verifier_create(f.cq); |
|
|
|
|
|
|
|
|
|
c = grpc_channel_create_call(f.client, f.client_cq, "/foo", |
|
|
|
|
c = grpc_channel_create_call(f.client, f.cq, "/foo", |
|
|
|
|
"foo.test.google.fr", deadline); |
|
|
|
|
GPR_ASSERT(c); |
|
|
|
|
|
|
|
|
@ -179,10 +174,10 @@ static void request_with_payload_template( |
|
|
|
|
|
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == |
|
|
|
|
grpc_server_request_call(f.server, &s, &call_details, |
|
|
|
|
&request_metadata_recv, f.server_cq, |
|
|
|
|
f.server_cq, tag(101))); |
|
|
|
|
cq_expect_completion(v_server, tag(101), 1); |
|
|
|
|
cq_verify(v_server); |
|
|
|
|
&request_metadata_recv, f.cq, |
|
|
|
|
f.cq, tag(101))); |
|
|
|
|
cq_expect_completion(cqv, tag(101), 1); |
|
|
|
|
cq_verify(cqv); |
|
|
|
|
|
|
|
|
|
op = ops; |
|
|
|
|
op->op = GRPC_OP_SEND_INITIAL_METADATA; |
|
|
|
@ -195,8 +190,8 @@ static void request_with_payload_template( |
|
|
|
|
op++; |
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102))); |
|
|
|
|
|
|
|
|
|
cq_expect_completion(v_server, tag(102), 1); |
|
|
|
|
cq_verify(v_server); |
|
|
|
|
cq_expect_completion(cqv, tag(102), 1); |
|
|
|
|
cq_verify(cqv); |
|
|
|
|
|
|
|
|
|
op = ops; |
|
|
|
|
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; |
|
|
|
@ -211,11 +206,9 @@ static void request_with_payload_template( |
|
|
|
|
op++; |
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(103))); |
|
|
|
|
|
|
|
|
|
cq_expect_completion(v_server, tag(103), 1); |
|
|
|
|
cq_verify(v_server); |
|
|
|
|
|
|
|
|
|
cq_expect_completion(v_client, tag(1), 1); |
|
|
|
|
cq_verify(v_client); |
|
|
|
|
cq_expect_completion(cqv, tag(103), 1); |
|
|
|
|
cq_expect_completion(cqv, tag(1), 1); |
|
|
|
|
cq_verify(cqv); |
|
|
|
|
|
|
|
|
|
GPR_ASSERT(status == GRPC_STATUS_OK); |
|
|
|
|
GPR_ASSERT(0 == strcmp(details, "xyz")); |
|
|
|
@ -238,8 +231,7 @@ static void request_with_payload_template( |
|
|
|
|
grpc_call_destroy(c); |
|
|
|
|
grpc_call_destroy(s); |
|
|
|
|
|
|
|
|
|
cq_verifier_destroy(v_client); |
|
|
|
|
cq_verifier_destroy(v_server); |
|
|
|
|
cq_verifier_destroy(cqv); |
|
|
|
|
|
|
|
|
|
grpc_byte_buffer_destroy(request_payload); |
|
|
|
|
grpc_byte_buffer_destroy(request_payload_recv); |
|
|
|
@ -274,9 +266,8 @@ static void test_invoke_request_with_uncompressed_payload( |
|
|
|
|
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void grpc_end2end_tests(grpc_end2end_test_config config) { |
|
|
|
|
test_invoke_request_with_exceptionally_uncompressed_payload(config); |
|
|
|
|
test_invoke_request_with_compressed_payload(config); |
|
|
|
|
test_invoke_request_with_uncompressed_payload(config); |
|
|
|
|
test_invoke_request_with_compressed_payload(config); |
|
|
|
|
} |
|
|
|
|