Fix test flakes in flaky_network_test

- Set channel arg for maximum time between reconnection attempts.
- Don't check status of RPCs that can fail due to network flakiness.
pull/18159/head
Prashant Jaikumar 6 years ago
parent 05d1d03fbd
commit 7f37d1cb0e
  1. 5
      test/cpp/end2end/flaky_network_test.cc

@ -339,11 +339,14 @@ TEST_F(FlakyNetworkTest, NetworkTransition) {
TEST_F(FlakyNetworkTest, ServerUnreachableWithKeepalive) { TEST_F(FlakyNetworkTest, ServerUnreachableWithKeepalive) {
const int kKeepAliveTimeMs = 1000; const int kKeepAliveTimeMs = 1000;
const int kKeepAliveTimeoutMs = 1000; const int kKeepAliveTimeoutMs = 1000;
const int kReconnectBackoffMs = 1000;
ChannelArguments args; ChannelArguments args;
args.SetInt(GRPC_ARG_KEEPALIVE_TIME_MS, kKeepAliveTimeMs); args.SetInt(GRPC_ARG_KEEPALIVE_TIME_MS, kKeepAliveTimeMs);
args.SetInt(GRPC_ARG_KEEPALIVE_TIMEOUT_MS, kKeepAliveTimeoutMs); args.SetInt(GRPC_ARG_KEEPALIVE_TIMEOUT_MS, kKeepAliveTimeoutMs);
args.SetInt(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS, 1); args.SetInt(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS, 1);
args.SetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA, 0); args.SetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA, 0);
args.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, kReconnectBackoffMs);
args.SetInt(GRPC_ARG_MAX_RECONNECT_BACKOFF_MS, kReconnectBackoffMs);
auto channel = BuildChannel("pick_first", args); auto channel = BuildChannel("pick_first", args);
auto stub = BuildStub(channel); auto stub = BuildStub(channel);
@ -421,7 +424,7 @@ TEST_F(FlakyNetworkTest, FlakyNetwork) {
// simulate flaky network (packet loss, corruption and delays) // simulate flaky network (packet loss, corruption and delays)
FlakeNetwork(); FlakeNetwork();
for (int i = 0; i < kMessageCount; ++i) { for (int i = 0; i < kMessageCount; ++i) {
EXPECT_TRUE(SendRpc(stub)); SendRpc(stub);
} }
// remove network flakiness // remove network flakiness
UnflakeNetwork(); UnflakeNetwork();

Loading…
Cancel
Save