fix rate limiter test flakiness

Summary:
fix when elapsed time spans non-integral number of intervals since the rate limiter may still be drained during a partial interval.
Closes https://github.com/facebook/rocksdb/pull/1948

Differential Revision: D4651304

Pulled By: ajkr

fbshipit-source-id: b1f9e70
This commit is contained in:
Andrew Kryczka 2017-03-03 11:00:46 -08:00 committed by Facebook Github Bot
parent 7c80a6d7d1
commit 4561275c2d
1 changed files with 2 additions and 2 deletions

View File

@ -2824,7 +2824,7 @@ TEST_F(DBTest, RateLimitingTest) {
// Most intervals should've been drained (interval time is 100ms, elapsed is
// micros)
ASSERT_GT(rate_limiter_drains, elapsed / 100000 / 2);
ASSERT_LE(rate_limiter_drains, elapsed / 100000);
ASSERT_LE(rate_limiter_drains, elapsed / 100000 + 1);
double ratio = env_->bytes_written_ * 1000000 / elapsed / raw_rate;
fprintf(stderr, "write rate ratio = %.2lf, expected 0.7\n", ratio);
ASSERT_TRUE(ratio < 0.8);
@ -2850,7 +2850,7 @@ TEST_F(DBTest, RateLimitingTest) {
// Most intervals should've been drained (interval time is 100ms, elapsed is
// micros)
ASSERT_GT(rate_limiter_drains, elapsed / 100000 / 2);
ASSERT_LE(rate_limiter_drains, elapsed / 100000);
ASSERT_LE(rate_limiter_drains, elapsed / 100000 + 1);
ratio = env_->bytes_written_ * 1000000 / elapsed / raw_rate;
fprintf(stderr, "write rate ratio = %.2lf, expected 0.5\n", ratio);
ASSERT_LT(ratio, 0.6);