Trailing metadata support.

Actually exposing it from the C API.
Also removing grpc_status, since it's mostly useless.
	Change on 2014/12/15 by ctiller <ctiller@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=82180546
pull/1/merge
ctiller 10 years ago committed by Nicolas Noble
parent c6d61c4dd6
commit 2845cade4c
  1. 252
      Makefile
  2. 17
      include/grpc/grpc.h
  3. 30
      src/core/surface/call.c
  4. 9
      src/core/surface/completion_queue.c
  5. 4
      src/core/surface/completion_queue.h
  6. 5
      src/core/surface/event_string.c
  7. 2
      src/cpp/client/channel.cc
  8. 10
      src/cpp/server/async_server_context.cc
  9. 7
      src/cpp/stream/stream_context.cc
  10. 6
      test/core/echo/server.c
  11. 32
      test/core/end2end/cq_verifier.c
  12. 3
      test/core/end2end/cq_verifier.h
  13. 11
      test/core/end2end/dualstack_socket_test.c
  14. 1
      test/core/end2end/gen_build_json.py
  15. 4
      test/core/end2end/no_server_test.c
  16. 7
      test/core/end2end/tests/cancel_after_accept.c
  17. 7
      test/core/end2end/tests/cancel_after_accept_and_writes_closed.c
  18. 4
      test/core/end2end/tests/cancel_after_invoke.c
  19. 4
      test/core/end2end/tests/cancel_before_invoke.c
  20. 8
      test/core/end2end/tests/disappearing_server.c
  21. 4
      test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c
  22. 8
      test/core/end2end/tests/invoke_large_request.c
  23. 21
      test/core/end2end/tests/max_concurrent_streams.c
  24. 8
      test/core/end2end/tests/ping_pong_streaming.c
  25. 8
      test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c
  26. 8
      test/core/end2end/tests/request_response_with_metadata_and_payload.c
  27. 8
      test/core/end2end/tests/request_response_with_payload.c
  28. 214
      test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c
  29. 5
      test/core/end2end/tests/request_with_large_metadata.c
  30. 8
      test/core/end2end/tests/request_with_payload.c
  31. 8
      test/core/end2end/tests/simple_delayed_request.c
  32. 16
      test/core/end2end/tests/simple_request.c
  33. 3
      test/core/end2end/tests/thread_stress.c
  34. 8
      test/core/end2end/tests/writes_done_hangs_with_pending_read.c
  35. 6
      test/core/fling/server.c

File diff suppressed because one or more lines are too long

@ -107,12 +107,6 @@ typedef struct {
/* Maximum message length that the channel can receive */
#define GRPC_ARG_MAX_MESSAGE_LENGTH "grpc.max_message_length"
/* Status of a completed call */
typedef struct grpc_status {
grpc_status_code code;
char *details;
} grpc_status;
/* Result of a grpc call. If the caller satisfies the prerequisites of a
particular operation, the grpc_call_error returned will be GRPC_CALL_OK.
Receiving any other value listed here is an indication of a bug in the
@ -221,7 +215,12 @@ typedef struct grpc_event {
size_t count;
grpc_metadata *elements;
} client_metadata_read;
grpc_status finished;
struct {
grpc_status_code status;
const char *details;
size_t metadata_count;
grpc_metadata *metadata_elements;
} finished;
struct {
const char *method;
const char *host;
@ -391,7 +390,9 @@ grpc_call_error grpc_call_start_write(grpc_call *call,
Only callable on the server.
Produces a GRPC_FINISH_ACCEPTED event when the status is sent. */
grpc_call_error grpc_call_start_write_status(grpc_call *call,
grpc_status status, void *tag);
grpc_status_code status_code,
const char *status_message,
void *tag);
/* No more messages to send.
REQUIRES: No other writes are pending on the call.

@ -296,8 +296,8 @@ grpc_call_error grpc_call_add_metadata(grpc_call *call, grpc_metadata *metadata,
grpc_call_element *elem;
grpc_call_op op;
if (call->state >= CALL_STARTED) {
return GRPC_CALL_ERROR_ALREADY_INVOKED;
if (call->state >= CALL_FINISHED) {
return GRPC_CALL_ERROR_ALREADY_FINISHED;
}
op.type = GRPC_SEND_METADATA;
@ -326,12 +326,17 @@ static void done_invoke(void *user_data, grpc_op_error error) {
}
static void finish_call(grpc_call *call) {
grpc_status status;
status.code = call->status_code;
status.details = call->status_details
? (char *)grpc_mdstr_as_c_string(call->status_details)
: NULL;
grpc_cq_end_finished(call->cq, call->finished_tag, call, NULL, NULL, status);
size_t count;
grpc_metadata *elements;
count = grpc_metadata_buffer_count(&call->incoming_metadata);
elements = grpc_metadata_buffer_extract_elements(&call->incoming_metadata);
grpc_cq_end_finished(
call->cq, call->finished_tag, call, grpc_metadata_buffer_cleanup_elements,
elements, call->status_code,
call->status_details
? (char *)grpc_mdstr_as_c_string(call->status_details)
: NULL,
elements, count);
}
grpc_call_error grpc_call_start_invoke(grpc_call *call,
@ -678,7 +683,8 @@ grpc_call_error grpc_call_writes_done(grpc_call *call, void *tag) {
}
grpc_call_error grpc_call_start_write_status(grpc_call *call,
grpc_status status, void *tag) {
grpc_status_code status,
const char *details, void *tag) {
grpc_call_element *elem;
grpc_call_op op;
@ -702,9 +708,9 @@ grpc_call_error grpc_call_start_write_status(grpc_call *call,
elem = CALL_ELEM_FROM_CALL(call, 0);
if (status.details && status.details[0]) {
if (details && details[0]) {
grpc_mdelem *md = grpc_mdelem_from_strings(call->metadata_context,
"grpc-message", status.details);
"grpc-message", details);
op.type = GRPC_SEND_METADATA;
op.dir = GRPC_CALL_DOWN;
@ -719,7 +725,7 @@ grpc_call_error grpc_call_start_write_status(grpc_call *call,
{
grpc_mdelem *md;
char buffer[32];
sprintf(buffer, "%d", status.code);
sprintf(buffer, "%d", status);
md =
grpc_mdelem_from_strings(call->metadata_context, "grpc-status", buffer);

@ -214,11 +214,16 @@ void grpc_cq_end_client_metadata_read(grpc_completion_queue *cc, void *tag,
void grpc_cq_end_finished(grpc_completion_queue *cc, void *tag, grpc_call *call,
grpc_event_finish_func on_finish, void *user_data,
grpc_status status) {
grpc_status_code status, const char *details,
grpc_metadata *metadata_elements,
size_t metadata_count) {
event *ev;
gpr_mu_lock(&grpc_iomgr_mu);
ev = add_locked(cc, GRPC_FINISHED, tag, call, on_finish, user_data);
ev->base.data.finished = status;
ev->base.data.finished.status = status;
ev->base.data.finished.details = details;
ev->base.data.finished.metadata_count = metadata_count;
ev->base.data.finished.metadata_elements = metadata_elements;
end_op_locked(cc, GRPC_FINISHED);
gpr_mu_unlock(&grpc_iomgr_mu);
}

@ -86,7 +86,9 @@ void grpc_cq_end_client_metadata_read(grpc_completion_queue *cc, void *tag,
void grpc_cq_end_finished(grpc_completion_queue *cc, void *tag, grpc_call *call,
grpc_event_finish_func on_finish, void *user_data,
grpc_status status);
grpc_status_code status, const char *details,
grpc_metadata *metadata_elements,
size_t metadata_count);
void grpc_cq_end_new_rpc(grpc_completion_queue *cc, void *tag, grpc_call *call,
grpc_event_finish_func on_finish, void *user_data,

@ -99,8 +99,9 @@ char *grpc_event_string(grpc_event *ev) {
case GRPC_FINISHED:
p += sprintf(p, "FINISHED: ");
p += addhdr(p, ev);
p += sprintf(p, " status_code=%d details='%s'", ev->data.finished.code,
ev->data.finished.details);
p += sprintf(p, " status=%d details='%s' %d metadata elements",
ev->data.finished.status, ev->data.finished.details,
(int)ev->data.finished.metadata_count);
break;
case GRPC_SERVER_RPC_NEW:
p += sprintf(p, "SERVER_RPC_NEW: ");

@ -63,7 +63,7 @@ void GetFinalStatus(grpc_completion_queue* cq, void* finished_tag,
grpc_event* ev =
grpc_completion_queue_pluck(cq, finished_tag, gpr_inf_future);
if (status) {
StatusCode error_code = static_cast<StatusCode>(ev->data.finished.code);
StatusCode error_code = static_cast<StatusCode>(ev->data.finished.status);
grpc::string details(ev->data.finished.details ? ev->data.finished.details
: "");
*status = Status(error_code, details);

@ -76,11 +76,11 @@ bool AsyncServerContext::StartWrite(const google::protobuf::Message& response,
}
bool AsyncServerContext::StartWriteStatus(const Status& status) {
grpc_status c_status = {static_cast<grpc_status_code>(status.code()),
status.details().empty()
? nullptr
: const_cast<char*>(status.details().c_str())};
grpc_call_error err = grpc_call_start_write_status(call_, c_status, this);
grpc_call_error err = grpc_call_start_write_status(
call_, static_cast<grpc_status_code>(status.code()),
status.details().empty() ? nullptr
: const_cast<char*>(status.details().c_str()),
this);
return err == GRPC_CALL_OK;
}

@ -170,11 +170,10 @@ const Status& StreamContext::Wait() {
grpc_event* finish_ev =
grpc_completion_queue_pluck(cq(), finished_tag(), gpr_inf_future);
GPR_ASSERT(finish_ev->type == GRPC_FINISHED);
std::string error_details(finish_ev->data.finished.details
? finish_ev->data.finished.details
: "");
final_status_ = Status(
static_cast<StatusCode>(finish_ev->data.finished.code), error_details);
static_cast<StatusCode>(finish_ev->data.finished.status),
finish_ev->data.finished.details ? finish_ev->data.finished.details
: "");
grpc_event_finish(finish_ev);
}
return final_status_;

@ -51,8 +51,6 @@ static grpc_completion_queue *cq;
static grpc_server *server;
static int got_sigint = 0;
static const grpc_status status_ok = {GRPC_STATUS_OK, NULL};
typedef struct {
gpr_refcount pending_ops;
gpr_intmax bytes_read;
@ -145,8 +143,8 @@ int main(int argc, char **argv) {
GRPC_WRITE_BUFFER_HINT) ==
GRPC_CALL_OK);
} else {
GPR_ASSERT(grpc_call_start_write_status(ev->call, status_ok, s) ==
GRPC_CALL_OK);
GPR_ASSERT(grpc_call_start_write_status(ev->call, GRPC_STATUS_OK,
NULL, s) == GRPC_CALL_OK);
}
break;
case GRPC_FINISH_ACCEPTED:

@ -80,7 +80,8 @@ typedef struct expectation {
} server_rpc_new;
metadata *client_metadata_read;
struct {
grpc_status status;
grpc_status_code status;
const char *details;
metadata *metadata;
} finished;
gpr_slice *read;
@ -201,12 +202,14 @@ static void verify_matches(expectation *e, grpc_event *ev) {
ev->data.client_metadata_read.count);
break;
case GRPC_FINISHED:
if (e->data.finished.status.code != GRPC_STATUS__DO_NOT_USE) {
GPR_ASSERT(e->data.finished.status.code == ev->data.finished.code);
GPR_ASSERT(string_equivalent(e->data.finished.status.details,
if (e->data.finished.status != GRPC_STATUS__DO_NOT_USE) {
GPR_ASSERT(e->data.finished.status == ev->data.finished.status);
GPR_ASSERT(string_equivalent(e->data.finished.details,
ev->data.finished.details));
}
verify_and_destroy_metadata(e->data.finished.metadata, NULL, 0);
verify_and_destroy_metadata(e->data.finished.metadata,
ev->data.finished.metadata_elements,
ev->data.finished.metadata_count);
break;
case GRPC_QUEUE_SHUTDOWN:
gpr_log(GPR_ERROR, "premature queue shutdown");
@ -279,9 +282,8 @@ static size_t expectation_to_string(char *out, expectation *e) {
return len;
case GRPC_FINISHED:
str = metadata_expectation_string(e->data.finished.metadata);
len = sprintf(out, "GRPC_FINISHED code=%d details=%s %s",
e->data.finished.status.code,
e->data.finished.status.details, str);
len = sprintf(out, "GRPC_FINISHED status=%d details=%s %s",
e->data.finished.status, e->data.finished.details, str);
gpr_free(str);
return len;
case GRPC_READ:
@ -456,25 +458,27 @@ void cq_expect_client_metadata_read(cq_verifier *v, void *tag, ...) {
va_end(args);
}
static void finished_internal(cq_verifier *v, void *tag, grpc_status status,
static void finished_internal(cq_verifier *v, void *tag,
grpc_status_code status, const char *details,
va_list args) {
expectation *e = add(v, GRPC_FINISHED, tag);
e->data.finished.status = status;
e->data.finished.details = details;
e->data.finished.metadata = metadata_from_args(args);
}
void cq_expect_finished_with_status(cq_verifier *v, void *tag,
grpc_status status, ...) {
grpc_status_code status,
const char *details, ...) {
va_list args;
va_start(args, status);
finished_internal(v, tag, status, args);
va_start(args, details);
finished_internal(v, tag, status, details, args);
va_end(args);
}
void cq_expect_finished(cq_verifier *v, void *tag, ...) {
va_list args;
grpc_status status = {GRPC_STATUS__DO_NOT_USE, NULL};
va_start(args, tag);
finished_internal(v, tag, status, args);
finished_internal(v, tag, GRPC_STATUS__DO_NOT_USE, NULL, args);
va_end(args);
}

@ -67,7 +67,8 @@ void cq_expect_server_rpc_new(cq_verifier *v, grpc_call **output_call,
gpr_timespec deadline, ...);
void cq_expect_client_metadata_read(cq_verifier *v, void *tag, ...);
void cq_expect_finished_with_status(cq_verifier *v, void *tag,
grpc_status status, ...);
grpc_status_code status_code,
const char *details, ...);
void cq_expect_finished(cq_verifier *v, void *tag, ...);
#endif /* __GRPC_TEST_END2END_CQ_VERIFIER_H__ */

@ -63,8 +63,6 @@ static void drain_cq(grpc_completion_queue *cq) {
void test_connect(const char *server_host, const char *client_host, int port,
int expect_ok) {
const grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
const grpc_status cancelled_status = {GRPC_STATUS_CANCELLED, NULL};
char *client_hostport;
char *server_hostport;
grpc_channel *client;
@ -130,8 +128,10 @@ void test_connect(const char *server_host, const char *client_host, int port,
cq_verify(v_client);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(5)));
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
grpc_call_start_write_status(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);
cq_expect_finish_accepted(v_server, tag(5), GRPC_OP_OK);
@ -145,7 +145,8 @@ void test_connect(const char *server_host, const char *client_host, int port,
/* Check for a failed connection. */
cq_expect_invoke_accepted(v_client, tag(1), GRPC_OP_ERROR);
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_expect_finished_with_status(v_client, tag(3), cancelled_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_CANCELLED,
NULL, NULL);
cq_verify(v_client);
grpc_call_destroy(c);

@ -31,6 +31,7 @@ END2END_TESTS = [
'request_response_with_binary_metadata_and_payload',
'request_response_with_metadata_and_payload',
'request_response_with_payload',
'request_response_with_trailing_metadata_and_payload',
'simple_delayed_request',
'simple_request',
'thread_stress',

@ -47,7 +47,6 @@ int main(int argc, char **argv) {
cq_verifier *cqv;
grpc_event *ev;
int done;
grpc_status expect_status = {GRPC_STATUS_CANCELLED, NULL};
grpc_test_init(argc, argv);
grpc_init();
@ -63,7 +62,8 @@ int main(int argc, char **argv) {
/* verify that all tags get completed */
cq_expect_invoke_accepted(cqv, tag(1), GRPC_OP_ERROR);
cq_expect_client_metadata_read(cqv, tag(2), NULL);
cq_expect_finished_with_status(cqv, tag(3), expect_status, NULL);
cq_expect_finished_with_status(cqv, tag(3), GRPC_STATUS_CANCELLED, NULL,
NULL);
cq_verify(cqv);
grpc_completion_queue_shutdown(cq);

@ -119,7 +119,6 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
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_status chk_status = {GRPC_STATUS_CANCELLED, NULL};
c = grpc_channel_create_call(f.client, "/foo", "test.google.com", deadline);
GPR_ASSERT(c);
@ -140,10 +139,12 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
GPR_ASSERT(GRPC_CALL_OK == call_cancel(c));
cq_expect_finished_with_status(v_client, tag(3), chk_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_CANCELLED, NULL,
NULL);
cq_verify(v_client);
cq_expect_finished_with_status(v_server, tag(102), chk_status, NULL);
cq_expect_finished_with_status(v_server, tag(102), GRPC_STATUS_CANCELLED,
NULL, NULL);
cq_verify(v_server);
grpc_call_destroy(c);

@ -119,7 +119,6 @@ static void test_cancel_after_accept_and_writes_closed(
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_status chk_status = {GRPC_STATUS_CANCELLED, NULL};
c = grpc_channel_create_call(f.client, "/foo", "test.google.com", deadline);
GPR_ASSERT(c);
@ -148,10 +147,12 @@ static void test_cancel_after_accept_and_writes_closed(
GPR_ASSERT(GRPC_CALL_OK == call_cancel(c));
cq_expect_finished_with_status(v_client, tag(3), chk_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_CANCELLED, NULL,
NULL);
cq_verify(v_client);
cq_expect_finished_with_status(v_server, tag(102), chk_status, NULL);
cq_expect_finished_with_status(v_server, tag(102), GRPC_STATUS_CANCELLED,
NULL, NULL);
cq_verify(v_server);
grpc_call_destroy(c);

@ -117,7 +117,6 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
gpr_timespec deadline = five_seconds_time();
cq_verifier *v_client = cq_verifier_create(f.client_cq);
grpc_status chk_status = {GRPC_STATUS_CANCELLED, NULL};
c = grpc_channel_create_call(f.client, "/foo", "test.google.com", deadline);
GPR_ASSERT(c);
@ -130,7 +129,8 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
GPR_ASSERT(GRPC_CALL_OK == call_cancel(c));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_expect_finished_with_status(v_client, tag(3), chk_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_CANCELLED, NULL,
NULL);
cq_verify(v_client);
grpc_call_destroy(c);

@ -112,7 +112,6 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
gpr_timespec deadline = five_seconds_time();
cq_verifier *v_client = cq_verifier_create(f.client_cq);
grpc_status chk_status = {GRPC_STATUS_CANCELLED, NULL};
c = grpc_channel_create_call(f.client, "/foo", "test.google.com", deadline);
GPR_ASSERT(c);
@ -123,7 +122,8 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config) {
grpc_call_start_invoke(c, f.client_cq, tag(1), tag(2), tag(3), 0));
cq_expect_invoke_accepted(v_client, tag(1), GRPC_OP_ERROR);
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_expect_finished_with_status(v_client, tag(3), chk_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_CANCELLED, NULL,
NULL);
cq_verify(v_client);
grpc_call_destroy(c);

@ -95,7 +95,6 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
cq_verifier *v_server) {
grpc_call *c;
grpc_call *s;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
gpr_timespec deadline = five_seconds_time();
c = grpc_channel_create_call(f->client, "/foo", "test.google.com", deadline);
@ -124,9 +123,10 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
- and still complete the request */
grpc_server_shutdown(f->server);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(5)));
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
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);
cq_expect_finish_accepted(v_server, tag(5), GRPC_OP_OK);

@ -107,7 +107,6 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
grpc_call *c;
grpc_call *s;
grpc_status expect_status = {GRPC_STATUS_UNAVAILABLE, NULL};
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);
@ -141,7 +140,8 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_call_destroy(s);
cq_expect_finished_with_status(v_client, tag(3), expect_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNAVAILABLE,
NULL, NULL);
cq_verify(v_client);
grpc_call_destroy(c);

@ -109,7 +109,6 @@ static gpr_slice large_slice() {
static void test_invoke_large_request(grpc_end2end_test_config config) {
grpc_call *c;
grpc_call *s;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
gpr_slice request_payload_slice = large_slice();
grpc_byte_buffer *request_payload =
grpc_byte_buffer_create(&request_payload_slice, 1);
@ -156,11 +155,12 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done(c, tag(8)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(9)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(9)));
cq_expect_finish_accepted(v_client, tag(8), GRPC_OP_OK);
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED,
"xyz", NULL);
cq_verify(v_client);
cq_expect_finish_accepted(v_server, tag(9), GRPC_OP_OK);

@ -105,7 +105,6 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_call *c;
grpc_call *s;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
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);
@ -131,9 +130,10 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(5)));
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
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);
cq_expect_finish_accepted(v_server, tag(5), GRPC_OP_OK);
@ -157,7 +157,6 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
grpc_call *s1;
grpc_call *s2;
gpr_timespec deadline;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
cq_verifier *v_client;
cq_verifier *v_server;
@ -208,13 +207,15 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
cq_verify(v_client);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s1, send_status, tag(103)));
grpc_call_start_write_status(s1, GRPC_STATUS_UNIMPLEMENTED, "xyz",
tag(103)));
cq_expect_finish_accepted(v_server, tag(103), GRPC_OP_OK);
cq_expect_finished(v_server, tag(102), NULL);
cq_verify(v_server);
/* first request is finished, we should be able to start the second */
cq_expect_finished_with_status(v_client, tag(302), send_status, NULL);
cq_expect_finished_with_status(v_client, tag(302), GRPC_STATUS_UNIMPLEMENTED,
"xyz", NULL);
cq_expect_invoke_accepted(v_client, tag(400), GRPC_OP_OK);
cq_verify(v_client);
@ -232,12 +233,14 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
cq_verify(v_client);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s2, send_status, tag(203)));
grpc_call_start_write_status(s2, GRPC_STATUS_UNIMPLEMENTED, "xyz",
tag(203)));
cq_expect_finish_accepted(v_server, tag(203), GRPC_OP_OK);
cq_expect_finished(v_server, tag(202), NULL);
cq_verify(v_server);
cq_expect_finished_with_status(v_client, tag(402), send_status, NULL);
cq_expect_finished_with_status(v_client, tag(402), GRPC_STATUS_UNIMPLEMENTED,
"xyz", NULL);
cq_verify(v_client);
cq_verifier_destroy(v_client);

@ -108,7 +108,6 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
int i;
grpc_call *c;
grpc_call *s = NULL;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
grpc_byte_buffer *request_payload = NULL;
@ -171,11 +170,12 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
gpr_slice_unref(response_payload_slice);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done(c, tag(6)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(7)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(7)));
cq_expect_finish_accepted(v_client, tag(6), GRPC_OP_OK);
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED,
"xyz", NULL);
cq_verify(v_client);
cq_expect_finish_accepted(v_server, tag(7), GRPC_OP_OK);

@ -107,7 +107,6 @@ static void test_request_response_with_metadata_and_payload(
grpc_end2end_test_config config) {
grpc_call *c;
grpc_call *s;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
grpc_byte_buffer *request_payload =
@ -197,11 +196,12 @@ static void test_request_response_with_metadata_and_payload(
cq_verify(v_client);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done(c, tag(8)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(9)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(9)));
cq_expect_finish_accepted(v_client, tag(8), GRPC_OP_OK);
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED,
"xyz", NULL);
cq_verify(v_client);
cq_expect_finish_accepted(v_server, tag(9), GRPC_OP_OK);

@ -107,7 +107,6 @@ static void test_request_response_with_metadata_and_payload(
grpc_end2end_test_config config) {
grpc_call *c;
grpc_call *s;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
grpc_byte_buffer *request_payload =
@ -183,11 +182,12 @@ static void test_request_response_with_metadata_and_payload(
cq_verify(v_client);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done(c, tag(8)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(9)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(9)));
cq_expect_finish_accepted(v_client, tag(8), GRPC_OP_OK);
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED,
"xyz", NULL);
cq_verify(v_client);
cq_expect_finish_accepted(v_server, tag(9), GRPC_OP_OK);

@ -105,7 +105,6 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void request_response_with_payload(grpc_end2end_test_fixture f) {
grpc_call *c;
grpc_call *s;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
grpc_byte_buffer *request_payload =
@ -162,11 +161,12 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
cq_expect_read(v_client, tag(7), gpr_slice_from_copied_string("hello you"));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done(c, tag(8)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(9)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(9)));
cq_expect_finish_accepted(v_client, tag(8), GRPC_OP_OK);
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED,
"xyz", NULL);
cq_verify(v_client);
cq_expect_finish_accepted(v_server, tag(9), GRPC_OP_OK);

@ -0,0 +1,214 @@
/*
*
* Copyright 2014, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "test/core/end2end/end2end_tests.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <grpc/byte_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
enum { TIMEOUT = 200000 };
static void *tag(gpr_intptr t) { return (void *)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
const char *test_name,
grpc_channel_args *client_args,
grpc_channel_args *server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
config.init_client(&f, client_args);
config.init_server(&f, server_args);
return f;
}
static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;
grpc_completion_type type;
do {
ev = grpc_completion_queue_next(cq, five_seconds_time());
GPR_ASSERT(ev);
type = ev->type;
grpc_event_finish(ev);
} while (type != GRPC_QUEUE_SHUTDOWN);
}
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown(f->server);
grpc_server_destroy(f->server);
f->server = NULL;
}
static void shutdown_client(grpc_end2end_test_fixture *f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
f->client = NULL;
}
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);
}
/* Request/response with metadata and payload.*/
static void test_request_response_with_metadata_and_payload(
grpc_end2end_test_config config) {
grpc_call *c;
grpc_call *s;
gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
grpc_byte_buffer *request_payload =
grpc_byte_buffer_create(&request_payload_slice, 1);
grpc_byte_buffer *response_payload =
grpc_byte_buffer_create(&response_payload_slice, 1);
gpr_timespec deadline = five_seconds_time();
grpc_metadata meta1 = {"key1", "val1", 4};
grpc_metadata meta2 = {"key2", "val2", 4};
grpc_metadata meta3 = {"key3", "val3", 4};
grpc_metadata meta4 = {"key4", "val4", 4};
grpc_metadata meta5 = {"key5", "val5", 4};
grpc_metadata meta6 = {"key6", "val6", 4};
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
cq_verifier *v_client = cq_verifier_create(f.client_cq);
cq_verifier *v_server = cq_verifier_create(f.server_cq);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, tag(100)));
/* byte buffer holds the slice, we can unref it already */
gpr_slice_unref(request_payload_slice);
gpr_slice_unref(response_payload_slice);
c = grpc_channel_create_call(f.client, "/foo", "test.google.com", deadline);
GPR_ASSERT(c);
/* add multiple metadata */
GPR_ASSERT(GRPC_CALL_OK == grpc_call_add_metadata(c, &meta1, 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_add_metadata(c, &meta2, 0));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_invoke(c, f.client_cq, tag(1), tag(2), tag(3), 0));
cq_expect_invoke_accepted(v_client, tag(1), GRPC_OP_OK);
cq_verify(v_client);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write(c, request_payload, tag(4), 0));
/* destroy byte buffer early to ensure async code keeps track of its contents
correctly */
grpc_byte_buffer_destroy(request_payload);
cq_expect_write_accepted(v_client, tag(4), GRPC_OP_OK);
cq_verify(v_client);
cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "test.google.com",
deadline, "key1", "val1", "key2", "val2", NULL);
cq_verify(v_server);
grpc_call_server_accept(s, f.server_cq, tag(102));
/* add multiple metadata */
GPR_ASSERT(GRPC_CALL_OK == grpc_call_add_metadata(s, &meta3, 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_add_metadata(s, &meta4, 0));
grpc_call_server_end_initial_metadata(s, 0);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_add_metadata(s, &meta5, 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_add_metadata(s, &meta6, 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_read(s, tag(5)));
cq_expect_read(v_server, tag(5), gpr_slice_from_copied_string("hello world"));
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write(s, response_payload, tag(6), 0));
/* destroy byte buffer early to ensure async code keeps track of its contents
correctly */
grpc_byte_buffer_destroy(response_payload);
cq_expect_write_accepted(v_server, tag(6), GRPC_OP_OK);
cq_verify(v_server);
/* fetch metadata.. */
cq_expect_client_metadata_read(v_client, tag(2), "key3", "val3", "key4",
"val4", NULL);
cq_verify(v_client);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_read(c, tag(7)));
cq_expect_read(v_client, tag(7), gpr_slice_from_copied_string("hello you"));
cq_verify(v_client);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done(c, tag(8)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(9)));
cq_expect_finish_accepted(v_client, tag(8), GRPC_OP_OK);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED,
"xyz", "key5", "val5", "key6", "val6", NULL);
cq_verify(v_client);
cq_expect_finish_accepted(v_server, tag(9), GRPC_OP_OK);
cq_expect_finished(v_server, tag(102), NULL);
cq_verify(v_server);
grpc_call_destroy(c);
grpc_call_destroy(s);
end_test(&f);
config.tear_down_data(&f);
cq_verifier_destroy(v_client);
cq_verifier_destroy(v_server);
}
void grpc_end2end_tests(grpc_end2end_test_config config) {
test_request_response_with_metadata_and_payload(config);
}

@ -106,7 +106,6 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void test_request_with_large_metadata(grpc_end2end_test_config config) {
grpc_call *c;
grpc_call *s;
grpc_status send_status = {GRPC_STATUS_OK, NULL};
gpr_timespec deadline = five_seconds_time();
grpc_metadata meta;
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
@ -145,10 +144,10 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done(c, tag(8)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(9)));
grpc_call_start_write_status(s, GRPC_STATUS_OK, NULL, tag(9)));
cq_expect_finish_accepted(v_client, tag(8), GRPC_OP_OK);
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_OK, NULL, NULL);
cq_verify(v_client);
cq_expect_finish_accepted(v_server, tag(9), GRPC_OP_OK);

@ -106,7 +106,6 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
grpc_call *c;
grpc_call *s;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
gpr_slice payload_slice = gpr_slice_from_copied_string("hello world");
grpc_byte_buffer *payload = grpc_byte_buffer_create(&payload_slice, 1);
gpr_timespec deadline = five_seconds_time();
@ -146,10 +145,11 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
cq_expect_read(v_server, tag(4), gpr_slice_from_copied_string("hello world"));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done(c, tag(5)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(6)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(6)));
cq_expect_finish_accepted(v_client, tag(5), GRPC_OP_OK);
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED,
"xyz", NULL);
cq_verify(v_client);
cq_expect_finish_accepted(v_server, tag(6), GRPC_OP_OK);

@ -97,7 +97,6 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
long delay_us) {
grpc_call *c;
grpc_call *s;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
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);
@ -129,9 +128,10 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(5)));
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
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);
cq_expect_finish_accepted(v_server, tag(5), GRPC_OP_OK);

@ -105,7 +105,6 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_call *c;
grpc_call *s;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
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);
@ -131,9 +130,10 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(5)));
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
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);
cq_expect_finish_accepted(v_server, tag(5), GRPC_OP_OK);
@ -152,7 +152,6 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
static void simple_request_body2(grpc_end2end_test_fixture f) {
grpc_call *c;
grpc_call *s;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
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);
@ -176,15 +175,16 @@ static void simple_request_body2(grpc_end2end_test_fixture f) {
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s, f.server_cq, tag(102), 0));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(5)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(5)));
cq_expect_finish_accepted(v_server, tag(5), GRPC_OP_OK);
cq_verify(v_server);
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED,
"xyz", NULL);
cq_verify(v_client);
cq_expect_finished(v_server, tag(102), NULL);

@ -187,10 +187,9 @@ static void request_server_call() {
}
static void maybe_end_server_call(grpc_call *call, gpr_refcount *rc) {
grpc_status ok_status = {GRPC_STATUS_OK, NULL};
if (gpr_unref(rc)) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(call, ok_status, NULL));
grpc_call_start_write_status(call, GRPC_STATUS_OK, NULL, NULL));
gpr_free(rc);
}
}

@ -109,7 +109,6 @@ static void test_writes_done_hangs_with_pending_read(
grpc_end2end_test_config config) {
grpc_call *c;
grpc_call *s;
grpc_status send_status = {GRPC_STATUS_UNIMPLEMENTED, "xyz"};
gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
grpc_byte_buffer *request_payload =
@ -163,8 +162,8 @@ static void test_writes_done_hangs_with_pending_read(
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done(c, tag(6)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write_status(s, send_status, tag(7)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(7)));
cq_expect_finish_accepted(v_client, tag(6), GRPC_OP_OK);
cq_verify(v_client);
@ -176,7 +175,8 @@ static void test_writes_done_hangs_with_pending_read(
cq_expect_read(v_client, tag(8), gpr_slice_from_copied_string("hello you"));
cq_verify(v_client);
cq_expect_finished_with_status(v_client, tag(3), send_status, NULL);
cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED,
"xyz", NULL);
cq_verify(v_client);
cq_expect_finish_accepted(v_server, tag(7), GRPC_OP_OK);

@ -52,8 +52,6 @@ static grpc_completion_queue *cq;
static grpc_server *server;
static int got_sigint = 0;
static const grpc_status status_ok = {GRPC_STATUS_OK, NULL};
typedef struct {
gpr_refcount pending_ops;
gpr_uint32 flags;
@ -149,8 +147,8 @@ int main(int argc, char **argv) {
GPR_ASSERT(grpc_call_start_write(ev->call, ev->data.read, s,
s->flags) == GRPC_CALL_OK);
} else {
GPR_ASSERT(grpc_call_start_write_status(ev->call, status_ok, s) ==
GRPC_CALL_OK);
GPR_ASSERT(grpc_call_start_write_status(ev->call, GRPC_STATUS_OK,
NULL, s) == GRPC_CALL_OK);
}
break;
case GRPC_FINISH_ACCEPTED:

Loading…
Cancel
Save