aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/end2end
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/end2end')
-rw-r--r--test/core/end2end/dualstack_socket_test.c33
-rw-r--r--test/core/end2end/end2end_tests.h2
-rw-r--r--test/core/end2end/fixtures/chttp2_fake_security.c25
-rw-r--r--test/core/end2end/fixtures/chttp2_fullstack.c4
-rw-r--r--test/core/end2end/fixtures/chttp2_fullstack_compression.c13
-rw-r--r--test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c4
-rw-r--r--test/core/end2end/fixtures/chttp2_fullstack_uds_posix_with_poll.c124
-rw-r--r--test/core/end2end/fixtures/chttp2_fullstack_with_poll.c4
-rw-r--r--test/core/end2end/fixtures/chttp2_fullstack_with_proxy.c132
-rw-r--r--test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c26
-rw-r--r--test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_poll.c26
-rw-r--r--test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_proxy.c217
-rw-r--r--test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c68
-rw-r--r--test/core/end2end/fixtures/chttp2_socket_pair.c2
-rw-r--r--test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c2
-rw-r--r--test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c7
-rw-r--r--test/core/end2end/fixtures/proxy.c430
-rw-r--r--test/core/end2end/fixtures/proxy.h55
-rwxr-xr-xtest/core/end2end/gen_build_json.py84
-rw-r--r--test/core/end2end/multiple_server_queues_test.c2
-rw-r--r--test/core/end2end/no_server_test.c5
-rw-r--r--test/core/end2end/tests/bad_hostname.c4
-rw-r--r--test/core/end2end/tests/cancel_after_accept.c7
-rw-r--r--test/core/end2end/tests/cancel_after_accept_and_writes_closed.c7
-rw-r--r--test/core/end2end/tests/cancel_after_invoke.c7
-rw-r--r--test/core/end2end/tests/cancel_before_invoke.c4
-rw-r--r--test/core/end2end/tests/cancel_in_a_vacuum.c4
-rw-r--r--test/core/end2end/tests/census_simple_request.c4
-rw-r--r--test/core/end2end/tests/channel_connectivity.c132
-rw-r--r--test/core/end2end/tests/default_host.c221
-rw-r--r--test/core/end2end/tests/disappearing_server.c9
-rw-r--r--test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c4
-rw-r--r--test/core/end2end/tests/empty_batch.c4
-rw-r--r--test/core/end2end/tests/graceful_server_shutdown.c4
-rw-r--r--test/core/end2end/tests/invoke_large_request.c4
-rw-r--r--test/core/end2end/tests/max_concurrent_streams.c12
-rw-r--r--test/core/end2end/tests/max_message_length.c4
-rw-r--r--test/core/end2end/tests/ping_pong_streaming.c4
-rw-r--r--test/core/end2end/tests/registered_call.c3
-rw-r--r--test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c4
-rw-r--r--test/core/end2end/tests/request_response_with_metadata_and_payload.c8
-rw-r--r--test/core/end2end/tests/request_response_with_payload.c4
-rw-r--r--test/core/end2end/tests/request_response_with_payload_and_call_creds.c137
-rw-r--r--test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c4
-rw-r--r--test/core/end2end/tests/request_with_compressed_payload.c4
-rw-r--r--test/core/end2end/tests/request_with_flags.c4
-rw-r--r--test/core/end2end/tests/request_with_large_metadata.c4
-rw-r--r--test/core/end2end/tests/request_with_payload.c4
-rw-r--r--test/core/end2end/tests/server_finishes_request.c4
-rw-r--r--test/core/end2end/tests/simple_delayed_request.c11
-rw-r--r--test/core/end2end/tests/simple_request.c19
-rw-r--r--test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c4
52 files changed, 1771 insertions, 143 deletions
diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c
index 05ad42ca1f..48a88be525 100644
--- a/test/core/end2end/dualstack_socket_test.c
+++ b/test/core/end2end/dualstack_socket_test.c
@@ -37,6 +37,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@@ -78,6 +79,7 @@ void test_connect(const char *server_host, const char *client_host, int port,
size_t details_capacity = 0;
int was_cancelled = 2;
grpc_call_details call_details;
+ char *peer;
if (port == 0) {
port = grpc_pick_unused_port_or_die();
@@ -94,8 +96,8 @@ void test_connect(const char *server_host, const char *client_host, int port,
cq = grpc_completion_queue_create();
server = grpc_server_create(NULL);
grpc_server_register_completion_queue(server, cq);
- GPR_ASSERT((got_port = grpc_server_add_http2_port(server, server_hostport)) >
- 0);
+ GPR_ASSERT((got_port = grpc_server_add_insecure_http2_port(
+ server, server_hostport)) > 0);
if (port == 0) {
port = got_port;
} else {
@@ -105,8 +107,13 @@ void test_connect(const char *server_host, const char *client_host, int port,
cqv = cq_verifier_create(cq);
/* Create client. */
- gpr_join_host_port(&client_hostport, client_host, port);
- client = grpc_channel_create(client_hostport, NULL);
+ if (client_host[0] == 'i') {
+ /* for ipv4:/ipv6: addresses, just concatenate the port */
+ gpr_asprintf(&client_hostport, "%s:%d", client_host, port);
+ } else {
+ gpr_join_host_port(&client_hostport, client_host, port);
+ }
+ client = grpc_insecure_channel_create(client_hostport, NULL);
gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)",
server_hostport, client_hostport, expect_ok ? "success" : "failure");
@@ -124,8 +131,8 @@ void test_connect(const char *server_host, const char *client_host, int port,
}
/* Send a trivial request. */
- c = grpc_channel_create_call(client, cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
op = ops;
@@ -179,6 +186,10 @@ void test_connect(const char *server_host, const char *client_host, int port,
cq_expect_completion(cqv, tag(1), 1);
cq_verify(cqv);
+ peer = grpc_call_get_peer(c);
+ gpr_log(GPR_DEBUG, "got peer: '%s'", peer);
+ gpr_free(peer);
+
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == strcmp(details, "xyz"));
GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
@@ -237,21 +248,31 @@ int main(int argc, char **argv) {
/* :: and 0.0.0.0 are handled identically. */
test_connect("::", "127.0.0.1", 0, 1);
test_connect("::", "::ffff:127.0.0.1", 0, 1);
+ test_connect("::", "ipv4:127.0.0.1", 0, 1);
+ test_connect("::", "ipv6:[::ffff:127.0.0.1]", 0, 1);
test_connect("::", "localhost", 0, 1);
test_connect("0.0.0.0", "127.0.0.1", 0, 1);
test_connect("0.0.0.0", "::ffff:127.0.0.1", 0, 1);
+ test_connect("0.0.0.0", "ipv4:127.0.0.1", 0, 1);
+ test_connect("0.0.0.0", "ipv6:[::ffff:127.0.0.1]", 0, 1);
test_connect("0.0.0.0", "localhost", 0, 1);
if (do_ipv6) {
test_connect("::", "::1", 0, 1);
test_connect("0.0.0.0", "::1", 0, 1);
+ test_connect("::", "ipv6:[::1]", 0, 1);
+ test_connect("0.0.0.0", "ipv6:[::1]", 0, 1);
}
/* These only work when the families agree. */
test_connect("127.0.0.1", "127.0.0.1", 0, 1);
+ test_connect("127.0.0.1", "ipv4:127.0.0.1", 0, 1);
if (do_ipv6) {
test_connect("::1", "::1", 0, 1);
test_connect("::1", "127.0.0.1", 0, 0);
test_connect("127.0.0.1", "::1", 0, 0);
+ test_connect("::1", "ipv6:[::1]", 0, 1);
+ test_connect("::1", "ipv4:127.0.0.1", 0, 0);
+ test_connect("127.0.0.1", "ipv6:[::1]", 0, 0);
}
}
diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h
index a18c702951..3f1665613c 100644
--- a/test/core/end2end/end2end_tests.h
+++ b/test/core/end2end/end2end_tests.h
@@ -43,6 +43,8 @@ typedef struct grpc_end2end_test_config grpc_end2end_test_config;
#define FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION 2
#define FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS 4
+#define FAIL_AUTH_CHECK_SERVER_ARG_NAME "fail_auth_check"
+
struct grpc_end2end_test_fixture {
grpc_completion_queue *cq;
grpc_server *server;
diff --git a/test/core/end2end/fixtures/chttp2_fake_security.c b/test/core/end2end/fixtures/chttp2_fake_security.c
index f879b43f79..78b692a45d 100644
--- a/test/core/end2end/fixtures/chttp2_fake_security.c
+++ b/test/core/end2end/fixtures/chttp2_fake_security.c
@@ -65,6 +65,14 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
return f;
}
+static void process_auth_failure(void *state, grpc_auth_context *ctx,
+ const grpc_metadata *md, size_t md_count,
+ grpc_process_auth_metadata_done_cb cb,
+ void *user_data) {
+ GPR_ASSERT(state == NULL);
+ cb(user_data, NULL, 0, 0);
+}
+
static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f,
grpc_channel_args *client_args,
grpc_credentials *creds) {
@@ -102,10 +110,27 @@ static void chttp2_init_client_fake_secure_fullstack(
chttp2_init_client_secure_fullstack(f, client_args, fake_ts_creds);
}
+static int fail_server_auth_check(grpc_channel_args *server_args) {
+ size_t i;
+ if (server_args == NULL) return 0;
+ for (i = 0; i < server_args->num_args; i++) {
+ if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
+ 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
static void chttp2_init_server_fake_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *server_args) {
grpc_server_credentials *fake_ts_creds =
grpc_fake_transport_security_server_credentials_create();
+ if (fail_server_auth_check(server_args)) {
+ grpc_auth_metadata_processor processor = {process_auth_failure, NULL};
+ grpc_server_credentials_set_auth_metadata_processor(fake_ts_creds,
+ processor);
+ }
chttp2_init_server_secure_fullstack(f, server_args, fake_ts_creds);
}
diff --git a/test/core/end2end/fixtures/chttp2_fullstack.c b/test/core/end2end/fixtures/chttp2_fullstack.c
index 8a1530e63b..53a6f0d7a5 100644
--- a/test/core/end2end/fixtures/chttp2_fullstack.c
+++ b/test/core/end2end/fixtures/chttp2_fullstack.c
@@ -72,7 +72,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
grpc_channel_args *client_args) {
fullstack_fixture_data *ffd = f->fixture_data;
- f->client = grpc_channel_create(ffd->localaddr, client_args);
+ f->client = grpc_insecure_channel_create(ffd->localaddr, client_args);
GPR_ASSERT(f->client);
}
@@ -84,7 +84,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
}
f->server = grpc_server_create(server_args);
grpc_server_register_completion_queue(f->server, f->cq);
- GPR_ASSERT(grpc_server_add_http2_port(f->server, ffd->localaddr));
+ GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
diff --git a/test/core/end2end/fixtures/chttp2_fullstack_compression.c b/test/core/end2end/fixtures/chttp2_fullstack_compression.c
index 0a9a312296..a75075d1d4 100644
--- a/test/core/end2end/fixtures/chttp2_fullstack_compression.c
+++ b/test/core/end2end/fixtures/chttp2_fullstack_compression.c
@@ -53,8 +53,8 @@
typedef struct fullstack_compression_fixture_data {
char *localaddr;
- grpc_channel_args* client_args_compression;
- grpc_channel_args* server_args_compression;
+ grpc_channel_args *client_args_compression;
+ grpc_channel_args *server_args_compression;
} fullstack_compression_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression(
@@ -75,18 +75,19 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression(
}
void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
+ grpc_channel_args *client_args) {
fullstack_compression_fixture_data *ffd = f->fixture_data;
if (ffd->client_args_compression != NULL) {
grpc_channel_args_destroy(ffd->client_args_compression);
}
ffd->client_args_compression = grpc_channel_args_set_compression_algorithm(
client_args, GRPC_COMPRESS_GZIP);
- f->client = grpc_channel_create(ffd->localaddr, ffd->client_args_compression);
+ f->client = grpc_insecure_channel_create(ffd->localaddr,
+ ffd->client_args_compression);
}
void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
+ grpc_channel_args *server_args) {
fullstack_compression_fixture_data *ffd = f->fixture_data;
if (ffd->server_args_compression != NULL) {
grpc_channel_args_destroy(ffd->server_args_compression);
@@ -98,7 +99,7 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture *f,
}
f->server = grpc_server_create(ffd->server_args_compression);
grpc_server_register_completion_queue(f->server, f->cq);
- GPR_ASSERT(grpc_server_add_http2_port(f->server, ffd->localaddr));
+ GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
diff --git a/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c b/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c
index 351e1c5459..20afdb868e 100644
--- a/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c
+++ b/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c
@@ -78,7 +78,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
grpc_channel_args *client_args) {
fullstack_fixture_data *ffd = f->fixture_data;
- f->client = grpc_channel_create(ffd->localaddr, client_args);
+ f->client = grpc_insecure_channel_create(ffd->localaddr, client_args);
}
void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
@@ -89,7 +89,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
}
f->server = grpc_server_create(server_args);
grpc_server_register_completion_queue(f->server, f->cq);
- GPR_ASSERT(grpc_server_add_http2_port(f->server, ffd->localaddr));
+ GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
diff --git a/test/core/end2end/fixtures/chttp2_fullstack_uds_posix_with_poll.c b/test/core/end2end/fixtures/chttp2_fullstack_uds_posix_with_poll.c
new file mode 100644
index 0000000000..8491ea6970
--- /dev/null
+++ b/test/core/end2end/fixtures/chttp2_fullstack_uds_posix_with_poll.c
@@ -0,0 +1,124 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "test/core/end2end/end2end_tests.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "src/core/channel/client_channel.h"
+#include "src/core/channel/connected_channel.h"
+#include "src/core/channel/http_server_filter.h"
+#include "src/core/support/string.h"
+#include "src/core/surface/channel.h"
+#include "src/core/surface/server.h"
+#include "src/core/transport/chttp2_transport.h"
+#include <grpc/support/alloc.h>
+#include <grpc/support/host_port.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/useful.h>
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+typedef struct fullstack_fixture_data {
+ char *localaddr;
+} fullstack_fixture_data;
+
+static int unique = 1;
+
+static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
+ grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_end2end_test_fixture f;
+ fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data));
+ memset(&f, 0, sizeof(f));
+
+ gpr_asprintf(&ffd->localaddr, "unix:/tmp/grpc_fullstack_test.%d.%d", getpid(),
+ unique++);
+
+ f.fixture_data = ffd;
+ f.cq = grpc_completion_queue_create();
+
+ return f;
+}
+
+void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
+ grpc_channel_args *client_args) {
+ fullstack_fixture_data *ffd = f->fixture_data;
+ f->client = grpc_insecure_channel_create(ffd->localaddr, client_args);
+}
+
+void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
+ grpc_channel_args *server_args) {
+ fullstack_fixture_data *ffd = f->fixture_data;
+ if (f->server) {
+ grpc_server_destroy(f->server);
+ }
+ f->server = grpc_server_create(server_args);
+ grpc_server_register_completion_queue(f->server, f->cq);
+ GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
+ grpc_server_start(f->server);
+}
+
+void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
+ fullstack_fixture_data *ffd = f->fixture_data;
+ gpr_free(ffd->localaddr);
+ gpr_free(ffd);
+}
+
+/* All test configurations */
+static grpc_end2end_test_config configs[] = {
+ {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION,
+ chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
+ chttp2_init_server_fullstack, chttp2_tear_down_fullstack},
+};
+
+int main(int argc, char **argv) {
+ size_t i;
+
+ grpc_platform_become_multipoller = grpc_poll_become_multipoller;
+
+ grpc_test_init(argc, argv);
+ grpc_init();
+
+ for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
+ grpc_end2end_tests(configs[i]);
+ }
+
+ grpc_shutdown();
+
+ return 0;
+}
diff --git a/test/core/end2end/fixtures/chttp2_fullstack_with_poll.c b/test/core/end2end/fixtures/chttp2_fullstack_with_poll.c
index 69860d04d5..2a4835add1 100644
--- a/test/core/end2end/fixtures/chttp2_fullstack_with_poll.c
+++ b/test/core/end2end/fixtures/chttp2_fullstack_with_poll.c
@@ -72,7 +72,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
grpc_channel_args *client_args) {
fullstack_fixture_data *ffd = f->fixture_data;
- f->client = grpc_channel_create(ffd->localaddr, client_args);
+ f->client = grpc_insecure_channel_create(ffd->localaddr, client_args);
}
void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
@@ -83,7 +83,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
}
f->server = grpc_server_create(server_args);
grpc_server_register_completion_queue(f->server, f->cq);
- GPR_ASSERT(grpc_server_add_http2_port(f->server, ffd->localaddr));
+ GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
diff --git a/test/core/end2end/fixtures/chttp2_fullstack_with_proxy.c b/test/core/end2end/fixtures/chttp2_fullstack_with_proxy.c
new file mode 100644
index 0000000000..248cc7d6e7
--- /dev/null
+++ b/test/core/end2end/fixtures/chttp2_fullstack_with_proxy.c
@@ -0,0 +1,132 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "test/core/end2end/end2end_tests.h"
+
+#include <string.h>
+
+#include "src/core/channel/client_channel.h"
+#include "src/core/channel/connected_channel.h"
+#include "src/core/channel/http_server_filter.h"
+#include "src/core/surface/channel.h"
+#include "src/core/surface/server.h"
+#include "src/core/transport/chttp2_transport.h"
+#include <grpc/support/alloc.h>
+#include <grpc/support/host_port.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/useful.h>
+#include "test/core/end2end/fixtures/proxy.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+typedef struct fullstack_fixture_data {
+ grpc_end2end_proxy *proxy;
+} fullstack_fixture_data;
+
+static grpc_server *create_proxy_server(const char *port) {
+ grpc_server *s = grpc_server_create(NULL);
+ GPR_ASSERT(grpc_server_add_insecure_http2_port(s, port));
+ return s;
+}
+
+static grpc_channel *create_proxy_client(const char *target) {
+ return grpc_insecure_channel_create(target, NULL);
+}
+
+static const grpc_end2end_proxy_def proxy_def = {create_proxy_server,
+ create_proxy_client};
+
+static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
+ grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_end2end_test_fixture f;
+ fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data));
+ memset(&f, 0, sizeof(f));
+
+ ffd->proxy = grpc_end2end_proxy_create(&proxy_def);
+
+ f.fixture_data = ffd;
+ f.cq = grpc_completion_queue_create();
+
+ return f;
+}
+
+void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
+ grpc_channel_args *client_args) {
+ fullstack_fixture_data *ffd = f->fixture_data;
+ f->client = grpc_insecure_channel_create(
+ grpc_end2end_proxy_get_client_target(ffd->proxy), client_args);
+ GPR_ASSERT(f->client);
+}
+
+void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
+ grpc_channel_args *server_args) {
+ fullstack_fixture_data *ffd = f->fixture_data;
+ if (f->server) {
+ grpc_server_destroy(f->server);
+ }
+ f->server = grpc_server_create(server_args);
+ grpc_server_register_completion_queue(f->server, f->cq);
+ GPR_ASSERT(grpc_server_add_insecure_http2_port(
+ f->server, grpc_end2end_proxy_get_server_port(ffd->proxy)));
+ grpc_server_start(f->server);
+}
+
+void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
+ fullstack_fixture_data *ffd = f->fixture_data;
+ grpc_end2end_proxy_destroy(ffd->proxy);
+ gpr_free(ffd);
+}
+
+/* All test configurations */
+static grpc_end2end_test_config configs[] = {
+ {"chttp2/fullstack+proxy", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION,
+ chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
+ chttp2_init_server_fullstack, chttp2_tear_down_fullstack},
+};
+
+int main(int argc, char **argv) {
+ size_t i;
+
+ grpc_test_init(argc, argv);
+ grpc_init();
+
+ for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
+ grpc_end2end_tests(configs[i]);
+ }
+
+ grpc_shutdown();
+
+ return 0;
+}
diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
index 73a36116fb..9850aac69b 100644
--- a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
+++ b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
@@ -68,6 +68,14 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
return f;
}
+static void process_auth_failure(void *state, grpc_auth_context *ctx,
+ const grpc_metadata *md, size_t md_count,
+ grpc_process_auth_metadata_done_cb cb,
+ void *user_data) {
+ GPR_ASSERT(state == NULL);
+ cb(user_data, NULL, 0, 0);
+}
+
static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f,
grpc_channel_args *client_args,
grpc_credentials *creds) {
@@ -110,12 +118,28 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_channel_args_destroy(new_client_args);
}
+static int fail_server_auth_check(grpc_channel_args *server_args) {
+ size_t i;
+ if (server_args == NULL) return 0;
+ for (i = 0; i < server_args->num_args; i++) {
+ if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
+ 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
static void chttp2_init_server_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *server_args) {
grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key,
test_server1_cert};
grpc_server_credentials *ssl_creds =
- grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1);
+ grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0);
+ if (fail_server_auth_check(server_args)) {
+ grpc_auth_metadata_processor processor = {process_auth_failure, NULL};
+ grpc_server_credentials_set_auth_metadata_processor(ssl_creds, processor);
+ }
chttp2_init_server_secure_fullstack(f, server_args, ssl_creds);
}
diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_poll.c b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_poll.c
index b1ac3e535f..3df2acd296 100644
--- a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_poll.c
+++ b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_poll.c
@@ -68,6 +68,14 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
return f;
}
+static void process_auth_failure(void *state, grpc_auth_context *ctx,
+ const grpc_metadata *md, size_t md_count,
+ grpc_process_auth_metadata_done_cb cb,
+ void *user_data) {
+ GPR_ASSERT(state == NULL);
+ cb(user_data, NULL, 0, 0);
+}
+
static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f,
grpc_channel_args *client_args,
grpc_credentials *creds) {
@@ -110,12 +118,28 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_channel_args_destroy(new_client_args);
}
+static int fail_server_auth_check(grpc_channel_args *server_args) {
+ size_t i;
+ if (server_args == NULL) return 0;
+ for (i = 0; i < server_args->num_args; i++) {
+ if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
+ 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
static void chttp2_init_server_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *server_args) {
grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key,
test_server1_cert};
grpc_server_credentials *ssl_creds =
- grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1);
+ grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0);
+ if (fail_server_auth_check(server_args)) {
+ grpc_auth_metadata_processor processor = {process_auth_failure, NULL};
+ grpc_server_credentials_set_auth_metadata_processor(ssl_creds, processor);
+ }
chttp2_init_server_secure_fullstack(f, server_args, ssl_creds);
}
diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_proxy.c b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_proxy.c
new file mode 100644
index 0000000000..4d77039cac
--- /dev/null
+++ b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_proxy.c
@@ -0,0 +1,217 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "test/core/end2end/end2end_tests.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "src/core/channel/channel_args.h"
+#include "src/core/security/credentials.h"
+#include "src/core/support/env.h"
+#include "src/core/support/file.h"
+#include "src/core/support/string.h"
+#include <grpc/support/alloc.h>
+#include <grpc/support/host_port.h>
+#include <grpc/support/log.h>
+#include "test/core/end2end/data/ssl_test_data.h"
+#include "test/core/end2end/fixtures/proxy.h"
+#include "test/core/util/test_config.h"
+#include "test/core/util/port.h"
+
+typedef struct fullstack_secure_fixture_data {
+ grpc_end2end_proxy *proxy;
+} fullstack_secure_fixture_data;
+
+static grpc_server *create_proxy_server(const char *port) {
+ grpc_server *s = grpc_server_create(NULL);
+ grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key,
+ test_server1_cert};
+ grpc_server_credentials *ssl_creds =
+ grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0);
+ GPR_ASSERT(grpc_server_add_secure_http2_port(s, port, ssl_creds));
+ grpc_server_credentials_release(ssl_creds);
+ return s;
+}
+
+static grpc_channel *create_proxy_client(const char *target) {
+ grpc_channel *channel;
+ grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL);
+ grpc_arg ssl_name_override = {GRPC_ARG_STRING,
+ GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
+ {"foo.test.google.fr"}};
+ grpc_channel_args client_args;
+ client_args.num_args = 1;
+ client_args.args = &ssl_name_override;
+ channel = grpc_secure_channel_create(ssl_creds, target, &client_args);
+ grpc_credentials_release(ssl_creds);
+ return channel;
+}
+
+static const grpc_end2end_proxy_def proxy_def = {create_proxy_server,
+ create_proxy_client};
+
+static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
+ grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_end2end_test_fixture f;
+ fullstack_secure_fixture_data *ffd =
+ gpr_malloc(sizeof(fullstack_secure_fixture_data));
+ memset(&f, 0, sizeof(f));
+
+ ffd->proxy = grpc_end2end_proxy_create(&proxy_def);
+
+ f.fixture_data = ffd;
+ f.cq = grpc_completion_queue_create();
+
+ return f;
+}
+
+static void process_auth_failure(void *state, grpc_auth_context *ctx,
+ const grpc_metadata *md, size_t md_count,
+ grpc_process_auth_metadata_done_cb cb,
+ void *user_data) {
+ GPR_ASSERT(state == NULL);
+ cb(user_data, NULL, 0, 0);
+}
+
+static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f,
+ grpc_channel_args *client_args,
+ grpc_credentials *creds) {
+ fullstack_secure_fixture_data *ffd = f->fixture_data;
+ f->client = grpc_secure_channel_create(
+ creds, grpc_end2end_proxy_get_client_target(ffd->proxy), client_args);
+ GPR_ASSERT(f->client != NULL);
+ grpc_credentials_release(creds);
+}
+
+static void chttp2_init_server_secure_fullstack(
+ grpc_end2end_test_fixture *f, grpc_channel_args *server_args,
+ grpc_server_credentials *server_creds) {
+ fullstack_secure_fixture_data *ffd = f->fixture_data;
+ if (f->server) {
+ grpc_server_destroy(f->server);
+ }
+ f->server = grpc_server_create(server_args);
+ grpc_server_register_completion_queue(f->server, f->cq);
+ GPR_ASSERT(grpc_server_add_secure_http2_port(
+ f->server, grpc_end2end_proxy_get_server_port(ffd->proxy), server_creds));
+ grpc_server_credentials_release(server_creds);
+ grpc_server_start(f->server);
+}
+
+void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
+ fullstack_secure_fixture_data *ffd = f->fixture_data;
+ grpc_end2end_proxy_destroy(ffd->proxy);
+ gpr_free(ffd);
+}
+
+static void chttp2_init_client_simple_ssl_secure_fullstack(
+ grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
+ grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL);
+ grpc_arg ssl_name_override = {GRPC_ARG_STRING,
+ GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
+ {"foo.test.google.fr"}};
+ grpc_channel_args *new_client_args =
+ grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
+ chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds);
+ grpc_channel_args_destroy(new_client_args);
+}
+
+static int fail_server_auth_check(grpc_channel_args *server_args) {
+ size_t i;
+ if (server_args == NULL) return 0;
+ for (i = 0; i < server_args->num_args; i++) {
+ if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
+ 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static void chttp2_init_server_simple_ssl_secure_fullstack(
+ grpc_end2end_test_fixture *f, grpc_channel_args *server_args) {
+ grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key,
+ test_server1_cert};
+ grpc_server_credentials *ssl_creds =
+ grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0);
+ if (fail_server_auth_check(server_args)) {
+ grpc_auth_metadata_processor processor = {process_auth_failure, NULL};
+ grpc_server_credentials_set_auth_metadata_processor(ssl_creds, processor);
+ }
+ chttp2_init_server_secure_fullstack(f, server_args, ssl_creds);
+}
+
+/* All test configurations */
+
+static grpc_end2end_test_config configs[] = {
+ {"chttp2/simple_ssl_fullstack",
+ FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
+ FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION |
+ FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS,
+ chttp2_create_fixture_secure_fullstack,
+ chttp2_init_client_simple_ssl_secure_fullstack,
+ chttp2_init_server_simple_ssl_secure_fullstack,
+ chttp2_tear_down_secure_fullstack},
+};
+
+int main(int argc, char **argv) {
+ size_t i;
+ FILE *roots_file;
+ size_t roots_size = strlen(test_root_cert);
+ char *roots_filename;
+
+ grpc_test_init(argc, argv);
+
+ /* Set the SSL roots env var. */
+ roots_file = gpr_tmpfile("chttp2_simple_ssl_fullstack_test", &roots_filename);
+ GPR_ASSERT(roots_filename != NULL);
+ GPR_ASSERT(roots_file != NULL);
+ GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size);
+ fclose(roots_file);
+ gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename);
+
+ grpc_init();
+
+ for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
+ grpc_end2end_tests(configs[i]);
+ }
+
+ grpc_shutdown();
+
+ /* Cleanup. */
+ remove(roots_filename);
+ gpr_free(roots_filename);
+
+ return 0;
+}
diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
index de418bf7ee..284d5f07ae 100644
--- a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
+++ b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
@@ -46,10 +46,54 @@
#include "test/core/util/port.h"
#include "test/core/end2end/data/ssl_test_data.h"
+static const char oauth2_md[] = "Bearer aaslkfjs424535asdf";
+static const char *client_identity_property_name = "smurf_name";
+static const char *client_identity = "Brainy Smurf";
+
typedef struct fullstack_secure_fixture_data {
char *localaddr;
} fullstack_secure_fixture_data;
+static const grpc_metadata *find_metadata(const grpc_metadata *md,
+ size_t md_count,
+ const char *key,
+ const char *value) {
+ size_t i;
+ for (i = 0; i < md_count; i++) {
+ if (strcmp(key, md[i].key) == 0 && strlen(value) == md[i].value_length &&
+ memcmp(md[i].value, value, md[i].value_length) == 0) {
+ return &md[i];
+ }
+ }
+ return NULL;
+}
+
+static void process_oauth2_success(void *state, grpc_auth_context *ctx,
+ const grpc_metadata *md, size_t md_count,
+ grpc_process_auth_metadata_done_cb cb,
+ void *user_data) {
+ const grpc_metadata *oauth2 =
+ find_metadata(md, md_count, "Authorization", oauth2_md);
+ GPR_ASSERT(state == NULL);
+ GPR_ASSERT(oauth2 != NULL);
+ grpc_auth_context_add_cstring_property(ctx, client_identity_property_name,
+ client_identity);
+ GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name(
+ ctx, client_identity_property_name) == 1);
+ cb(user_data, oauth2, 1, 1);
+}
+
+static void process_oauth2_failure(void *state, grpc_auth_context *ctx,
+ const grpc_metadata *md, size_t md_count,
+ grpc_process_auth_metadata_done_cb cb,
+ void *user_data) {
+ const grpc_metadata *oauth2 =
+ find_metadata(md, md_count, "Authorization", oauth2_md);
+ GPR_ASSERT(state == NULL);
+ GPR_ASSERT(oauth2 != NULL);
+ cb(user_data, oauth2, 1, 0);
+}
+
static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
grpc_channel_args *client_args, grpc_channel_args *server_args) {
grpc_end2end_test_fixture f;
@@ -101,7 +145,7 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_credentials *ssl_creds =
grpc_ssl_credentials_create(test_root_cert, NULL);
grpc_credentials *oauth2_creds =
- grpc_fake_oauth2_credentials_create("Bearer aaslkfjs424535asdf", 1);
+ grpc_md_only_test_credentials_create("Authorization", oauth2_md, 1);
grpc_credentials *ssl_oauth2_creds =
grpc_composite_credentials_create(ssl_creds, oauth2_creds);
grpc_arg ssl_name_override = {GRPC_ARG_STRING,
@@ -115,12 +159,32 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_credentials_release(oauth2_creds);
}
+static int fail_server_auth_check(grpc_channel_args *server_args) {
+ size_t i;
+ if (server_args == NULL) return 0;
+ for (i = 0; i < server_args->num_args; i++) {
+ if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
+ 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
static void chttp2_init_server_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *server_args) {
grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key,
test_server1_cert};
grpc_server_credentials *ssl_creds =
- grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1);
+ grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1, 0);
+ grpc_auth_metadata_processor processor;
+ processor.state = NULL;
+ if (fail_server_auth_check(server_args)) {
+ processor.process = process_oauth2_failure;
+ } else {
+ processor.process = process_oauth2_success;
+ }
+ grpc_server_credentials_set_auth_metadata_processor(ssl_creds, processor);
chttp2_init_server_secure_fullstack(f, server_args, ssl_creds);
}
diff --git a/test/core/end2end/fixtures/chttp2_socket_pair.c b/test/core/end2end/fixtures/chttp2_socket_pair.c
index 37b61cf37f..807fc8e7bc 100644
--- a/test/core/end2end/fixtures/chttp2_socket_pair.c
+++ b/test/core/end2end/fixtures/chttp2_socket_pair.c
@@ -80,7 +80,7 @@ static void client_setup_transport(void *ts, grpc_transport *transport,
&grpc_connected_channel_filter};
size_t nfilters = sizeof(filters) / sizeof(*filters);
grpc_channel *channel = grpc_channel_create_from_filters(
- filters, nfilters, cs->client_args, mdctx, 1);
+ "socketpair-target", filters, nfilters, cs->client_args, mdctx, 1);
cs->f->client = channel;
diff --git a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c
index 2ec2697288..21d4404237 100644
--- a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c
+++ b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c
@@ -80,7 +80,7 @@ static void client_setup_transport(void *ts, grpc_transport *transport,
&grpc_connected_channel_filter};
size_t nfilters = sizeof(filters) / sizeof(*filters);
grpc_channel *channel = grpc_channel_create_from_filters(
- filters, nfilters, cs->client_args, mdctx, 1);
+ "socketpair-target", filters, nfilters, cs->client_args, mdctx, 1);
cs->f->client = channel;
diff --git a/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c b/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c
index 3aa364c5e0..9d798ad1d2 100644
--- a/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c
+++ b/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c
@@ -81,7 +81,7 @@ static void client_setup_transport(void *ts, grpc_transport *transport,
&grpc_connected_channel_filter};
size_t nfilters = sizeof(filters) / sizeof(*filters);
grpc_channel *channel = grpc_channel_create_from_filters(
- filters, nfilters, cs->client_args, mdctx, 1);
+ "socketpair-target", filters, nfilters, cs->client_args, mdctx, 1);
cs->f->client = channel;
@@ -148,6 +148,11 @@ int main(int argc, char **argv) {
/* force tracing on, with a value to force many
code paths in trace.c to be taken */
gpr_setenv("GRPC_TRACE", "doesnt-exist,http,all");
+#ifdef GPR_POSIX_SOCKET
+ g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10.0 : 1.0;
+#else
+ g_fixture_slowdown_factor = 10.0;
+#endif
grpc_test_init(argc, argv);
grpc_init();
diff --git a/test/core/end2end/fixtures/proxy.c b/test/core/end2end/fixtures/proxy.c
new file mode 100644
index 0000000000..e4f6263334
--- /dev/null
+++ b/test/core/end2end/fixtures/proxy.c
@@ -0,0 +1,430 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "test/core/end2end/fixtures/proxy.h"
+
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/host_port.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/useful.h>
+
+#include "test/core/util/port.h"
+
+struct grpc_end2end_proxy {
+ gpr_thd_id thd;
+ char *proxy_port;
+ char *server_port;
+ grpc_completion_queue *cq;
+ grpc_server *server;
+ grpc_channel *client;
+
+ int shutdown;
+
+ /* requested call */
+ grpc_call *new_call;
+ grpc_call_details new_call_details;
+ grpc_metadata_array new_call_metadata;
+};
+
+typedef struct {
+ void (*func)(void *arg, int success);
+ void *arg;
+} closure;
+
+typedef struct {
+ gpr_refcount refs;
+ grpc_end2end_proxy *proxy;
+
+ grpc_call *c2p;
+ grpc_call *p2s;
+
+ grpc_metadata_array c2p_initial_metadata;
+ grpc_metadata_array p2s_initial_metadata;
+
+ grpc_byte_buffer *c2p_msg;
+ grpc_byte_buffer *p2s_msg;
+
+ grpc_metadata_array p2s_trailing_metadata;
+ grpc_status_code p2s_status;
+ char *p2s_status_details;
+ size_t p2s_status_details_capacity;
+
+ int c2p_server_cancelled;
+} proxy_call;
+
+static void thread_main(void *arg);
+static void request_call(grpc_end2end_proxy *proxy);
+
+grpc_end2end_proxy *grpc_end2end_proxy_create(
+ const grpc_end2end_proxy_def *def) {
+ gpr_thd_options opt = gpr_thd_options_default();
+ int proxy_port = grpc_pick_unused_port_or_die();
+ int server_port = grpc_pick_unused_port_or_die();
+
+ grpc_end2end_proxy *proxy = gpr_malloc(sizeof(*proxy));
+ memset(proxy, 0, sizeof(*proxy));
+
+ gpr_join_host_port(&proxy->proxy_port, "localhost", proxy_port);
+ gpr_join_host_port(&proxy->server_port, "localhost", server_port);
+ proxy->cq = grpc_completion_queue_create();
+ proxy->server = def->create_server(proxy->proxy_port);
+ proxy->client = def->create_client(proxy->server_port);
+
+ grpc_server_register_completion_queue(proxy->server, proxy->cq);
+ grpc_server_start(proxy->server);
+
+ gpr_thd_options_set_joinable(&opt);
+ GPR_ASSERT(gpr_thd_new(&proxy->thd, thread_main, proxy, &opt));
+
+ request_call(proxy);
+
+ return proxy;
+}
+
+static closure *new_closure(void (*func)(void *arg, int success), void *arg) {
+ closure *cl = gpr_malloc(sizeof(*cl));
+ cl->func = func;
+ cl->arg = arg;
+ return cl;
+}
+
+static void shutdown_complete(void *arg, int success) {
+ grpc_end2end_proxy *proxy = arg;
+ proxy->shutdown = 1;
+ grpc_completion_queue_shutdown(proxy->cq);
+}
+
+void grpc_end2end_proxy_destroy(grpc_end2end_proxy *proxy) {
+ grpc_server_shutdown_and_notify(proxy->server, proxy->cq,
+ new_closure(shutdown_complete, proxy));
+ gpr_thd_join(proxy->thd);
+ gpr_free(proxy->proxy_port);
+ gpr_free(proxy->server_port);
+ grpc_server_destroy(proxy->server);
+ grpc_channel_destroy(proxy->client);
+ grpc_completion_queue_destroy(proxy->cq);
+ grpc_call_details_destroy(&proxy->new_call_details);
+ gpr_free(proxy);
+}
+
+static void unrefpc(proxy_call *pc, const char *reason) {
+ gpr_log(GPR_DEBUG, "unref %p: %s %d -> %d", pc, reason, pc->refs.count,
+ pc->refs.count - 1);
+ if (gpr_unref(&pc->refs)) {
+ grpc_call_destroy(pc->c2p);
+ grpc_call_destroy(pc->p2s);
+ grpc_metadata_array_destroy(&pc->c2p_initial_metadata);
+ grpc_metadata_array_destroy(&pc->p2s_initial_metadata);
+ grpc_metadata_array_destroy(&pc->p2s_trailing_metadata);
+ gpr_free(pc->p2s_status_details);
+ gpr_free(pc);
+ }
+}
+
+static void refpc(proxy_call *pc, const char *reason) {
+ gpr_log(GPR_DEBUG, "ref %p: %s %d -> %d", pc, reason, pc->refs.count,
+ pc->refs.count + 1);
+ gpr_ref(&pc->refs);
+}
+
+static void on_c2p_sent_initial_metadata(void *arg, int success) {
+ proxy_call *pc = arg;
+ unrefpc(pc, "on_c2p_sent_initial_metadata");
+}
+
+static void on_p2s_recv_initial_metadata(void *arg, int success) {
+ proxy_call *pc = arg;
+ grpc_op op;
+ grpc_call_error err;
+
+ if (!pc->proxy->shutdown) {
+ op.op = GRPC_OP_SEND_INITIAL_METADATA;
+ op.flags = 0;
+ op.data.send_initial_metadata.count = pc->p2s_initial_metadata.count;
+ op.data.send_initial_metadata.metadata = pc->p2s_initial_metadata.metadata;
+ refpc(pc, "on_c2p_sent_initial_metadata");
+ err = grpc_call_start_batch(pc->c2p, &op, 1,
+ new_closure(on_c2p_sent_initial_metadata, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+ }
+
+ unrefpc(pc, "on_p2s_recv_initial_metadata");
+}
+
+static void on_p2s_sent_initial_metadata(void *arg, int success) {
+ proxy_call *pc = arg;
+ unrefpc(pc, "on_p2s_sent_initial_metadata");
+}
+
+static void on_c2p_recv_msg(void *arg, int success);
+
+static void on_p2s_sent_message(void *arg, int success) {
+ proxy_call *pc = arg;
+ grpc_op op;
+ grpc_call_error err;
+
+ grpc_byte_buffer_destroy(pc->c2p_msg);
+ if (!pc->proxy->shutdown && success) {
+ op.op = GRPC_OP_RECV_MESSAGE;
+ op.flags = 0;
+ op.data.recv_message = &pc->c2p_msg;
+ refpc(pc, "on_c2p_recv_msg");
+ err = grpc_call_start_batch(pc->c2p, &op, 1,
+ new_closure(on_c2p_recv_msg, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+ }
+
+ unrefpc(pc, "on_p2s_sent_message");
+}
+
+static void on_p2s_sent_close(void *arg, int success) {
+ proxy_call *pc = arg;
+ unrefpc(pc, "on_p2s_sent_close");
+}
+
+static void on_c2p_recv_msg(void *arg, int success) {
+ proxy_call *pc = arg;
+ grpc_op op;
+ grpc_call_error err;
+
+ if (!pc->proxy->shutdown && success) {
+ if (pc->c2p_msg != NULL) {
+ op.op = GRPC_OP_SEND_MESSAGE;
+ op.flags = 0;
+ op.data.send_message = pc->c2p_msg;
+ refpc(pc, "on_p2s_sent_message");
+ err = grpc_call_start_batch(pc->p2s, &op, 1,
+ new_closure(on_p2s_sent_message, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+ } else {
+ op.op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op.flags = 0;
+ refpc(pc, "on_p2s_sent_close");
+ err = grpc_call_start_batch(pc->p2s, &op, 1,
+ new_closure(on_p2s_sent_close, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+ }
+ }
+
+ unrefpc(pc, "on_c2p_recv_msg");
+}
+
+static void on_p2s_recv_msg(void *arg, int success);
+
+static void on_c2p_sent_message(void *arg, int success) {
+ proxy_call *pc = arg;
+ grpc_op op;
+ grpc_call_error err;
+
+ grpc_byte_buffer_destroy(pc->p2s_msg);
+ if (!pc->proxy->shutdown && success) {
+ op.op = GRPC_OP_RECV_MESSAGE;
+ op.flags = 0;
+ op.data.recv_message = &pc->p2s_msg;
+ refpc(pc, "on_p2s_recv_msg");
+ err = grpc_call_start_batch(pc->p2s, &op, 1,
+ new_closure(on_p2s_recv_msg, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+ }
+
+ unrefpc(pc, "on_c2p_sent_message");
+}
+
+static void on_p2s_recv_msg(void *arg, int success) {
+ proxy_call *pc = arg;
+ grpc_op op;
+ grpc_call_error err;
+
+ if (!pc->proxy->shutdown && success && pc->p2s_msg) {
+ op.op = GRPC_OP_SEND_MESSAGE;
+ op.flags = 0;
+ op.data.send_message = pc->p2s_msg;
+ refpc(pc, "on_c2p_sent_message");
+ err = grpc_call_start_batch(pc->c2p, &op, 1,
+ new_closure(on_c2p_sent_message, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+ }
+ unrefpc(pc, "on_p2s_recv_msg");
+}
+
+static void on_c2p_sent_status(void *arg, int success) {
+ proxy_call *pc = arg;
+ unrefpc(pc, "on_c2p_sent_status");
+}
+
+static void on_p2s_status(void *arg, int success) {
+ proxy_call *pc = arg;
+ grpc_op op;
+ grpc_call_error err;
+
+ if (!pc->proxy->shutdown) {
+ GPR_ASSERT(success);
+ op.op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+ op.flags = 0;
+ op.data.send_status_from_server.trailing_metadata_count =
+ pc->p2s_trailing_metadata.count;
+ op.data.send_status_from_server.trailing_metadata =
+ pc->p2s_trailing_metadata.metadata;
+ op.data.send_status_from_server.status = pc->p2s_status;
+ op.data.send_status_from_server.status_details = pc->p2s_status_details;
+ refpc(pc, "on_c2p_sent_status");
+ err = grpc_call_start_batch(pc->c2p, &op, 1,
+ new_closure(on_c2p_sent_status, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+ }
+
+ unrefpc(pc, "on_p2s_status");
+}
+
+static void on_c2p_closed(void *arg, int success) {
+ proxy_call *pc = arg;
+ unrefpc(pc, "on_c2p_closed");
+}
+
+static void on_new_call(void *arg, int success) {
+ grpc_end2end_proxy *proxy = arg;
+ grpc_call_error err;
+
+ if (success) {
+ grpc_op op;
+ proxy_call *pc = gpr_malloc(sizeof(*pc));
+ memset(pc, 0, sizeof(*pc));
+ pc->proxy = proxy;
+ GPR_SWAP(grpc_metadata_array, pc->c2p_initial_metadata,
+ proxy->new_call_metadata);
+ pc->c2p = proxy->new_call;
+ pc->p2s = grpc_channel_create_call(
+ proxy->client, pc->c2p, GRPC_PROPAGATE_DEFAULTS, proxy->cq,
+ proxy->new_call_details.method, proxy->new_call_details.host,
+ proxy->new_call_details.deadline);
+ gpr_ref_init(&pc->refs, 1);
+
+ op.flags = 0;
+
+ op.op = GRPC_OP_RECV_INITIAL_METADATA;
+ op.data.recv_initial_metadata = &pc->p2s_initial_metadata;
+ refpc(pc, "on_p2s_recv_initial_metadata");
+ err = grpc_call_start_batch(pc->p2s, &op, 1,
+ new_closure(on_p2s_recv_initial_metadata, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+
+ op.op = GRPC_OP_SEND_INITIAL_METADATA;
+ op.data.send_initial_metadata.count = pc->c2p_initial_metadata.count;
+ op.data.send_initial_metadata.metadata = pc->c2p_initial_metadata.metadata;
+ refpc(pc, "on_p2s_sent_initial_metadata");
+ err = grpc_call_start_batch(pc->p2s, &op, 1,
+ new_closure(on_p2s_sent_initial_metadata, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+
+ op.op = GRPC_OP_RECV_MESSAGE;
+ op.data.recv_message = &pc->c2p_msg;
+ refpc(pc, "on_c2p_recv_msg");
+ err = grpc_call_start_batch(pc->c2p, &op, 1,
+ new_closure(on_c2p_recv_msg, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+
+ op.op = GRPC_OP_RECV_MESSAGE;
+ op.data.recv_message = &pc->p2s_msg;
+ refpc(pc, "on_p2s_recv_msg");
+ err = grpc_call_start_batch(pc->p2s, &op, 1,
+ new_closure(on_p2s_recv_msg, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+
+ op.op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op.data.recv_status_on_client.trailing_metadata =
+ &pc->p2s_trailing_metadata;
+ op.data.recv_status_on_client.status = &pc->p2s_status;
+ op.data.recv_status_on_client.status_details = &pc->p2s_status_details;
+ op.data.recv_status_on_client.status_details_capacity =
+ &pc->p2s_status_details_capacity;
+ refpc(pc, "on_p2s_status");
+ err =
+ grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_status, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+
+ op.op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op.data.recv_close_on_server.cancelled = &pc->c2p_server_cancelled;
+ refpc(pc, "on_c2p_closed");
+ err =
+ grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_closed, pc));
+ GPR_ASSERT(err == GRPC_CALL_OK);
+
+ request_call(proxy);
+
+ unrefpc(pc, "init");
+ } else {
+ GPR_ASSERT(proxy->new_call == NULL);
+ }
+}
+
+static void request_call(grpc_end2end_proxy *proxy) {
+ proxy->new_call = NULL;
+ GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
+ proxy->server, &proxy->new_call,
+ &proxy->new_call_details,
+ &proxy->new_call_metadata, proxy->cq,
+ proxy->cq, new_closure(on_new_call, proxy)));
+}
+
+static void thread_main(void *arg) {
+ grpc_end2end_proxy *proxy = arg;
+ closure *cl;
+ for (;;) {
+ grpc_event ev = grpc_completion_queue_next(
+ proxy->cq, gpr_inf_future(GPR_CLOCK_MONOTONIC));
+ switch (ev.type) {
+ case GRPC_QUEUE_TIMEOUT:
+ gpr_log(GPR_ERROR, "Should never reach here");
+ abort();
+ case GRPC_QUEUE_SHUTDOWN:
+ return;
+ case GRPC_OP_COMPLETE:
+ cl = ev.tag;
+ cl->func(cl->arg, ev.success);
+ gpr_free(cl);
+ break;
+ }
+ }
+}
+
+const char *grpc_end2end_proxy_get_client_target(grpc_end2end_proxy *proxy) {
+ return proxy->proxy_port;
+}
+
+const char *grpc_end2end_proxy_get_server_port(grpc_end2end_proxy *proxy) {
+ return proxy->server_port;
+}
diff --git a/test/core/end2end/fixtures/proxy.h b/test/core/end2end/fixtures/proxy.h
new file mode 100644
index 0000000000..c1cf01d39a
--- /dev/null
+++ b/test/core/end2end/fixtures/proxy.h
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPC_TEST_CORE_END2END_FIXTURES_PROXY_H
+#define GRPC_TEST_CORE_END2END_FIXTURES_PROXY_H
+
+#include <grpc/grpc.h>
+
+/* proxy service for _with_proxy fixtures */
+
+typedef struct grpc_end2end_proxy grpc_end2end_proxy;
+
+typedef struct grpc_end2end_proxy_def {
+ grpc_server *(*create_server)(const char *port);
+ grpc_channel *(*create_client)(const char *target);
+} grpc_end2end_proxy_def;
+
+grpc_end2end_proxy *grpc_end2end_proxy_create(
+ const grpc_end2end_proxy_def *def);
+void grpc_end2end_proxy_destroy(grpc_end2end_proxy *proxy);
+
+const char *grpc_end2end_proxy_get_client_target(grpc_end2end_proxy *proxy);
+const char *grpc_end2end_proxy_get_server_port(grpc_end2end_proxy *proxy);
+
+#endif /* GRPC_TEST_CORE_END2END_FIXTURES_PROXY_H */
diff --git a/test/core/end2end/gen_build_json.py b/test/core/end2end/gen_build_json.py
index 8b0dd3166b..6f10b78dad 100755
--- a/test/core/end2end/gen_build_json.py
+++ b/test/core/end2end/gen_build_json.py
@@ -36,64 +36,91 @@ import simplejson
import collections
-FixtureOptions = collections.namedtuple('FixtureOptions', 'secure platforms')
-default_unsecure_fixture_options = FixtureOptions(False, ['windows', 'posix'])
-default_secure_fixture_options = FixtureOptions(True, ['windows', 'posix'])
+FixtureOptions = collections.namedtuple('FixtureOptions', 'fullstack includes_proxy dns_resolver secure platforms ci_mac')
+default_unsecure_fixture_options = FixtureOptions(True, False, True, False, ['windows', 'linux', 'mac', 'posix'], True)
+socketpair_unsecure_fixture_options = default_unsecure_fixture_options._replace(fullstack=False, dns_resolver=False)
+default_secure_fixture_options = default_unsecure_fixture_options._replace(secure=True)
+uds_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, platforms=['linux', 'mac', 'posix'])
# maps fixture name to whether it requires the security library
END2END_FIXTURES = {
- 'chttp2_fake_security': default_secure_fixture_options,
+ 'chttp2_fake_security': default_secure_fixture_options._replace(ci_mac=False),
'chttp2_fullstack': default_unsecure_fixture_options,
'chttp2_fullstack_compression': default_unsecure_fixture_options,
- 'chttp2_fullstack_with_poll': FixtureOptions(False, ['posix']),
- 'chttp2_fullstack_uds_posix': FixtureOptions(False, ['posix']),
+ 'chttp2_fullstack_uds_posix': uds_fixture_options,
+ 'chttp2_fullstack_uds_posix_with_poll': uds_fixture_options._replace(platforms=['linux']),
+ 'chttp2_fullstack_with_poll': default_unsecure_fixture_options._replace(platforms=['linux']),
+ 'chttp2_fullstack_with_proxy': default_unsecure_fixture_options._replace(includes_proxy=True, ci_mac=False),
'chttp2_simple_ssl_fullstack': default_secure_fixture_options,
- 'chttp2_simple_ssl_fullstack_with_poll': FixtureOptions(True, ['posix']),
- 'chttp2_simple_ssl_with_oauth2_fullstack': default_secure_fixture_options,
- 'chttp2_socket_pair': default_unsecure_fixture_options,
- 'chttp2_socket_pair_one_byte_at_a_time': default_unsecure_fixture_options,
- 'chttp2_socket_pair_with_grpc_trace': default_unsecure_fixture_options,
+ 'chttp2_simple_ssl_fullstack_with_poll': default_secure_fixture_options._replace(platforms=['linux']),
+ 'chttp2_simple_ssl_fullstack_with_proxy': default_secure_fixture_options._replace(includes_proxy=True, ci_mac=False),
+ 'chttp2_simple_ssl_with_oauth2_fullstack': default_secure_fixture_options._replace(ci_mac=False),
+ 'chttp2_socket_pair': socketpair_unsecure_fixture_options._replace(ci_mac=False),
+ 'chttp2_socket_pair_one_byte_at_a_time': socketpair_unsecure_fixture_options._replace(ci_mac=False),
+ 'chttp2_socket_pair_with_grpc_trace': socketpair_unsecure_fixture_options,
}
-TestOptions = collections.namedtuple('TestOptions', 'flaky secure')
-default_test_options = TestOptions(False, False)
+TestOptions = collections.namedtuple('TestOptions', 'needs_fullstack needs_dns proxyable flaky secure')
+default_test_options = TestOptions(False, False, True, False, False)
+connectivity_test_options = default_test_options._replace(needs_fullstack=True)
# maps test names to options
END2END_TESTS = {
'bad_hostname': default_test_options,
- 'cancel_after_accept': default_test_options,
'cancel_after_accept_and_writes_closed': default_test_options,
+ 'cancel_after_accept': default_test_options,
'cancel_after_invoke': default_test_options,
'cancel_before_invoke': default_test_options,
'cancel_in_a_vacuum': default_test_options,
'census_simple_request': default_test_options,
- 'disappearing_server': default_test_options,
+ 'channel_connectivity': connectivity_test_options._replace(proxyable=False),
+ 'default_host': default_test_options._replace(needs_fullstack=True, needs_dns=True),
+ 'disappearing_server': connectivity_test_options,
'early_server_shutdown_finishes_inflight_calls': default_test_options,
'early_server_shutdown_finishes_tags': default_test_options,
'empty_batch': default_test_options,
'graceful_server_shutdown': default_test_options,
'invoke_large_request': default_test_options,
- 'max_concurrent_streams': default_test_options,
+ 'max_concurrent_streams': default_test_options._replace(proxyable=False),
'max_message_length': default_test_options,
'no_op': default_test_options,
'ping_pong_streaming': default_test_options,
'registered_call': default_test_options,
'request_response_with_binary_metadata_and_payload': default_test_options,
- 'request_response_with_trailing_metadata_and_payload': default_test_options,
'request_response_with_metadata_and_payload': default_test_options,
+ 'request_response_with_payload_and_call_creds': default_test_options._replace(secure=True),
'request_response_with_payload': default_test_options,
- 'request_response_with_payload_and_call_creds': TestOptions(flaky=False, secure=True),
+ 'request_response_with_trailing_metadata_and_payload': default_test_options,
+ 'request_with_compressed_payload': default_test_options._replace(proxyable=False),
+ 'request_with_flags': default_test_options._replace(proxyable=False),
'request_with_large_metadata': default_test_options,
'request_with_payload': default_test_options,
- 'request_with_compressed_payload': default_test_options,
- 'request_with_flags': default_test_options,
'server_finishes_request': default_test_options,
- 'simple_delayed_request': default_test_options,
+ 'simple_delayed_request': connectivity_test_options,
'simple_request': default_test_options,
'simple_request_with_high_initial_sequence_number': default_test_options,
}
+def compatible(f, t):
+ if END2END_TESTS[t].needs_fullstack:
+ if not END2END_FIXTURES[f].fullstack:
+ return False
+ if END2END_TESTS[t].needs_dns:
+ if not END2END_FIXTURES[f].dns_resolver:
+ return False
+ if not END2END_TESTS[t].proxyable:
+ if END2END_FIXTURES[f].includes_proxy:
+ return False
+ return True
+
+
+def without(l, e):
+ l = l[:]
+ l.remove(e)
+ return l
+
+
def main():
sec_deps = [
'end2end_certs',
@@ -117,7 +144,7 @@ def main():
'language': 'c',
'secure': 'check' if END2END_FIXTURES[f].secure else 'no',
'src': ['test/core/end2end/fixtures/%s.c' % f],
- 'platforms': [ 'posix' ] if f.endswith('_posix') else END2END_FIXTURES[f].platforms,
+ 'platforms': [ 'linux', 'mac', 'posix' ] if f.endswith('_posix') else END2END_FIXTURES[f].platforms,
'deps': sec_deps if END2END_FIXTURES[f].secure else unsec_deps,
'headers': ['test/core/end2end/end2end_tests.h'],
}
@@ -152,26 +179,33 @@ def main():
'src': [],
'flaky': END2END_TESTS[t].flaky,
'platforms': END2END_FIXTURES[f].platforms,
+ 'ci_platforms': (END2END_FIXTURES[f].platforms
+ if END2END_FIXTURES[f].ci_mac
+ else without(END2END_FIXTURES[f].platforms, 'mac')),
'deps': [
'end2end_fixture_%s' % f,
'end2end_test_%s' % t] + sec_deps
}
for f in sorted(END2END_FIXTURES.keys())
- for t in sorted(END2END_TESTS.keys())] + [
+ for t in sorted(END2END_TESTS.keys())
+ if compatible(f, t)] + [
{
'name': '%s_%s_unsecure_test' % (f, t),
'build': 'test',
'language': 'c',
'secure': 'no',
'src': [],
- 'flaky': 'invoke_large_request' in t,
+ 'flaky': END2END_TESTS[t].flaky,
'platforms': END2END_FIXTURES[f].platforms,
+ 'ci_platforms': (END2END_FIXTURES[f].platforms
+ if END2END_FIXTURES[f].ci_mac
+ else without(END2END_FIXTURES[f].platforms, 'mac')),
'deps': [
'end2end_fixture_%s' % f,
'end2end_test_%s' % t] + unsec_deps
}
for f in sorted(END2END_FIXTURES.keys()) if not END2END_FIXTURES[f].secure
- for t in sorted(END2END_TESTS.keys()) if not END2END_TESTS[t].secure]}
+ for t in sorted(END2END_TESTS.keys()) if compatible(f, t) and not END2END_TESTS[t].secure]}
print simplejson.dumps(json, sort_keys=True, indent=2 * ' ')
diff --git a/test/core/end2end/multiple_server_queues_test.c b/test/core/end2end/multiple_server_queues_test.c
index 208d42e6e7..7772d14ba5 100644
--- a/test/core/end2end/multiple_server_queues_test.c
+++ b/test/core/end2end/multiple_server_queues_test.c
@@ -45,7 +45,7 @@ int main(int argc, char **argv) {
cq2 = grpc_completion_queue_create();
server = grpc_server_create(NULL);
grpc_server_register_completion_queue(server, cq1);
- grpc_server_add_http2_port(server, "[::]:0");
+ grpc_server_add_insecure_http2_port(server, "[::]:0");
grpc_server_register_completion_queue(server, cq2);
grpc_server_start(server);
grpc_server_shutdown_and_notify(server, cq2, NULL);
diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c
index 79797f9375..6a5e12325d 100644
--- a/test/core/end2end/no_server_test.c
+++ b/test/core/end2end/no_server_test.c
@@ -61,8 +61,9 @@ int main(int argc, char **argv) {
cqv = cq_verifier_create(cq);
/* create a call, channel to a non existant server */
- chan = grpc_channel_create("nonexistant:54321", NULL);
- call = grpc_channel_create_call(chan, cq, "/Foo", "nonexistant", deadline);
+ chan = grpc_insecure_channel_create("nonexistant:54321", NULL);
+ call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
+ "/Foo", "nonexistant", deadline);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c
index 2509ea06a0..198ba46cd2 100644
--- a/test/core/end2end/tests/bad_hostname.c
+++ b/test/core/end2end/tests/bad_hostname.c
@@ -113,8 +113,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
char *details = NULL;
size_t details_capacity = 0;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "slartibartfast.local",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "slartibartfast.local", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c
index 1cc6b2d147..2e166b8412 100644
--- a/test/core/end2end/tests/cancel_after_accept.c
+++ b/test/core/end2end/tests/cancel_after_accept.c
@@ -126,8 +126,8 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -192,8 +192,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
cq_expect_completion(cqv, tag(1), 1);
cq_verify(cqv);
- GPR_ASSERT(status == mode.expect_status);
- GPR_ASSERT(0 == strcmp(details, mode.expect_details));
+ GPR_ASSERT(status == mode.expect_status || status == GRPC_STATUS_INTERNAL);
GPR_ASSERT(was_cancelled == 1);
grpc_metadata_array_destroy(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c b/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c
index 015d437543..171c1874cc 100644
--- a/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c
+++ b/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c
@@ -126,8 +126,8 @@ static void test_cancel_after_accept_and_writes_closed(
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -195,8 +195,7 @@ static void test_cancel_after_accept_and_writes_closed(
cq_expect_completion(cqv, tag(1), 1);
cq_verify(cqv);
- GPR_ASSERT(status == mode.expect_status);
- GPR_ASSERT(0 == strcmp(details, mode.expect_details));
+ GPR_ASSERT(status == mode.expect_status || status == GRPC_STATUS_INTERNAL);
GPR_ASSERT(was_cancelled == 1);
grpc_metadata_array_destroy(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c
index 414ec706ce..186cd44a43 100644
--- a/test/core/end2end/tests/cancel_after_invoke.c
+++ b/test/core/end2end/tests/cancel_after_invoke.c
@@ -121,8 +121,8 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
grpc_byte_buffer *request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -164,8 +164,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
cq_expect_completion(cqv, tag(1), 1);
cq_verify(cqv);
- GPR_ASSERT(status == mode.expect_status);
- GPR_ASSERT(0 == strcmp(details, mode.expect_details));
+ GPR_ASSERT(status == mode.expect_status || status == GRPC_STATUS_INTERNAL);
grpc_metadata_array_destroy(&initial_metadata_recv);
grpc_metadata_array_destroy(&trailing_metadata_recv);
diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c
index 3cfe56eca2..b511908b4f 100644
--- a/test/core/end2end/tests/cancel_before_invoke.c
+++ b/test/core/end2end/tests/cancel_before_invoke.c
@@ -119,8 +119,8 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
grpc_byte_buffer *request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_cancel(c));
diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c
index 8bffc3f4d3..7645410184 100644
--- a/test/core/end2end/tests/cancel_in_a_vacuum.c
+++ b/test/core/end2end/tests/cancel_in_a_vacuum.c
@@ -107,8 +107,8 @@ static void test_cancel_in_a_vacuum(grpc_end2end_test_config config,
gpr_timespec deadline = five_seconds_time();
cq_verifier *v_client = cq_verifier_create(f.cq);
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c));
diff --git a/test/core/end2end/tests/census_simple_request.c b/test/core/end2end/tests/census_simple_request.c
index b414755cd1..2142dde921 100644
--- a/test/core/end2end/tests/census_simple_request.c
+++ b/test/core/end2end/tests/census_simple_request.c
@@ -111,8 +111,8 @@ static void test_body(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo",
- "foo.test.google.fr:1234", deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/channel_connectivity.c b/test/core/end2end/tests/channel_connectivity.c
new file mode 100644
index 0000000000..ec0417abda
--- /dev/null
+++ b/test/core/end2end/tests/channel_connectivity.c
@@ -0,0 +1,132 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "test/core/end2end/end2end_tests.h"
+
+#include <grpc/support/log.h>
+#include <grpc/support/time.h>
+
+#include "test/core/end2end/cq_verifier.h"
+
+static void *tag(gpr_intptr t) { return (void *)t; }
+
+static void test_connectivity(grpc_end2end_test_config config) {
+ grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
+ grpc_connectivity_state state;
+ cq_verifier *cqv = cq_verifier_create(f.cq);
+
+ config.init_client(&f, NULL);
+
+ /* channels should start life in IDLE, and stay there */
+ GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 0) == GRPC_CHANNEL_IDLE);
+ gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100));
+ GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 0) == GRPC_CHANNEL_IDLE);
+
+ /* start watching for a change */
+ grpc_channel_watch_connectivity_state(
+ f.client, GRPC_CHANNEL_IDLE, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(1));
+ /* nothing should happen */
+ cq_verify_empty(cqv);
+
+ /* check that we're still in idle, and start connecting */
+ GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 1) == GRPC_CHANNEL_IDLE);
+
+ /* and now the watch should trigger */
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
+ state = grpc_channel_check_connectivity_state(f.client, 0);
+ GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE ||
+ state == GRPC_CHANNEL_CONNECTING);
+
+ /* quickly followed by a transition to TRANSIENT_FAILURE */
+ grpc_channel_watch_connectivity_state(
+ f.client, GRPC_CHANNEL_CONNECTING, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(2));
+ cq_expect_completion(cqv, tag(2), 1);
+ cq_verify(cqv);
+ state = grpc_channel_check_connectivity_state(f.client, 0);
+ GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE ||
+ state == GRPC_CHANNEL_CONNECTING);
+
+ gpr_log(GPR_DEBUG, "*** STARTING SERVER ***");
+
+ /* now let's bring up a server to connect to */
+ config.init_server(&f, NULL);
+
+ gpr_log(GPR_DEBUG, "*** STARTED SERVER ***");
+
+ /* we'll go through some set of transitions (some might be missed), until
+ READY is reached */
+ while (state != GRPC_CHANNEL_READY) {
+ grpc_channel_watch_connectivity_state(
+ f.client, state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(3));
+ cq_expect_completion(cqv, tag(3), 1);
+ cq_verify(cqv);
+ state = grpc_channel_check_connectivity_state(f.client, 0);
+ GPR_ASSERT(state == GRPC_CHANNEL_READY ||
+ state == GRPC_CHANNEL_CONNECTING ||
+ state == GRPC_CHANNEL_TRANSIENT_FAILURE);
+ }
+
+ /* bring down the server again */
+ /* we should go immediately to TRANSIENT_FAILURE */
+ gpr_log(GPR_DEBUG, "*** SHUTTING DOWN SERVER ***");
+
+ grpc_channel_watch_connectivity_state(
+ f.client, GRPC_CHANNEL_READY, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(4));
+
+ grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead));
+
+ cq_expect_completion(cqv, tag(4), 1);
+ cq_expect_completion(cqv, tag(0xdead), 1);
+ cq_verify(cqv);
+ state = grpc_channel_check_connectivity_state(f.client, 0);
+ GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE ||
+ state == GRPC_CHANNEL_CONNECTING);
+
+ /* cleanup server */
+ grpc_server_destroy(f.server);
+
+ gpr_log(GPR_DEBUG, "*** SHUTDOWN SERVER ***");
+
+ grpc_channel_destroy(f.client);
+ grpc_completion_queue_shutdown(f.cq);
+ grpc_completion_queue_destroy(f.cq);
+ config.tear_down_data(&f);
+
+ cq_verifier_destroy(cqv);
+}
+
+void grpc_end2end_tests(grpc_end2end_test_config config) {
+ GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION);
+ test_connectivity(config);
+}
diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.c
new file mode 100644
index 0000000000..920449f4fa
--- /dev/null
+++ b/test/core/end2end/tests/default_host.c
@@ -0,0 +1,221 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "test/core/end2end/end2end_tests.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "src/core/support/string.h"
+#include <grpc/byte_buffer.h>
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/time.h>
+#include <grpc/support/useful.h>
+#include "test/core/end2end/cq_verifier.h"
+
+enum { TIMEOUT = 200000 };
+
+static void *tag(gpr_intptr t) { return (void *)t; }
+
+static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
+ const char *test_name,
+ grpc_channel_args *client_args,
+ grpc_channel_args *server_args) {
+ grpc_end2end_test_fixture f;
+ gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture(client_args, server_args);
+ config.init_client(&f, client_args);
+ config.init_server(&f, server_args);
+ return f;
+}
+
+static gpr_timespec n_seconds_time(int n) {
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+}
+
+static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+
+static void drain_cq(grpc_completion_queue *cq) {
+ grpc_event ev;
+ do {
+ ev = grpc_completion_queue_next(cq, five_seconds_time());
+ } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+}
+
+static void shutdown_server(grpc_end2end_test_fixture *f) {
+ if (!f->server) return;
+ grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
+ GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
+ GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
+ .type == GRPC_OP_COMPLETE);
+ grpc_server_destroy(f->server);
+ f->server = NULL;
+}
+
+static void shutdown_client(grpc_end2end_test_fixture *f) {
+ if (!f->client) return;
+ grpc_channel_destroy(f->client);
+ f->client = NULL;
+}
+
+static void end_test(grpc_end2end_test_fixture *f) {
+ shutdown_server(f);
+ shutdown_client(f);
+
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
+}
+
+static void simple_request_body(grpc_end2end_test_fixture f) {
+ grpc_call *c;
+ grpc_call *s;
+ gpr_timespec deadline = five_seconds_time();
+ cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_op ops[6];
+ grpc_op *op;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_call_details call_details;
+ grpc_status_code status;
+ char *details = NULL;
+ size_t details_capacity = 0;
+ int was_cancelled = 2;
+ char *peer;
+
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", NULL, deadline);
+ GPR_ASSERT(c);
+
+ peer = grpc_call_get_peer(c);
+ GPR_ASSERT(peer != NULL);
+ gpr_log(GPR_DEBUG, "client_peer_before_call=%s", peer);
+ gpr_free(peer);
+
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details_init(&call_details);
+
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = 0;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->data.recv_status_on_client.status_details_capacity = &details_capacity;
+ op->flags = 0;
+ op++;
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
+
+ GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
+ f.server, &s, &call_details,
+ &request_metadata_recv, f.cq, f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
+
+ peer = grpc_call_get_peer(s);
+ GPR_ASSERT(peer != NULL);
+ gpr_log(GPR_DEBUG, "server_peer=%s", peer);
+ gpr_free(peer);
+ peer = grpc_call_get_peer(c);
+ GPR_ASSERT(peer != NULL);
+ gpr_log(GPR_DEBUG, "client_peer=%s", peer);
+ gpr_free(peer);
+
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = 0;
+ op++;
+ op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+ op->data.send_status_from_server.trailing_metadata_count = 0;
+ op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
+ op->data.send_status_from_server.status_details = "xyz";
+ op->flags = 0;
+ op++;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled;
+ op->flags = 0;
+ op++;
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
+
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
+
+ GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT(0 == strcmp(details, "xyz"));
+ GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
+ GPR_ASSERT(0 == strcmp(call_details.host, "localhost"));
+ GPR_ASSERT(was_cancelled == 1);
+
+ gpr_free(details);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+
+ grpc_call_destroy(c);
+ grpc_call_destroy(s);
+
+ cq_verifier_destroy(cqv);
+}
+
+static void test_invoke_simple_request(grpc_end2end_test_config config) {
+ grpc_end2end_test_fixture f;
+
+ f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
+ simple_request_body(f);
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+void grpc_end2end_tests(grpc_end2end_test_config config) {
+ if ((config.feature_mask & FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION) != 0) return;
+ if ((config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) == 0) return;
+ test_invoke_simple_request(config);
+}
diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c
index 9acd18902a..94bed336e8 100644
--- a/test/core/end2end/tests/disappearing_server.c
+++ b/test/core/end2end/tests/disappearing_server.c
@@ -97,8 +97,8 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f->client, f->cq, "/foo",
- "foo.test.google.fr:1234", deadline);
+ c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq,
+ "/foo", "foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -199,7 +199,6 @@ static void disappearing_server_test(grpc_end2end_test_config config) {
}
void grpc_end2end_tests(grpc_end2end_test_config config) {
- if (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) {
- disappearing_server_test(config);
- }
+ GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION);
+ disappearing_server_test(config);
}
diff --git a/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c b/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c
index adc59b4e94..36cbe8067b 100644
--- a/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c
+++ b/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c
@@ -105,8 +105,8 @@ static void test_early_server_shutdown_finishes_inflight_calls(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c
index db8458d3d9..138c6b07c5 100644
--- a/test/core/end2end/tests/empty_batch.c
+++ b/test/core/end2end/tests/empty_batch.c
@@ -105,8 +105,8 @@ static void empty_batch_body(grpc_end2end_test_fixture f) {
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op *op = NULL;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, op, 0, tag(1)));
diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c
index 8c1889add9..23efa0304f 100644
--- a/test/core/end2end/tests/graceful_server_shutdown.c
+++ b/test/core/end2end/tests/graceful_server_shutdown.c
@@ -112,8 +112,8 @@ static void test_early_server_shutdown_finishes_inflight_calls(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c
index 744a9ada57..e32645e2ba 100644
--- a/test/core/end2end/tests/invoke_large_request.c
+++ b/test/core/end2end/tests/invoke_large_request.c
@@ -128,8 +128,8 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c
index 1204c070af..049c028835 100644
--- a/test/core/end2end/tests/max_concurrent_streams.c
+++ b/test/core/end2end/tests/max_concurrent_streams.c
@@ -113,8 +113,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo",
- "foo.test.google.fr:1234", deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -244,11 +244,11 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
/* start two requests - ensuring that the second is not accepted until
the first completes */
deadline = n_seconds_time(1000);
- c1 = grpc_channel_create_call(f.client, f.cq, "/alpha",
- "foo.test.google.fr:1234", deadline);
+ c1 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/alpha", "foo.test.google.fr:1234", deadline);
GPR_ASSERT(c1);
- c2 = grpc_channel_create_call(f.client, f.cq, "/beta",
- "foo.test.google.fr:1234", deadline);
+ c2 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/beta", "foo.test.google.fr:1234", deadline);
GPR_ASSERT(c2);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c
index ea59a9385f..feea49c68f 100644
--- a/test/core/end2end/tests/max_message_length.c
+++ b/test/core/end2end/tests/max_message_length.c
@@ -128,8 +128,8 @@ static void test_max_message_length(grpc_end2end_test_config config) {
f = begin_test(config, "test_max_message_length", NULL, &server_args);
cqv = cq_verifier_create(f.cq);
- c = grpc_channel_create_call(f.client, f.cq, "/foo",
- "foo.test.google.fr:1234",
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr:1234",
gpr_inf_future(GPR_CLOCK_REALTIME));
GPR_ASSERT(c);
diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c
index 8a3ec96212..0ae611b518 100644
--- a/test/core/end2end/tests/ping_pong_streaming.c
+++ b/test/core/end2end/tests/ping_pong_streaming.c
@@ -124,8 +124,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
- c = grpc_channel_create_call(f.client, f.cq, "/foo",
- "foo.test.google.fr:1234", deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c
index f44fd3a224..ffc4cd40a0 100644
--- a/test/core/end2end/tests/registered_call.c
+++ b/test/core/end2end/tests/registered_call.c
@@ -115,7 +115,8 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_registered_call(f.client, f.cq, rc, deadline);
+ c = grpc_channel_create_registered_call(
+ f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, rc, deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c b/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c
index 8b8a11babe..600642e6a7 100644
--- a/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c
+++ b/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c
@@ -143,8 +143,8 @@ static void test_request_response_with_metadata_and_payload(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/request_response_with_metadata_and_payload.c b/test/core/end2end/tests/request_response_with_metadata_and_payload.c
index ef6dfe9561..7e8cce10f4 100644
--- a/test/core/end2end/tests/request_response_with_metadata_and_payload.c
+++ b/test/core/end2end/tests/request_response_with_metadata_and_payload.c
@@ -111,8 +111,8 @@ static void test_request_response_with_metadata_and_payload(
gpr_timespec deadline = five_seconds_time();
grpc_metadata meta_c[2] = {{"key1", "val1", 4, {{NULL, NULL, NULL}}},
{"key2", "val2", 4, {{NULL, NULL, NULL}}}};
- grpc_metadata meta_s[2] = {{"key3", "val3", 4, {{NULL, NULL, NULL}}},
- {"key4", "val4", 4, {{NULL, NULL, NULL}}}};
+ grpc_metadata meta_s[2] = {{"KeY3", "val3", 4, {{NULL, NULL, NULL}}},
+ {"KeY4", "val4", 4, {{NULL, NULL, NULL}}}};
grpc_end2end_test_fixture f = begin_test(
config, "test_request_response_with_metadata_and_payload", NULL, NULL);
cq_verifier *cqv = cq_verifier_create(f.cq);
@@ -129,8 +129,8 @@ static void test_request_response_with_metadata_and_payload(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/request_response_with_payload.c b/test/core/end2end/tests/request_response_with_payload.c
index 38d3432f94..55323895fb 100644
--- a/test/core/end2end/tests/request_response_with_payload.c
+++ b/test/core/end2end/tests/request_response_with_payload.c
@@ -121,8 +121,8 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/request_response_with_payload_and_call_creds.c b/test/core/end2end/tests/request_response_with_payload_and_call_creds.c
index b5c743b405..342dfa03f6 100644
--- a/test/core/end2end/tests/request_response_with_payload_and_call_creds.c
+++ b/test/core/end2end/tests/request_response_with_payload_and_call_creds.c
@@ -59,13 +59,21 @@ static void *tag(gpr_intptr t) { return (void *)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ int fail_server_auth_check) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ f = config.create_fixture(NULL, NULL);
+ config.init_client(&f, NULL);
+ if (fail_server_auth_check) {
+ grpc_arg fail_auth_arg = {
+ GRPC_ARG_STRING, FAIL_AUTH_CHECK_SERVER_ARG_NAME, {NULL}};
+ grpc_channel_args args;
+ args.num_args= 1;
+ args.args = &fail_auth_arg;
+ config.init_server(&f, &args);
+ } else {
+ config.init_server(&f, NULL);
+ }
return f;
}
@@ -128,10 +136,10 @@ static void test_call_creds_failure(grpc_end2end_test_config config) {
grpc_call *c;
grpc_credentials *creds = NULL;
grpc_end2end_test_fixture f =
- begin_test(config, "test_call_creds_failure", NULL, NULL);
+ begin_test(config, "test_call_creds_failure", 0);
gpr_timespec deadline = five_seconds_time();
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
/* Try with credentials unfit to be set on a call (channel creds). */
@@ -157,9 +165,8 @@ static void request_response_with_payload_and_call_creds(
grpc_byte_buffer *response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
gpr_timespec deadline = five_seconds_time();
-
- grpc_end2end_test_fixture f = begin_test(config, test_name, NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_end2end_test_fixture f;
+ cq_verifier *cqv;
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -174,9 +181,13 @@ static void request_response_with_payload_and_call_creds(
int was_cancelled = 2;
grpc_credentials *creds = NULL;
grpc_auth_context *s_auth_context = NULL;
+ grpc_auth_context *c_auth_context = NULL;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ f = begin_test(config, test_name, 0);
+ cqv = cq_verifier_create(f.cq);
+
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
creds = grpc_iam_credentials_create(iam_token, iam_selector);
GPR_ASSERT(creds != NULL);
@@ -241,6 +252,11 @@ static void request_response_with_payload_and_call_creds(
print_auth_context(0, s_auth_context);
grpc_auth_context_release(s_auth_context);
+ c_auth_context = grpc_call_auth_context(c);
+ GPR_ASSERT(c_auth_context != NULL);
+ print_auth_context(1, c_auth_context);
+ grpc_auth_context_release(c_auth_context);
+
/* Cannot set creds on the server call object. */
GPR_ASSERT(grpc_call_set_credentials(s, NULL) != GRPC_CALL_OK);
@@ -340,31 +356,120 @@ static void request_response_with_payload_and_call_creds(
config.tear_down_data(&f);
}
-void test_request_response_with_payload_and_call_creds(
+static void test_request_response_with_payload_and_call_creds(
grpc_end2end_test_config config) {
request_response_with_payload_and_call_creds(
"test_request_response_with_payload_and_call_creds", config, NONE);
}
-void test_request_response_with_payload_and_overridden_call_creds(
+static void test_request_response_with_payload_and_overridden_call_creds(
grpc_end2end_test_config config) {
request_response_with_payload_and_call_creds(
"test_request_response_with_payload_and_overridden_call_creds", config,
OVERRIDE);
}
-void test_request_response_with_payload_and_deleted_call_creds(
+static void test_request_response_with_payload_and_deleted_call_creds(
grpc_end2end_test_config config) {
request_response_with_payload_and_call_creds(
"test_request_response_with_payload_and_deleted_call_creds", config,
DESTROY);
}
+static void test_request_with_server_rejecting_client_creds(
+ grpc_end2end_test_config config) {
+ grpc_op ops[6];
+ grpc_op *op;
+ grpc_call *c;
+ grpc_end2end_test_fixture f;
+ gpr_timespec deadline = five_seconds_time();
+ cq_verifier *cqv;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_call_details call_details;
+ grpc_status_code status;
+ char *details = NULL;
+ size_t details_capacity = 0;
+ grpc_byte_buffer *response_payload_recv = NULL;
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
+ grpc_byte_buffer *request_payload =
+ grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+ grpc_credentials *creds;
+
+ f = begin_test(config, "test_request_with_server_rejecting_client_creds", 1);
+ cqv = cq_verifier_create(f.cq);
+
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
+ GPR_ASSERT(c);
+
+ creds = grpc_iam_credentials_create(iam_token, iam_selector);
+ GPR_ASSERT(creds != NULL);
+ GPR_ASSERT(grpc_call_set_credentials(c, creds) == GRPC_CALL_OK);
+ grpc_credentials_release(creds);
+
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details_init(&call_details);
+
+ op = ops;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->data.recv_status_on_client.status_details_capacity = &details_capacity;
+ op->flags = 0;
+ op++;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = 0;
+ op++;
+ op->op = GRPC_OP_SEND_MESSAGE;
+ op->data.send_message = request_payload;
+ op->flags = 0;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op++;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message = &response_payload_recv;
+ op->flags = 0;
+ op++;
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
+
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
+
+ GPR_ASSERT(status == GRPC_STATUS_UNAUTHENTICATED);
+
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+
+ grpc_byte_buffer_destroy(request_payload);
+ grpc_byte_buffer_destroy(response_payload_recv);
+ gpr_free(details);
+
+ grpc_call_destroy(c);
+
+ cq_verifier_destroy(cqv);
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
void grpc_end2end_tests(grpc_end2end_test_config config) {
if (config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) {
test_call_creds_failure(config);
test_request_response_with_payload_and_call_creds(config);
test_request_response_with_payload_and_overridden_call_creds(config);
test_request_response_with_payload_and_deleted_call_creds(config);
+ test_request_with_server_rejecting_client_creds(config);
}
}
diff --git a/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c b/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c
index a5c0851d05..26be4ef643 100644
--- a/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c
+++ b/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c
@@ -131,8 +131,8 @@ static void test_request_response_with_metadata_and_payload(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/request_with_compressed_payload.c b/test/core/end2end/tests/request_with_compressed_payload.c
index 676af46920..fe6014a42a 100644
--- a/test/core/end2end/tests/request_with_compressed_payload.c
+++ b/test/core/end2end/tests/request_with_compressed_payload.c
@@ -142,8 +142,8 @@ static void request_with_payload_template(
f = begin_test(config, test_name, client_args, server_args);
cqv = cq_verifier_create(f.cq);
- c = grpc_channel_create_call(f.client, f.cq, "/foo",
- "foo.test.google.fr", deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c
index 0bfedca0ab..37c4825c8b 100644
--- a/test/core/end2end/tests/request_with_flags.c
+++ b/test/core/end2end/tests/request_with_flags.c
@@ -121,8 +121,8 @@ static void test_invoke_request_with_flags(
size_t details_capacity = 0;
grpc_call_error expectation;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/request_with_large_metadata.c b/test/core/end2end/tests/request_with_large_metadata.c
index ad34c69774..9ea8273ab0 100644
--- a/test/core/end2end/tests/request_with_large_metadata.c
+++ b/test/core/end2end/tests/request_with_large_metadata.c
@@ -122,8 +122,8 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
int was_cancelled = 2;
const int large_size = 64 * 1024;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
meta.key = "key";
diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c
index 8db6457830..6b5f173f01 100644
--- a/test/core/end2end/tests/request_with_payload.c
+++ b/test/core/end2end/tests/request_with_payload.c
@@ -120,8 +120,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c
index 062a59aca2..661c099d93 100644
--- a/test/core/end2end/tests/server_finishes_request.c
+++ b/test/core/end2end/tests/server_finishes_request.c
@@ -115,8 +115,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo",
- "foo.test.google.fr:1234", deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c
index a2665d7564..82d2bf9657 100644
--- a/test/core/end2end/tests/simple_delayed_request.c
+++ b/test/core/end2end/tests/simple_delayed_request.c
@@ -107,8 +107,8 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
config.init_client(f, client_args);
- c = grpc_channel_create_call(f->client, f->cq, "/foo", "foo.test.google.fr",
- deadline);
+ c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq,
+ "/foo", "foo.test.google.fr", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -207,8 +207,7 @@ static void test_simple_delayed_request_long(grpc_end2end_test_config config) {
}
void grpc_end2end_tests(grpc_end2end_test_config config) {
- if (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) {
- test_simple_delayed_request_short(config);
- test_simple_delayed_request_long(config);
- }
+ GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION);
+ test_simple_delayed_request_short(config);
+ test_simple_delayed_request_long(config);
}
diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c
index 6194b841d8..d60a63e682 100644
--- a/test/core/end2end/tests/simple_request.c
+++ b/test/core/end2end/tests/simple_request.c
@@ -114,11 +114,17 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
char *details = NULL;
size_t details_capacity = 0;
int was_cancelled = 2;
+ char *peer;
- c = grpc_channel_create_call(f.client, f.cq, "/foo",
- "foo.test.google.fr:1234", deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
+ peer = grpc_call_get_peer(c);
+ GPR_ASSERT(peer != NULL);
+ gpr_log(GPR_DEBUG, "client_peer_before_call=%s", peer);
+ gpr_free(peer);
+
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
grpc_metadata_array_init(&request_metadata_recv);
@@ -151,6 +157,15 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
+ peer = grpc_call_get_peer(s);
+ GPR_ASSERT(peer != NULL);
+ gpr_log(GPR_DEBUG, "server_peer=%s", peer);
+ gpr_free(peer);
+ peer = grpc_call_get_peer(c);
+ GPR_ASSERT(peer != NULL);
+ gpr_log(GPR_DEBUG, "client_peer=%s", peer);
+ gpr_free(peer);
+
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
diff --git a/test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c b/test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c
index 2cd638cbb9..2244e22416 100644
--- a/test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c
+++ b/test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c
@@ -115,8 +115,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.cq, "/foo",
- "foo.test.google.fr:1234", deadline);
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);