grpc_authz test: longer wait for authz policy reload (#29779)

* longer wait for authz policy reload

* fixup
pull/29798/head
Jan Tattermusch 3 years ago committed by GitHub
parent 23a06f7ef5
commit c34a006801
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      test/core/end2end/tests/grpc_authz.cc

@ -51,6 +51,13 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
static void wait_for_policy_reload(void) {
// Wait for the provider's refresh thread to read the updated files.
// TODO(jtattermusch): Refactor the tests to use a more reliable mechanism of
// detecting that the policy has been reloaded. See b/204329811
gpr_sleep_until(grpc_timeout_seconds_to_deadline(5));
}
static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
@ -576,8 +583,7 @@ static void test_file_watcher_valid_policy_reload(
" ]"
"}";
tmp_policy.RewriteFile(authz_policy);
// Wait 2 seconds for the provider's refresh thread to read the updated files.
gpr_sleep_until(grpc_timeout_seconds_to_deadline(2));
wait_for_policy_reload();
test_deny_unauthorized_request(f);
end_test(&f);
@ -623,8 +629,7 @@ static void test_file_watcher_invalid_policy_skip_reload(
// Replace exisiting policy in file with an invalid policy.
authz_policy = "{}";
tmp_policy.RewriteFile(authz_policy);
// Wait 2 seconds for the provider's refresh thread to read the updated files.
gpr_sleep_until(grpc_timeout_seconds_to_deadline(2));
wait_for_policy_reload();
test_allow_authorized_request(f);
end_test(&f);
@ -669,8 +674,7 @@ static void test_file_watcher_recovers_from_failure(
// Replace exisiting policy in file with an invalid policy.
authz_policy = "{}";
tmp_policy.RewriteFile(authz_policy);
// Wait 2 seconds for the provider's refresh thread to read the updated files.
gpr_sleep_until(grpc_timeout_seconds_to_deadline(2));
wait_for_policy_reload();
test_allow_authorized_request(f);
// Recover from reload errors, by replacing invalid policy in file with a
// valid policy.
@ -699,8 +703,7 @@ static void test_file_watcher_recovers_from_failure(
" ]"
"}";
tmp_policy.RewriteFile(authz_policy);
// Wait 2 seconds for the provider's refresh thread to read the updated files.
gpr_sleep_until(grpc_timeout_seconds_to_deadline(2));
wait_for_policy_reload();
test_deny_unauthorized_request(f);
end_test(&f);

Loading…
Cancel
Save