Fix bad test

pull/11866/head
Craig Tiller 8 years ago
parent e0a90891db
commit 07e81dd900
  1. 24
      src/core/ext/transport/chttp2/transport/chttp2_transport.c
  2. 17
      test/core/end2end/tests/bad_ping.c

@ -1563,16 +1563,20 @@ static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport *t) {
gpr_log(GPR_DEBUG, "PING strike");
if (++t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes &&
t->ping_policy.max_ping_strikes != 0) {
send_goaway(exec_ctx, t,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("too_many_pings"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM));
/*The transport will be closed after the write is done */
close_transport_locked(
exec_ctx, t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"));
t->ping_recv_state.ping_strikes++;
if (t->ping_policy.max_ping_strikes != 0) {
gpr_log(GPR_DEBUG, "%s: PING strike %d/%d", t->peer_string,
t->ping_recv_state.ping_strikes, t->ping_policy.max_ping_strikes);
if (t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes) {
send_goaway(
exec_ctx, t,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("too_many_pings"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM));
/*The transport will be closed after the write is done */
close_transport_locked(
exec_ctx, t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"));
}
}
}

@ -154,14 +154,16 @@ static void test_bad_ping(grpc_end2end_test_config config) {
cq_verify(cqv);
// Send too many pings to the server to trigger the punishment:
// The first ping is sent after data frames, it won't trigger a ping strike.
// Each of the following pings will trigger a ping strike, and we need at
// least (MAX_PING_STRIKES + 1) strikes to trigger the punishment. So
// (MAX_PING_STRIKES + 2) pings are needed here.
// Each ping will trigger a ping strike, and we need at least MAX_PING_STRIKES
// strikes to trigger the punishment. So (MAX_PING_STRIKES + 1) pings are
// needed here.
int i;
for (i = 200; i < 202 + MAX_PING_STRIKES; i++) {
grpc_channel_ping(f.client, f.cq, tag(i), NULL);
CQ_EXPECT_COMPLETION(cqv, tag(i), 1);
for (i = 1; i <= MAX_PING_STRIKES + 1; i++) {
grpc_channel_ping(f.client, f.cq, tag(200 + i), NULL);
CQ_EXPECT_COMPLETION(cqv, tag(200 + i), 1);
if (i == MAX_PING_STRIKES + 1) {
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
}
cq_verify(cqv);
}
@ -189,7 +191,6 @@ static void test_bad_ping(grpc_end2end_test_config config) {
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
cq_verify(cqv);
grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead));

Loading…
Cancel
Save