Skip minimum rate check in Sandcastle (#7728)

Summary:
The minimum rate check in RateLimiterTest.Rate can fail in
Facebook's CI system Sandcastle, presumably due to heavily loaded
machines. This change disables the minimum rate check for Sandcastle
runs, and cleans up the code disabling it on other CI environments. (The
amount of conditionally compiled code shall be minimized.)

Pull Request resolved: https://github.com/facebook/rocksdb/pull/7728

Test Plan: try new test with and without setting envvar SANDCASTLE=1

Reviewed By: ltamasi

Differential Revision: D25247642

Pulled By: pdillinger

fbshipit-source-id: d786233af37af9a874adbb3a9e2707ec52c27a5a
main
Peter Dillinger 4 years ago committed by Facebook GitHub Bot
parent 7fec715db4
commit 3b9bfe8f14
  1. 24
      util/rate_limiter_test.cc

@ -59,7 +59,6 @@ TEST_F(RateLimiterTest, Modes) {
} }
} }
#if !((defined(TRAVIS) || defined(CIRCLECI)) && defined(OS_MACOSX))
TEST_F(RateLimiterTest, Rate) { TEST_F(RateLimiterTest, Rate) {
auto* env = Env::Default(); auto* env = Env::Default();
struct Arg { struct Arg {
@ -90,6 +89,9 @@ TEST_F(RateLimiterTest, Rate) {
} }
}; };
int samples = 0;
int samples_at_minimum = 0;
for (int i = 1; i <= 16; i *= 2) { for (int i = 1; i <= 16; i *= 2) {
int32_t target = i * 1024 * 10; int32_t target = i * 1024 * 10;
Arg arg(target, i / 4 + 1); Arg arg(target, i / 4 + 1);
@ -117,12 +119,28 @@ TEST_F(RateLimiterTest, Rate) {
arg.request_size - 1, target / 1024, rate / 1024, arg.request_size - 1, target / 1024, rate / 1024,
elapsed / 1000000.0); elapsed / 1000000.0);
ASSERT_GE(rate / target, 0.80); ++samples;
if (rate / target >= 0.80) {
++samples_at_minimum;
}
ASSERT_LE(rate / target, 1.25); ASSERT_LE(rate / target, 1.25);
} }
} }
}
// This can fail in heavily loaded CI environments
bool skip_minimum_rate_check =
#if (defined(TRAVIS) || defined(CIRCLECI)) && defined(OS_MACOSX)
true;
#else
getenv("SANDCASTLE");
#endif #endif
if (skip_minimum_rate_check) {
fprintf(stderr, "Skipped minimum rate check (%d / %d passed)\n",
samples_at_minimum, samples);
} else {
ASSERT_EQ(samples_at_minimum, samples);
}
}
TEST_F(RateLimiterTest, LimitChangeTest) { TEST_F(RateLimiterTest, LimitChangeTest) {
// starvation test when limit changes to a smaller value // starvation test when limit changes to a smaller value

Loading…
Cancel
Save