Skip to content

Commit a3b803c

Browse files
committed
Added another test case for status ordering
1 parent acd07f7 commit a3b803c

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

test/core/end2end/tests/streaming_error_response.cc

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ static void end_test(grpc_end2end_test_fixture* f) {
8989
}
9090

9191
/* Client sends a request with payload, server reads then returns status. */
92-
static void test(grpc_end2end_test_config config, bool request_status_early) {
92+
static void test(grpc_end2end_test_config config, bool request_status_early,
93+
bool recv_message_separately) {
9394
grpc_call* c;
9495
grpc_call* s;
9596
grpc_slice response_payload1_slice = grpc_slice_from_copied_string("hello");
@@ -116,6 +117,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
116117
int was_cancelled = 2;
117118

118119
gpr_timespec deadline = five_seconds_from_now();
120+
GPR_ASSERT(!recv_message_separately || request_status_early);
119121
c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
120122
grpc_slice_from_static_string("/foo"), nullptr,
121123
deadline, nullptr);
@@ -136,9 +138,11 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
136138
op->op = GRPC_OP_RECV_INITIAL_METADATA;
137139
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
138140
op++;
139-
op->op = GRPC_OP_RECV_MESSAGE;
140-
op->data.recv_message.recv_message = &response_payload1_recv;
141-
op++;
141+
if (!recv_message_separately) {
142+
op->op = GRPC_OP_RECV_MESSAGE;
143+
op->data.recv_message.recv_message = &response_payload1_recv;
144+
op++;
145+
}
142146
if (request_status_early) {
143147
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
144148
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
@@ -168,10 +172,24 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
168172
nullptr);
169173
GPR_ASSERT(GRPC_CALL_OK == error);
170174

175+
if (recv_message_separately) {
176+
memset(ops, 0, sizeof(ops));
177+
op = ops;
178+
op->op = GRPC_OP_RECV_MESSAGE;
179+
op->data.recv_message.recv_message = &response_payload1_recv;
180+
op++;
181+
error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(4),
182+
nullptr);
183+
GPR_ASSERT(GRPC_CALL_OK == error);
184+
}
185+
171186
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
172187
if (!request_status_early) {
173188
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
174189
}
190+
if (recv_message_separately) {
191+
CQ_EXPECT_COMPLETION(cqv, tag(4), 1);
192+
}
175193
cq_verify(cqv);
176194

177195
memset(ops, 0, sizeof(ops));
@@ -265,8 +283,9 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
265283
}
266284

267285
void streaming_error_response(grpc_end2end_test_config config) {
268-
test(config, false);
269-
test(config, true);
286+
test(config, false, false);
287+
test(config, true, false);
288+
test(config, true, true);
270289
}
271290

272291
void streaming_error_response_pre_init(void) {}

0 commit comments

Comments
 (0)