aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/end2end/tests/request_with_flags.c
diff options
context:
space:
mode:
authorGravatar Chris Evans <wevans@google.com>2017-03-27 17:34:51 -0500
committerGravatar Chris Evans <wevans@google.com>2017-04-04 10:18:11 -0500
commited2a5470dbf2154aa3bd6ed44ad6151d557b4446 (patch)
treee4a1cb5a7b0ae1bb3797ab48781a33a3c6f5b239 /test/core/end2end/tests/request_with_flags.c
parent82c7fec59c41c7d0be23550169a46848489ba68c (diff)
Calculate RPC deadline right before call creation
Most core end2end tests are written around a single RPC with an explicit deadline. Currently, this deadline is calculated before bringing up the test fixture, and thus time spent bringing up the test fixture is taken from the time allotted to the RPC. This change moves the calculation of these deadlines immediately before call creation. Additionally, the functions that calculate these deadlines have been renamed from 'xx_seconds_time()' to 'xx_seconds_from_now()' for clarity.
Diffstat (limited to 'test/core/end2end/tests/request_with_flags.c')
-rw-r--r--test/core/end2end/tests/request_with_flags.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c
index 329359e08b..10ecf5b1af 100644
--- a/test/core/end2end/tests/request_with_flags.c
+++ b/test/core/end2end/tests/request_with_flags.c
@@ -58,16 +58,18 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
return f;
}
-static gpr_timespec n_seconds_time(int n) {
+static gpr_timespec n_seconds_from_now(int n) {
return grpc_timeout_seconds_to_deadline(n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec five_seconds_from_now(void) {
+ return n_seconds_from_now(5);
+}
static void drain_cq(grpc_completion_queue *cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
@@ -104,7 +106,6 @@ static void test_invoke_request_with_flags(
grpc_slice_from_copied_string("hello world");
grpc_byte_buffer *request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- gpr_timespec deadline = five_seconds_time();
grpc_end2end_test_fixture f =
begin_test(config, "test_invoke_request_with_flags", NULL, NULL);
cq_verifier *cqv = cq_verifier_create(f.cq);
@@ -120,6 +121,7 @@ static void test_invoke_request_with_flags(
grpc_slice details;
grpc_call_error expectation;
+ gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),