From 955a364e340cc1954938ae2269693b0a57bec389 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Fri, 17 Jun 2016 13:48:03 -0700 Subject: Add bad_server_response_test --- test/core/end2end/bad_server_response_test.c | 335 +++++++++++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 test/core/end2end/bad_server_response_test.c (limited to 'test') diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c new file mode 100644 index 0000000000..6c00942fb7 --- /dev/null +++ b/test/core/end2end/bad_server_response_test.c @@ -0,0 +1,335 @@ +/* + * + * Copyright 2016, 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 + +#include +#include +#include +#include +#include +#include + +#include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/lib/iomgr/sockaddr.h" +#include "src/core/lib/support/string.h" +#include "test/core/end2end/cq_verifier.h" +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/core/util/test_tcp_server.h" + +#define HTTP1_RESP \ + "HTTP/1.0 400 Bad Request\n" \ + "Content-Type: text/html; charset=UTF-8\n" \ + "Content-Length: 0\n" \ + "Date: Tue, 07 Jun 2016 17:43:20 GMT\n\n" + +#define HTTP2_RESP(STATUS_CODE) \ + "\x00\x00\x00\x04\x00\x00\x00\x00\x00" \ + "\x00\x00" \ + "7\x01\x04\x00\x00\x00\x01" \ + "\x10\x0e" \ + "content-length\x01" \ + "0" \ + "\x10\x0c" \ + "content-type\x09text/html" \ + "\x10\x07:status\x03" #STATUS_CODE + +#define UNPARSEABLE_RESP "Bad Request\n" + +#define HTTP1_DETAIL_MSG "Connection dropped: received http1.x response" + +#define HTTP2_DETAIL_MSG(STATUS_CODE) \ + "Received http2 header with status: " #STATUS_CODE + +#define UNPARSEABLE_DETAIL_MSG \ + "Connection dropped: received unparseable response" + +struct rpc_state { + char *target; + grpc_completion_queue *cq; + grpc_channel *channel; + grpc_call *call; + size_t incoming_data_length; + gpr_slice_buffer temp_incoming_buffer; + gpr_slice_buffer outgoing_buffer; + grpc_endpoint *tcp; + gpr_atm done_atm; + bool write_done; + const char *response_payload; + size_t response_payload_length; +}; + +static int server_port; +static struct rpc_state state; +static grpc_closure on_read; +static grpc_closure on_write; + +static void *tag(intptr_t t) { return (void *)t; } + +static void done_write(grpc_exec_ctx *exec_ctx, void *arg, bool success) { + GPR_ASSERT(success); + + gpr_atm_rel_store(&state.done_atm, 1); +} + +static void handle_write(grpc_exec_ctx *exec_ctx) { + gpr_slice slice = gpr_slice_from_copied_buffer(state.response_payload, + state.response_payload_length); + + gpr_slice_buffer_reset_and_unref(&state.outgoing_buffer); + gpr_slice_buffer_add(&state.outgoing_buffer, slice); + grpc_endpoint_write(exec_ctx, state.tcp, &state.outgoing_buffer, &on_write); +} + +static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, bool success) { + GPR_ASSERT(success); + state.incoming_data_length += state.temp_incoming_buffer.length; + + size_t i; + gpr_log(GPR_DEBUG, "read: success=%d", success); + for (i = 0; i < state.temp_incoming_buffer.count; i++) { + char *dump = gpr_dump_slice(state.temp_incoming_buffer.slices[i], + GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_DEBUG, "%s", dump); + gpr_free(dump); + } + + gpr_log(GPR_DEBUG, "got %d bytes, http2 connect string is %d bytes", + state.incoming_data_length, GRPC_CHTTP2_CLIENT_CONNECT_STRLEN); + if (state.incoming_data_length > GRPC_CHTTP2_CLIENT_CONNECT_STRLEN) { + handle_write(exec_ctx); + } else { + grpc_endpoint_read(exec_ctx, state.tcp, &state.temp_incoming_buffer, + &on_read); + } +} + +static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, + grpc_pollset *accepting_pollset, + grpc_tcp_server_acceptor *acceptor) { + test_tcp_server *server = arg; + grpc_closure_init(&on_read, handle_read, NULL); + grpc_closure_init(&on_write, done_write, NULL); + gpr_slice_buffer_init(&state.temp_incoming_buffer); + gpr_slice_buffer_init(&state.outgoing_buffer); + state.tcp = tcp; + grpc_endpoint_add_to_pollset(exec_ctx, tcp, server->pollset); + grpc_endpoint_read(exec_ctx, tcp, &state.temp_incoming_buffer, &on_read); +} + +static gpr_timespec n_sec_deadline(int seconds) { + return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_seconds(seconds, GPR_TIMESPAN)); +} + +static void start_rpc(int target_port, grpc_status_code expected_status, + const char *expected_detail) { + grpc_op ops[6]; + grpc_op *op; + grpc_metadata_array initial_metadata_recv; + grpc_metadata_array trailing_metadata_recv; + grpc_status_code status; + grpc_call_error error; + cq_verifier *cqv; + char *details = NULL; + size_t details_capacity = 0; + + state.cq = grpc_completion_queue_create(NULL); + cqv = cq_verifier_create(state.cq); + gpr_join_host_port(&state.target, "127.0.0.1", target_port); + state.channel = grpc_insecure_channel_create(state.target, NULL, NULL); + state.call = grpc_channel_create_call( + state.channel, NULL, GRPC_PROPAGATE_DEFAULTS, state.cq, "/Service/Method", + "localhost", gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata = &initial_metadata_recv; + op->flags = 0; + op->reserved = NULL; + 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->reserved = NULL; + op++; + error = + grpc_call_start_batch(state.call, ops, (size_t)(op - ops), tag(1), NULL); + + GPR_ASSERT(GRPC_CALL_OK == error); + + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); + + gpr_log(GPR_DEBUG, "Rpc status: %d, details: %s", status, details); + GPR_ASSERT(status == expected_status); + GPR_ASSERT(0 == strcmp(details, expected_detail)); + gpr_free(details); + cq_verifier_destroy(cqv); +} + +static void cleanup_rpc(void) { + grpc_event ev; + gpr_slice_buffer_destroy(&state.temp_incoming_buffer); + gpr_slice_buffer_destroy(&state.outgoing_buffer); + grpc_call_destroy(state.call); + grpc_completion_queue_shutdown(state.cq); + do { + ev = grpc_completion_queue_next(state.cq, n_sec_deadline(1), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); + grpc_completion_queue_destroy(state.cq); + grpc_channel_destroy(state.channel); + gpr_free(state.target); +} + +typedef struct { + test_tcp_server *server; + gpr_event *signal_when_done; +} poll_args; + +static void actually_poll_server(void *arg) { + poll_args *pa = arg; + gpr_timespec deadline = n_sec_deadline(10); + while (true) { + bool done = gpr_atm_acq_load(&state.done_atm) != 0; + gpr_timespec time_left = + gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME)); + gpr_log(GPR_DEBUG, "done=%d, time_left=%d.%09d", done, time_left.tv_sec, + time_left.tv_nsec); + if (done || gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) < 0) { + break; + } + test_tcp_server_poll(pa->server, 1); + } + gpr_event_set(pa->signal_when_done, (void *)1); + gpr_free(pa); +} + +static void poll_server_until_read_done(test_tcp_server *server, + gpr_event *signal_when_done) { + gpr_atm_rel_store(&state.done_atm, 0); + state.write_done = 0; + gpr_thd_id id; + poll_args *pa = gpr_malloc(sizeof(*pa)); + pa->server = server; + pa->signal_when_done = signal_when_done; + gpr_thd_new(&id, actually_poll_server, pa, NULL); +} + +static void run_test(const char *response_payload, + size_t response_payload_length, + grpc_status_code expected_status, + const char *expected_detail) { + test_tcp_server test_server; + server_port = grpc_pick_unused_port_or_die(); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + gpr_event ev; + gpr_event_init(&ev); + + test_tcp_server_init(&test_server, on_connect, &test_server); + test_tcp_server_start(&test_server, server_port); + state.response_payload = response_payload; + state.response_payload_length = response_payload_length; + + /* poll server until sending out the response */ + poll_server_until_read_done(&test_server, &ev); + start_rpc(server_port, expected_status, expected_detail); + gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME)); + + /* clean up */ + grpc_endpoint_shutdown(&exec_ctx, state.tcp); + grpc_endpoint_destroy(&exec_ctx, state.tcp); + grpc_exec_ctx_finish(&exec_ctx); + cleanup_rpc(); + test_tcp_server_destroy(&test_server); +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + grpc_init(); + + /* status defined in hpack static table */ + run_test(HTTP2_RESP(204), sizeof(HTTP2_RESP(204)) - 1, GRPC_STATUS_CANCELLED, + HTTP2_DETAIL_MSG(204)); + + run_test(HTTP2_RESP(206), sizeof(HTTP2_RESP(206)) - 1, GRPC_STATUS_CANCELLED, + HTTP2_DETAIL_MSG(206)); + + run_test(HTTP2_RESP(304), sizeof(HTTP2_RESP(304)) - 1, GRPC_STATUS_CANCELLED, + HTTP2_DETAIL_MSG(304)); + + run_test(HTTP2_RESP(400), sizeof(HTTP2_RESP(400)) - 1, GRPC_STATUS_CANCELLED, + HTTP2_DETAIL_MSG(400)); + + run_test(HTTP2_RESP(404), sizeof(HTTP2_RESP(404)) - 1, GRPC_STATUS_CANCELLED, + HTTP2_DETAIL_MSG(404)); + + run_test(HTTP2_RESP(500), sizeof(HTTP2_RESP(500)) - 1, GRPC_STATUS_CANCELLED, + HTTP2_DETAIL_MSG(500)); + + /* status not defined in hpack static table */ + run_test(HTTP2_RESP(401), sizeof(HTTP2_RESP(401)) - 1, GRPC_STATUS_CANCELLED, + HTTP2_DETAIL_MSG(401)); + + run_test(HTTP2_RESP(403), sizeof(HTTP2_RESP(403)) - 1, GRPC_STATUS_CANCELLED, + HTTP2_DETAIL_MSG(403)); + + run_test(HTTP2_RESP(502), sizeof(HTTP2_RESP(502)) - 1, GRPC_STATUS_CANCELLED, + HTTP2_DETAIL_MSG(502)); + + /* unparseable response */ + run_test(UNPARSEABLE_RESP, sizeof(UNPARSEABLE_RESP) - 1, + GRPC_STATUS_UNAVAILABLE, UNPARSEABLE_DETAIL_MSG); + + /* http1 response */ + run_test(HTTP1_RESP, sizeof(HTTP1_RESP) - 1, GRPC_STATUS_UNAVAILABLE, + HTTP1_DETAIL_MSG); + + grpc_shutdown(); + return 0; +} -- cgit v1.2.3 From adb65a6a4905ee8a74e6f6cb222c0b95ed1b7b1b Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Mon, 20 Jun 2016 15:56:43 -0700 Subject: Fixed gpr_log format issues --- .../ext/transport/chttp2/transport/chttp2_transport.c | 2 +- test/core/end2end/bad_server_response_test.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index aad655effd..2a5b503c0c 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1705,7 +1705,7 @@ static void parsing_action(grpc_exec_ctx *exec_ctx, void *arg, errors[1] = grpc_chttp2_perform_read(exec_ctx, &t->parsing, t->read_buffer.slices[i]); }; - if (i != t->read_buffer.count) { + if (i != t->read_buffer.count || errors[1] != GRPC_ERROR_NONE) { gpr_slice_unref(t->optional_drop_message); errors[2] = try_http_parsing(exec_ctx, t); if (errors[2] != GRPC_ERROR_NONE) { diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c index 6c00942fb7..c2882b6243 100644 --- a/test/core/end2end/bad_server_response_test.c +++ b/test/core/end2end/bad_server_response_test.c @@ -96,8 +96,8 @@ static grpc_closure on_write; static void *tag(intptr_t t) { return (void *)t; } -static void done_write(grpc_exec_ctx *exec_ctx, void *arg, bool success) { - GPR_ASSERT(success); +static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { + GPR_ASSERT(error == GRPC_ERROR_NONE); gpr_atm_rel_store(&state.done_atm, 1); } @@ -111,12 +111,11 @@ static void handle_write(grpc_exec_ctx *exec_ctx) { grpc_endpoint_write(exec_ctx, state.tcp, &state.outgoing_buffer, &on_write); } -static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, bool success) { - GPR_ASSERT(success); +static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { + GPR_ASSERT(error == GRPC_ERROR_NONE); state.incoming_data_length += state.temp_incoming_buffer.length; size_t i; - gpr_log(GPR_DEBUG, "read: success=%d", success); for (i = 0; i < state.temp_incoming_buffer.count; i++) { char *dump = gpr_dump_slice(state.temp_incoming_buffer.slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); @@ -124,7 +123,8 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, bool success) { gpr_free(dump); } - gpr_log(GPR_DEBUG, "got %d bytes, http2 connect string is %d bytes", + gpr_log(GPR_DEBUG, + "got %" PRIuPTR " bytes, http2 connect string is %" PRIuMAX " bytes", state.incoming_data_length, GRPC_CHTTP2_CLIENT_CONNECT_STRLEN); if (state.incoming_data_length > GRPC_CHTTP2_CLIENT_CONNECT_STRLEN) { handle_write(exec_ctx); @@ -239,8 +239,8 @@ static void actually_poll_server(void *arg) { bool done = gpr_atm_acq_load(&state.done_atm) != 0; gpr_timespec time_left = gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME)); - gpr_log(GPR_DEBUG, "done=%d, time_left=%d.%09d", done, time_left.tv_sec, - time_left.tv_nsec); + gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done, + time_left.tv_sec, time_left.tv_nsec); if (done || gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) < 0) { break; } -- cgit v1.2.3 From 113cdb4fc3a9c35f5493fd3a5ba53814a6470b9b Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Mon, 20 Jun 2016 17:08:29 -0700 Subject: Fixed gpr_log format issues in linux_x86_default_bo --- test/core/end2end/bad_server_response_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c index c2882b6243..4a2355b5f6 100644 --- a/test/core/end2end/bad_server_response_test.c +++ b/test/core/end2end/bad_server_response_test.c @@ -124,7 +124,7 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { } gpr_log(GPR_DEBUG, - "got %" PRIuPTR " bytes, http2 connect string is %" PRIuMAX " bytes", + "got %" PRIuPTR " bytes, http2 connect string is %" PRIuPTR " bytes", state.incoming_data_length, GRPC_CHTTP2_CLIENT_CONNECT_STRLEN); if (state.incoming_data_length > GRPC_CHTTP2_CLIENT_CONNECT_STRLEN) { handle_write(exec_ctx); -- cgit v1.2.3 From d9c6ac09625e548faf286b73f0b0d74fb1b3bb1d Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Wed, 22 Jun 2016 11:11:46 -0700 Subject: Memset ops before being used, destroy metadata_recv after beign used --- test/core/end2end/bad_server_response_test.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c index 4a2355b5f6..ebf2caa070 100644 --- a/test/core/end2end/bad_server_response_test.c +++ b/test/core/end2end/bad_server_response_test.c @@ -55,13 +55,13 @@ #define HTTP2_RESP(STATUS_CODE) \ "\x00\x00\x00\x04\x00\x00\x00\x00\x00" \ - "\x00\x00" \ - "7\x01\x04\x00\x00\x00\x01" \ + "\x00\x00>\x01\x04\x00\x00\x00\x01" \ "\x10\x0e" \ "content-length\x01" \ "0" \ "\x10\x0c" \ - "content-type\x09text/html" \ + "content-type\x10" \ + "application/grpc" \ "\x10\x07:status\x03" #STATUS_CODE #define UNPARSEABLE_RESP "Bad Request\n" @@ -119,7 +119,7 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { for (i = 0; i < state.temp_incoming_buffer.count; i++) { char *dump = gpr_dump_slice(state.temp_incoming_buffer.slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "%s", dump); + gpr_log(GPR_DEBUG, "Server received: %s", dump); gpr_free(dump); } @@ -175,6 +175,7 @@ static void start_rpc(int target_port, grpc_status_code expected_status, grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -209,6 +210,9 @@ static void start_rpc(int target_port, grpc_status_code expected_status, gpr_log(GPR_DEBUG, "Rpc status: %d, details: %s", status, details); GPR_ASSERT(status == expected_status); GPR_ASSERT(0 == strcmp(details, expected_detail)); + + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); gpr_free(details); cq_verifier_destroy(cqv); } -- cgit v1.2.3 From f7c7f330a8efa7f264a52973a0c62dc1016f0648 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Wed, 22 Jun 2016 13:37:02 -0700 Subject: Init grpc for each test --- test/core/end2end/bad_server_response_test.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c index ebf2caa070..878dfaed5a 100644 --- a/test/core/end2end/bad_server_response_test.c +++ b/test/core/end2end/bad_server_response_test.c @@ -270,11 +270,12 @@ static void run_test(const char *response_payload, grpc_status_code expected_status, const char *expected_detail) { test_tcp_server test_server; - server_port = grpc_pick_unused_port_or_die(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_event ev; - gpr_event_init(&ev); + grpc_init(); + gpr_event_init(&ev); + server_port = grpc_pick_unused_port_or_die(); test_tcp_server_init(&test_server, on_connect, &test_server); test_tcp_server_start(&test_server, server_port); state.response_payload = response_payload; @@ -291,11 +292,12 @@ static void run_test(const char *response_payload, grpc_exec_ctx_finish(&exec_ctx); cleanup_rpc(); test_tcp_server_destroy(&test_server); + + grpc_shutdown(); } int main(int argc, char **argv) { grpc_test_init(argc, argv); - grpc_init(); /* status defined in hpack static table */ run_test(HTTP2_RESP(204), sizeof(HTTP2_RESP(204)) - 1, GRPC_STATUS_CANCELLED, @@ -334,6 +336,5 @@ int main(int argc, char **argv) { run_test(HTTP1_RESP, sizeof(HTTP1_RESP) - 1, GRPC_STATUS_UNAVAILABLE, HTTP1_DETAIL_MSG); - grpc_shutdown(); return 0; } -- cgit v1.2.3 From df4455a34d73578c1ad5bdb829327bfaa1720026 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Fri, 24 Jun 2016 16:15:18 -0700 Subject: Fix test failure --- test/core/end2end/bad_server_response_test.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c index 878dfaed5a..a6b0d71e18 100644 --- a/test/core/end2end/bad_server_response_test.c +++ b/test/core/end2end/bad_server_response_test.c @@ -39,7 +39,7 @@ #include #include -#include "src/core/ext/transport/chttp2/transport/internal.h" +// #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" @@ -74,6 +74,9 @@ #define UNPARSEABLE_DETAIL_MSG \ "Connection dropped: received unparseable response" +/* TODO(zyc) Check the content of incomming data instead of using this length */ +#define EXPECTED_INCOMING_DATA_LENGTH (size_t)310 + struct rpc_state { char *target; grpc_completion_queue *cq; @@ -124,9 +127,9 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { } gpr_log(GPR_DEBUG, - "got %" PRIuPTR " bytes, http2 connect string is %" PRIuPTR " bytes", - state.incoming_data_length, GRPC_CHTTP2_CLIENT_CONNECT_STRLEN); - if (state.incoming_data_length > GRPC_CHTTP2_CLIENT_CONNECT_STRLEN) { + "got %" PRIuPTR " bytes, expected %" PRIuPTR " bytes", + state.incoming_data_length, EXPECTED_INCOMING_DATA_LENGTH); + if (state.incoming_data_length > EXPECTED_INCOMING_DATA_LENGTH) { handle_write(exec_ctx); } else { grpc_endpoint_read(exec_ctx, state.tcp, &state.temp_incoming_buffer, @@ -143,6 +146,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, gpr_slice_buffer_init(&state.temp_incoming_buffer); gpr_slice_buffer_init(&state.outgoing_buffer); state.tcp = tcp; + state.incoming_data_length = 0; grpc_endpoint_add_to_pollset(exec_ctx, tcp, server->pollset); grpc_endpoint_read(exec_ctx, tcp, &state.temp_incoming_buffer, &on_read); } -- cgit v1.2.3 From c8e47ca36eb04438fd3ee96c71ec646a225bbaa2 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Tue, 28 Jun 2016 12:47:49 -0700 Subject: Fix format issues --- test/core/end2end/bad_server_response_test.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test') diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c index a6b0d71e18..5b39d10143 100644 --- a/test/core/end2end/bad_server_response_test.c +++ b/test/core/end2end/bad_server_response_test.c @@ -126,8 +126,7 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { gpr_free(dump); } - gpr_log(GPR_DEBUG, - "got %" PRIuPTR " bytes, expected %" PRIuPTR " bytes", + gpr_log(GPR_DEBUG, "got %" PRIuPTR " bytes, expected %" PRIuPTR " bytes", state.incoming_data_length, EXPECTED_INCOMING_DATA_LENGTH); if (state.incoming_data_length > EXPECTED_INCOMING_DATA_LENGTH) { handle_write(exec_ctx); -- cgit v1.2.3 From eda85c6765bf9b201fe5fa3185b704490f14026e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 1 Jul 2016 12:45:19 -0700 Subject: Expunge all references to zookeeper --- Makefile | 96 +-------- doc/naming.md | 22 --- include/grpc/grpc_zookeeper.h | 59 ------ src/core/ext/resolver/zookeeper/README.md | 1 - templates/Makefile.template | 199 ++----------------- .../dockerfile/run_tests_addons_nocache.include | 4 - test/build/zookeeper.c | 43 ---- test/cpp/end2end/shutdown_test.cc | 1 - test/cpp/end2end/zookeeper_test.cc | 219 --------------------- .../grpc_check_generated_pb_files/Dockerfile | 5 - .../interoptest/grpc_interop_csharp/Dockerfile | 4 - .../interoptest/grpc_interop_cxx/Dockerfile | 4 - .../interoptest/grpc_interop_node/Dockerfile | 4 - .../interoptest/grpc_interop_php/Dockerfile | 4 - .../interoptest/grpc_interop_python/Dockerfile | 4 - .../interoptest/grpc_interop_ruby/Dockerfile | 4 - .../grpc_interop_stress_node/Dockerfile | 4 - .../stress_test/grpc_interop_stress_php/Dockerfile | 4 - .../dockerfile/test/csharp_coreclr_x64/Dockerfile | 4 - tools/dockerfile/test/csharp_jessie_x64/Dockerfile | 4 - tools/dockerfile/test/cxx_jessie_x64/Dockerfile | 4 - tools/dockerfile/test/cxx_jessie_x86/Dockerfile | 4 - .../dockerfile/test/cxx_ubuntu1404_x64/Dockerfile | 4 - .../dockerfile/test/cxx_ubuntu1604_x64/Dockerfile | 4 - tools/dockerfile/test/cxx_wheezy_x64/Dockerfile | 4 - tools/dockerfile/test/fuzzer/Dockerfile | 4 - .../test/multilang_jessie_x64/Dockerfile | 4 - tools/dockerfile/test/node_jessie_x64/Dockerfile | 4 - tools/dockerfile/test/php_jessie_x64/Dockerfile | 4 - tools/dockerfile/test/python_jessie_x64/Dockerfile | 4 - tools/dockerfile/test/ruby_jessie_x64/Dockerfile | 4 - 31 files changed, 20 insertions(+), 713 deletions(-) delete mode 100644 include/grpc/grpc_zookeeper.h delete mode 100644 src/core/ext/resolver/zookeeper/README.md delete mode 100644 test/build/zookeeper.c delete mode 100644 test/cpp/end2end/zookeeper_test.cc (limited to 'test') diff --git a/Makefile b/Makefile index 8fd86e78ed..f1d908dce7 100644 --- a/Makefile +++ b/Makefile @@ -492,7 +492,6 @@ PROTOC_CHECK_CMD = which protoc > /dev/null PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3 DTRACE_CHECK_CMD = which dtrace > /dev/null SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS) -ZOOKEEPER_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/zookeeper.c $(LDFLAGS) -lzookeeper_mt ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG) HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false) @@ -560,8 +559,6 @@ ifeq ($(HAS_SYSTEMTAP),true) CACHE_MK += HAS_SYSTEMTAP = true, endif -HAS_ZOOKEEPER = $(shell $(ZOOKEEPER_CHECK_CMD) 2> /dev/null && echo true || echo false) - # Note that for testing purposes, one can do: # make HAS_EMBEDDED_OPENSSL_ALPN=false # to emulate the fact we do not have OpenSSL in the third_party folder. @@ -705,14 +702,6 @@ PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) PC_LIB = -lgrpc GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE) -# grpc_zookeeper .pc file -PC_NAME = gRPC zookeeper -PC_DESCRIPTION = gRPC's zookeeper plugin -PC_CFLAGS = -PC_REQUIRES_PRIVATE = -PC_LIBS_PRIVATE = -lzookeeper_mt -GRPC_ZOOKEEPER_PC_FILE := $(PC_TEMPLATE) - PROTOBUF_PKG_CONFIG = false PC_REQUIRES_GRPCXX = @@ -1151,7 +1140,6 @@ run_dep_checks: $(PERFTOOLS_CHECK_CMD) || true $(PROTOBUF_CHECK_CMD) || true $(PROTOC_CHECK_VERSION_CMD) || true - $(ZOOKEEPER_CHECK_CMD) || true third_party/protobuf/configure: $(E) "[AUTOGEN] Preparing protobuf" @@ -1170,29 +1158,16 @@ $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure static: static_c static_cxx -static_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgrpc_cronet.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a static_zookeeper_libs - +static_c: pc_c pc_c_unsecure cache.mk $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgrpc_cronet.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a static_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a shared: shared_c shared_cxx -shared_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)gpr$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION).$(SHARED_EXT) shared_zookeeper_libs - +shared_c: pc_c pc_c_unsecure cache.mk $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)gpr$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION).$(SHARED_EXT) shared_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT) shared_csharp: shared_c $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION).$(SHARED_EXT) -ifeq ($(HAS_ZOOKEEPER),true) -static_zookeeper_libs: -shared_zookeeper_libs: -else - -static_zookeeper_libs: - -shared_zookeeper_libs: - -endif - grpc_csharp_ext: shared_csharp plugins: $(PROTOC_PLUGINS) @@ -1204,12 +1179,6 @@ pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc -ifeq ($(HAS_ZOOKEEPER),true) -pc_c_zookeeper: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc -else -pc_c_zookeeper: -endif - pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc @@ -1221,14 +1190,7 @@ privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG endif -ifeq ($(HAS_ZOOKEEPER),true) -privatelibs_zookeeper: -else -privatelibs_zookeeper: -endif - - -buildtests: buildtests_c buildtests_cxx buildtests_zookeeper +buildtests: buildtests_c buildtests_cxx buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/alarm_test \ @@ -1388,7 +1350,7 @@ buildtests_c: privatelibs_c \ ifeq ($(EMBED_OPENSSL),true) -buildtests_cxx: buildtests_zookeeper privatelibs_cxx \ +buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/alarm_cpp_test \ $(BINDIR)/$(CONFIG)/async_end2end_test \ $(BINDIR)/$(CONFIG)/auth_property_iterator_test \ @@ -1472,7 +1434,7 @@ buildtests_cxx: buildtests_zookeeper privatelibs_cxx \ $(BINDIR)/$(CONFIG)/boringssl_ssl_test \ else -buildtests_cxx: buildtests_zookeeper privatelibs_cxx \ +buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/alarm_cpp_test \ $(BINDIR)/$(CONFIG)/async_end2end_test \ $(BINDIR)/$(CONFIG)/auth_property_iterator_test \ @@ -1520,17 +1482,9 @@ buildtests_cxx: buildtests_zookeeper privatelibs_cxx \ endif -ifeq ($(HAS_ZOOKEEPER),true) -buildtests_zookeeper: privatelibs_zookeeper \ - -else -buildtests_zookeeper: -endif - - -test: test_c test_cxx test_zookeeper +test: test_c test_cxx -flaky_test: flaky_test_c flaky_test_cxx flaky_test_zookeeper +flaky_test: flaky_test_c flaky_test_cxx test_c: buildtests_c $(E) "[RUN] Testing alarm_test" @@ -1752,7 +1706,7 @@ flaky_test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/mlog_test || ( echo test mlog_test failed ; exit 1 ) -test_cxx: test_zookeeper buildtests_cxx +test_cxx: buildtests_cxx $(E) "[RUN] Testing alarm_cpp_test" $(Q) $(BINDIR)/$(CONFIG)/alarm_cpp_test || ( echo test alarm_cpp_test failed ; exit 1 ) $(E) "[RUN] Testing async_end2end_test" @@ -1818,18 +1772,6 @@ test_cxx: test_zookeeper buildtests_cxx flaky_test_cxx: buildtests_cxx -ifeq ($(HAS_ZOOKEEPER),true) -test_zookeeper: buildtests_zookeeper - - -flaky_test_zookeeper: buildtests_zookeeper - -else -test_zookeeper: -flaky_test_zookeeper: -endif - - test_python: static_c $(E) "[RUN] Testing python code" $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG) @@ -1867,8 +1809,6 @@ ifeq ($(CONFIG),opt) $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc_cronet.a $(E) "[STRIP] Stripping libgrpc_unsecure.a" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a -ifeq ($(HAS_ZOOKEEPER),true) -endif endif strip-static_cxx: static_cxx @@ -1891,8 +1831,6 @@ ifeq ($(CONFIG),opt) $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION).$(SHARED_EXT) $(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION).$(SHARED_EXT)" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION).$(SHARED_EXT) -ifeq ($(HAS_ZOOKEEPER),true) -endif endif strip-shared_cxx: shared_cxx @@ -1925,11 +1863,6 @@ $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc: $(Q) mkdir -p $(@D) $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@ -$(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc: - $(E) "[MAKE] Generating $@" - $(Q) mkdir -p $(@D) - $(Q) echo "$(GRPC_ZOOKEEPER_PC_FILE)" | tr , '\n' >$@ - $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc: $(E) "[MAKE] Generating $@" $(Q) mkdir -p $(@D) @@ -2205,8 +2138,6 @@ install-static_c: static_c strip-static_c install-pkg-config_c $(E) "[INSTALL] Installing libgrpc_unsecure.a" $(Q) $(INSTALL) -d $(prefix)/lib $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(prefix)/lib/libgrpc_unsecure.a -ifeq ($(HAS_ZOOKEEPER),true) -endif install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx $(E) "[INSTALL] Installing libgrpc++.a" @@ -2258,8 +2189,6 @@ else ifneq ($(SYSTEM),Darwin) $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc_unsecure.so.0 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc_unsecure.so endif -ifeq ($(HAS_ZOOKEEPER),true) -endif ifneq ($(SYSTEM),MINGW32) ifneq ($(SYSTEM),Darwin) $(Q) ldconfig || true @@ -2295,8 +2224,6 @@ else ifneq ($(SYSTEM),Darwin) $(Q) ln -sf $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc++_unsecure.so.0 $(Q) ln -sf $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc++_unsecure.so endif -ifeq ($(HAS_ZOOKEEPER),true) -endif ifneq ($(SYSTEM),MINGW32) ifneq ($(SYSTEM),Darwin) $(Q) ldconfig || true @@ -2314,8 +2241,6 @@ else ifneq ($(SYSTEM),Darwin) $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc_csharp_ext.so.0 $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc_csharp_ext.so endif -ifeq ($(HAS_ZOOKEEPER),true) -endif ifneq ($(SYSTEM),MINGW32) ifneq ($(SYSTEM),Darwin) $(Q) ldconfig || true @@ -2342,14 +2267,11 @@ else $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/grpc_ruby_plugin $(prefix)/bin/grpc_ruby_plugin endif -install-pkg-config_c: pc_c pc_c_unsecure pc_c_zookeeper +install-pkg-config_c: pc_c pc_c_unsecure $(E) "[INSTALL] Installing C pkg-config files" $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc -ifeq ($(HAS_ZOOKEEPER),true) - $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc $(prefix)/lib/pkgconfig/grpc_zookeeper.pc -endif install-pkg-config_cxx: pc_cxx pc_cxx_unsecure $(E) "[INSTALL] Installing C++ pkg-config files" diff --git a/doc/naming.md b/doc/naming.md index 5ad7e6622e..d0c892e8d9 100644 --- a/doc/naming.md +++ b/doc/naming.md @@ -16,8 +16,6 @@ Here, scheme indicates the name-system to be used. Example schemes to be support * `dns` -* `zookeeper` - * `etcd` Authority indicates some scheme-specific bootstrap information, e.g., for DNS, the authority may include the IP[:port] of the DNS server to use. Often, a DNS name may used as the authority, since the ability to resolve DNS names is already built into all gRPC client libraries. @@ -30,23 +28,3 @@ The gRPC client library will switch on the scheme to pick the right resolver plu Resolvers should be able to contact the authority and get a resolution that they return back to the gRPC client library. The returned contents include a list of IP:port, an optional config and optional auth config data to be used for channel authentication. The plugin API allows the resolvers to continuously watch an endpoint_name and return updated resolutions as needed. -## Zookeeper - -Apache [ZooKeeper](https://zookeeper.apache.org/) is a popular solution for building name-systems. Curator is a service discovery system built on to of ZooKeeper. We propose to organize names hierarchically as `/path/service/instance` similar to Apache Curator. - -A fully-qualified ZooKeeper name used to construct a gRPC channel will look as follows: - -``` -zookeeper://host:port/path/service/instance -``` -Here `zookeeper` is the scheme identifying the name-system. `host:port` identifies an authoritative name-server for this scheme (i.e., a Zookeeper server). The host can be an IP address or a DNS name. -Finally `/path/service/instance` is the Zookeeper name to be resolved. - -## Service Registration - - -Service providers can register their services in Zookeeper by using a Zookeeper client. - -Each service is a zookeeper node, and each instance is a child node of the corresponding service. For example, a MySQL service may have multiple instances, `/mysql/1`, `/mysql/2`, `/mysql/3`. The name of the service or instance, as well as an optional path is specified by the service provider. - -The data in service nodes is empty. Each instance node stores its address in the format of `host:port`, where host can be either hostname or IP address. diff --git a/include/grpc/grpc_zookeeper.h b/include/grpc/grpc_zookeeper.h deleted file mode 100644 index 2b195c18bf..0000000000 --- a/include/grpc/grpc_zookeeper.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * 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. - * - */ - -/** Support zookeeper as alternative name system in addition to DNS - * Zookeeper name in gRPC is represented as a URI: - * zookeeper://host:port/path/service/instance - * - * Where zookeeper is the name system scheme - * host:port is the address of a zookeeper server - * /path/service/instance is the zookeeper name to be resolved - * - * Refer doc/naming.md for more details - */ - -#ifndef GRPC_GRPC_ZOOKEEPER_H -#define GRPC_GRPC_ZOOKEEPER_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** Register zookeeper name resolver in grpc */ -void grpc_zookeeper_register(); - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_GRPC_ZOOKEEPER_H */ diff --git a/src/core/ext/resolver/zookeeper/README.md b/src/core/ext/resolver/zookeeper/README.md deleted file mode 100644 index ce6f39683b..0000000000 --- a/src/core/ext/resolver/zookeeper/README.md +++ /dev/null @@ -1 +0,0 @@ -Zookeeper based name resolver: WIP diff --git a/templates/Makefile.template b/templates/Makefile.template index 0e3b9926b7..0cbd8bfdd5 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -380,7 +380,6 @@ PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3 DTRACE_CHECK_CMD = which dtrace > /dev/null SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS) - ZOOKEEPER_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/zookeeper.c $(LDFLAGS) -lzookeeper_mt ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG) HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false) @@ -448,8 +447,6 @@ CACHE_MK += HAS_SYSTEMTAP = true, endif - HAS_ZOOKEEPER = $(shell $(ZOOKEEPER_CHECK_CMD) 2> /dev/null && echo true || echo false) - # Note that for testing purposes, one can do: # make HAS_EMBEDDED_OPENSSL_ALPN=false # to emulate the fact we do not have OpenSSL in the third_party folder. @@ -593,14 +590,6 @@ PC_LIB = -lgrpc GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE) - # grpc_zookeeper .pc file - PC_NAME = gRPC zookeeper - PC_DESCRIPTION = gRPC's zookeeper plugin - PC_CFLAGS = - PC_REQUIRES_PRIVATE = - PC_LIBS_PRIVATE = -lzookeeper_mt - GRPC_ZOOKEEPER_PC_FILE := $(PC_TEMPLATE) - PROTOBUF_PKG_CONFIG = false PC_REQUIRES_GRPCXX = @@ -796,7 +785,6 @@ $(PERFTOOLS_CHECK_CMD) || true $(PROTOBUF_CHECK_CMD) || true $(PROTOC_CHECK_VERSION_CMD) || true - $(ZOOKEEPER_CHECK_CMD) || true third_party/protobuf/configure: $(E) "[AUTOGEN] Preparing protobuf" @@ -815,7 +803,7 @@ static: static_c static_cxx - static_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper\ + static_c: pc_c pc_c_unsecure cache.mk \ % for lib in libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None): @@ -823,7 +811,6 @@ % endif % endif % endfor - static_zookeeper_libs static_cxx: pc_cxx pc_cxx_unsecure cache.mk \ @@ -838,7 +825,7 @@ shared: shared_c shared_cxx - shared_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper\ + shared_c: pc_c pc_c_unsecure cache.mk\ % for lib in libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None): @@ -846,7 +833,6 @@ % endif % endif % endfor - shared_zookeeper_libs shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\ % for lib in libs: @@ -867,33 +853,6 @@ % endif % endfor - ifeq ($(HAS_ZOOKEEPER),true) - static_zookeeper_libs:\ - % for lib in libs: - % if 'Makefile' in lib.get('build_system', ['Makefile']): - % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []): - $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ - % endif - % endif - % endfor - - shared_zookeeper_libs:\ - % for lib in libs: - % if 'Makefile' in lib.get('build_system', ['Makefile']): - % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []): - $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\ - % endif - % endif - % endfor - - else - - static_zookeeper_libs: - - shared_zookeeper_libs: - - endif - grpc_csharp_ext: shared_csharp plugins: $(PROTOC_PLUGINS) @@ -913,12 +872,6 @@ pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc - ifeq ($(HAS_ZOOKEEPER),true) - pc_c_zookeeper: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc - else - pc_c_zookeeper: - endif - pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc @@ -932,7 +885,7 @@ % endif % endif % endfor - + else privatelibs_cxx: \ % for lib in libs: @@ -942,26 +895,11 @@ % endif % endif % endfor - - endif - - - ifeq ($(HAS_ZOOKEEPER),true) - privatelibs_zookeeper: \ - % for lib in libs: - % if 'Makefile' in lib.get('build_system', ['Makefile']): - % if lib.build == 'private' and lib.language == 'c++' and zookeeper in lib.get('external_deps', []): - $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ - % endif - % endif - % endfor - else - privatelibs_zookeeper: endif - buildtests: buildtests_c buildtests_cxx buildtests_zookeeper + buildtests: buildtests_c buildtests_cxx buildtests_c: privatelibs_c <%text>\ % for tgt in targets: @@ -972,40 +910,27 @@ ifeq ($(EMBED_OPENSSL),true) - buildtests_cxx: buildtests_zookeeper privatelibs_cxx <%text>\ + buildtests_cxx: privatelibs_cxx <%text>\ % for tgt in targets: % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None): $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\ % endif % endfor - + else - buildtests_cxx: buildtests_zookeeper privatelibs_cxx <%text>\ + buildtests_cxx: privatelibs_cxx <%text>\ % for tgt in targets: % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl: $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\ % endif % endfor - - endif - - - ifeq ($(HAS_ZOOKEEPER),true) - buildtests_zookeeper: privatelibs_zookeeper <%text>\ - % for tgt in targets: - % if tgt.build == 'test' and tgt.language == 'c++' and 'zookeeper' in tgt.get('external_deps', []): - $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\ - % endif - % endfor - else - buildtests_zookeeper: endif - test: test_c test_cxx test_zookeeper + test: test_c test_cxx - flaky_test: flaky_test_c flaky_test_cxx flaky_test_zookeeper + flaky_test: flaky_test_c flaky_test_cxx test_c: buildtests_c % for tgt in targets: @@ -1025,7 +950,7 @@ % endfor - test_cxx: test_zookeeper buildtests_cxx + test_cxx: buildtests_cxx % for tgt in targets: % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and not tgt.get('flaky', False) and not tgt.get('external_deps', None): $(E) "[RUN] Testing ${tgt.name}" @@ -1043,30 +968,6 @@ % endfor - ifeq ($(HAS_ZOOKEEPER),true) - test_zookeeper: buildtests_zookeeper - % for tgt in targets: - % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and not tgt.get('flaky', False) and 'zookeeper' in tgt.get('external_deps', []): - $(E) "[RUN] Testing ${tgt.name}" - $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 ) - % endif - % endfor - - - flaky_test_zookeeper: buildtests_zookeeper - % for tgt in targets: - % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and tgt.get('flaky', False) and 'zookeeper' in tgt.get('external_deps', []): - $(E) "[RUN] Testing ${tgt.name}" - $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 ) - % endif - % endfor - - else - test_zookeeper: - flaky_test_zookeeper: - endif - - test_python: static_c $(E) "[RUN] Testing python code" $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG) @@ -1126,20 +1027,6 @@ % endif % endif % endfor - ifeq ($(HAS_ZOOKEEPER),true) - % for lib in libs: - % if 'Makefile' in lib.get('build_system', ['Makefile']): - % if lib.language == "c": - % if lib.build == "all": - % if 'zookeeper' in lib.get('external_deps', []): - $(E) "[STRIP] Stripping lib${lib.name}.a" - $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a - % endif - % endif - % endif - % endif - % endfor - endif endif strip-static_cxx: static_cxx @@ -1170,20 +1057,6 @@ % endif % endif % endfor - ifeq ($(HAS_ZOOKEEPER),true) - % for lib in libs: - % if 'Makefile' in lib.get('build_system', ['Makefile']): - % if lib.language == "c": - % if lib.build == "all": - % if 'zookeeper' in lib.get('external_deps', []): - $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)" - $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) - % endif - % endif - % endif - % endif - % endfor - endif endif strip-shared_cxx: shared_cxx @@ -1228,11 +1101,6 @@ $(Q) mkdir -p $(@D) $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@ - $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc: - $(E) "[MAKE] Generating $@" - $(Q) mkdir -p $(@D) - $(Q) echo "$(GRPC_ZOOKEEPER_PC_FILE)" | tr , '\n' >$@ - $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc: $(E) "[MAKE] Generating $@" $(Q) mkdir -p $(@D) @@ -1331,21 +1199,6 @@ % endif % endif % endfor - ifeq ($(HAS_ZOOKEEPER),true) - % for lib in libs: - % if 'Makefile' in lib.get('build_system', ['Makefile']): - % if lib.language == "c": - % if lib.build == "all": - % if 'zookeeper' in lib.get('external_deps', []): - $(E) "[INSTALL] Installing lib${lib.name}.a" - $(Q) $(INSTALL) -d $(prefix)/lib - $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a - % endif - % endif - % endif - % endif - % endfor - endif install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx % for lib in libs: @@ -1380,27 +1233,6 @@ % endif % endif % endfor - ifeq ($(HAS_ZOOKEEPER),true) - % for lib in libs: - % if 'Makefile' in lib.get('build_system', ['Makefile']): - % if lib.language == lang_filter: - % if lib.build == "all": - % if 'zookeeper' in lib.get('external_deps', []): - $(E) "[INSTALL] Installing $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)" - $(Q) $(INSTALL) -d $(prefix)/lib - $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) - ifeq ($(SYSTEM),MINGW32) - $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a - else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.core_version.major} - $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so - endif - % endif - % endif - % endif - % endif - % endfor - endif ifneq ($(SYSTEM),MINGW32) ifneq ($(SYSTEM),Darwin) $(Q) ldconfig || true @@ -1430,14 +1262,11 @@ % endfor endif - install-pkg-config_c: pc_c pc_c_unsecure pc_c_zookeeper + install-pkg-config_c: pc_c pc_c_unsecure $(E) "[INSTALL] Installing C pkg-config files" $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc - ifeq ($(HAS_ZOOKEEPER),true) - $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc $(prefix)/lib/pkgconfig/grpc_zookeeper.pc - endif install-pkg-config_cxx: pc_cxx pc_cxx_unsecure $(E) "[INSTALL] Installing C++ pkg-config files" @@ -1645,9 +1474,6 @@ for src in lib.src: sources_that_don_t_need_openssl.add(src) - if 'zookeeper' in lib.get('external_deps', []): - libs = libs + ' -lzookeeper_mt' - if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check': lib_deps = lib_deps + ' $(OPENSSL_DEP)' mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)' @@ -1802,9 +1628,6 @@ % for dep in tgt.deps: $(LIBDIR)/$(CONFIG)/lib${dep}.a\ % endfor - % if 'zookeeper' in tgt.get('external_deps', []): - -lzookeeper_mt\ - % endif % if tgt.language == "c++": % if tgt.build == 'protoc': $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\ diff --git a/templates/tools/dockerfile/run_tests_addons_nocache.include b/templates/tools/dockerfile/run_tests_addons_nocache.include index 242a1acfb3..74b01e386c 100644 --- a/templates/tools/dockerfile/run_tests_addons_nocache.include +++ b/templates/tools/dockerfile/run_tests_addons_nocache.include @@ -1,6 +1,2 @@ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/test/build/zookeeper.c b/test/build/zookeeper.c deleted file mode 100644 index 7cd3d0da9e..0000000000 --- a/test/build/zookeeper.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * 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. - * - */ - -/* This is just a compilation test, to see if we have Zookeeper C client - library installed. */ - -#include -#include - -int main() { - zookeeper_init(NULL, NULL, 0, 0, 0, 0); - return 0; -} diff --git a/test/cpp/end2end/shutdown_test.cc b/test/cpp/end2end/shutdown_test.cc index aa8d42141d..3f98de6db7 100644 --- a/test/cpp/end2end/shutdown_test.cc +++ b/test/cpp/end2end/shutdown_test.cc @@ -123,7 +123,6 @@ class ShutdownTest : public ::testing::Test { TestServiceImpl service_; }; -// Tests zookeeper state change between two RPCs // TODO(ctiller): leaked objects in this test TEST_F(ShutdownTest, ShutdownTest) { ResetStub(); diff --git a/test/cpp/end2end/zookeeper_test.cc b/test/cpp/end2end/zookeeper_test.cc deleted file mode 100644 index fdc500e535..0000000000 --- a/test/cpp/end2end/zookeeper_test.cc +++ /dev/null @@ -1,219 +0,0 @@ -/* - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "src/core/lib/support/env.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -namespace grpc { -namespace testing { - -class ZookeeperTestServiceImpl - : public ::grpc::testing::EchoTestService::Service { - public: - Status Echo(ServerContext* context, const EchoRequest* request, - EchoResponse* response) GRPC_OVERRIDE { - response->set_message(request->message()); - return Status::OK; - } -}; - -class ZookeeperTest : public ::testing::Test { - protected: - ZookeeperTest() {} - - void SetUp() GRPC_OVERRIDE { - SetUpZookeeper(); - - // Sets up two servers - int port1 = grpc_pick_unused_port_or_die(); - server1_ = SetUpServer(port1); - - int port2 = grpc_pick_unused_port_or_die(); - server2_ = SetUpServer(port2); - - // Registers service /test in zookeeper - RegisterService("/test", "test"); - - // Registers service instance /test/1 in zookeeper - string value = - "{\"host\":\"localhost\",\"port\":\"" + to_string(port1) + "\"}"; - RegisterService("/test/1", value); - - // Registers service instance /test/2 in zookeeper - value = "{\"host\":\"localhost\",\"port\":\"" + to_string(port2) + "\"}"; - RegisterService("/test/2", value); - } - - // Requires zookeeper server running - void SetUpZookeeper() { - // Finds zookeeper server address in environment - // Default is localhost:2181 - zookeeper_address_ = "localhost:2181"; - char* addr = gpr_getenv("GRPC_ZOOKEEPER_SERVER_TEST"); - if (addr != NULL) { - string addr_str(addr); - zookeeper_address_ = addr_str; - gpr_free(addr); - } - gpr_log(GPR_DEBUG, "%s", zookeeper_address_.c_str()); - - // Connects to zookeeper server - zoo_set_debug_level(ZOO_LOG_LEVEL_WARN); - zookeeper_handle_ = - zookeeper_init(zookeeper_address_.c_str(), NULL, 15000, 0, 0, 0); - GPR_ASSERT(zookeeper_handle_ != NULL); - - // Registers zookeeper name resolver in grpc - grpc_zookeeper_register(); - } - - std::unique_ptr SetUpServer(const int port) { - string server_address = "localhost:" + to_string(port); - - ServerBuilder builder; - builder.AddListeningPort(server_address, InsecureServerCredentials()); - builder.RegisterService(&service_); - std::unique_ptr server = builder.BuildAndStart(); - return server; - } - - void RegisterService(const string& name, const string& value) { - char* path = (char*)gpr_malloc(name.size()); - - int status = zoo_exists(zookeeper_handle_, name.c_str(), 0, NULL); - if (status == ZNONODE) { - status = - zoo_create(zookeeper_handle_, name.c_str(), value.c_str(), - value.size(), &ZOO_OPEN_ACL_UNSAFE, 0, path, name.size()); - } else { - status = zoo_set(zookeeper_handle_, name.c_str(), value.c_str(), - value.size(), -1); - } - gpr_free(path); - GPR_ASSERT(status == 0); - } - - void DeleteService(const string& name) { - int status = zoo_delete(zookeeper_handle_, name.c_str(), -1); - GPR_ASSERT(status == 0); - } - - void ChangeZookeeperState() { - server1_->Shutdown(); - DeleteService("/test/1"); - } - - void TearDown() GRPC_OVERRIDE { - server1_->Shutdown(); - server2_->Shutdown(); - zookeeper_close(zookeeper_handle_); - } - - void ResetStub() { - string target = "zookeeper://" + zookeeper_address_ + "/test"; - channel_ = CreateChannel(target, InsecureChannelCredentials()); - stub_ = grpc::testing::EchoTestService::NewStub(channel_); - } - - string to_string(const int number) { - std::stringstream strs; - strs << number; - return strs.str(); - } - - std::shared_ptr channel_; - std::unique_ptr stub_; - std::unique_ptr server1_; - std::unique_ptr server2_; - ZookeeperTestServiceImpl service_; - zhandle_t* zookeeper_handle_; - string zookeeper_address_; -}; - -// Tests zookeeper state change between two RPCs -// TODO(ctiller): leaked objects in this test -TEST_F(ZookeeperTest, ZookeeperStateChangeTwoRpc) { - ResetStub(); - - // First RPC - EchoRequest request1; - EchoResponse response1; - ClientContext context1; - context1.set_authority("test"); - request1.set_message("Hello"); - Status s1 = stub_->Echo(&context1, request1, &response1); - EXPECT_EQ(response1.message(), request1.message()); - EXPECT_TRUE(s1.ok()); - - // Zookeeper state changes - gpr_log(GPR_DEBUG, "Zookeeper state change"); - ChangeZookeeperState(); - // Waits for re-resolving addresses - // TODO(ctiller): RPC will probably fail if not waiting - sleep(1); - - // Second RPC - EchoRequest request2; - EchoResponse response2; - ClientContext context2; - context2.set_authority("test"); - request2.set_message("World"); - Status s2 = stub_->Echo(&context2, request2, &response2); - EXPECT_EQ(response2.message(), request2.message()); - EXPECT_TRUE(s2.ok()); -} - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc_test_init(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tools/dockerfile/grpc_check_generated_pb_files/Dockerfile b/tools/dockerfile/grpc_check_generated_pb_files/Dockerfile index 7658991462..d19bc67120 100644 --- a/tools/dockerfile/grpc_check_generated_pb_files/Dockerfile +++ b/tools/dockerfile/grpc_check_generated_pb_files/Dockerfile @@ -67,11 +67,6 @@ RUN apt-get update && apt-get install -y time && apt-get clean # C++ dependencies RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev libc++-dev clang && apt-get clean -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev - RUN mkdir /var/local/jenkins # Define the default command. diff --git a/tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile index baab2f5638..150dde4f21 100644 --- a/tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile @@ -88,10 +88,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile index 2bbccca9e5..bbd903e269 100644 --- a/tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile @@ -75,10 +75,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile index 2a8d35a5dc..be07094cd2 100644 --- a/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile @@ -82,10 +82,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/interoptest/grpc_interop_php/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_php/Dockerfile index e27a6a2301..af83ee6164 100644 --- a/tools/dockerfile/interoptest/grpc_interop_php/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_php/Dockerfile @@ -100,10 +100,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile index 071fb2c93b..db01e301de 100644 --- a/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile @@ -86,10 +86,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile index df8eef5438..88b513032a 100644 --- a/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile @@ -86,10 +86,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/stress_test/grpc_interop_stress_node/Dockerfile b/tools/dockerfile/stress_test/grpc_interop_stress_node/Dockerfile index 4fd7cc29a3..0738e95e9b 100644 --- a/tools/dockerfile/stress_test/grpc_interop_stress_node/Dockerfile +++ b/tools/dockerfile/stress_test/grpc_interop_stress_node/Dockerfile @@ -87,10 +87,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/stress_test/grpc_interop_stress_php/Dockerfile b/tools/dockerfile/stress_test/grpc_interop_stress_php/Dockerfile index c29aaf7c3f..3092bd955e 100644 --- a/tools/dockerfile/stress_test/grpc_interop_stress_php/Dockerfile +++ b/tools/dockerfile/stress_test/grpc_interop_stress_php/Dockerfile @@ -105,10 +105,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/csharp_coreclr_x64/Dockerfile b/tools/dockerfile/test/csharp_coreclr_x64/Dockerfile index fd7215716d..98515aa5d7 100644 --- a/tools/dockerfile/test/csharp_coreclr_x64/Dockerfile +++ b/tools/dockerfile/test/csharp_coreclr_x64/Dockerfile @@ -103,10 +103,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/csharp_jessie_x64/Dockerfile b/tools/dockerfile/test/csharp_jessie_x64/Dockerfile index baab2f5638..150dde4f21 100644 --- a/tools/dockerfile/test/csharp_jessie_x64/Dockerfile +++ b/tools/dockerfile/test/csharp_jessie_x64/Dockerfile @@ -88,10 +88,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/cxx_jessie_x64/Dockerfile b/tools/dockerfile/test/cxx_jessie_x64/Dockerfile index 6492158929..a8aa74dd0e 100644 --- a/tools/dockerfile/test/cxx_jessie_x64/Dockerfile +++ b/tools/dockerfile/test/cxx_jessie_x64/Dockerfile @@ -108,10 +108,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/cxx_jessie_x86/Dockerfile b/tools/dockerfile/test/cxx_jessie_x86/Dockerfile index 92c9c4ce86..abd3e42f26 100644 --- a/tools/dockerfile/test/cxx_jessie_x86/Dockerfile +++ b/tools/dockerfile/test/cxx_jessie_x86/Dockerfile @@ -75,10 +75,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/cxx_ubuntu1404_x64/Dockerfile b/tools/dockerfile/test/cxx_ubuntu1404_x64/Dockerfile index 5982c9783e..5ef25e80b4 100644 --- a/tools/dockerfile/test/cxx_ubuntu1404_x64/Dockerfile +++ b/tools/dockerfile/test/cxx_ubuntu1404_x64/Dockerfile @@ -67,10 +67,6 @@ RUN apt-get update && apt-get install -y time && apt-get clean # C++ dependencies RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev libc++-dev clang && apt-get clean -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile b/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile index d356433163..c65fc61977 100644 --- a/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile +++ b/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile @@ -75,10 +75,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/cxx_wheezy_x64/Dockerfile b/tools/dockerfile/test/cxx_wheezy_x64/Dockerfile index dd9a79b1ed..9d5dd52c18 100644 --- a/tools/dockerfile/test/cxx_wheezy_x64/Dockerfile +++ b/tools/dockerfile/test/cxx_wheezy_x64/Dockerfile @@ -86,10 +86,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/fuzzer/Dockerfile b/tools/dockerfile/test/fuzzer/Dockerfile index 6ba31114ab..3ac134ad7d 100644 --- a/tools/dockerfile/test/fuzzer/Dockerfile +++ b/tools/dockerfile/test/fuzzer/Dockerfile @@ -108,10 +108,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/multilang_jessie_x64/Dockerfile b/tools/dockerfile/test/multilang_jessie_x64/Dockerfile index 5c3f77405e..5e5969cda2 100644 --- a/tools/dockerfile/test/multilang_jessie_x64/Dockerfile +++ b/tools/dockerfile/test/multilang_jessie_x64/Dockerfile @@ -147,10 +147,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/node_jessie_x64/Dockerfile b/tools/dockerfile/test/node_jessie_x64/Dockerfile index 2a8d35a5dc..be07094cd2 100644 --- a/tools/dockerfile/test/node_jessie_x64/Dockerfile +++ b/tools/dockerfile/test/node_jessie_x64/Dockerfile @@ -82,10 +82,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/php_jessie_x64/Dockerfile b/tools/dockerfile/test/php_jessie_x64/Dockerfile index d8d27846c1..e477295722 100644 --- a/tools/dockerfile/test/php_jessie_x64/Dockerfile +++ b/tools/dockerfile/test/php_jessie_x64/Dockerfile @@ -85,10 +85,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/python_jessie_x64/Dockerfile b/tools/dockerfile/test/python_jessie_x64/Dockerfile index 071fb2c93b..db01e301de 100644 --- a/tools/dockerfile/test/python_jessie_x64/Dockerfile +++ b/tools/dockerfile/test/python_jessie_x64/Dockerfile @@ -86,10 +86,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/ruby_jessie_x64/Dockerfile b/tools/dockerfile/test/ruby_jessie_x64/Dockerfile index df8eef5438..88b513032a 100644 --- a/tools/dockerfile/test/ruby_jessie_x64/Dockerfile +++ b/tools/dockerfile/test/ruby_jessie_x64/Dockerfile @@ -86,10 +86,6 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/c++ RUN ln -s /usr/bin/ccache /usr/local/bin/clang RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ -#====================== -# Zookeeper dependencies -# TODO(jtattermusch): is zookeeper still needed? -RUN apt-get install -y libzookeeper-mt-dev RUN mkdir /var/local/jenkins -- cgit v1.2.3