blob: 381671e3314484c6e8d00e5c40370ea152ba0589 [file] [log] [blame]
ctiller33023c42014-12-12 16:28:33 -08001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
ctiller33023c42014-12-12 16:28:33 -08004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
ctiller33023c42014-12-12 16:28:33 -08008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
ctiller33023c42014-12-12 16:28:33 -080010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
ctiller33023c42014-12-12 16:28:33 -080016 *
17 */
18
19#include "test/core/end2end/end2end_tests.h"
20
21#include <stdio.h>
22#include <string.h>
ctiller33023c42014-12-12 16:28:33 -080023
24#include <grpc/byte_buffer.h>
25#include <grpc/support/alloc.h>
26#include <grpc/support/log.h>
27#include <grpc/support/time.h>
28#include <grpc/support/useful.h>
29#include "test/core/end2end/cq_verifier.h"
30
Craig Tillerbaa14a92017-11-03 09:09:36 -070031static void* tag(intptr_t t) { return (void*)t; }
ctiller33023c42014-12-12 16:28:33 -080032
33static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
Craig Tillerbaa14a92017-11-03 09:09:36 -070034 const char* test_name,
35 grpc_channel_args* client_args,
36 grpc_channel_args* server_args) {
ctiller33023c42014-12-12 16:28:33 -080037 grpc_end2end_test_fixture f;
Robbie Shade55a046a2017-01-25 15:14:28 -050038 gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
ctiller33023c42014-12-12 16:28:33 -080039 f = config.create_fixture(client_args, server_args);
ctiller33023c42014-12-12 16:28:33 -080040 config.init_server(&f, server_args);
Mark D. Rothe127a392016-10-27 08:27:15 -070041 config.init_client(&f, client_args);
ctiller33023c42014-12-12 16:28:33 -080042 return f;
43}
44
Chris Evansed2a5472017-03-27 17:34:51 -050045static gpr_timespec n_seconds_from_now(int n) {
Robbie Shadeca7effc2017-01-17 09:14:29 -050046 return grpc_timeout_seconds_to_deadline(n);
ctiller33023c42014-12-12 16:28:33 -080047}
48
Chris Evansed2a5472017-03-27 17:34:51 -050049static gpr_timespec five_seconds_from_now(void) {
50 return n_seconds_from_now(5);
51}
ctiller33023c42014-12-12 16:28:33 -080052
Craig Tillerbaa14a92017-11-03 09:09:36 -070053static void drain_cq(grpc_completion_queue* cq) {
Craig Tiller64be9f72015-05-04 14:53:51 -070054 grpc_event ev;
ctiller33023c42014-12-12 16:28:33 -080055 do {
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080056 ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
Craig Tiller64be9f72015-05-04 14:53:51 -070057 } while (ev.type != GRPC_QUEUE_SHUTDOWN);
ctiller33023c42014-12-12 16:28:33 -080058}
59
Craig Tillerbaa14a92017-11-03 09:09:36 -070060static void shutdown_server(grpc_end2end_test_fixture* f) {
ctiller33023c42014-12-12 16:28:33 -080061 if (!f->server) return;
Sree Kuchibhotla321881d2017-02-27 11:25:28 -080062 grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
63 GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
64 grpc_timeout_seconds_to_deadline(5),
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080065 nullptr)
Craig Tillerf40df232016-03-25 13:38:14 -070066 .type == GRPC_OP_COMPLETE);
ctiller33023c42014-12-12 16:28:33 -080067 grpc_server_destroy(f->server);
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080068 f->server = nullptr;
ctiller33023c42014-12-12 16:28:33 -080069}
70
Craig Tillerbaa14a92017-11-03 09:09:36 -070071static void shutdown_client(grpc_end2end_test_fixture* f) {
ctiller33023c42014-12-12 16:28:33 -080072 if (!f->client) return;
73 grpc_channel_destroy(f->client);
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080074 f->client = nullptr;
ctiller33023c42014-12-12 16:28:33 -080075}
76
Craig Tillerbaa14a92017-11-03 09:09:36 -070077static void end_test(grpc_end2end_test_fixture* f) {
ctiller33023c42014-12-12 16:28:33 -080078 shutdown_server(f);
79 shutdown_client(f);
80
Craig Tillerbc0ec332015-05-11 12:11:32 -070081 grpc_completion_queue_shutdown(f->cq);
82 drain_cq(f->cq);
83 grpc_completion_queue_destroy(f->cq);
Sree Kuchibhotla321881d2017-02-27 11:25:28 -080084 grpc_completion_queue_destroy(f->shutdown_cq);
ctiller33023c42014-12-12 16:28:33 -080085}
86
87/* Request/response with metadata and payload.*/
88static void test_request_response_with_metadata_and_payload(
89 grpc_end2end_test_config config) {
Craig Tillerbaa14a92017-11-03 09:09:36 -070090 grpc_call* c;
91 grpc_call* s;
Craig Tiller28b72422016-10-26 21:15:29 -070092 grpc_slice request_payload_slice =
93 grpc_slice_from_copied_string("hello world");
94 grpc_slice response_payload_slice =
95 grpc_slice_from_copied_string("hello you");
Craig Tillerbaa14a92017-11-03 09:09:36 -070096 grpc_byte_buffer* request_payload =
David Garcia Quintas59f905d2015-06-08 16:31:19 -070097 grpc_raw_byte_buffer_create(&request_payload_slice, 1);
Craig Tillerbaa14a92017-11-03 09:09:36 -070098 grpc_byte_buffer* response_payload =
David Garcia Quintas59f905d2015-06-08 16:31:19 -070099 grpc_raw_byte_buffer_create(&response_payload_slice, 1);
Craig Tillerbea38402015-02-05 13:01:33 -0800100 grpc_metadata meta_c[2] = {
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800101 {grpc_slice_from_static_string("key1-bin"),
102 grpc_slice_from_static_string(
103 "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc"),
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200104 0,
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800105 {{nullptr, nullptr, nullptr, nullptr}}},
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800106 {grpc_slice_from_static_string("key2-bin"),
107 grpc_slice_from_static_string(
108 "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d"),
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200109 0,
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800110 {{nullptr, nullptr, nullptr, nullptr}}}};
Craig Tillerbea38402015-02-05 13:01:33 -0800111 grpc_metadata meta_s[2] = {
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800112 {grpc_slice_from_static_string("key3-bin"),
113 grpc_slice_from_static_string(
114 "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee"),
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200115 0,
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800116 {{nullptr, nullptr, nullptr, nullptr}}},
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800117 {grpc_slice_from_static_string("key4-bin"),
118 grpc_slice_from_static_string(
119 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"),
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200120 0,
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800121 {{nullptr, nullptr, nullptr, nullptr}}}};
Craig Tillerbe98d242017-11-10 15:26:57 -0800122 grpc_end2end_test_fixture f =
123 begin_test(config, "test_request_response_with_metadata_and_payload",
124 nullptr, nullptr);
Craig Tillerbaa14a92017-11-03 09:09:36 -0700125 cq_verifier* cqv = cq_verifier_create(f.cq);
Craig Tillerbea38402015-02-05 13:01:33 -0800126 grpc_op ops[6];
Craig Tillerbaa14a92017-11-03 09:09:36 -0700127 grpc_op* op;
Craig Tillerbea38402015-02-05 13:01:33 -0800128 grpc_metadata_array initial_metadata_recv;
129 grpc_metadata_array trailing_metadata_recv;
130 grpc_metadata_array request_metadata_recv;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800131 grpc_byte_buffer* request_payload_recv = nullptr;
132 grpc_byte_buffer* response_payload_recv = nullptr;
Craig Tillerbea38402015-02-05 13:01:33 -0800133 grpc_call_details call_details;
134 grpc_status_code status;
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200135 grpc_call_error error;
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800136 grpc_slice details;
Craig Tillerbea38402015-02-05 13:01:33 -0800137 int was_cancelled = 2;
ctiller33023c42014-12-12 16:28:33 -0800138
Chris Evansed2a5472017-03-27 17:34:51 -0500139 gpr_timespec deadline = five_seconds_from_now();
Muxi Yan5ebd3272016-10-31 07:27:07 -0700140 c = grpc_channel_create_call(
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800141 f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800142 grpc_slice_from_static_string("/foo"),
143 get_host_override_slice("foo.test.google.fr:1234", config), deadline,
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800144 nullptr);
ctiller33023c42014-12-12 16:28:33 -0800145 GPR_ASSERT(c);
146
Craig Tillerbea38402015-02-05 13:01:33 -0800147 grpc_metadata_array_init(&initial_metadata_recv);
148 grpc_metadata_array_init(&trailing_metadata_recv);
149 grpc_metadata_array_init(&request_metadata_recv);
150 grpc_call_details_init(&call_details);
ctiller33023c42014-12-12 16:28:33 -0800151
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700152 memset(ops, 0, sizeof(ops));
Craig Tillerbea38402015-02-05 13:01:33 -0800153 op = ops;
154 op->op = GRPC_OP_SEND_INITIAL_METADATA;
155 op->data.send_initial_metadata.count = 2;
156 op->data.send_initial_metadata.metadata = meta_c;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700157 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800158 op->reserved = nullptr;
Craig Tillerbea38402015-02-05 13:01:33 -0800159 op++;
160 op->op = GRPC_OP_SEND_MESSAGE;
Mark D. Roth435f9f22017-01-25 12:53:54 -0800161 op->data.send_message.send_message = request_payload;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700162 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800163 op->reserved = nullptr;
Craig Tillerbea38402015-02-05 13:01:33 -0800164 op++;
165 op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700166 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800167 op->reserved = nullptr;
Craig Tillerbea38402015-02-05 13:01:33 -0800168 op++;
169 op->op = GRPC_OP_RECV_INITIAL_METADATA;
Mark D. Roth435f9f22017-01-25 12:53:54 -0800170 op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700171 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800172 op->reserved = nullptr;
Craig Tillerbea38402015-02-05 13:01:33 -0800173 op++;
174 op->op = GRPC_OP_RECV_MESSAGE;
Mark D. Roth435f9f22017-01-25 12:53:54 -0800175 op->data.recv_message.recv_message = &response_payload_recv;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700176 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800177 op->reserved = nullptr;
Craig Tillerbea38402015-02-05 13:01:33 -0800178 op++;
179 op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
180 op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
181 op->data.recv_status_on_client.status = &status;
182 op->data.recv_status_on_client.status_details = &details;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700183 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800184 op->reserved = nullptr;
Craig Tillerbea38402015-02-05 13:01:33 -0800185 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800186 error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200187 GPR_ASSERT(GRPC_CALL_OK == error);
ctiller33023c42014-12-12 16:28:33 -0800188
Craig Tillerd6c98df2015-08-18 09:33:44 -0700189 error =
190 grpc_server_request_call(f.server, &s, &call_details,
191 &request_metadata_recv, f.cq, f.cq, tag(101));
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200192 GPR_ASSERT(GRPC_CALL_OK == error);
Mark D. Roth7187ab92016-08-24 13:49:22 -0700193 CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
Craig Tillerbc0ec332015-05-11 12:11:32 -0700194 cq_verify(cqv);
ctiller33023c42014-12-12 16:28:33 -0800195
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700196 memset(ops, 0, sizeof(ops));
Craig Tillerbea38402015-02-05 13:01:33 -0800197 op = ops;
198 op->op = GRPC_OP_SEND_INITIAL_METADATA;
199 op->data.send_initial_metadata.count = 2;
200 op->data.send_initial_metadata.metadata = meta_s;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700201 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800202 op->reserved = nullptr;
Craig Tillerbea38402015-02-05 13:01:33 -0800203 op++;
Craig Tiller4541f332015-05-19 16:26:33 -0700204 op->op = GRPC_OP_RECV_MESSAGE;
Mark D. Roth435f9f22017-01-25 12:53:54 -0800205 op->data.recv_message.recv_message = &request_payload_recv;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700206 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800207 op->reserved = nullptr;
Craig Tiller4541f332015-05-19 16:26:33 -0700208 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800209 error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200210 GPR_ASSERT(GRPC_CALL_OK == error);
Craig Tiller4541f332015-05-19 16:26:33 -0700211
Mark D. Roth7187ab92016-08-24 13:49:22 -0700212 CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
Craig Tiller595cc5b2015-05-24 16:46:13 -0700213 cq_verify(cqv);
Craig Tiller4541f332015-05-19 16:26:33 -0700214
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700215 memset(ops, 0, sizeof(ops));
Craig Tiller4541f332015-05-19 16:26:33 -0700216 op = ops;
217 op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
218 op->data.recv_close_on_server.cancelled = &was_cancelled;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700219 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800220 op->reserved = nullptr;
Craig Tiller4541f332015-05-19 16:26:33 -0700221 op++;
Craig Tillerbea38402015-02-05 13:01:33 -0800222 op->op = GRPC_OP_SEND_MESSAGE;
Mark D. Roth435f9f22017-01-25 12:53:54 -0800223 op->data.send_message.send_message = response_payload;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700224 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800225 op->reserved = nullptr;
Craig Tillerbea38402015-02-05 13:01:33 -0800226 op++;
227 op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
228 op->data.send_status_from_server.trailing_metadata_count = 0;
Craig Tillerd1abc812015-05-06 14:35:19 -0700229 op->data.send_status_from_server.status = GRPC_STATUS_OK;
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800230 grpc_slice status_string = grpc_slice_from_static_string(
Craig Tillerb121fc72016-11-03 15:22:59 -0700231 "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12"
232 "\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24"
233 "\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36"
234 "\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48"
235 "\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a"
236 "\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c"
237 "\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e"
238 "\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90"
239 "\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2"
240 "\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4"
241 "\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6"
242 "\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8"
243 "\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea"
244 "\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc"
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800245 "\xfd\xfe\xff");
246 op->data.send_status_from_server.status_details = &status_string;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700247 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800248 op->reserved = nullptr;
Craig Tillerbea38402015-02-05 13:01:33 -0800249 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800250 error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200251 GPR_ASSERT(GRPC_CALL_OK == error);
ctiller33023c42014-12-12 16:28:33 -0800252
Mark D. Roth7187ab92016-08-24 13:49:22 -0700253 CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
254 CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
Craig Tillerbc0ec332015-05-11 12:11:32 -0700255 cq_verify(cqv);
ctiller33023c42014-12-12 16:28:33 -0800256
Craig Tillerd1abc812015-05-06 14:35:19 -0700257 GPR_ASSERT(status == GRPC_STATUS_OK);
Craig Tillerb121fc72016-11-03 15:22:59 -0700258 GPR_ASSERT(
259 0 ==
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800260 grpc_slice_str_cmp(
261 details,
262 "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
263 "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
264 "\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30"
265 "\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40"
266 "\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50"
267 "\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60"
268 "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
269 "\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80"
270 "\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90"
271 "\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0"
272 "\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0"
273 "\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0"
274 "\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0"
275 "\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0"
276 "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0"
277 "\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"));
278 GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
Muxi Yan5ebd3272016-10-31 07:27:07 -0700279 validate_host_override_string("foo.test.google.fr:1234", call_details.host,
280 config);
Craig Tillere801eb32015-02-10 14:01:14 -0800281 GPR_ASSERT(was_cancelled == 0);
Craig Tillerbea38402015-02-05 13:01:33 -0800282 GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world"));
283 GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you"));
284 GPR_ASSERT(contains_metadata(
285 &request_metadata_recv, "key1-bin",
286 "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc"));
287 GPR_ASSERT(contains_metadata(
288 &request_metadata_recv, "key2-bin",
289 "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d"));
290 GPR_ASSERT(contains_metadata(
291 &initial_metadata_recv, "key3-bin",
292 "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee"));
293 GPR_ASSERT(contains_metadata(
294 &initial_metadata_recv, "key4-bin",
295 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"));
ctiller33023c42014-12-12 16:28:33 -0800296
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800297 grpc_slice_unref(details);
Craig Tillerbea38402015-02-05 13:01:33 -0800298 grpc_metadata_array_destroy(&initial_metadata_recv);
299 grpc_metadata_array_destroy(&trailing_metadata_recv);
300 grpc_metadata_array_destroy(&request_metadata_recv);
301 grpc_call_details_destroy(&call_details);
ctiller33023c42014-12-12 16:28:33 -0800302
Craig Tillerdd36b152017-03-31 08:27:28 -0700303 grpc_call_unref(c);
304 grpc_call_unref(s);
ctiller33023c42014-12-12 16:28:33 -0800305
Craig Tillerbc0ec332015-05-11 12:11:32 -0700306 cq_verifier_destroy(cqv);
Craig Tillerbea38402015-02-05 13:01:33 -0800307
308 grpc_byte_buffer_destroy(request_payload);
309 grpc_byte_buffer_destroy(response_payload);
310 grpc_byte_buffer_destroy(request_payload_recv);
311 grpc_byte_buffer_destroy(response_payload_recv);
312
313 end_test(&f);
314 config.tear_down_data(&f);
ctiller33023c42014-12-12 16:28:33 -0800315}
316
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800317void binary_metadata(grpc_end2end_test_config config) {
ctiller33023c42014-12-12 16:28:33 -0800318 test_request_response_with_metadata_and_payload(config);
Craig Tiller190d3602015-02-18 09:23:38 -0800319}
Craig Tiller9e9edbc2016-04-04 10:38:49 -0700320
321void binary_metadata_pre_init(void) {}