blob: 944edc7a70fcf2a76e3aa87f4b043d06203636b6 [file] [log] [blame]
David Garcia Quintasf74a49e2015-06-18 17:22:45 -07001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
David Garcia Quintasf74a49e2015-06-18 17:22:45 -07004 *
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
David Garcia Quintasf74a49e2015-06-18 17:22:45 -07008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070010 *
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.
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070016 *
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/byte_buffer_reader.h>
David Garcia Quintas73dcbda2016-04-23 00:17:05 -070026#include <grpc/compression.h>
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070027#include <grpc/support/alloc.h>
28#include <grpc/support/log.h>
David Garcia Quintas73dcbda2016-04-23 00:17:05 -070029#include <grpc/support/string_util.h>
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070030#include <grpc/support/time.h>
31#include <grpc/support/useful.h>
32
Craig Tiller9533d042016-03-25 17:11:06 -070033#include "src/core/lib/channel/channel_args.h"
David Garcia Quintasa301eaa2016-05-06 16:59:03 -070034#include "src/core/lib/surface/call.h"
Craig Tiller9533d042016-03-25 17:11:06 -070035#include "src/core/lib/surface/call_test_only.h"
Craig Tiller7c70b6c2017-01-23 07:48:42 -080036#include "src/core/lib/transport/static_metadata.h"
Craig Tillerf40df232016-03-25 13:38:14 -070037#include "test/core/end2end/cq_verifier.h"
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070038
Craig Tillerbaa14a92017-11-03 09:09:36 -070039static void* tag(intptr_t t) { return (void*)t; }
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070040
41static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
Craig Tillerbaa14a92017-11-03 09:09:36 -070042 const char* test_name,
43 grpc_channel_args* client_args,
44 grpc_channel_args* server_args) {
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070045 grpc_end2end_test_fixture f;
Robbie Shade55a046a2017-01-25 15:14:28 -050046 gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070047 f = config.create_fixture(client_args, server_args);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070048 config.init_server(&f, server_args);
Mark D. Rothe127a392016-10-27 08:27:15 -070049 config.init_client(&f, client_args);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070050 return f;
51}
52
Chris Evansed2a5472017-03-27 17:34:51 -050053static gpr_timespec n_seconds_from_now(int n) {
Robbie Shadeca7effc2017-01-17 09:14:29 -050054 return grpc_timeout_seconds_to_deadline(n);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070055}
56
Chris Evansed2a5472017-03-27 17:34:51 -050057static gpr_timespec five_seconds_from_now(void) {
58 return n_seconds_from_now(5);
59}
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070060
Craig Tillerbaa14a92017-11-03 09:09:36 -070061static void drain_cq(grpc_completion_queue* cq) {
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070062 grpc_event ev;
63 do {
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080064 ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070065 } while (ev.type != GRPC_QUEUE_SHUTDOWN);
66}
67
Craig Tillerbaa14a92017-11-03 09:09:36 -070068static void shutdown_server(grpc_end2end_test_fixture* f) {
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070069 if (!f->server) return;
Sree Kuchibhotla321881d2017-02-27 11:25:28 -080070 grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
71 GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
72 grpc_timeout_seconds_to_deadline(5),
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080073 nullptr)
Craig Tillerf40df232016-03-25 13:38:14 -070074 .type == GRPC_OP_COMPLETE);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070075 grpc_server_destroy(f->server);
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080076 f->server = nullptr;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070077}
78
Craig Tillerbaa14a92017-11-03 09:09:36 -070079static void shutdown_client(grpc_end2end_test_fixture* f) {
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070080 if (!f->client) return;
81 grpc_channel_destroy(f->client);
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080082 f->client = nullptr;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070083}
84
Craig Tillerbaa14a92017-11-03 09:09:36 -070085static void end_test(grpc_end2end_test_fixture* f) {
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070086 shutdown_server(f);
87 shutdown_client(f);
88
David Garcia Quintas92ce5882015-06-23 17:07:12 -070089 grpc_completion_queue_shutdown(f->cq);
90 drain_cq(f->cq);
91 grpc_completion_queue_destroy(f->cq);
Sree Kuchibhotla321881d2017-02-27 11:25:28 -080092 grpc_completion_queue_destroy(f->shutdown_cq);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -070093}
94
David Garcia Quintas73dcbda2016-04-23 00:17:05 -070095static void request_for_disabled_algorithm(
Craig Tillerbaa14a92017-11-03 09:09:36 -070096 grpc_end2end_test_config config, const char* test_name,
David Garcia Quintas73dcbda2016-04-23 00:17:05 -070097 uint32_t send_flags_bitmask,
98 grpc_compression_algorithm algorithm_to_disable,
99 grpc_compression_algorithm requested_client_compression_algorithm,
Craig Tillerbaa14a92017-11-03 09:09:36 -0700100 grpc_status_code expected_error, grpc_metadata* client_metadata) {
101 grpc_call* c;
102 grpc_call* s;
Craig Tillerd41a4a72016-10-26 16:16:06 -0700103 grpc_slice request_payload_slice;
Craig Tillerbaa14a92017-11-03 09:09:36 -0700104 grpc_byte_buffer* request_payload;
105 grpc_channel_args* client_args;
106 grpc_channel_args* server_args;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700107 grpc_end2end_test_fixture f;
108 grpc_op ops[6];
Craig Tillerbaa14a92017-11-03 09:09:36 -0700109 grpc_op* op;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700110 grpc_metadata_array initial_metadata_recv;
111 grpc_metadata_array trailing_metadata_recv;
112 grpc_metadata_array request_metadata_recv;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800113 grpc_byte_buffer* request_payload_recv = nullptr;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700114 grpc_call_details call_details;
115 grpc_status_code status;
116 grpc_call_error error;
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800117 grpc_slice details;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700118 int was_cancelled = 2;
Craig Tillerbaa14a92017-11-03 09:09:36 -0700119 cq_verifier* cqv;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700120 char str[1024];
121
122 memset(str, 'x', 1023);
123 str[1023] = '\0';
Craig Tillerd41a4a72016-10-26 16:16:06 -0700124 request_payload_slice = grpc_slice_from_copied_string(str);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700125 request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1);
126
127 client_args = grpc_channel_args_set_compression_algorithm(
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800128 nullptr, requested_client_compression_algorithm);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700129 server_args =
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800130 grpc_channel_args_set_compression_algorithm(nullptr, GRPC_COMPRESS_NONE);
Craig Tiller87a7e1f2016-11-09 09:42:19 -0800131 {
Yash Tibrewal8cf14702017-12-06 09:47:54 -0800132 grpc_core::ExecCtx exec_ctx;
Craig Tiller87a7e1f2016-11-09 09:42:19 -0800133 server_args = grpc_channel_args_compression_algorithm_set_state(
Yash Tibrewal8cf14702017-12-06 09:47:54 -0800134 &server_args, algorithm_to_disable, false);
Craig Tiller87a7e1f2016-11-09 09:42:19 -0800135 }
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700136
137 f = begin_test(config, test_name, client_args, server_args);
138 cqv = cq_verifier_create(f.cq);
139
Chris Evansed2a5472017-03-27 17:34:51 -0500140 gpr_timespec deadline = five_seconds_from_now();
Muxi Yan5ebd3272016-10-31 07:27:07 -0700141 c = grpc_channel_create_call(
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800142 f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800143 grpc_slice_from_static_string("/foo"),
144 get_host_override_slice("foo.test.google.fr:1234", config), deadline,
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800145 nullptr);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700146 GPR_ASSERT(c);
147
148 grpc_metadata_array_init(&initial_metadata_recv);
149 grpc_metadata_array_init(&trailing_metadata_recv);
150 grpc_metadata_array_init(&request_metadata_recv);
151 grpc_call_details_init(&call_details);
152
Muxi Yan4b527a72017-09-20 13:35:05 -0700153 error =
154 grpc_server_request_call(f.server, &s, &call_details,
155 &request_metadata_recv, f.cq, f.cq, tag(101));
156 GPR_ASSERT(GRPC_CALL_OK == error);
157
David Garcia Quintasac094472016-05-18 20:25:57 -0700158 memset(ops, 0, sizeof(ops));
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700159 op = ops;
160 op->op = GRPC_OP_SEND_INITIAL_METADATA;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800161 if (client_metadata != nullptr) {
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700162 op->data.send_initial_metadata.count = 1;
163 op->data.send_initial_metadata.metadata = client_metadata;
164 } else {
165 op->data.send_initial_metadata.count = 0;
166 }
167 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800168 op->reserved = nullptr;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700169 op++;
170 op->op = GRPC_OP_SEND_MESSAGE;
Mark D. Roth435f9f22017-01-25 12:53:54 -0800171 op->data.send_message.send_message = request_payload;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700172 op->flags = send_flags_bitmask;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800173 op->reserved = nullptr;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700174 op++;
175 op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
176 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800177 op->reserved = nullptr;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700178 op++;
179 op->op = GRPC_OP_RECV_INITIAL_METADATA;
Mark D. Roth435f9f22017-01-25 12:53:54 -0800180 op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700181 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800182 op->reserved = nullptr;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700183 op++;
184 op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
185 op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
186 op->data.recv_status_on_client.status = &status;
187 op->data.recv_status_on_client.status_details = &details;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700188 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800189 op->reserved = nullptr;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700190 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800191 error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700192 GPR_ASSERT(GRPC_CALL_OK == error);
193
Mark D. Roth7187ab92016-08-24 13:49:22 -0700194 CQ_EXPECT_COMPLETION(cqv, tag(101), true);
Yash Tibrewalbdf998a2017-09-27 17:07:43 -0700195 CQ_EXPECT_COMPLETION(cqv, tag(1), true);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700196 cq_verify(cqv);
197
198 op = ops;
199 op->op = GRPC_OP_SEND_INITIAL_METADATA;
200 op->data.send_initial_metadata.count = 0;
201 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800202 op->reserved = nullptr;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700203 op++;
204 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 Quintas73dcbda2016-04-23 00:17:05 -0700206 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800207 op->reserved = nullptr;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700208 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800209 error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700210 GPR_ASSERT(GRPC_CALL_OK == error);
211
Mark D. Roth7187ab92016-08-24 13:49:22 -0700212 CQ_EXPECT_COMPLETION(cqv, tag(102), false);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700213
214 op = ops;
215 op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
216 op->data.recv_close_on_server.cancelled = &was_cancelled;
217 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800218 op->reserved = nullptr;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700219 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800220 error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700221 GPR_ASSERT(GRPC_CALL_OK == error);
222
Mark D. Roth7187ab92016-08-24 13:49:22 -0700223 CQ_EXPECT_COMPLETION(cqv, tag(103), true);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700224 cq_verify(cqv);
225
226 /* call was cancelled (closed) ... */
227 GPR_ASSERT(was_cancelled != 0);
228 /* with a certain error */
229 GPR_ASSERT(status == expected_error);
230
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800231 const char* algo_name = nullptr;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700232 GPR_ASSERT(grpc_compression_algorithm_name(algorithm_to_disable, &algo_name));
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800233 char* expected_details = nullptr;
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700234 gpr_asprintf(&expected_details, "Compression algorithm '%s' is disabled.",
235 algo_name);
236 /* and we expect a specific reason for it */
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800237 GPR_ASSERT(0 == grpc_slice_str_cmp(details, expected_details));
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700238 gpr_free(expected_details);
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800239 GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
Muxi Yan5ebd3272016-10-31 07:27:07 -0700240 validate_host_override_string("foo.test.google.fr:1234", call_details.host,
241 config);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700242
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800243 grpc_slice_unref(details);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700244 grpc_metadata_array_destroy(&initial_metadata_recv);
245 grpc_metadata_array_destroy(&trailing_metadata_recv);
246 grpc_metadata_array_destroy(&request_metadata_recv);
247 grpc_call_details_destroy(&call_details);
248
Craig Tillerdd36b152017-03-31 08:27:28 -0700249 grpc_call_unref(c);
250 grpc_call_unref(s);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700251
252 cq_verifier_destroy(cqv);
253
Craig Tillerd41a4a72016-10-26 16:16:06 -0700254 grpc_slice_unref(request_payload_slice);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700255 grpc_byte_buffer_destroy(request_payload);
256 grpc_byte_buffer_destroy(request_payload_recv);
257
Craig Tiller87a7e1f2016-11-09 09:42:19 -0800258 {
Yash Tibrewal8cf14702017-12-06 09:47:54 -0800259 grpc_core::ExecCtx exec_ctx;
260 grpc_channel_args_destroy(client_args);
261 grpc_channel_args_destroy(server_args);
Craig Tiller87a7e1f2016-11-09 09:42:19 -0800262 }
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700263
264 end_test(&f);
265 config.tear_down_data(&f);
266}
267
David Garcia Quintas5927aec2015-06-18 17:24:44 -0700268static void request_with_payload_template(
Craig Tillerbaa14a92017-11-03 09:09:36 -0700269 grpc_end2end_test_config config, const char* test_name,
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700270 uint32_t client_send_flags_bitmask,
271 grpc_compression_algorithm default_client_channel_compression_algorithm,
272 grpc_compression_algorithm default_server_channel_compression_algorithm,
273 grpc_compression_algorithm expected_algorithm_from_client,
274 grpc_compression_algorithm expected_algorithm_from_server,
Craig Tillerbaa14a92017-11-03 09:09:36 -0700275 grpc_metadata* client_init_metadata, bool set_server_level,
Mark D. Roth7cd14252017-06-22 10:49:43 -0700276 grpc_compression_level server_compression_level,
277 bool send_message_before_initial_metadata) {
Craig Tillerbaa14a92017-11-03 09:09:36 -0700278 grpc_call* c;
279 grpc_call* s;
Craig Tillerd41a4a72016-10-26 16:16:06 -0700280 grpc_slice request_payload_slice;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800281 grpc_byte_buffer* request_payload = nullptr;
Craig Tillerbaa14a92017-11-03 09:09:36 -0700282 grpc_channel_args* client_args;
283 grpc_channel_args* server_args;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700284 grpc_end2end_test_fixture f;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700285 grpc_op ops[6];
Craig Tillerbaa14a92017-11-03 09:09:36 -0700286 grpc_op* op;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700287 grpc_metadata_array initial_metadata_recv;
288 grpc_metadata_array trailing_metadata_recv;
289 grpc_metadata_array request_metadata_recv;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800290 grpc_byte_buffer* request_payload_recv = nullptr;
Craig Tillerbaa14a92017-11-03 09:09:36 -0700291 grpc_byte_buffer* response_payload;
292 grpc_byte_buffer* response_payload_recv;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700293 grpc_call_details call_details;
294 grpc_status_code status;
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200295 grpc_call_error error;
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800296 grpc_slice details;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700297 int was_cancelled = 2;
Craig Tillerbaa14a92017-11-03 09:09:36 -0700298 cq_verifier* cqv;
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700299 char request_str[1024];
300 char response_str[1024];
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700301
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700302 memset(request_str, 'x', 1023);
303 request_str[1023] = '\0';
304
305 memset(response_str, 'y', 1023);
306 response_str[1023] = '\0';
307
Craig Tillerd41a4a72016-10-26 16:16:06 -0700308 request_payload_slice = grpc_slice_from_copied_string(request_str);
Craig Tiller28b72422016-10-26 21:15:29 -0700309 grpc_slice response_payload_slice =
310 grpc_slice_from_copied_string(response_str);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700311
David Garcia Quintascadbf222015-07-17 15:33:13 -0700312 client_args = grpc_channel_args_set_compression_algorithm(
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800313 nullptr, default_client_channel_compression_algorithm);
David Garcia Quintascadbf222015-07-17 15:33:13 -0700314 server_args = grpc_channel_args_set_compression_algorithm(
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800315 nullptr, default_server_channel_compression_algorithm);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700316
David Garcia Quintas5927aec2015-06-18 17:24:44 -0700317 f = begin_test(config, test_name, client_args, server_args);
David Garcia Quintas92ce5882015-06-23 17:07:12 -0700318 cqv = cq_verifier_create(f.cq);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700319
Chris Evansed2a5472017-03-27 17:34:51 -0500320 gpr_timespec deadline = five_seconds_from_now();
Muxi Yan5ebd3272016-10-31 07:27:07 -0700321 c = grpc_channel_create_call(
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800322 f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800323 grpc_slice_from_static_string("/foo"),
324 get_host_override_slice("foo.test.google.fr:1234", config), deadline,
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800325 nullptr);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700326 GPR_ASSERT(c);
327
328 grpc_metadata_array_init(&initial_metadata_recv);
329 grpc_metadata_array_init(&trailing_metadata_recv);
330 grpc_metadata_array_init(&request_metadata_recv);
331 grpc_call_details_init(&call_details);
332
Mark D. Roth7cd14252017-06-22 10:49:43 -0700333 if (send_message_before_initial_metadata) {
334 request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1);
335 memset(ops, 0, sizeof(ops));
336 op = ops;
337 op->op = GRPC_OP_SEND_MESSAGE;
338 op->data.send_message.send_message = request_payload;
339 op->flags = client_send_flags_bitmask;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800340 op->reserved = nullptr;
Mark D. Roth7cd14252017-06-22 10:49:43 -0700341 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800342 error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
Mark D. Roth7cd14252017-06-22 10:49:43 -0700343 GPR_ASSERT(GRPC_CALL_OK == error);
344 CQ_EXPECT_COMPLETION(cqv, tag(2), true);
345 }
346
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700347 memset(ops, 0, sizeof(ops));
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700348 op = ops;
349 op->op = GRPC_OP_SEND_INITIAL_METADATA;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800350 if (client_init_metadata != nullptr) {
David Garcia Quintasfc0fa332015-06-25 18:11:07 -0700351 op->data.send_initial_metadata.count = 1;
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700352 op->data.send_initial_metadata.metadata = client_init_metadata;
David Garcia Quintasfc0fa332015-06-25 18:11:07 -0700353 } else {
354 op->data.send_initial_metadata.count = 0;
355 }
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700356 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800357 op->reserved = nullptr;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700358 op++;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700359 op->op = GRPC_OP_RECV_INITIAL_METADATA;
Mark D. Roth435f9f22017-01-25 12:53:54 -0800360 op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700361 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800362 op->reserved = nullptr;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700363 op++;
364 op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
365 op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
366 op->data.recv_status_on_client.status = &status;
367 op->data.recv_status_on_client.status_details = &details;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700368 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800369 op->reserved = nullptr;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700370 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800371 error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200372 GPR_ASSERT(GRPC_CALL_OK == error);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700373
Craig Tillerd6c98df2015-08-18 09:33:44 -0700374 error =
375 grpc_server_request_call(f.server, &s, &call_details,
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700376 &request_metadata_recv, f.cq, f.cq, tag(100));
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200377 GPR_ASSERT(GRPC_CALL_OK == error);
Mark D. Roth7187ab92016-08-24 13:49:22 -0700378 CQ_EXPECT_COMPLETION(cqv, tag(100), true);
David Garcia Quintas92ce5882015-06-23 17:07:12 -0700379 cq_verify(cqv);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700380
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700381 GPR_ASSERT(GPR_BITCOUNT(grpc_call_test_only_get_encodings_accepted_by_peer(
382 s)) == GRPC_COMPRESS_ALGORITHMS_COUNT);
David Garcia Quintas0c331882015-10-08 14:51:54 -0700383 GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
David Garcia Quintase091af82015-07-15 21:37:02 -0700384 GRPC_COMPRESS_NONE) != 0);
David Garcia Quintas0c331882015-10-08 14:51:54 -0700385 GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
David Garcia Quintase091af82015-07-15 21:37:02 -0700386 GRPC_COMPRESS_DEFLATE) != 0);
David Garcia Quintas0c331882015-10-08 14:51:54 -0700387 GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
David Garcia Quintase091af82015-07-15 21:37:02 -0700388 GRPC_COMPRESS_GZIP) != 0);
389
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700390 memset(ops, 0, sizeof(ops));
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700391 op = ops;
392 op->op = GRPC_OP_SEND_INITIAL_METADATA;
393 op->data.send_initial_metadata.count = 0;
David Garcia Quintas1ebf1f12016-05-17 19:15:43 -0700394 if (set_server_level) {
395 op->data.send_initial_metadata.maybe_compression_level.is_set = true;
David Garcia Quintas8ba42be2016-06-07 17:30:20 -0700396 op->data.send_initial_metadata.maybe_compression_level.level =
David Garcia Quintas1ebf1f12016-05-17 19:15:43 -0700397 server_compression_level;
398 }
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700399 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800400 op->reserved = nullptr;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700401 op++;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700402 op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
403 op->data.recv_close_on_server.cancelled = &was_cancelled;
404 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800405 op->reserved = nullptr;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700406 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800407 error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700408 GPR_ASSERT(GRPC_CALL_OK == error);
409
410 for (int i = 0; i < 2; i++) {
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700411 response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1);
412
Mark D. Roth7cd14252017-06-22 10:49:43 -0700413 if (i > 0 || !send_message_before_initial_metadata) {
414 request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1);
415 memset(ops, 0, sizeof(ops));
416 op = ops;
417 op->op = GRPC_OP_SEND_MESSAGE;
418 op->data.send_message.send_message = request_payload;
419 op->flags = client_send_flags_bitmask;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800420 op->reserved = nullptr;
Mark D. Roth7cd14252017-06-22 10:49:43 -0700421 op++;
Craig Tillerbe98d242017-11-10 15:26:57 -0800422 error =
423 grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
Mark D. Roth7cd14252017-06-22 10:49:43 -0700424 GPR_ASSERT(GRPC_CALL_OK == error);
425 CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
426 }
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700427
428 memset(ops, 0, sizeof(ops));
429 op = ops;
430 op->op = GRPC_OP_RECV_MESSAGE;
Mark D. Roth435f9f22017-01-25 12:53:54 -0800431 op->data.recv_message.recv_message = &request_payload_recv;
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700432 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800433 op->reserved = nullptr;
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700434 op++;
Craig Tillerbe98d242017-11-10 15:26:57 -0800435 error =
436 grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700437 GPR_ASSERT(GRPC_CALL_OK == error);
Mark D. Roth7cd14252017-06-22 10:49:43 -0700438
Mark D. Roth7187ab92016-08-24 13:49:22 -0700439 CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700440 cq_verify(cqv);
441
442 GPR_ASSERT(request_payload_recv->type == GRPC_BB_RAW);
443 GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, request_str));
444 GPR_ASSERT(request_payload_recv->data.raw.compression ==
445 expected_algorithm_from_client);
446
447 memset(ops, 0, sizeof(ops));
448 op = ops;
449 op->op = GRPC_OP_SEND_MESSAGE;
Mark D. Roth435f9f22017-01-25 12:53:54 -0800450 op->data.send_message.send_message = response_payload;
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700451 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800452 op->reserved = nullptr;
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700453 op++;
Craig Tillerbe98d242017-11-10 15:26:57 -0800454 error =
455 grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700456 GPR_ASSERT(GRPC_CALL_OK == error);
Mark D. Roth7cd14252017-06-22 10:49:43 -0700457
458 memset(ops, 0, sizeof(ops));
459 op = ops;
460 op->op = GRPC_OP_RECV_MESSAGE;
461 op->data.recv_message.recv_message = &response_payload_recv;
462 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800463 op->reserved = nullptr;
Mark D. Roth7cd14252017-06-22 10:49:43 -0700464 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800465 error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
Mark D. Roth7cd14252017-06-22 10:49:43 -0700466 GPR_ASSERT(GRPC_CALL_OK == error);
467
Mark D. Roth7187ab92016-08-24 13:49:22 -0700468 CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
Mark D. Roth7cd14252017-06-22 10:49:43 -0700469 CQ_EXPECT_COMPLETION(cqv, tag(3), 1);
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700470 cq_verify(cqv);
471
472 GPR_ASSERT(response_payload_recv->type == GRPC_BB_RAW);
473 GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, response_str));
474 if (server_compression_level > GRPC_COMPRESS_LEVEL_NONE) {
475 const grpc_compression_algorithm algo_for_server_level =
476 grpc_call_compression_for_level(s, server_compression_level);
477 GPR_ASSERT(response_payload_recv->data.raw.compression ==
478 algo_for_server_level);
479 } else {
480 GPR_ASSERT(response_payload_recv->data.raw.compression ==
481 expected_algorithm_from_server);
482 }
483
484 grpc_byte_buffer_destroy(request_payload);
485 grpc_byte_buffer_destroy(response_payload);
486 grpc_byte_buffer_destroy(request_payload_recv);
487 grpc_byte_buffer_destroy(response_payload_recv);
488 }
489
Craig Tillerd41a4a72016-10-26 16:16:06 -0700490 grpc_slice_unref(request_payload_slice);
491 grpc_slice_unref(response_payload_slice);
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700492
493 memset(ops, 0, sizeof(ops));
494 op = ops;
495 op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
496 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800497 op->reserved = nullptr;
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700498 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800499 error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700500 GPR_ASSERT(GRPC_CALL_OK == error);
501
502 memset(ops, 0, sizeof(ops));
503 op = ops;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700504 op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
505 op->data.send_status_from_server.trailing_metadata_count = 0;
506 op->data.send_status_from_server.status = GRPC_STATUS_OK;
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800507 grpc_slice status_details = grpc_slice_from_static_string("xyz");
508 op->data.send_status_from_server.status_details = &status_details;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700509 op->flags = 0;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800510 op->reserved = nullptr;
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700511 op++;
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800512 error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +0200513 GPR_ASSERT(GRPC_CALL_OK == error);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700514
Mark D. Roth7187ab92016-08-24 13:49:22 -0700515 CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
Mark D. Roth7cd14252017-06-22 10:49:43 -0700516 CQ_EXPECT_COMPLETION(cqv, tag(4), 1);
Mark D. Roth7187ab92016-08-24 13:49:22 -0700517 CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
518 CQ_EXPECT_COMPLETION(cqv, tag(104), 1);
David Garcia Quintas92ce5882015-06-23 17:07:12 -0700519 cq_verify(cqv);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700520
521 GPR_ASSERT(status == GRPC_STATUS_OK);
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800522 GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz"));
523 GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
Muxi Yan5ebd3272016-10-31 07:27:07 -0700524 validate_host_override_string("foo.test.google.fr:1234", call_details.host,
525 config);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700526 GPR_ASSERT(was_cancelled == 0);
David Garcia Quintas5927aec2015-06-18 17:24:44 -0700527
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800528 grpc_slice_unref(details);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700529 grpc_metadata_array_destroy(&initial_metadata_recv);
530 grpc_metadata_array_destroy(&trailing_metadata_recv);
531 grpc_metadata_array_destroy(&request_metadata_recv);
532 grpc_call_details_destroy(&call_details);
533
Craig Tillerdd36b152017-03-31 08:27:28 -0700534 grpc_call_unref(c);
535 grpc_call_unref(s);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700536
David Garcia Quintas92ce5882015-06-23 17:07:12 -0700537 cq_verifier_destroy(cqv);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700538
Craig Tiller87a7e1f2016-11-09 09:42:19 -0800539 {
Yash Tibrewal8cf14702017-12-06 09:47:54 -0800540 grpc_core::ExecCtx exec_ctx;
541 grpc_channel_args_destroy(client_args);
542 grpc_channel_args_destroy(server_args);
Craig Tiller87a7e1f2016-11-09 09:42:19 -0800543 }
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700544
545 end_test(&f);
546 config.tear_down_data(&f);
547}
548
David Garcia Quintasd16af0e2015-06-22 22:39:21 -0700549static void test_invoke_request_with_exceptionally_uncompressed_payload(
David Garcia Quintas5927aec2015-06-18 17:24:44 -0700550 grpc_end2end_test_config config) {
551 request_with_payload_template(
David Garcia Quintasd16af0e2015-06-22 22:39:21 -0700552 config, "test_invoke_request_with_exceptionally_uncompressed_payload",
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700553 GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800554 GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, nullptr, false,
Mark D. Roth7cd14252017-06-22 10:49:43 -0700555 /* ignored */ GRPC_COMPRESS_LEVEL_NONE, false);
David Garcia Quintas5927aec2015-06-18 17:24:44 -0700556}
557
558static void test_invoke_request_with_uncompressed_payload(
559 grpc_end2end_test_config config) {
560 request_with_payload_template(
561 config, "test_invoke_request_with_uncompressed_payload", 0,
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700562 GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
Craig Tillerbe98d242017-11-10 15:26:57 -0800563 GRPC_COMPRESS_NONE, nullptr, false,
564 /* ignored */ GRPC_COMPRESS_LEVEL_NONE, false);
David Garcia Quintasfc0fa332015-06-25 18:11:07 -0700565}
566
567static void test_invoke_request_with_compressed_payload(
568 grpc_end2end_test_config config) {
569 request_with_payload_template(
570 config, "test_invoke_request_with_compressed_payload", 0,
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700571 GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
Craig Tillerbe98d242017-11-10 15:26:57 -0800572 GRPC_COMPRESS_GZIP, nullptr, false,
573 /* ignored */ GRPC_COMPRESS_LEVEL_NONE, false);
Mark D. Roth7cd14252017-06-22 10:49:43 -0700574}
575
576static void test_invoke_request_with_send_message_before_initial_metadata(
577 grpc_end2end_test_config config) {
578 request_with_payload_template(
579 config, "test_invoke_request_with_compressed_payload", 0,
580 GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
Craig Tillerbe98d242017-11-10 15:26:57 -0800581 GRPC_COMPRESS_GZIP, nullptr, false,
582 /* ignored */ GRPC_COMPRESS_LEVEL_NONE, true);
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700583}
584
585static void test_invoke_request_with_server_level(
586 grpc_end2end_test_config config) {
587 request_with_payload_template(
588 config, "test_invoke_request_with_server_level", 0, GRPC_COMPRESS_NONE,
589 GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE /* ignored */,
Craig Tiller4ac2b8e2017-11-10 14:14:17 -0800590 nullptr, true, GRPC_COMPRESS_LEVEL_HIGH, false);
David Garcia Quintasfc0fa332015-06-25 18:11:07 -0700591}
592
593static void test_invoke_request_with_compressed_payload_md_override(
594 grpc_end2end_test_config config) {
595 grpc_metadata gzip_compression_override;
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700596 grpc_metadata identity_compression_override;
David Garcia Quintasfc0fa332015-06-25 18:11:07 -0700597
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800598 gzip_compression_override.key = GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST;
599 gzip_compression_override.value = grpc_slice_from_static_string("gzip");
David Garcia Quintasfc0fa332015-06-25 18:11:07 -0700600 memset(&gzip_compression_override.internal_data, 0,
601 sizeof(gzip_compression_override.internal_data));
602
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800603 identity_compression_override.key = GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST;
604 identity_compression_override.value =
605 grpc_slice_from_static_string("identity");
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700606 memset(&identity_compression_override.internal_data, 0,
607 sizeof(identity_compression_override.internal_data));
David Garcia Quintasfc0fa332015-06-25 18:11:07 -0700608
David Garcia Quintascddd95b2015-08-13 16:59:16 -0700609 /* Channel default NONE (aka IDENTITY), call override to GZIP */
David Garcia Quintasfc0fa332015-06-25 18:11:07 -0700610 request_with_payload_template(
611 config, "test_invoke_request_with_compressed_payload_md_override_1", 0,
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700612 GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP,
David Garcia Quintas1ebf1f12016-05-17 19:15:43 -0700613 GRPC_COMPRESS_NONE, &gzip_compression_override, false,
Mark D. Roth7cd14252017-06-22 10:49:43 -0700614 /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false);
David Garcia Quintasfc0fa332015-06-25 18:11:07 -0700615
616 /* Channel default DEFLATE, call override to GZIP */
617 request_with_payload_template(
618 config, "test_invoke_request_with_compressed_payload_md_override_2", 0,
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700619 GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP,
David Garcia Quintas1ebf1f12016-05-17 19:15:43 -0700620 GRPC_COMPRESS_NONE, &gzip_compression_override, false,
Mark D. Roth7cd14252017-06-22 10:49:43 -0700621 /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false);
David Garcia Quintasfc0fa332015-06-25 18:11:07 -0700622
David Garcia Quintascddd95b2015-08-13 16:59:16 -0700623 /* Channel default DEFLATE, call override to NONE (aka IDENTITY) */
David Garcia Quintasfc0fa332015-06-25 18:11:07 -0700624 request_with_payload_template(
625 config, "test_invoke_request_with_compressed_payload_md_override_3", 0,
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700626 GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
David Garcia Quintas1ebf1f12016-05-17 19:15:43 -0700627 GRPC_COMPRESS_NONE, &identity_compression_override, false,
Mark D. Roth7cd14252017-06-22 10:49:43 -0700628 /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false);
David Garcia Quintas5927aec2015-06-18 17:24:44 -0700629}
630
David Garcia Quintasaf1c7e42016-05-17 11:38:45 -0700631static void test_invoke_request_with_disabled_algorithm(
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700632 grpc_end2end_test_config config) {
Craig Tillerbe98d242017-11-10 15:26:57 -0800633 request_for_disabled_algorithm(config,
634 "test_invoke_request_with_disabled_algorithm",
635 0, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
636 GRPC_STATUS_UNIMPLEMENTED, nullptr);
David Garcia Quintas73dcbda2016-04-23 00:17:05 -0700637}
638
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800639void compressed_payload(grpc_end2end_test_config config) {
David Garcia Quintasd16af0e2015-06-22 22:39:21 -0700640 test_invoke_request_with_exceptionally_uncompressed_payload(config);
David Garcia Quintas5927aec2015-06-18 17:24:44 -0700641 test_invoke_request_with_uncompressed_payload(config);
David Garcia Quintas92ce5882015-06-23 17:07:12 -0700642 test_invoke_request_with_compressed_payload(config);
Mark D. Roth7cd14252017-06-22 10:49:43 -0700643 test_invoke_request_with_send_message_before_initial_metadata(config);
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700644 test_invoke_request_with_server_level(config);
David Garcia Quintasfc0fa332015-06-25 18:11:07 -0700645 test_invoke_request_with_compressed_payload_md_override(config);
David Garcia Quintasaf1c7e42016-05-17 11:38:45 -0700646 test_invoke_request_with_disabled_algorithm(config);
David Garcia Quintasf74a49e2015-06-18 17:22:45 -0700647}
Craig Tiller9e9edbc2016-04-04 10:38:49 -0700648
649void compressed_payload_pre_init(void) {}