|
|
|
@ -39,6 +39,7 @@ |
|
|
|
|
|
|
|
|
|
#include "src/core/support/string.h" |
|
|
|
|
#include <grpc/byte_buffer.h> |
|
|
|
|
#include <grpc/grpc.h> |
|
|
|
|
#include <grpc/support/alloc.h> |
|
|
|
|
#include <grpc/support/log.h> |
|
|
|
|
#include <grpc/support/time.h> |
|
|
|
@ -109,19 +110,22 @@ static void simple_request_body(grpc_end2end_test_fixture f) { |
|
|
|
|
gpr_timespec deadline = five_seconds_time(); |
|
|
|
|
cq_verifier *v_client = cq_verifier_create(f.client_cq); |
|
|
|
|
cq_verifier *v_server = cq_verifier_create(f.server_cq); |
|
|
|
|
grpc_op ops[4]; |
|
|
|
|
grpc_op ops[6]; |
|
|
|
|
grpc_op *op; |
|
|
|
|
grpc_metadata_array initial_metadata_recv; |
|
|
|
|
grpc_metadata_array trailing_metadata_recv; |
|
|
|
|
grpc_metadata_array request_metadata_recv; |
|
|
|
|
grpc_call_details call_details; |
|
|
|
|
grpc_status_code status; |
|
|
|
|
char *details = NULL; |
|
|
|
|
size_t details_capacity = NULL; |
|
|
|
|
int was_cancelled = 2; |
|
|
|
|
|
|
|
|
|
c = grpc_channel_create_call(f.client, f.client_cq, "/foo", "test.google.com", |
|
|
|
|
deadline); |
|
|
|
|
deadline); |
|
|
|
|
GPR_ASSERT(c); |
|
|
|
|
|
|
|
|
|
grpc_metadata_array_init(&initial_metadata_recv); |
|
|
|
|
grpc_metadata_array_init(&trailing_metadata_recv); |
|
|
|
|
grpc_metadata_array_init(&request_metadata_recv); |
|
|
|
|
grpc_call_details_init(&call_details); |
|
|
|
@ -130,86 +134,54 @@ static void simple_request_body(grpc_end2end_test_fixture f) { |
|
|
|
|
op->op = GRPC_OP_SEND_INITIAL_METADATA; |
|
|
|
|
op->data.send_initial_metadata.count = 0; |
|
|
|
|
op++; |
|
|
|
|
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; |
|
|
|
|
op++; |
|
|
|
|
op->op = GRPC_OP_RECV_INITIAL_METADATA; |
|
|
|
|
op->data.recv_initial_metadata = &initial_metadata_recv; |
|
|
|
|
op++; |
|
|
|
|
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; |
|
|
|
|
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata; |
|
|
|
|
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; |
|
|
|
|
op->data.recv_status_on_client.status = &status; |
|
|
|
|
op->data.recv_status_on_client.status_details = &details; |
|
|
|
|
op->data.recv_status_on_client.status_details_capacity = &details_capacity; |
|
|
|
|
op++; |
|
|
|
|
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; |
|
|
|
|
op++; |
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_call_send_batch(call, ops, op - ops, tag(1))); |
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &call_details, &request_metadata_recv, f.server_cq, tag(101))); |
|
|
|
|
cq_expect_ |
|
|
|
|
|
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(100))); |
|
|
|
|
cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "test.google.com", |
|
|
|
|
deadline, NULL); |
|
|
|
|
cq_verify(v_server); |
|
|
|
|
|
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == |
|
|
|
|
grpc_call_server_accept_old(s, f.server_cq, tag(102))); |
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata_old(s, 0)); |
|
|
|
|
cq_expect_client_metadata_read(v_client, tag(2), NULL); |
|
|
|
|
cq_verify(v_client); |
|
|
|
|
|
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status_old( |
|
|
|
|
s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(5))); |
|
|
|
|
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED, |
|
|
|
|
"xyz", NULL); |
|
|
|
|
cq_verify(v_client); |
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1))); |
|
|
|
|
|
|
|
|
|
cq_expect_finish_accepted(v_server, tag(5), GRPC_OP_OK); |
|
|
|
|
cq_expect_finished(v_server, tag(102), NULL); |
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s, |
|
|
|
|
&call_details, |
|
|
|
|
&request_metadata_recv, |
|
|
|
|
f.server_cq, tag(101))); |
|
|
|
|
cq_expect_completion(v_server, tag(101), GRPC_OP_OK); |
|
|
|
|
cq_verify(v_server); |
|
|
|
|
|
|
|
|
|
grpc_call_destroy(c); |
|
|
|
|
grpc_call_destroy(s); |
|
|
|
|
|
|
|
|
|
cq_verifier_destroy(v_client); |
|
|
|
|
cq_verifier_destroy(v_server); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* an alternative ordering of the simple request body */ |
|
|
|
|
static void simple_request_body2(grpc_end2end_test_fixture f) { |
|
|
|
|
grpc_call *c; |
|
|
|
|
grpc_call *s; |
|
|
|
|
gpr_timespec deadline = five_seconds_time(); |
|
|
|
|
cq_verifier *v_client = cq_verifier_create(f.client_cq); |
|
|
|
|
cq_verifier *v_server = cq_verifier_create(f.server_cq); |
|
|
|
|
|
|
|
|
|
c = grpc_channel_create_call_old(f.client, "/foo", "test.google.com", |
|
|
|
|
deadline); |
|
|
|
|
GPR_ASSERT(c); |
|
|
|
|
|
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == |
|
|
|
|
grpc_call_invoke_old(c, f.client_cq, tag(2), tag(3), 0)); |
|
|
|
|
|
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done_old(c, tag(4))); |
|
|
|
|
cq_expect_finish_accepted(v_client, tag(4), GRPC_OP_OK); |
|
|
|
|
cq_verify(v_client); |
|
|
|
|
|
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(100))); |
|
|
|
|
cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "test.google.com", |
|
|
|
|
deadline, NULL); |
|
|
|
|
cq_verify(v_server); |
|
|
|
|
|
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == |
|
|
|
|
grpc_call_server_accept_old(s, f.server_cq, tag(102))); |
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata_old(s, 0)); |
|
|
|
|
op = ops; |
|
|
|
|
op->op = GRPC_OP_SEND_INITIAL_METADATA; |
|
|
|
|
op->data.send_initial_metadata.count = 0; |
|
|
|
|
op++; |
|
|
|
|
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; |
|
|
|
|
op->data.send_status_from_server.trailing_metadata_count = 0; |
|
|
|
|
op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; |
|
|
|
|
op->data.send_status_from_server.status_details = "xyz"; |
|
|
|
|
op++; |
|
|
|
|
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; |
|
|
|
|
op->data.recv_close_on_server.cancelled = &was_cancelled; |
|
|
|
|
op++; |
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102))); |
|
|
|
|
|
|
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status_old( |
|
|
|
|
s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(5))); |
|
|
|
|
cq_expect_completion(v_server, tag(102), GRPC_OP_OK); |
|
|
|
|
cq_verify(v_server); |
|
|
|
|
|
|
|
|
|
cq_expect_client_metadata_read(v_client, tag(2), NULL); |
|
|
|
|
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED, |
|
|
|
|
"xyz", NULL); |
|
|
|
|
cq_expect_completion(v_client, tag(1), GRPC_OP_OK); |
|
|
|
|
cq_verify(v_client); |
|
|
|
|
|
|
|
|
|
cq_expect_finish_accepted(v_server, tag(5), GRPC_OP_OK); |
|
|
|
|
cq_expect_finished(v_server, tag(102), NULL); |
|
|
|
|
cq_verify(v_server); |
|
|
|
|
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); |
|
|
|
|
GPR_ASSERT(0 == strcmp(details, "xyz")); |
|
|
|
|
GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); |
|
|
|
|
GPR_ASSERT(0 == strcmp(call_details.host, "test.google.com")); |
|
|
|
|
GPR_ASSERT(was_cancelled == 0); |
|
|
|
|
GPR_ASSERT(initial_metadata_recv.count == 0); |
|
|
|
|
GPR_ASSERT(trailing_metadata_recv.count == 0); |
|
|
|
|
GPR_ASSERT(request_metadata_recv.count == 0); |
|
|
|
|
|
|
|
|
|
grpc_call_destroy(c); |
|
|
|
|
grpc_call_destroy(s); |
|
|
|
@ -218,19 +190,13 @@ static void simple_request_body2(grpc_end2end_test_fixture f) { |
|
|
|
|
cq_verifier_destroy(v_server); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void test_invoke_simple_request( |
|
|
|
|
grpc_end2end_test_config config, const char *name, |
|
|
|
|
void (*body)(grpc_end2end_test_fixture f)) { |
|
|
|
|
char *fullname; |
|
|
|
|
static void test_invoke_simple_request(grpc_end2end_test_config config) { |
|
|
|
|
grpc_end2end_test_fixture f; |
|
|
|
|
|
|
|
|
|
gpr_asprintf(&fullname, "%s/%s", __FUNCTION__, name); |
|
|
|
|
|
|
|
|
|
f = begin_test(config, fullname, NULL, NULL); |
|
|
|
|
body(f); |
|
|
|
|
f = begin_test(config, __FUNCTION__, NULL, NULL); |
|
|
|
|
simple_request_body(f); |
|
|
|
|
end_test(&f); |
|
|
|
|
config.tear_down_data(&f); |
|
|
|
|
gpr_free(fullname); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { |
|
|
|
@ -245,9 +211,6 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void grpc_end2end_tests(grpc_end2end_test_config config) { |
|
|
|
|
test_invoke_simple_request(config, "simple_request_body", |
|
|
|
|
simple_request_body); |
|
|
|
|
test_invoke_simple_request(config, "simple_request_body2", |
|
|
|
|
simple_request_body2); |
|
|
|
|
test_invoke_simple_request(config); |
|
|
|
|
test_invoke_10_simple_requests(config); |
|
|
|
|
} |
|
|
|
|