UV tests pass on linux

reviewable/pr8125/r4
murgatroid99 8 years ago
parent eebb129fd3
commit 2c287ca750
  1. 4
      Makefile
  2. 31
      build.yaml
  3. 4
      src/core/lib/iomgr/endpoint_pair_uv.c
  4. 77
      src/core/lib/iomgr/pollset_uv.c
  5. 2
      src/core/lib/iomgr/pollset_uv.h
  6. 2
      src/core/lib/iomgr/resolve_address_uv.c
  7. 4
      src/core/lib/iomgr/tcp_client_uv.c
  8. 47
      src/core/lib/iomgr/tcp_server_uv.c
  9. 12
      src/core/lib/iomgr/tcp_uv.c
  10. 4
      src/core/lib/iomgr/timer_uv.c
  11. 7
      src/node/ext/node_grpc.cc
  12. 1
      test/core/bad_client/gen_build_yaml.py
  13. 46
      test/core/end2end/cq_verifier.c
  14. 7
      test/core/end2end/cq_verifier_uv.c
  15. 38
      test/core/end2end/gen_build_yaml.py
  16. 2
      test/core/util/port_server_client.c
  17. 69
      test/core/util/port_uv.c
  18. 1
      tools/buildgen/plugins/make_fuzzer_tests.py
  19. 2
      tools/run_tests/run_tests.py
  20. 4
      tools/run_tests/sources_and_headers.json
  21. 13719
      tools/run_tests/tests.json
  22. 5
      vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj
  23. 9
      vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters
  24. 5
      vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj
  25. 9
      vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj.filters

@ -3084,8 +3084,6 @@ LIBGRPC_TEST_UTIL_SRC = \
test/core/end2end/data/test_root_cert.c \
test/core/security/oauth2_utils.c \
test/core/end2end/cq_verifier.c \
test/core/end2end/cq_verifier_native.c \
test/core/end2end/cq_verifier_uv.c \
test/core/end2end/fixtures/http_proxy.c \
test/core/end2end/fixtures/proxy.c \
test/core/iomgr/endpoint_tests.c \
@ -3266,8 +3264,6 @@ endif
LIBGRPC_TEST_UTIL_UNSECURE_SRC = \
test/core/end2end/cq_verifier.c \
test/core/end2end/cq_verifier_native.c \
test/core/end2end/cq_verifier_uv.c \
test/core/end2end/fixtures/http_proxy.c \
test/core/end2end/fixtures/proxy.c \
test/core/iomgr/endpoint_tests.c \

@ -525,7 +525,6 @@ filegroups:
build: test
headers:
- test/core/end2end/cq_verifier.h
- test/core/end2end/cq_verifier_internal.h
- test/core/end2end/fixtures/http_proxy.h
- test/core/end2end/fixtures/proxy.h
- test/core/iomgr/endpoint_tests.h
@ -539,8 +538,6 @@ filegroups:
- test/core/util/slice_splitter.h
src:
- test/core/end2end/cq_verifier.c
- test/core/end2end/cq_verifier_native.c
- test/core/end2end/cq_verifier_uv.c
- test/core/end2end/fixtures/http_proxy.c
- test/core/end2end/fixtures/proxy.c
- test/core/iomgr/endpoint_tests.c
@ -1344,6 +1341,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
- name: bin_decoder_test
build: test
language: c
@ -1485,6 +1484,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
- name: dns_resolver_connectivity_test
cpu_cost: 0.1
build: test
@ -1496,6 +1497,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
- name: dns_resolver_test
build: test
language: c
@ -1533,6 +1536,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
- name: ev_epoll_linux_test
build: test
language: c
@ -1543,6 +1548,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
platforms:
- linux
- name: fd_conservation_posix_test
@ -1555,6 +1562,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
platforms:
- mac
- linux
@ -1569,6 +1578,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
platforms:
- mac
- linux
@ -1656,6 +1667,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
platforms:
- mac
- linux
@ -1876,6 +1889,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
- name: grpc_create_jwt
build: tool
language: c
@ -2338,6 +2353,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
- name: secure_channel_create_test
build: test
language: c
@ -2358,6 +2375,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
- name: sequential_connectivity_test
build: test
language: c
@ -2368,6 +2387,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
- name: server_chttp2_test
build: test
language: c
@ -2414,6 +2435,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
- name: sockaddr_resolver_test
build: test
language: c
@ -2444,6 +2467,8 @@ targets:
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
platforms:
- mac
- linux

@ -37,13 +37,15 @@
#include <stdlib.h>
#include <grpc/support/log.h>
#include "src/core/lib/iomgr/endpoint_pair.h"
grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char *name,
size_t read_slice_size) {
grpc_endpoint_pair endpoint_pair;
// TODO(mlumish): implement this properly under libuv
abort();
GPR_ASSERT(false && "grpc_iomgr_create_endpoint_pair is not suppoted with libuv");
return endpoint_pair;
}

@ -35,40 +35,105 @@
#ifdef GRPC_UV
#include <uv.h>
#include <string.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/iomgr/pollset_uv.h"
struct grpc_pollset {
uv_timer_t timer;
int shutting_down;
};
/* Indicates that grpc_pollset_work should run an iteration of the UV loop
before running callbacks. This defaults to 1, and should be disabled if
grpc_pollset_work will be called within the callstack of uv_run */
int grpc_pollset_work_run_loop;
gpr_mu grpc_polling_mu;
size_t grpc_pollset_size() { return 1; }
size_t grpc_pollset_size() { return sizeof(grpc_pollset); }
void grpc_pollset_global_init(void) { gpr_mu_init(&grpc_polling_mu); }
void grpc_pollset_global_init(void) {
gpr_mu_init(&grpc_polling_mu);
grpc_pollset_work_run_loop = 1;
}
void grpc_pollset_global_shutdown(void) { gpr_mu_destroy(&grpc_polling_mu); }
void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
*mu = &grpc_polling_mu;
memset(pollset, 0, sizeof(grpc_pollset));
uv_timer_init(uv_default_loop(), &pollset->timer);
pollset->shutting_down = 0;
}
static void timer_close_cb(uv_handle_t *handle) {
handle->data = (void *)1;
}
void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
grpc_closure *closure) {
GPR_ASSERT(!pollset->shutting_down);
pollset->shutting_down = 1;
if (grpc_pollset_work_run_loop) {
// Drain any pending UV callbacks without blocking
uv_run(uv_default_loop(), UV_RUN_NOWAIT);
}
grpc_exec_ctx_sched(exec_ctx, closure, GRPC_ERROR_NONE, NULL);
}
void grpc_pollset_destroy(grpc_pollset *pollset) {}
void grpc_pollset_destroy(grpc_pollset *pollset) {
uv_close((uv_handle_t*)&pollset->timer, timer_close_cb);
// timer.data is a boolean indicating that the timer has finished closing
pollset->timer.data = (void *)0;
if (grpc_pollset_work_run_loop) {
while (!pollset->timer.data) {
uv_run(uv_default_loop(), UV_RUN_NOWAIT);
}
}
}
void grpc_pollset_reset(grpc_pollset *pollset) {}
void grpc_pollset_reset(grpc_pollset *pollset) {
GPR_ASSERT(pollset->shutting_down);
pollset->shutting_down = 0;
}
static void timer_run_cb(uv_timer_t *timer) {
}
grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
grpc_pollset_worker **worker_hdl,
gpr_timespec now, gpr_timespec deadline) {
uint64_t timeout;
gpr_mu_unlock(&grpc_polling_mu);
if (grpc_pollset_work_run_loop) {
if (gpr_time_cmp(deadline, now) >= 0) {
timeout = (uint64_t)gpr_time_to_millis(gpr_time_sub(deadline, now));
} else {
timeout = 0;
}
/* We special-case timeout=0 so that we don't bother with the timer when
the loop won't block anyway */
if (timeout > 0) {
uv_timer_start(&pollset->timer, timer_run_cb, timeout, 0);
/* Run until there is some I/O activity or the timer triggers. It doesn't
matter which happens */
uv_run(uv_default_loop(), UV_RUN_ONCE);
uv_timer_stop(&pollset->timer);
} else {
uv_run(uv_default_loop(), UV_RUN_NOWAIT);
}
}
if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
gpr_mu_unlock(&grpc_polling_mu);
grpc_exec_ctx_flush(exec_ctx);
gpr_mu_lock(&grpc_polling_mu);
}
gpr_mu_lock(&grpc_polling_mu);
return GRPC_ERROR_NONE;
}

@ -31,5 +31,7 @@
*
*/
extern int grpc_pollset_work_run_loop;
void grpc_pollset_global_init(void);
void grpc_pollset_global_shutdown(void);

@ -143,6 +143,8 @@ static grpc_error *blocking_resolve_address_impl(
int s;
grpc_error *err;
req.addrinfo = NULL;
err = try_split_host_port(name, default_port, &host, &port);
if (err != GRPC_ERROR_NONE) {
goto done;

@ -61,7 +61,6 @@ static void uv_tcp_connect_cleanup(grpc_uv_tcp_connect *connect) {
}
static void tcp_close_callback(uv_handle_t *handle) {
gpr_log(GPR_DEBUG, "Freeing uv_tcp_t handle %p", handle);
gpr_free(handle);
}
@ -73,7 +72,6 @@ static void uv_tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp,
/* error == NONE implies that the timer ran out, and wasn't cancelled. If
it was cancelled, then the handler that cancelled it also should close
the handle, if applicable */
gpr_log(GPR_DEBUG, "Closing uv_tcp_t handle %p", connect->tcp_handle);
uv_close((uv_handle_t *)connect->tcp_handle, tcp_close_callback);
}
done = (--connect->refs == 0);
@ -104,7 +102,6 @@ static void uv_tc_on_connect(uv_connect_t *req, int status) {
} else {
error = grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR,
uv_strerror(status));
gpr_log(GPR_DEBUG, "Closing uv_tcp_t handle %p", connect->tcp_handle);
uv_close((uv_handle_t *)connect->tcp_handle, tcp_close_callback);
}
}
@ -128,7 +125,6 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
connect->closure = closure;
connect->endpoint = ep;
connect->tcp_handle = gpr_malloc(sizeof(uv_tcp_t));
gpr_log(GPR_DEBUG, "Allocated uv_tcp_t handle %p", connect->tcp_handle);
connect->addr_name = grpc_sockaddr_to_uri(resolved_addr);
uv_tcp_init(uv_default_loop(), connect->tcp_handle);
connect->connect_req.data = connect;

@ -116,7 +116,6 @@ static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
grpc_tcp_listener *sp = s->head;
s->head = sp->next;
sp->next = NULL;
gpr_log(GPR_DEBUG, "Freeing uv_tcp_t handle %p", sp->handle);
gpr_free(sp->handle);
gpr_free(sp);
}
@ -141,7 +140,6 @@ static void tcp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
immediately_done = 1;
}
for (sp = s->head; sp; sp = sp->next) {
gpr_log(GPR_DEBUG, "Closing uv_tcp_t handle %p", sp->handle);
uv_close((uv_handle_t *)sp->handle, handle_close_callback);
}
@ -166,6 +164,10 @@ void grpc_tcp_server_unref(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
}
}
static void accepted_connection_close_cb(uv_handle_t *handle) {
gpr_free(handle);
}
static void on_connect(uv_stream_t *server, int status) {
grpc_tcp_listener *sp = (grpc_tcp_listener *)server->data;
grpc_tcp_server_acceptor acceptor = {sp->server, sp->port_index, 0};
@ -176,7 +178,6 @@ static void on_connect(uv_stream_t *server, int status) {
char *peer_name_string;
int err;
gpr_log(GPR_DEBUG, "Server %p received a connection", sp->server);
if (status < 0) {
gpr_log(GPR_INFO, "Skipping on_accept due to error: %s",
@ -184,25 +185,28 @@ static void on_connect(uv_stream_t *server, int status) {
return;
}
client = gpr_malloc(sizeof(uv_tcp_t));
gpr_log(GPR_DEBUG, "Allocated uv_tcp_t handle %p", client);
uv_tcp_init(uv_default_loop(), client);
// UV documentation says this is guaranteed to succeed
uv_accept((uv_stream_t *)server, (uv_stream_t *)client);
peer_name_string = NULL;
memset(&peer_name, 0, sizeof(grpc_resolved_address));
peer_name.len = sizeof(struct sockaddr_storage);
err = uv_tcp_getpeername(client, (struct sockaddr *)&peer_name.addr,
(int *)&peer_name.len);
if (err == 0) {
peer_name_string = grpc_sockaddr_to_uri(&peer_name);
// If the server has not been started, we discard incoming connections
if (sp->server->on_accept_cb == NULL) {
uv_close((uv_handle_t *)client, accepted_connection_close_cb);
} else {
gpr_log(GPR_INFO, "uv_tcp_getpeername error: %s", uv_strerror(status));
peer_name_string = NULL;
memset(&peer_name, 0, sizeof(grpc_resolved_address));
peer_name.len = sizeof(struct sockaddr_storage);
err = uv_tcp_getpeername(client, (struct sockaddr *)&peer_name.addr,
(int *)&peer_name.len);
if (err == 0) {
peer_name_string = grpc_sockaddr_to_uri(&peer_name);
} else {
gpr_log(GPR_INFO, "uv_tcp_getpeername error: %s", uv_strerror(status));
}
ep = grpc_tcp_create(client, peer_name_string);
sp->server->on_accept_cb(&exec_ctx, sp->server->on_accept_cb_arg, ep, NULL,
&acceptor);
grpc_exec_ctx_finish(&exec_ctx);
}
ep = grpc_tcp_create(client, peer_name_string);
gpr_log(GPR_DEBUG, "Calling on_accept_cb for server %p", sp->server);
sp->server->on_accept_cb(&exec_ctx, sp->server->on_accept_cb_arg, ep, NULL,
&acceptor);
grpc_exec_ctx_finish(&exec_ctx);
}
static grpc_error *add_socket_to_server(grpc_tcp_server *s, uv_tcp_t *handle,
@ -224,6 +228,14 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, uv_tcp_t *handle,
return error;
}
status = uv_listen((uv_stream_t *)handle, SOMAXCONN, on_connect);
if (status != 0) {
error = GRPC_ERROR_CREATE("Failed to listen to port");
error =
grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, uv_strerror(status));
return error;
}
sockname_temp.len = (int)sizeof(struct sockaddr_storage);
status = uv_tcp_getsockname(handle, (struct sockaddr *)&sockname_temp.addr,
(int *)&sockname_temp.len);
@ -308,7 +320,6 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
}
handle = gpr_malloc(sizeof(uv_tcp_t));
gpr_log(GPR_DEBUG, "Allocating uv_tcp_t handle %p", handle);
status = uv_tcp_init(uv_default_loop(), handle);
if (status == 0) {
error = add_socket_to_server(s, handle, addr, port_index, &sp);

@ -64,13 +64,12 @@ typedef struct {
gpr_slice_buffer *write_slices;
uv_buf_t *write_buffers;
int shutting_down;
bool shutting_down;
char *peer_string;
grpc_pollset *pollset;
} grpc_tcp;
static void uv_close_callback(uv_handle_t *handle) {
gpr_log(GPR_DEBUG, "Freeing uv_tcp_t handle %p", handle);
gpr_free(handle);
}
@ -281,14 +280,16 @@ static void shutdown_callback(uv_shutdown_t *req, int status) { gpr_free(req); }
static void uv_endpoint_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
grpc_tcp *tcp = (grpc_tcp *)ep;
uv_shutdown_t *req = gpr_malloc(sizeof(uv_shutdown_t));
uv_shutdown(req, (uv_stream_t *)tcp->handle, shutdown_callback);
if (!tcp->shutting_down) {
tcp->shutting_down = true;
uv_shutdown_t *req = gpr_malloc(sizeof(uv_shutdown_t));
uv_shutdown(req, (uv_stream_t *)tcp->handle, shutdown_callback);
}
}
static void uv_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
grpc_network_status_unregister_endpoint(ep);
grpc_tcp *tcp = (grpc_tcp *)ep;
gpr_log(GPR_DEBUG, "Closing uv_tcp_t handle %p", tcp->handle);
uv_close((uv_handle_t *)tcp->handle, uv_close_callback);
TCP_UNREF(tcp, "destroy");
}
@ -322,6 +323,7 @@ grpc_endpoint *grpc_tcp_create(uv_tcp_t *handle, char *peer_string) {
handle->data = tcp;
gpr_ref_init(&tcp->refcount, 1);
tcp->peer_string = gpr_strdup(peer_string);
tcp->shutting_down = false;
/* Tell network status tracking code about the new endpoint */
grpc_network_status_register_endpoint(&tcp->base);

@ -47,14 +47,12 @@ static void timer_close_callback(uv_handle_t *handle) { gpr_free(handle); }
static void stop_uv_timer(uv_timer_t *handle) {
uv_timer_stop(handle);
uv_unref((uv_handle_t *)handle);
gpr_log(GPR_DEBUG, "Closing uv_timer_t handle %p", handle);
uv_close((uv_handle_t *)handle, timer_close_callback);
}
void run_expired_timer(uv_timer_t *handle) {
grpc_timer *timer = (grpc_timer *)handle->data;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_log(GPR_DEBUG, "Timer callback: %p", timer);
GPR_ASSERT(!timer->triggered);
timer->triggered = 1;
grpc_exec_ctx_sched(&exec_ctx, &timer->closure, GRPC_ERROR_NONE, NULL);
@ -75,7 +73,6 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
}
timer->triggered = 0;
timeout = (uint64_t)gpr_time_to_millis(gpr_time_sub(deadline, now));
gpr_log(GPR_DEBUG, "Setting timer %p: %lu", timer, timeout);
uv_timer = gpr_malloc(sizeof(uv_timer_t));
uv_timer_init(uv_default_loop(), uv_timer);
uv_timer->data = timer;
@ -85,7 +82,6 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer) {
if (!timer->triggered) {
gpr_log(GPR_DEBUG, "Running cancelled timer callback");
timer->triggered = 1;
grpc_exec_ctx_sched(exec_ctx, &timer->closure, GRPC_ERROR_CANCELLED, NULL);
stop_uv_timer((uv_timer_t *)timer->uv_timer);

@ -42,6 +42,10 @@
#include "grpc/support/log.h"
#include "grpc/support/time.h"
#ifdef GRPC_UV
#include "src/core/lib/iomgr/pollset_uv.h"
#endif
#include "call.h"
#include "call_credentials.h"
#include "channel.h"
@ -439,6 +443,9 @@ void init(Local<Object> exports) {
uv_signal_start(&signal_handle, signal_callback, SIGUSR2);
uv_unref((uv_handle_t *)&signal_handle);
#ifdef GRPC_UV
grpc_pollset_work_run_loop = 0;
#endif
grpc::node::Call::Init(exports);
grpc::node::CallCredentials::Init(exports);

@ -83,6 +83,7 @@ def main():
'secure': 'no',
'src': ['test/core/bad_client/tests/%s.c' % t],
'vs_proj_dir': 'test',
'exclude_iomgrs': ['uv'],
'deps': [
'bad_client_test',
'grpc_test_util_unsecure',

@ -32,7 +32,6 @@
*/
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/cq_verifier_internal.h"
#include <stdarg.h>
#include <stdio.h>
@ -60,15 +59,35 @@ typedef struct metadata {
/* details what we expect to find on a single event - and forms a linked
list to detail other expectations */
struct expectation {
typedef struct expectation {
struct expectation *next;
const char *file;
int line;
grpc_completion_type type;
void *tag;
int success;
} expectation;
/* the verifier itself */
struct cq_verifier {
/* bound completion queue */
grpc_completion_queue *cq;
/* start of expectation list */
expectation *first_expectation;
};
cq_verifier *cq_verifier_create(grpc_completion_queue *cq) {
cq_verifier *v = gpr_malloc(sizeof(cq_verifier));
v->cq = cq;
v->first_expectation = NULL;
return v;
}
void cq_verifier_destroy(cq_verifier *v) {
cq_verify(v);
gpr_free(v);
}
static int has_metadata(const grpc_metadata *md, size_t count, const char *key,
const char *value) {
size_t i;
@ -178,7 +197,7 @@ static void expectation_to_strvec(gpr_strvec *buf, expectation *e) {
static void expectations_to_strvec(gpr_strvec *buf, cq_verifier *v) {
expectation *e;
for (e = cq_verifier_get_first_expectation(v); e != NULL; e = e->next) {
for (e = v->first_expectation; e != NULL; e = e->next) {
expectation_to_strvec(buf, e);
gpr_strvec_add(buf, gpr_strdup("\n"));
}
@ -198,19 +217,19 @@ static void fail_no_event_received(cq_verifier *v) {
}
void cq_verify(cq_verifier *v) {
int timeout_seconds = 10;
while (cq_verifier_get_first_expectation(v) != NULL) {
grpc_event ev = cq_verifier_next_event(v, timeout_seconds);
const gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10);
while (v->first_expectation != NULL) {
grpc_event ev = grpc_completion_queue_next(v->cq, deadline, NULL);
if (ev.type == GRPC_QUEUE_TIMEOUT) {
fail_no_event_received(v);
break;
}
expectation *e;
expectation *prev = NULL;
for (e = cq_verifier_get_first_expectation(v); e != NULL; e = e->next) {
for (e = v->first_expectation; e != NULL; e = e->next) {
if (e->tag == ev.tag) {
verify_matches(e, &ev);
if (e == cq_verifier_get_first_expectation(v)) cq_verifier_set_first_expectation(v, e->next);
if (e == v->first_expectation) v->first_expectation = e->next;
if (prev != NULL) prev->next = e->next;
gpr_free(e);
break;
@ -234,11 +253,14 @@ void cq_verify(cq_verifier *v) {
}
void cq_verify_empty_timeout(cq_verifier *v, int timeout_sec) {
gpr_timespec deadline =
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_seconds(timeout_sec, GPR_TIMESPAN));
grpc_event ev;
GPR_ASSERT(cq_verifier_get_first_expectation(v) == NULL && "expectation queue must be empty");
GPR_ASSERT(v->first_expectation == NULL && "expectation queue must be empty");
ev = cq_verifier_next_event(v, timeout_sec);
ev = grpc_completion_queue_next(v->cq, deadline, NULL);
if (ev.type != GRPC_QUEUE_TIMEOUT) {
char *s = grpc_event_string(&ev);
gpr_log(GPR_ERROR, "unexpected event (expected nothing): %s", s);
@ -257,8 +279,8 @@ static void add(cq_verifier *v, const char *file, int line,
e->line = line;
e->tag = tag;
e->success = success;
e->next = cq_verifier_get_first_expectation(v);
cq_verifier_set_first_expectation(v, e);
e->next = v->first_expectation;
v->first_expectation = e;
}
void cq_expect_completion(cq_verifier *v, const char *file, int line, void *tag,

@ -38,6 +38,7 @@
#include <uv.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "test/core/end2end/cq_verifier_internal.h"
@ -65,7 +66,7 @@ cq_verifier *cq_verifier_create(grpc_completion_queue *cq) {
return v;
}
void timer_close_cb(uv_handle_t *handle) {
static void timer_close_cb(uv_handle_t *handle) {
handle->data = (void *)TIMER_CLOSED;
}
@ -86,12 +87,12 @@ void cq_verifier_set_first_expectation(cq_verifier *v, expectation *e) {
v->first_expectation = e;
}
void timer_run_cb(uv_timer_t *timer) {
static void timer_run_cb(uv_timer_t *timer) {
timer->data = (void *)TIMER_TRIGGERED;
}
grpc_event cq_verifier_next_event(cq_verifier *v, int timeout_seconds) {
uint64_t timeout_ms = timeout_seconds < 0 ? 0 : (uint64_t)timeout_seconds * 1000;
uint64_t timeout_ms = timeout_seconds < 0 ? 0 : (uint64_t)timeout_seconds * 1000;
grpc_event ev;
v->timer.data = (void *)TIMER_STARTED;
uv_timer_start(&v->timer, timer_run_cb, timeout_ms, 0);

@ -44,14 +44,15 @@ default_unsecure_fixture_options = FixtureOptions(
True, False, True, False, ['windows', 'linux', 'mac', 'posix'], True, False, [], [])
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'])
uds_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, platforms=['linux', 'mac', 'posix'], exclude_iomgrs=['uv'])
fd_unsecure_fixture_options = default_unsecure_fixture_options._replace(
dns_resolver=False, fullstack=False, platforms=['linux', 'mac', 'posix'])
dns_resolver=False, fullstack=False, platforms=['linux', 'mac', 'posix'], exclude_iomgrs=['uv'])
# maps fixture name to whether it requires the security library
END2END_FIXTURES = {
'h2_compress': default_unsecure_fixture_options,
'h2_census': default_unsecure_fixture_options,
'h2_load_reporting': default_unsecure_fixture_options,
'h2_fakesec': default_secure_fixture_options._replace(ci_mac=False),
@ -60,26 +61,29 @@ END2END_FIXTURES = {
'h2_full+pipe': default_unsecure_fixture_options._replace(
platforms=['linux'], exclude_iomgrs=['uv']),
'h2_full+trace': default_unsecure_fixture_options._replace(tracing=True),
'h2_http_proxy': default_unsecure_fixture_options._replace(ci_mac=False),
'h2_oauth2': default_secure_fixture_options._replace(ci_mac=False),
'h2_proxy': default_unsecure_fixture_options._replace(includes_proxy=True,
ci_mac=False),
'h2_http_proxy': default_unsecure_fixture_options._replace(
ci_mac=False, exclude_iomgrs=['uv']),
'h2_oauth2': default_secure_fixture_options._replace(
ci_mac=False, exclude_iomgrs=['uv']),
'h2_proxy': default_unsecure_fixture_options._replace(
includes_proxy=True, ci_mac=False, exclude_iomgrs=['uv']),
'h2_sockpair_1byte': socketpair_unsecure_fixture_options._replace(
ci_mac=False, exclude_configs=['msan']),
'h2_sockpair': socketpair_unsecure_fixture_options._replace(ci_mac=False),
ci_mac=False, exclude_configs=['msan'], exclude_iomgrs=['uv']),
'h2_sockpair': socketpair_unsecure_fixture_options._replace(
ci_mac=False, exclude_iomgrs=['uv']),
'h2_sockpair+trace': socketpair_unsecure_fixture_options._replace(
ci_mac=False, tracing=True),
ci_mac=False, tracing=True, exclude_iomgrs=['uv']),
'h2_ssl': default_secure_fixture_options,
'h2_ssl_cert': default_secure_fixture_options,
'h2_ssl_proxy': default_secure_fixture_options._replace(includes_proxy=True,
ci_mac=False),
'h2_ssl_proxy': default_secure_fixture_options._replace(
includes_proxy=True, ci_mac=False, exclude_iomgrs=['uv']),
'h2_uds': uds_fixture_options,
}
TestOptions = collections.namedtuple(
'TestOptions',
'needs_fullstack needs_dns proxyable secure traceable cpu_cost')
default_test_options = TestOptions(False, False, True, False, True, 1.0)
'needs_fullstack needs_dns proxyable secure traceable cpu_cost exclude_iomgrs')
default_test_options = TestOptions(False, False, True, False, True, 1.0, [])
connectivity_test_options = default_test_options._replace(needs_fullstack=True)
LOWCPU = 0.1
@ -96,8 +100,8 @@ END2END_TESTS = {
'cancel_in_a_vacuum': default_test_options._replace(cpu_cost=LOWCPU),
'cancel_with_status': default_test_options._replace(cpu_cost=LOWCPU),
'compressed_payload': default_test_options._replace(proxyable=False),
'connectivity': connectivity_test_options._replace(proxyable=False,
cpu_cost=LOWCPU),
'connectivity': connectivity_test_options._replace(
proxyable=False, cpu_cost=LOWCPU, exclude_iomgrs=['uv']),
'default_host': default_test_options._replace(needs_fullstack=True,
needs_dns=True),
'disappearing_server': connectivity_test_options,
@ -246,6 +250,8 @@ def main():
'name': '%s_test' % f,
'args': [t],
'exclude_configs': [],
'exclude_iomgrs': list(set(END2END_FIXTURES[f].exclude_iomgrs) |
set(END2END_TESTS[t].exclude_iomgrs)),
'platforms': END2END_FIXTURES[f].platforms,
'ci_platforms': (END2END_FIXTURES[f].platforms
if END2END_FIXTURES[f].ci_mac else without(
@ -261,6 +267,8 @@ def main():
'name': '%s_nosec_test' % f,
'args': [t],
'exclude_configs': END2END_FIXTURES[f].exclude_configs,
'exclude_iomgrs': list(set(END2END_FIXTURES[f].exclude_iomgrs) |
set(END2END_TESTS[t].exclude_iomgrs)),
'platforms': END2END_FIXTURES[f].platforms,
'ci_platforms': (END2END_FIXTURES[f].platforms
if END2END_FIXTURES[f].ci_mac else without(

@ -80,7 +80,7 @@ void grpc_free_port_using_server(char *server, int port) {
grpc_httpcli_response rsp;
freereq pr;
char *path;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_RUN_INNER_LOOP;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_closure *shutdown_closure;
grpc_init();

@ -35,13 +35,75 @@
#include "test/core/util/test_config.h"
#if defined(GRPC_UV) && defined(GRPC_TEST_PICK_PORT)
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/support/env.h"
#include "test/core/util/port.h"
#include "test/core/util/port_server_client.h"
// Almost everything in this file has been copied from port_posix.c
static int *chosen_ports = NULL;
static size_t num_chosen_ports = 0;
static int free_chosen_port(int port) {
size_t i;
int found = 0;
size_t found_at = 0;
char *env = gpr_getenv("GRPC_TEST_PORT_SERVER");
/* Find the port and erase it from the list, then tell the server it can be
freed. */
for (i = 0; i < num_chosen_ports; i++) {
if (chosen_ports[i] == port) {
GPR_ASSERT(found == 0);
found = 1;
found_at = i;
}
}
if (found) {
chosen_ports[found_at] = chosen_ports[num_chosen_ports - 1];
num_chosen_ports--;
if (env) {
grpc_free_port_using_server(env, port);
}
}
gpr_free(env);
return found;
}
static void free_chosen_ports(void) {
char *env = gpr_getenv("GRPC_TEST_PORT_SERVER");
if (env != NULL) {
size_t i;
for (i = 0; i < num_chosen_ports; i++) {
grpc_free_port_using_server(env, chosen_ports[i]);
}
gpr_free(env);
}
gpr_free(chosen_ports);
}
static void chose_port(int port) {
if (chosen_ports == NULL) {
atexit(free_chosen_ports);
}
num_chosen_ports++;
chosen_ports = gpr_realloc(chosen_ports, sizeof(int) * num_chosen_ports);
chosen_ports[num_chosen_ports - 1] = port;
}
int grpc_pick_unused_port(void) {
// Temporary implementation
return 4242;
// Currently only works with the port server
char *env = gpr_getenv("GRPC_TEST_PORT_SERVER");
GPR_ASSERT(env);
int port = grpc_pick_port_using_server(env);
gpr_free(env);
if (port != 0) {
chose_port(port);
}
return port;
}
int grpc_pick_unused_port_or_die(void) {
@ -51,8 +113,7 @@ int grpc_pick_unused_port_or_die(void) {
}
void grpc_recycle_unused_port(int port) {
// Temporary implementation
(void)port;
GPR_ASSERT(free_chosen_port(port));
}
#endif /* GRPC_UV && GRPC_TEST_PICK_PORT */

@ -49,6 +49,7 @@ def mako_plugin(dictionary):
tests.append({
'name': new_target['name'],
'args': [fn],
'exclude_iomgrs': ['uv'],
'exclude_configs': ['tsan'],
'uses_polling': False,
'platforms': ['linux'],

@ -223,6 +223,8 @@ class CLanguage(object):
polling_strategies = (_POLLING_STRATEGIES.get(self.platform, ['all'])
if target.get('uses_polling', True)
else ['all'])
if self.args.iomgr_platform == 'uv':
polling_strategies = ['all']
for polling_strategy in polling_strategies:
env={'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH':
_ROOT + '/src/core/lib/tsi/test_creds/ca.pem',

@ -6906,7 +6906,6 @@
],
"headers": [
"test/core/end2end/cq_verifier.h",
"test/core/end2end/cq_verifier_internal.h",
"test/core/end2end/fixtures/http_proxy.h",
"test/core/end2end/fixtures/proxy.h",
"test/core/iomgr/endpoint_tests.h",
@ -6925,9 +6924,6 @@
"src": [
"test/core/end2end/cq_verifier.c",
"test/core/end2end/cq_verifier.h",
"test/core/end2end/cq_verifier_internal.h",
"test/core/end2end/cq_verifier_native.c",
"test/core/end2end/cq_verifier_uv.c",
"test/core/end2end/fixtures/http_proxy.c",
"test/core/end2end/fixtures/http_proxy.h",
"test/core/end2end/fixtures/proxy.c",

File diff suppressed because it is too large Load Diff

@ -176,7 +176,6 @@
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\data\ssl_test_data.h" />
<ClInclude Include="$(SolutionDir)\..\test\core\security\oauth2_utils.h" />
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\cq_verifier.h" />
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\cq_verifier_internal.h" />
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\fixtures\http_proxy.h" />
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\fixtures\proxy.h" />
<ClInclude Include="$(SolutionDir)\..\test\core\iomgr\endpoint_tests.h" />
@ -292,10 +291,6 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\cq_verifier.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\cq_verifier_native.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\cq_verifier_uv.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\fixtures\http_proxy.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\fixtures\proxy.c">

@ -19,12 +19,6 @@
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\cq_verifier.c">
<Filter>test\core\end2end</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\cq_verifier_native.c">
<Filter>test\core\end2end</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\cq_verifier_uv.c">
<Filter>test\core\end2end</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\fixtures\http_proxy.c">
<Filter>test\core\end2end\fixtures</Filter>
</ClCompile>
@ -461,9 +455,6 @@
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\cq_verifier.h">
<Filter>test\core\end2end</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\cq_verifier_internal.h">
<Filter>test\core\end2end</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\fixtures\http_proxy.h">
<Filter>test\core\end2end\fixtures</Filter>
</ClInclude>

@ -148,7 +148,6 @@
<ItemGroup>
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\cq_verifier.h" />
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\cq_verifier_internal.h" />
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\fixtures\http_proxy.h" />
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\fixtures\proxy.h" />
<ClInclude Include="$(SolutionDir)\..\test\core\iomgr\endpoint_tests.h" />
@ -164,10 +163,6 @@
<ItemGroup>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\cq_verifier.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\cq_verifier_native.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\cq_verifier_uv.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\fixtures\http_proxy.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\fixtures\proxy.c">

@ -4,12 +4,6 @@
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\cq_verifier.c">
<Filter>test\core\end2end</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\cq_verifier_native.c">
<Filter>test\core\end2end</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\cq_verifier_uv.c">
<Filter>test\core\end2end</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\fixtures\http_proxy.c">
<Filter>test\core\end2end\fixtures</Filter>
</ClCompile>
@ -54,9 +48,6 @@
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\cq_verifier.h">
<Filter>test\core\end2end</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\cq_verifier_internal.h">
<Filter>test\core\end2end</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\test\core\end2end\fixtures\http_proxy.h">
<Filter>test\core\end2end\fixtures</Filter>
</ClInclude>

Loading…
Cancel
Save