From 3b9bfe8f14e01fd51d662e753fd12b49df43a4a1 Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Wed, 2 Dec 2020 15:15:17 -0800 Subject: [PATCH] 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 --- util/rate_limiter_test.cc | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/util/rate_limiter_test.cc b/util/rate_limiter_test.cc index 228837aa6..90b221f84 100644 --- a/util/rate_limiter_test.cc +++ b/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) { auto* env = Env::Default(); 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) { int32_t target = i * 1024 * 10; Arg arg(target, i / 4 + 1); @@ -117,12 +119,28 @@ TEST_F(RateLimiterTest, Rate) { arg.request_size - 1, target / 1024, rate / 1024, elapsed / 1000000.0); - ASSERT_GE(rate / target, 0.80); + ++samples; + if (rate / target >= 0.80) { + ++samples_at_minimum; + } 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 + 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) { // starvation test when limit changes to a smaller value