blob: 7ac5fefa229b1301915f0b12a6f75228220db5f5 [file] [log] [blame]
Craig Tiller027a74c2015-11-10 08:37:46 +00001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
Craig Tiller027a74c2015-11-10 08:37:46 +00004 *
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
Craig Tiller027a74c2015-11-10 08:37:46 +00008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Craig Tiller027a74c2015-11-10 08:37:46 +000010 *
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.
Craig Tiller027a74c2015-11-10 08:37:46 +000016 *
17 */
18
19#include "test/core/end2end/end2end_tests.h"
20
21#include <stdio.h>
22#include <string.h>
23
24#include <grpc/byte_buffer.h>
25#include <grpc/grpc.h>
26#include <grpc/support/alloc.h>
27#include <grpc/support/log.h>
28#include <grpc/support/string_util.h>
29#include <grpc/support/time.h>
30#include <grpc/support/useful.h>
31
Craig Tiller9533d042016-03-25 17:11:06 -070032#include "src/core/lib/support/string.h"
Craig Tiller027a74c2015-11-10 08:37:46 +000033#include "test/core/end2end/cq_verifier.h"
34
Craig Tillerbaa14a92017-11-03 09:09:36 -070035static void* tag(intptr_t t) { return (void*)t; }
Craig Tiller027a74c2015-11-10 08:37:46 +000036
Craig Tillerbaa14a92017-11-03 09:09:36 -070037const char* hobbits[][2] = {
Craig Tillere2715df2016-06-17 17:37:40 -070038 {"Adaldrida", "Brandybuck"}, {"Adamanta", "Took"},
39 {"Adalgrim", "Took"}, {"Adelard", "Took"},
40 {"Amaranth", "Brandybuck"}, {"Andwise", "Roper"},
41 {"Angelica", "Baggins"}, {"Asphodel", "Burrows"},
42 {"Balbo", "Baggins"}, {"Bandobras", "Took"},
43 {"Belba", "Bolger"}, {"Bell", "Gamgee"},
44 {"Belladonna", "Baggins"}, {"Berylla", "Baggins"},
45 {"Bilbo", "Baggins"}, {"Bilbo", "Gardner"},
46 {"Bill", "Butcher"}, {"Bingo", "Baggins"},
47 {"Bodo", "Proudfoot"}, {"Bowman", "Cotton"},
48 {"Bungo", "Baggins"}, {"Camellia", "Sackville"},
49 {"Carl", "Cotton"}, {"Celandine", "Brandybuck"},
50 {"Chica", "Baggins"}, {"Daddy", "Twofoot"},
51 {"Daisy", "Boffin"}, {"Diamond", "Took"},
52 {"Dinodas", "Brandybuck"}, {"Doderic", "Brandybuck"},
53 {"Dodinas", "Brandybuck"}, {"Donnamira", "Boffin"},
54 {"Dora", "Baggins"}, {"Drogo", "Baggins"},
55 {"Dudo", "Baggins"}, {"Eglantine", "Took"},
56 {"Elanor", "Fairbairn"}, {"Elfstan", "Fairbairn"},
57 {"Esmeralda", "Brandybuck"}, {"Estella", "Brandybuck"},
58 {"Everard", "Took"}, {"Falco", "Chubb-Baggins"},
59 {"Faramir", "Took"}, {"Farmer", "Maggot"},
60 {"Fastolph", "Bolger"}, {"Ferdibrand", "Took"},
61 {"Ferdinand", "Took"}, {"Ferumbras", "Took"},
62 {"Ferumbras", "Took"}, {"Filibert", "Bolger"},
63 {"Firiel", "Fairbairn"}, {"Flambard", "Took"},
64 {"Folco", "Boffin"}, {"Fortinbras", "Took"},
65 {"Fortinbras", "Took"}, {"Fosco", "Baggins"},
66 {"Fredegar", "Bolger"}, {"Frodo", "Baggins"},
67 {"Frodo", "Gardner"}, {"Gerontius", "Took"},
68 {"Gilly", "Baggins"}, {"Goldilocks", "Took"},
69 {"Gorbadoc", "Brandybuck"}, {"Gorbulas", "Brandybuck"},
70 {"Gorhendad", "Brandybuck"}, {"Gormadoc", "Brandybuck"},
71 {"Griffo", "Boffin"}, {"Halfast", "Gamgee"},
72 {"Halfred", "Gamgee"}, {"Halfred", "Greenhand"},
73 {"Hanna", "Brandybuck"}, {"Hamfast", "Gamgee"},
74 {"Hamfast", "Gardner"}, {"Hamson", "Gamgee"},
75 {"Harding", "Gardner"}, {"Hilda", "Brandybuck"},
76 {"Hildibrand", "Took"}, {"Hildifons", "Took"},
77 {"Hildigard", "Took"}, {"Hildigrim", "Took"},
78 {"Hob", "Gammidge"}, {"Hob", "Hayward"},
79 {"Hobson", "Gamgee"}, {"Holfast", "Gardner"},
80 {"Holman", "Cotton"}, {"Holman", "Greenhand"},
81 {"Hugo", "Boffin"}, {"Hugo", "Bracegirdle"},
82 {"Ilberic", "Brandybuck"}, {"Isembard", "Took"},
83 {"Isembold", "Took"}, {"Isengar", "Took"},
84 {"Isengrim", "Took"}, {"Isengrim", "Took"},
85 {"Isumbras", "Took"}, {"Isumbras", "Took"},
86 {"Jolly", "Cotton"},
87 /*
88 {"Lalia", "Took"},
89 {"Largo", "Baggins"},
90 {"Laura", "Baggins"},
91 {"Lily", "Goodbody"},
92 {"Lily", "Cotton"},
93 {"Linda", "Proudfoot"},
94 {"Lobelia", "Sackville-Baggins"},
95 {"Longo", "Baggins"},
96 {"Lotho", "Sackville-Baggins"},
97 {"Madoc", "Brandybuck"},
98 {"Malva", "Brandybuck"},
99 {"Marigold", "Cotton"},
100 {"Marmadas", "Brandybuck"},
101 {"Marmadoc", "Brandybuck"},
102 {"Marroc", "Brandybuck"},
103 {"May", "Gamgee"},
104 {"Melilot", "Brandybuck"},
105 {"Menegilda", "Brandybuck"},
106 {"Mentha", "Brandybuck"},
107 {"Meriadoc", "Brandybuck"},
108 {"Merimac", "Brandybuck"},
109 {"Merimas", "Brandybuck"},
110 {"Merry", "Gardner"},
111 {"Milo", "Burrows"},
112 {"Mimosa", "Baggins"},
113 {"Minto", "Burrows"},
114 {"Mirabella", "Brandybuck"},
115 {"Moro", "Burrows"},
116 {"Mosco", "Burrows"},
117 {"Mungo", "Baggins"},
118 {"Myrtle", "Burrows"},
119 {"Odo", "Proudfoot"},
120 {"Odovacar", "Bolger"},
121 {"Olo", "Proudfoot"},
122 {"Orgulas", "Brandybuck"},
123 {"Otho", "Sackville-Baggins"},
124 {"Paladin", "Took"},
125 {"Pansy", "Bolger"},
126 {"Pearl", "Took"},
127 {"Peony", "Burrows"},
128 {"Peregrin", "Took"},
129 {"Pervinca", "Took"},
130 {"Pimpernel", "Took"},
131 {"Pippin", "Gardner"},
132 {"Polo", "Baggins"},
133 {"Ponto", "Baggins"},
134 {"Porto", "Baggins"},
135 {"Posco", "Baggins"},
136 {"Poppy", "Bolger"},
137 {"Primrose", "Gardner"},
138 {"Primula", "Baggins"},
139 {"Prisca", "Bolger"},
140 {"Reginard", "Took"},
141 {"Robin", "Smallburrow"},
142 {"Robin", "Gardner"},
143 {"Rorimac", "Brandybuck"},
144 {"Rosa", "Took"},
145 {"Rosamunda", "Bolger"},
146 {"Rose", "Gardner"},
147 {"Ruby", "Baggins"},
148 {"Ruby", "Gardner"},
149 {"Rudigar", "Bolger"},
150 {"Rufus", "Burrows"},
151 {"Sadoc", "Brandybuck"},
152 {"Salvia", "Bolger"},
153 {"Samwise", "Gamgee"},
154 {"Sancho", "Proudfoot"},
155 {"Saradas", "Brandybuck"},
156 {"Saradoc", "Brandybuck"},
157 {"Seredic", "Brandybuck"},
158 {"Sigismond", "Took"},
159 {"Smeagol", "Gollum"},
160 {"Tanta", "Baggins"},
161 {"Ted", "Sandyman"},
162 {"Tobold", "Hornblower"},
163 {"Togo", "Goodbody"},
164 {"Tolman", "Cotton"},
165 {"Tolman", "Gardner"},
166 {"Widow", "Rumble"},
167 {"Wilcome", "Cotton"},
168 {"Wilcome", "Cotton"},
169 {"Wilibald", "Bolger"},
170 {"Will", "Whitfoot"},
171 {"Wiseman", "Gamwich"}*/
172};
Craig Tiller027a74c2015-11-10 08:37:46 +0000173
Craig Tillerbaa14a92017-11-03 09:09:36 -0700174const char* dragons[] = {"Ancalagon", "Glaurung", "Scatha",
Craig Tiller3c53bb22015-11-10 14:24:36 +0000175 "Smaug the Magnificent"};
Craig Tiller027a74c2015-11-10 08:37:46 +0000176
177static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
Craig Tillerbaa14a92017-11-03 09:09:36 -0700178 const char* test_name,
179 grpc_channel_args* client_args,
180 grpc_channel_args* server_args) {
Craig Tiller027a74c2015-11-10 08:37:46 +0000181 grpc_end2end_test_fixture f;
Robbie Shade55a046a2017-01-25 15:14:28 -0500182 gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
Craig Tiller027a74c2015-11-10 08:37:46 +0000183 f = config.create_fixture(client_args, server_args);
Craig Tiller027a74c2015-11-10 08:37:46 +0000184 config.init_server(&f, server_args);
Mark D. Rothe127a392016-10-27 08:27:15 -0700185 config.init_client(&f, client_args);
Craig Tiller027a74c2015-11-10 08:37:46 +0000186 return f;
187}
188
Chris Evansed2a5472017-03-27 17:34:51 -0500189static gpr_timespec n_seconds_from_now(int n) {
Robbie Shadeca7effc2017-01-17 09:14:29 -0500190 return grpc_timeout_seconds_to_deadline(n);
Craig Tiller027a74c2015-11-10 08:37:46 +0000191}
192
Chris Evansed2a5472017-03-27 17:34:51 -0500193static gpr_timespec five_seconds_from_now(void) {
194 return n_seconds_from_now(5);
195}
Craig Tiller027a74c2015-11-10 08:37:46 +0000196
Craig Tillerbaa14a92017-11-03 09:09:36 -0700197static void drain_cq(grpc_completion_queue* cq) {
Craig Tiller027a74c2015-11-10 08:37:46 +0000198 grpc_event ev;
199 do {
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800200 ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
Craig Tiller027a74c2015-11-10 08:37:46 +0000201 } while (ev.type != GRPC_QUEUE_SHUTDOWN);
202}
203
Craig Tillerbaa14a92017-11-03 09:09:36 -0700204static void shutdown_server(grpc_end2end_test_fixture* f) {
Craig Tiller027a74c2015-11-10 08:37:46 +0000205 if (!f->server) return;
Sree Kuchibhotla321881d2017-02-27 11:25:28 -0800206 grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
207 GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
208 grpc_timeout_seconds_to_deadline(5),
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800209 nullptr)
Craig Tillerf40df232016-03-25 13:38:14 -0700210 .type == GRPC_OP_COMPLETE);
Craig Tiller027a74c2015-11-10 08:37:46 +0000211 grpc_server_destroy(f->server);
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800212 f->server = nullptr;
Craig Tiller027a74c2015-11-10 08:37:46 +0000213}
214
Craig Tillerbaa14a92017-11-03 09:09:36 -0700215static void shutdown_client(grpc_end2end_test_fixture* f) {
Craig Tiller027a74c2015-11-10 08:37:46 +0000216 if (!f->client) return;
217 grpc_channel_destroy(f->client);
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800218 f->client = nullptr;
Craig Tiller027a74c2015-11-10 08:37:46 +0000219}
220
Craig Tillerbaa14a92017-11-03 09:09:36 -0700221static void end_test(grpc_end2end_test_fixture* f) {
Craig Tiller027a74c2015-11-10 08:37:46 +0000222 shutdown_server(f);
223 shutdown_client(f);
224
225 grpc_completion_queue_shutdown(f->cq);
226 drain_cq(f->cq);
227 grpc_completion_queue_destroy(f->cq);
Sree Kuchibhotla321881d2017-02-27 11:25:28 -0800228 grpc_completion_queue_destroy(f->shutdown_cq);
Craig Tiller027a74c2015-11-10 08:37:46 +0000229}
230
Muxi Yan5ebd3272016-10-31 07:27:07 -0700231static void simple_request_body(grpc_end2end_test_config config,
232 grpc_end2end_test_fixture f, size_t index) {
Craig Tillerbaa14a92017-11-03 09:09:36 -0700233 grpc_call* c;
234 grpc_call* s;
235 cq_verifier* cqv = cq_verifier_create(f.cq);
Craig Tiller027a74c2015-11-10 08:37:46 +0000236 grpc_op ops[6];
Craig Tillerbaa14a92017-11-03 09:09:36 -0700237 grpc_op* op;
Craig Tiller027a74c2015-11-10 08:37:46 +0000238 grpc_metadata_array initial_metadata_recv;
239 grpc_metadata_array trailing_metadata_recv;
240 grpc_metadata_array request_metadata_recv;
241 grpc_call_details call_details;
242 grpc_status_code status;
243 grpc_call_error error;
244 grpc_metadata extra_metadata[3];
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800245 grpc_slice details;
Craig Tiller027a74c2015-11-10 08:37:46 +0000246 int was_cancelled = 2;
247
248 memset(extra_metadata, 0, sizeof(extra_metadata));
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800249 extra_metadata[0].key = grpc_slice_from_static_string("hobbit-first-name");
250 extra_metadata[0].value = grpc_slice_from_static_string(
251 hobbits[index % GPR_ARRAY_SIZE(hobbits)][0]);
252 extra_metadata[1].key = grpc_slice_from_static_string("hobbit-second-name");
253 extra_metadata[1].value = grpc_slice_from_static_string(
254 hobbits[index % GPR_ARRAY_SIZE(hobbits)][1]);
255 extra_metadata[2].key = grpc_slice_from_static_string("dragon");
256 extra_metadata[2].value =
257 grpc_slice_from_static_string(dragons[index % GPR_ARRAY_SIZE(dragons)]);
Craig Tiller027a74c2015-11-10 08:37:46 +0000258
Chris Evansed2a5472017-03-27 17:34:51 -0500259 gpr_timespec deadline = five_seconds_from_now();
Muxi Yan5ebd3272016-10-31 07:27:07 -0700260 c = grpc_channel_create_call(
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800261 f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800262 grpc_slice_from_static_string("/foo"),
263 get_host_override_slice("foo.test.google.fr:1234", config), deadline,
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800264 nullptr);
Craig Tiller027a74c2015-11-10 08:37:46 +0000265 GPR_ASSERT(c);
266
267 grpc_metadata_array_init(&initial_metadata_recv);
268 grpc_metadata_array_init(&trailing_metadata_recv);
269 grpc_metadata_array_init(&request_metadata_recv);
270 grpc_call_details_init(&call_details);
271
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700272 memset(ops, 0, sizeof(ops));
Craig Tiller027a74c2015-11-10 08:37:46 +0000273 op = ops;
274 op->op = GRPC_OP_SEND_INITIAL_METADATA;
275 op->data.send_initial_metadata.count = GPR_ARRAY_SIZE(extra_metadata);
276 op->data.send_initial_metadata.metadata = extra_metadata;
277 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800278 op->reserved = nullptr;
Craig Tiller027a74c2015-11-10 08:37:46 +0000279 op++;
280 op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
281 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800282 op->reserved = nullptr;
Craig Tiller027a74c2015-11-10 08:37:46 +0000283 op++;
284 op->op = GRPC_OP_RECV_INITIAL_METADATA;
Mark D. Roth435f9f22017-01-25 12:53:54 -0800285 op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
Craig Tiller027a74c2015-11-10 08:37:46 +0000286 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800287 op->reserved = nullptr;
Craig Tiller027a74c2015-11-10 08:37:46 +0000288 op++;
289 op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
290 op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
291 op->data.recv_status_on_client.status = &status;
292 op->data.recv_status_on_client.status_details = &details;
Craig Tiller027a74c2015-11-10 08:37:46 +0000293 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800294 op->reserved = nullptr;
Craig Tiller027a74c2015-11-10 08:37:46 +0000295 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800296 error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
Craig Tiller027a74c2015-11-10 08:37:46 +0000297 GPR_ASSERT(GRPC_CALL_OK == error);
298
299 error =
300 grpc_server_request_call(f.server, &s, &call_details,
301 &request_metadata_recv, f.cq, f.cq, tag(101));
302 GPR_ASSERT(GRPC_CALL_OK == error);
Mark D. Roth7187ab92016-08-24 13:49:22 -0700303 CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
Craig Tiller027a74c2015-11-10 08:37:46 +0000304 cq_verify(cqv);
305
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700306 memset(ops, 0, sizeof(ops));
Craig Tiller027a74c2015-11-10 08:37:46 +0000307 op = ops;
308 op->op = GRPC_OP_SEND_INITIAL_METADATA;
309 op->data.send_initial_metadata.count = 0;
310 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800311 op->reserved = nullptr;
Craig Tiller027a74c2015-11-10 08:37:46 +0000312 op++;
313 op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
314 op->data.send_status_from_server.trailing_metadata_count = 0;
315 op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800316 grpc_slice status_details = grpc_slice_from_static_string("xyz");
317 op->data.send_status_from_server.status_details = &status_details;
Craig Tiller027a74c2015-11-10 08:37:46 +0000318 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800319 op->reserved = nullptr;
Craig Tiller027a74c2015-11-10 08:37:46 +0000320 op++;
321 op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
322 op->data.recv_close_on_server.cancelled = &was_cancelled;
323 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800324 op->reserved = nullptr;
Craig Tiller027a74c2015-11-10 08:37:46 +0000325 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800326 error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
Craig Tiller027a74c2015-11-10 08:37:46 +0000327 GPR_ASSERT(GRPC_CALL_OK == error);
328
Mark D. Roth7187ab92016-08-24 13:49:22 -0700329 CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
330 CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
Craig Tiller027a74c2015-11-10 08:37:46 +0000331 cq_verify(cqv);
332
333 GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800334 GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz"));
335 GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
Muxi Yan5ebd3272016-10-31 07:27:07 -0700336 validate_host_override_string("foo.test.google.fr:1234", call_details.host,
337 config);
Craig Tiller027a74c2015-11-10 08:37:46 +0000338 GPR_ASSERT(was_cancelled == 1);
339
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800340 grpc_slice_unref(details);
Craig Tiller027a74c2015-11-10 08:37:46 +0000341 grpc_metadata_array_destroy(&initial_metadata_recv);
342 grpc_metadata_array_destroy(&trailing_metadata_recv);
343 grpc_metadata_array_destroy(&request_metadata_recv);
344 grpc_call_details_destroy(&call_details);
345
Craig Tillerdd36b152017-03-31 08:27:28 -0700346 grpc_call_unref(c);
347 grpc_call_unref(s);
Craig Tiller027a74c2015-11-10 08:37:46 +0000348
349 cq_verifier_destroy(cqv);
350}
351
Craig Tiller3c53bb22015-11-10 14:24:36 +0000352static void test_size(grpc_end2end_test_config config, int encode_size,
353 int decode_size) {
Craig Tiller027a74c2015-11-10 08:37:46 +0000354 size_t i;
355 grpc_end2end_test_fixture f;
356 grpc_arg server_arg;
357 grpc_channel_args server_args;
358 grpc_arg client_arg;
359 grpc_channel_args client_args;
Craig Tillerbaa14a92017-11-03 09:09:36 -0700360 char* name;
Craig Tiller027a74c2015-11-10 08:37:46 +0000361
362 server_arg.type = GRPC_ARG_INTEGER;
Yash Tibrewal40422d52017-11-06 14:39:17 -0800363 server_arg.key = const_cast<char*>(GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER);
Craig Tiller027a74c2015-11-10 08:37:46 +0000364 server_arg.value.integer = decode_size;
365 server_args.num_args = 1;
366 server_args.args = &server_arg;
367
368 client_arg.type = GRPC_ARG_INTEGER;
Yash Tibrewal40422d52017-11-06 14:39:17 -0800369 client_arg.key = const_cast<char*>(GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER);
Craig Tiller027a74c2015-11-10 08:37:46 +0000370 client_arg.value.integer = encode_size;
371 client_args.num_args = 1;
372 client_args.args = &client_arg;
373
374 gpr_asprintf(&name, "test_size:e=%d:d=%d", encode_size, decode_size);
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800375 f = begin_test(config, name, encode_size != 4096 ? &client_args : nullptr,
376 decode_size != 4096 ? &server_args : nullptr);
Craig Tiller027a74c2015-11-10 08:37:46 +0000377 for (i = 0; i < 4 * GPR_ARRAY_SIZE(hobbits); i++) {
Muxi Yan56456c32016-10-30 23:11:11 -0700378 simple_request_body(config, f, i);
Craig Tiller027a74c2015-11-10 08:37:46 +0000379 }
380 end_test(&f);
381 config.tear_down_data(&f);
382 gpr_free(name);
383}
384
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800385void hpack_size(grpc_end2end_test_config config) {
Craig Tillerb1136492015-11-18 11:30:17 -0800386 static const int interesting_sizes[] = {4096, 0, 100,
387 1000, 32768, 4 * 1024 * 1024};
Craig Tiller027a74c2015-11-10 08:37:46 +0000388 size_t i, j;
389
390 for (i = 0; i < GPR_ARRAY_SIZE(interesting_sizes); i++) {
391 for (j = 0; j < GPR_ARRAY_SIZE(interesting_sizes); j++) {
392 test_size(config, interesting_sizes[i], interesting_sizes[j]);
393 }
394 }
395}
Craig Tiller9e9edbc2016-04-04 10:38:49 -0700396
397void hpack_size_pre_init(void) {}