Deflake lb_policies_test

pull/9138/head
David Garcia Quintas 8 years ago
parent 2cf4f35a38
commit d3b83f4693
  1. 32
      test/core/client_channel/lb_policies_test.c

@ -241,6 +241,8 @@ static request_sequences request_sequences_create(size_t n) {
res.n = n; res.n = n;
res.connections = gpr_malloc(sizeof(*res.connections) * n); res.connections = gpr_malloc(sizeof(*res.connections) * n);
res.connectivity_states = gpr_malloc(sizeof(*res.connectivity_states) * n); res.connectivity_states = gpr_malloc(sizeof(*res.connectivity_states) * n);
memset(res.connections, 0, sizeof(*res.connections) * n);
memset(res.connectivity_states, 0, sizeof(*res.connectivity_states) * n);
return res; return res;
} }
@ -782,17 +784,15 @@ static void verify_total_carnage_round_robin(const servers_fixture *f,
} }
} }
/* no server is ever available. The persistent state is TRANSIENT_FAILURE. May /* No server is ever available. There should be no READY states (or SHUTDOWN).
* also be CONNECTING if, under load, this check took too long to run and some * Note that all other states (IDLE, CONNECTING, TRANSIENT_FAILURE) are still
* subchannel already transitioned to retrying. */ * possible, as the policy transitions while attempting to reconnect. */
for (size_t i = 0; i < sequences->n; i++) { for (size_t i = 0; i < sequences->n; i++) {
const grpc_connectivity_state actual = sequences->connectivity_states[i]; const grpc_connectivity_state actual = sequences->connectivity_states[i];
if (actual != GRPC_CHANNEL_TRANSIENT_FAILURE && if (actual == GRPC_CHANNEL_READY || actual == GRPC_CHANNEL_SHUTDOWN) {
actual != GRPC_CHANNEL_CONNECTING) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"CONNECTIVITY STATUS SEQUENCE FAILURE: expected " "CONNECTIVITY STATUS SEQUENCE FAILURE: got unexpected state "
"GRPC_CHANNEL_TRANSIENT_FAILURE or GRPC_CHANNEL_CONNECTING, got " "'%s' at iteration #%d.",
"'%s' at iteration #%d",
grpc_connectivity_state_name(actual), (int)i); grpc_connectivity_state_name(actual), (int)i);
abort(); abort();
} }
@ -841,17 +841,15 @@ static void verify_partial_carnage_round_robin(
abort(); abort();
} }
/* ... and that the last one should be TRANSIENT_FAILURE, after all servers /* ... and that the last one shouldn't be READY (or SHUTDOWN): all servers are
* are gone. May also be CONNECTING if, under load, this check took too long * gone. It may be all other states (IDLE, CONNECTING, TRANSIENT_FAILURE), as
* to run and the subchannel already transitioned to retrying. */ * the policy transitions while attempting to reconnect. */
actual = sequences->connectivity_states[num_iters - 1]; actual = sequences->connectivity_states[num_iters - 1];
for (i = 0; i < sequences->n; i++) { for (i = 0; i < sequences->n; i++) {
if (actual != GRPC_CHANNEL_TRANSIENT_FAILURE && if (actual == GRPC_CHANNEL_READY || actual == GRPC_CHANNEL_SHUTDOWN) {
actual != GRPC_CHANNEL_CONNECTING) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"CONNECTIVITY STATUS SEQUENCE FAILURE: expected " "CONNECTIVITY STATUS SEQUENCE FAILURE: got unexpected state "
"GRPC_CHANNEL_TRANSIENT_FAILURE or GRPC_CHANNEL_CONNECTING, got " "'%s' at iteration #%d.",
"'%s' at iteration #%d",
grpc_connectivity_state_name(actual), (int)i); grpc_connectivity_state_name(actual), (int)i);
abort(); abort();
} }
@ -948,8 +946,8 @@ int main(int argc, char **argv) {
const size_t NUM_ITERS = 10; const size_t NUM_ITERS = 10;
const size_t NUM_SERVERS = 4; const size_t NUM_SERVERS = 4;
grpc_test_init(argc, argv);
grpc_init(); grpc_init();
grpc_test_init(argc, argv);
grpc_tracer_set_enabled("round_robin", 1); grpc_tracer_set_enabled("round_robin", 1);
GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, "this-lb-policy-does-not-exist", GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, "this-lb-policy-does-not-exist",

Loading…
Cancel
Save