[fixit] More max_connection_idle fixes (#30639)

* [fixit] More max_connection_idle fixes

- handle the case that the idle timeout occurs between the connection becoming ready and the request being made (by making the request WAIT_FOR_READY to reconnect if needed)
- fix up the math for cq verification: the MAX_CONNECTION_IDLE_MS is an unscaled timeout, whereas the 3000 ms is scaled, so we cannot directly add them and scale

* Automated change: Fix sanity tests

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
pull/30665/head
Craig Tiller 3 years ago committed by GitHub
parent 96af4084c9
commit 1dc7685c55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      test/core/end2end/tests/max_connection_idle.cc

@ -27,6 +27,7 @@
#include <grpc/status.h> #include <grpc/status.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/useful.h" #include "src/core/lib/gpr/useful.h"
@ -84,7 +85,8 @@ static void simple_request_body(grpc_end2end_test_config /*config*/,
op = ops; op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA; op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0; op->data.send_initial_metadata.count = 0;
op->flags = 0; op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY |
GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET;
op->reserved = nullptr; op->reserved = nullptr;
op++; op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
@ -210,7 +212,8 @@ static void test_max_connection_idle(grpc_end2end_test_config config) {
/* wait for the channel to reach its maximum idle time */ /* wait for the channel to reach its maximum idle time */
grpc_channel_watch_connectivity_state( grpc_channel_watch_connectivity_state(
f.client, GRPC_CHANNEL_READY, f.client, GRPC_CHANNEL_READY,
grpc_timeout_milliseconds_to_deadline(MAX_CONNECTION_IDLE_MS + 3000), gpr_time_add(grpc_timeout_milliseconds_to_deadline(3000),
gpr_time_from_millis(MAX_CONNECTION_IDLE_MS, GPR_TIMESPAN)),
f.cq, tag(99)); f.cq, tag(99));
cqv.Expect(tag(99), true); cqv.Expect(tag(99), true);
cqv.Verify(); cqv.Verify();

Loading…
Cancel
Save