blob: 1e29b6668bb51972bc414f197f4cdbe3c7cd037d [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001/*
2 *
Craig Tiller06059952015-02-18 08:34:56 -08003 * Copyright 2015, Google Inc.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34#include "test/core/end2end/end2end_tests.h"
35
36#include <stdio.h>
37#include <string.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080038
39#include <grpc/byte_buffer.h>
40#include <grpc/support/alloc.h>
41#include <grpc/support/log.h>
42#include <grpc/support/time.h>
43#include <grpc/support/useful.h>
44#include "test/core/end2end/cq_verifier.h"
45
46enum { TIMEOUT = 200000 };
47
48static void *tag(gpr_intptr t) { return (void *)t; }
49
50static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
51 const char *test_name,
52 grpc_channel_args *client_args,
53 grpc_channel_args *server_args) {
54 grpc_end2end_test_fixture f;
55 gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
56 f = config.create_fixture(client_args, server_args);
57 config.init_client(&f, client_args);
58 config.init_server(&f, server_args);
59 return f;
60}
61
62static gpr_timespec n_seconds_time(int n) {
Craig Tiller8ad8a412015-02-25 08:36:40 -080063 return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080064}
65
Craig Tiller32946d32015-01-15 11:37:30 -080066static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080067
68static void drain_cq(grpc_completion_queue *cq) {
Craig Tiller64be9f72015-05-04 14:53:51 -070069 grpc_event ev;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080070 do {
71 ev = grpc_completion_queue_next(cq, five_seconds_time());
Craig Tiller64be9f72015-05-04 14:53:51 -070072 } while (ev.type != GRPC_QUEUE_SHUTDOWN);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080073}
74
75static void shutdown_server(grpc_end2end_test_fixture *f) {
76 if (!f->server) return;
77 grpc_server_shutdown(f->server);
78 grpc_server_destroy(f->server);
79 f->server = NULL;
80}
81
82static void shutdown_client(grpc_end2end_test_fixture *f) {
83 if (!f->client) return;
84 grpc_channel_destroy(f->client);
85 f->client = NULL;
86}
87
88static void end_test(grpc_end2end_test_fixture *f) {
89 shutdown_server(f);
90 shutdown_client(f);
91
92 grpc_completion_queue_shutdown(f->server_cq);
93 drain_cq(f->server_cq);
94 grpc_completion_queue_destroy(f->server_cq);
95 grpc_completion_queue_shutdown(f->client_cq);
96 drain_cq(f->client_cq);
97 grpc_completion_queue_destroy(f->client_cq);
98}
99
100static void simple_request_body(grpc_end2end_test_fixture f) {
101 grpc_call *c;
102 grpc_call *s;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800103 gpr_timespec deadline = five_seconds_time();
104 cq_verifier *v_client = cq_verifier_create(f.client_cq);
105 cq_verifier *v_server = cq_verifier_create(f.server_cq);
Craig Tiller8b1d9892015-04-28 14:28:19 -0700106 grpc_op ops[6];
107 grpc_op *op;
108 grpc_metadata_array initial_metadata_recv;
109 grpc_metadata_array trailing_metadata_recv;
110 grpc_metadata_array request_metadata_recv;
111 grpc_call_details call_details;
112 grpc_status_code status;
113 char *details = NULL;
114 size_t details_capacity = 0;
115 int was_cancelled = 2;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800116
Craig Tiller8b1d9892015-04-28 14:28:19 -0700117 c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
118 "foo.test.google.fr:1234", deadline);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800119 GPR_ASSERT(c);
120
Craig Tiller8b1d9892015-04-28 14:28:19 -0700121 grpc_metadata_array_init(&initial_metadata_recv);
122 grpc_metadata_array_init(&trailing_metadata_recv);
123 grpc_metadata_array_init(&request_metadata_recv);
124 grpc_call_details_init(&call_details);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800125
Craig Tiller8b1d9892015-04-28 14:28:19 -0700126 op = ops;
127 op->op = GRPC_OP_SEND_INITIAL_METADATA;
128 op->data.send_initial_metadata.count = 0;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700129 op->flags = 0;
Craig Tiller8b1d9892015-04-28 14:28:19 -0700130 op++;
131 op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700132 op->flags = 0;
Craig Tiller8b1d9892015-04-28 14:28:19 -0700133 op++;
134 op->op = GRPC_OP_RECV_INITIAL_METADATA;
135 op->data.recv_initial_metadata = &initial_metadata_recv;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700136 op->flags = 0;
Craig Tiller8b1d9892015-04-28 14:28:19 -0700137 op++;
138 op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
139 op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
140 op->data.recv_status_on_client.status = &status;
141 op->data.recv_status_on_client.status_details = &details;
142 op->data.recv_status_on_client.status_details_capacity = &details_capacity;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700143 op->flags = 0;
Craig Tiller8b1d9892015-04-28 14:28:19 -0700144 op++;
145 GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800146
Craig Tillerf9e6adf2015-05-06 11:45:59 -0700147 GPR_ASSERT(GRPC_CALL_OK ==
148 grpc_server_request_call(f.server, &s, &call_details,
149 &request_metadata_recv, f.server_cq,
150 f.server_cq, tag(101)));
Craig Tiller64be9f72015-05-04 14:53:51 -0700151 cq_expect_completion(v_server, tag(101), 1);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800152 cq_verify(v_server);
153
Craig Tiller8b1d9892015-04-28 14:28:19 -0700154 op = ops;
155 op->op = GRPC_OP_SEND_INITIAL_METADATA;
156 op->data.send_initial_metadata.count = 0;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700157 op->flags = 0;
Craig Tiller8b1d9892015-04-28 14:28:19 -0700158 op++;
159 op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
160 op->data.send_status_from_server.trailing_metadata_count = 0;
161 op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
162 op->data.send_status_from_server.status_details = "xyz";
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700163 op->flags = 0;
Craig Tiller8b1d9892015-04-28 14:28:19 -0700164 op++;
165 op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
166 op->data.recv_close_on_server.cancelled = &was_cancelled;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700167 op->flags = 0;
Craig Tiller8b1d9892015-04-28 14:28:19 -0700168 op++;
169 GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800170
Craig Tiller64be9f72015-05-04 14:53:51 -0700171 cq_expect_completion(v_server, tag(102), 1);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800172 cq_verify(v_server);
173
Craig Tiller64be9f72015-05-04 14:53:51 -0700174 cq_expect_completion(v_client, tag(1), 1);
Craig Tiller8b1d9892015-04-28 14:28:19 -0700175 cq_verify(v_client);
176
177 GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
178 GPR_ASSERT(0 == strcmp(details, "xyz"));
179 GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
180 GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234"));
181 GPR_ASSERT(was_cancelled == 0);
182
183 gpr_free(details);
184 grpc_metadata_array_destroy(&initial_metadata_recv);
185 grpc_metadata_array_destroy(&trailing_metadata_recv);
186 grpc_metadata_array_destroy(&request_metadata_recv);
187 grpc_call_details_destroy(&call_details);
188
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800189 grpc_call_destroy(c);
190 grpc_call_destroy(s);
191
192 cq_verifier_destroy(v_client);
193 cq_verifier_destroy(v_server);
194}
195
196static void test_max_concurrent_streams(grpc_end2end_test_config config) {
197 grpc_end2end_test_fixture f;
198 grpc_arg server_arg;
199 grpc_channel_args server_args;
200 grpc_call *c1;
201 grpc_call *c2;
202 grpc_call *s1;
203 grpc_call *s2;
ctiller58393c22015-01-07 14:03:30 -0800204 int live_call;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800205 gpr_timespec deadline;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800206 cq_verifier *v_client;
207 cq_verifier *v_server;
Craig Tiller64be9f72015-05-04 14:53:51 -0700208 grpc_event ev;
Craig Tiller3b05a122015-04-28 15:14:40 -0700209 grpc_call_details call_details;
210 grpc_metadata_array request_metadata_recv;
211 grpc_metadata_array initial_metadata_recv1;
212 grpc_metadata_array trailing_metadata_recv1;
213 grpc_metadata_array initial_metadata_recv2;
214 grpc_metadata_array trailing_metadata_recv2;
215 grpc_status_code status1;
216 char *details1 = NULL;
217 size_t details_capacity1 = 0;
218 grpc_status_code status2;
219 char *details2 = NULL;
220 size_t details_capacity2 = 0;
Craig Tillerfe2b8352015-04-28 15:46:50 -0700221 grpc_op ops[6];
222 grpc_op *op;
223 int was_cancelled;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800224
225 server_arg.key = GRPC_ARG_MAX_CONCURRENT_STREAMS;
226 server_arg.type = GRPC_ARG_INTEGER;
227 server_arg.value.integer = 1;
228
229 server_args.num_args = 1;
230 server_args.args = &server_arg;
231
Craig Tiller35696192015-05-24 15:00:37 -0700232 f = begin_test(config, "test_max_concurrent_streams", NULL, &server_args);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800233 v_client = cq_verifier_create(f.client_cq);
234 v_server = cq_verifier_create(f.server_cq);
235
Craig Tiller3b05a122015-04-28 15:14:40 -0700236 grpc_metadata_array_init(&request_metadata_recv);
Craig Tillerf1071202015-04-30 13:29:48 -0700237 grpc_metadata_array_init(&initial_metadata_recv1);
238 grpc_metadata_array_init(&trailing_metadata_recv1);
239 grpc_metadata_array_init(&initial_metadata_recv2);
240 grpc_metadata_array_init(&trailing_metadata_recv2);
241 grpc_call_details_init(&call_details);
Craig Tiller3b05a122015-04-28 15:14:40 -0700242
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800243 /* perform a ping-pong to ensure that settings have had a chance to round
244 trip */
245 simple_request_body(f);
246 /* perform another one to make sure that the one stream case still works */
247 simple_request_body(f);
248
249 /* start two requests - ensuring that the second is not accepted until
250 the first completes */
Craig Tillerf1071202015-04-30 13:29:48 -0700251 deadline = n_seconds_time(10);
Craig Tiller3b05a122015-04-28 15:14:40 -0700252 c1 = grpc_channel_create_call(f.client, f.client_cq, "/alpha",
Craig Tiller9f3675f2015-04-29 13:56:33 -0700253 "foo.test.google.fr:1234", deadline);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800254 GPR_ASSERT(c1);
Craig Tiller3b05a122015-04-28 15:14:40 -0700255 c2 = grpc_channel_create_call(f.client, f.client_cq, "/beta",
Craig Tiller9f3675f2015-04-29 13:56:33 -0700256 "foo.test.google.fr:1234", deadline);
Craig Tiller3b05a122015-04-28 15:14:40 -0700257 GPR_ASSERT(c2);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800258
Craig Tillerf9e6adf2015-05-06 11:45:59 -0700259 GPR_ASSERT(GRPC_CALL_OK ==
260 grpc_server_request_call(f.server, &s1, &call_details,
261 &request_metadata_recv, f.server_cq,
262 f.server_cq, tag(101)));
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800263
Craig Tiller3b05a122015-04-28 15:14:40 -0700264 op = ops;
265 op->op = GRPC_OP_SEND_INITIAL_METADATA;
266 op->data.send_initial_metadata.count = 0;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700267 op->flags = 0;
Craig Tiller3b05a122015-04-28 15:14:40 -0700268 op++;
269 op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700270 op->flags = 0;
Craig Tiller3b05a122015-04-28 15:14:40 -0700271 op++;
Craig Tiller9f3675f2015-04-29 13:56:33 -0700272 GPR_ASSERT(GRPC_CALL_OK ==
273 grpc_call_start_batch(c1, ops, op - ops, tag(301)));
Craig Tiller3b05a122015-04-28 15:14:40 -0700274
275 op = ops;
276 op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
Craig Tillerfe2b8352015-04-28 15:46:50 -0700277 op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv1;
278 op->data.recv_status_on_client.status = &status1;
279 op->data.recv_status_on_client.status_details = &details1;
280 op->data.recv_status_on_client.status_details_capacity = &details_capacity1;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700281 op->flags = 0;
Craig Tiller3b05a122015-04-28 15:14:40 -0700282 op++;
Craig Tiller06eb5ae2015-04-30 13:48:58 -0700283 op->op = GRPC_OP_RECV_INITIAL_METADATA;
284 op->data.recv_initial_metadata = &initial_metadata_recv1;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700285 op->flags = 0;
Craig Tiller06eb5ae2015-04-30 13:48:58 -0700286 op++;
Craig Tiller9f3675f2015-04-29 13:56:33 -0700287 GPR_ASSERT(GRPC_CALL_OK ==
288 grpc_call_start_batch(c1, ops, op - ops, tag(302)));
Craig Tiller3b05a122015-04-28 15:14:40 -0700289
290 op = ops;
291 op->op = GRPC_OP_SEND_INITIAL_METADATA;
292 op->data.send_initial_metadata.count = 0;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700293 op->flags = 0;
Craig Tiller3b05a122015-04-28 15:14:40 -0700294 op++;
295 op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700296 op->flags = 0;
Craig Tiller3b05a122015-04-28 15:14:40 -0700297 op++;
Craig Tiller9f3675f2015-04-29 13:56:33 -0700298 GPR_ASSERT(GRPC_CALL_OK ==
299 grpc_call_start_batch(c2, ops, op - ops, tag(401)));
Craig Tiller3b05a122015-04-28 15:14:40 -0700300
301 op = ops;
302 op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
Craig Tillerfe2b8352015-04-28 15:46:50 -0700303 op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv2;
304 op->data.recv_status_on_client.status = &status2;
305 op->data.recv_status_on_client.status_details = &details2;
306 op->data.recv_status_on_client.status_details_capacity = &details_capacity2;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700307 op->flags = 0;
Craig Tiller3b05a122015-04-28 15:14:40 -0700308 op++;
Craig Tiller06eb5ae2015-04-30 13:48:58 -0700309 op->op = GRPC_OP_RECV_INITIAL_METADATA;
310 op->data.recv_initial_metadata = &initial_metadata_recv1;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700311 op->flags = 0;
Craig Tiller06eb5ae2015-04-30 13:48:58 -0700312 op++;
Craig Tiller9f3675f2015-04-29 13:56:33 -0700313 GPR_ASSERT(GRPC_CALL_OK ==
314 grpc_call_start_batch(c2, ops, op - ops, tag(402)));
Craig Tiller80fa15c2015-01-13 16:10:49 -0800315
Craig Tiller64be9f72015-05-04 14:53:51 -0700316 cq_expect_completion(v_server, tag(101), 1);
Craig Tiller06eb5ae2015-04-30 13:48:58 -0700317 cq_verify(v_server);
318
Craig Tillerf1071202015-04-30 13:29:48 -0700319 ev = grpc_completion_queue_next(f.client_cq,
320 GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3));
Craig Tiller64be9f72015-05-04 14:53:51 -0700321 GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
322 GPR_ASSERT(ev.success);
323 GPR_ASSERT(ev.tag == tag(301) || ev.tag == tag(401));
ctiller58393c22015-01-07 14:03:30 -0800324 /* The /alpha or /beta calls started above could be invoked (but NOT both);
325 * check this here */
Craig Tillerfc84e7b2015-01-13 16:49:44 -0800326 /* We'll get tag 303 or 403, we want 300, 400 */
Craig Tiller64be9f72015-05-04 14:53:51 -0700327 live_call = ((int)(gpr_intptr)ev.tag) - 1;
ctiller58393c22015-01-07 14:03:30 -0800328
Craig Tiller3b05a122015-04-28 15:14:40 -0700329 op = ops;
330 op->op = GRPC_OP_SEND_INITIAL_METADATA;
331 op->data.send_initial_metadata.count = 0;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700332 op->flags = 0;
Craig Tiller3b05a122015-04-28 15:14:40 -0700333 op++;
334 op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
335 op->data.recv_close_on_server.cancelled = &was_cancelled;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700336 op->flags = 0;
Craig Tiller3b05a122015-04-28 15:14:40 -0700337 op++;
Craig Tiller3b05a122015-04-28 15:14:40 -0700338 op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
339 op->data.send_status_from_server.trailing_metadata_count = 0;
340 op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
341 op->data.send_status_from_server.status_details = "xyz";
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700342 op->flags = 0;
Craig Tiller3b05a122015-04-28 15:14:40 -0700343 op++;
Craig Tiller9f3675f2015-04-29 13:56:33 -0700344 GPR_ASSERT(GRPC_CALL_OK ==
Craig Tiller06eb5ae2015-04-30 13:48:58 -0700345 grpc_call_start_batch(s1, ops, op - ops, tag(102)));
Craig Tiller3b05a122015-04-28 15:14:40 -0700346
Craig Tiller64be9f72015-05-04 14:53:51 -0700347 cq_expect_completion(v_server, tag(102), 1);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800348 cq_verify(v_server);
349
Craig Tiller64be9f72015-05-04 14:53:51 -0700350 cq_expect_completion(v_client, tag(live_call + 2), 1);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800351 /* first request is finished, we should be able to start the second */
Craig Tillerbf444932015-01-13 17:13:08 -0800352 live_call = (live_call == 300) ? 400 : 300;
Craig Tiller64be9f72015-05-04 14:53:51 -0700353 cq_expect_completion(v_client, tag(live_call + 1), 1);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800354 cq_verify(v_client);
355
Craig Tillerf9e6adf2015-05-06 11:45:59 -0700356 GPR_ASSERT(GRPC_CALL_OK ==
357 grpc_server_request_call(f.server, &s2, &call_details,
358 &request_metadata_recv, f.server_cq,
359 f.server_cq, tag(201)));
Craig Tiller64be9f72015-05-04 14:53:51 -0700360 cq_expect_completion(v_server, tag(201), 1);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800361 cq_verify(v_server);
362
Craig Tiller3b05a122015-04-28 15:14:40 -0700363 op = ops;
364 op->op = GRPC_OP_SEND_INITIAL_METADATA;
365 op->data.send_initial_metadata.count = 0;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700366 op->flags = 0;
Craig Tiller3b05a122015-04-28 15:14:40 -0700367 op++;
368 op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
369 op->data.recv_close_on_server.cancelled = &was_cancelled;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700370 op->flags = 0;
Craig Tiller3b05a122015-04-28 15:14:40 -0700371 op++;
Craig Tillerfe2b8352015-04-28 15:46:50 -0700372 op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
373 op->data.send_status_from_server.trailing_metadata_count = 0;
374 op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
375 op->data.send_status_from_server.status_details = "xyz";
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700376 op->flags = 0;
Craig Tillerfe2b8352015-04-28 15:46:50 -0700377 op++;
Craig Tiller9f3675f2015-04-29 13:56:33 -0700378 GPR_ASSERT(GRPC_CALL_OK ==
Craig Tiller06eb5ae2015-04-30 13:48:58 -0700379 grpc_call_start_batch(s2, ops, op - ops, tag(202)));
380
Craig Tiller64be9f72015-05-04 14:53:51 -0700381 cq_expect_completion(v_client, tag(live_call + 2), 1);
Craig Tiller06eb5ae2015-04-30 13:48:58 -0700382 cq_verify(v_client);
Craig Tillerfe2b8352015-04-28 15:46:50 -0700383
Craig Tiller64be9f72015-05-04 14:53:51 -0700384 cq_expect_completion(v_server, tag(202), 1);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800385 cq_verify(v_server);
386
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800387 cq_verifier_destroy(v_client);
388 cq_verifier_destroy(v_server);
389
390 grpc_call_destroy(c1);
391 grpc_call_destroy(s1);
392 grpc_call_destroy(c2);
393 grpc_call_destroy(s2);
394
Craig Tiller5fe7e5d2015-05-01 10:52:35 -0700395 gpr_free(details1);
396 gpr_free(details2);
397 grpc_metadata_array_destroy(&initial_metadata_recv1);
398 grpc_metadata_array_destroy(&trailing_metadata_recv1);
399 grpc_metadata_array_destroy(&initial_metadata_recv2);
400 grpc_metadata_array_destroy(&trailing_metadata_recv2);
401 grpc_metadata_array_destroy(&request_metadata_recv);
402 grpc_call_details_destroy(&call_details);
403
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800404 end_test(&f);
405 config.tear_down_data(&f);
406}
407
408void grpc_end2end_tests(grpc_end2end_test_config config) {
409 test_max_concurrent_streams(config);
Craig Tiller190d3602015-02-18 09:23:38 -0800410}