Skip to content

Commit

Permalink
address comments and fix clang tidy tests that failed: replace initia…
Browse files Browse the repository at this point in the history
…l delay argument string with minimum delay, remove error handling, and update tests with new backoff strategy limits
  • Loading branch information
alevenberg committed May 24, 2023
1 parent f41e756 commit d0f192c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
4 changes: 2 additions & 2 deletions google/cloud/internal/backoff_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ class ExponentialBackoffPolicy : public BackoffPolicy {
template <typename Rep1, typename Period1, typename Rep2, typename Period2,
typename Rep3, typename Period3>
ExponentialBackoffPolicy(
std::chrono::duration<Rep1, Period1> initial_delay_range,
std::chrono::duration<Rep2, Period2> minimum_delay,
std::chrono::duration<Rep1, Period1> minimum_delay,
std::chrono::duration<Rep2, Period2> initial_delay_upper_bound,
std::chrono::duration<Rep3, Period3> maximum_delay, double scaling)
: minimum_delay_(minimum_delay),
initial_delay_upper_bound_(initial_delay_upper_bound),
Expand Down
36 changes: 0 additions & 36 deletions google/cloud/internal/backoff_policy_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,6 @@ TEST(ExponentialBackoffPolicy, Simple) {
TEST(ExponentialBackoffPolicy, VerifyFullJitterPolicy) {
ExponentialBackoffPolicy tested(ms(0), ms(10), ms(50), 2.0);

auto delay = tested.OnCompletion();
EXPECT_LE(ms(0), delay);
EXPECT_GE(ms(10), delay);
delay = tested.OnCompletion();
EXPECT_LE(ms(0), delay);
EXPECT_GE(ms(20), delay);
delay = tested.OnCompletion();
EXPECT_LE(ms(0), delay);
EXPECT_GE(ms(40), delay);
delay = tested.OnCompletion();
EXPECT_LE(ms(10), delay);
EXPECT_GE(ms(100), delay);
}

/// @test Verify a full jitter policy, where the minimum delay is set to 0.
TEST(ExponentialBackoffPolicy, VerifyFullJitterPolicy) {
ExponentialBackoffPolicy tested(ms(0), ms(10), ms(50), 2.0);

auto delay = tested.OnCompletion();
EXPECT_LE(ms(0), delay);
EXPECT_GE(ms(10), delay);
delay = tested.OnCompletion();
EXPECT_LE(ms(0), delay);
EXPECT_GE(ms(20), delay);
delay = tested.OnCompletion();
EXPECT_LE(ms(0), delay);
EXPECT_GE(ms(40), delay);
delay = tested.OnCompletion();
EXPECT_LE(ms(10), delay);
EXPECT_GE(ms(100), delay);
}

/// @test Verify a full jitter policy, where the minimum delay is set to 0.
TEST(ExponentialBackoffPolicy, VerifyFullJitterPolicy) {
ExponentialBackoffPolicy tested(ms(10), ms(0), ms(50), 2.0);

auto delay = tested.OnCompletion();
EXPECT_LE(ms(0), delay);
EXPECT_GE(ms(10), delay);
Expand Down

0 comments on commit d0f192c

Please sign in to comment.