From f62c4d5a988f37d812373580137ff69a77305102 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 4 Dec 2015 07:43:07 -0800 Subject: [PATCH] Test repeatability fixes --- src/core/channel/client_channel.c | 2 ++ src/core/security/credentials.c | 14 ++++++-------- test/core/end2end/tests/high_initial_seqno.c | 10 ++++++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index da0fdba6435..9f993b39d64 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -124,6 +124,8 @@ static void on_lb_policy_state_changed_locked( w->chand->resolver != NULL) { publish_state = GRPC_CHANNEL_TRANSIENT_FAILURE; grpc_resolver_channel_saw_error(exec_ctx, w->chand->resolver); + GRPC_LB_POLICY_UNREF(exec_ctx, w->chand->lb_policy, "channel"); + w->chand->lb_policy = NULL; } grpc_connectivity_state_set(exec_ctx, &w->chand->state_tracker, publish_state, "lb_changed"); diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c index 543c75044b9..38a6710cd47 100644 --- a/src/core/security/credentials.c +++ b/src/core/security/credentials.c @@ -39,7 +39,7 @@ #include "src/core/channel/channel_args.h" #include "src/core/channel/http_client_filter.h" #include "src/core/httpcli/httpcli.h" -#include "src/core/iomgr/iomgr.h" +#include "src/core/iomgr/executor.h" #include "src/core/json/json.h" #include "src/core/support/string.h" #include "src/core/surface/api_trace.h" @@ -48,7 +48,6 @@ #include #include #include -#include #include /* -- Common. -- */ @@ -792,15 +791,14 @@ static void md_only_test_destruct(grpc_call_credentials *creds) { grpc_credentials_md_store_unref(c->md_store); } -static void on_simulated_token_fetch_done(void *user_data) { +static void on_simulated_token_fetch_done(grpc_exec_ctx *exec_ctx, + void *user_data, int success) { grpc_credentials_metadata_request *r = (grpc_credentials_metadata_request *)user_data; grpc_md_only_test_credentials *c = (grpc_md_only_test_credentials *)r->creds; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - r->cb(&exec_ctx, r->user_data, c->md_store->entries, c->md_store->num_entries, + r->cb(exec_ctx, r->user_data, c->md_store->entries, c->md_store->num_entries, GRPC_CREDENTIALS_OK); grpc_credentials_metadata_request_destroy(r); - grpc_exec_ctx_finish(&exec_ctx); } static void md_only_test_get_request_metadata( @@ -810,10 +808,10 @@ static void md_only_test_get_request_metadata( grpc_md_only_test_credentials *c = (grpc_md_only_test_credentials *)creds; if (c->is_async) { - gpr_thd_id thd_id; grpc_credentials_metadata_request *cb_arg = grpc_credentials_metadata_request_create(creds, cb, user_data); - gpr_thd_new(&thd_id, on_simulated_token_fetch_done, cb_arg, NULL); + grpc_executor_enqueue( + grpc_closure_create(on_simulated_token_fetch_done, cb_arg), 1); } else { cb(exec_ctx, user_data, c->md_store->entries, 1, GRPC_CREDENTIALS_OK); } diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index 578fdf7b350..399b6e21837 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -36,13 +36,15 @@ #include #include -#include "src/core/support/string.h" #include #include #include #include +#include #include #include + +#include "src/core/support/string.h" #include "test/core/end2end/cq_verifier.h" enum { TIMEOUT = 200000 }; @@ -208,6 +210,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config, grpc_end2end_test_fixture f; grpc_arg client_arg; grpc_channel_args client_args; + char *name; client_arg.type = GRPC_ARG_INTEGER; client_arg.key = GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER; @@ -216,13 +219,16 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config, client_args.num_args = 1; client_args.args = &client_arg; - f = begin_test(config, "test_invoke_10_simple_requests", &client_args, NULL); + gpr_asprintf(&name, "test_invoke_requests first_seqno=%d", + initial_sequence_number); + f = begin_test(config, name, &client_args, NULL); for (i = 0; i < 10; i++) { simple_request_body(f); gpr_log(GPR_INFO, "Passed simple request %d", i); } end_test(&f); config.tear_down_data(&f); + gpr_free(name); } void grpc_end2end_tests(grpc_end2end_test_config config) {