From 2ad7859b28dec131ddfb0114915ecc67245aaf3f Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Sat, 11 Apr 2020 00:04:33 +0200 Subject: [PATCH] Update Envoy to 8e8209fa75f87ab53d4c78a466c8f927df930e50 Make unit tests to use advanceTimeWait in favor of sleep (see https://github.com/envoyproxy/envoy/pull/10551) Signed-off-by: Otto van der Schaaf --- bazel/repositories.bzl | 4 ++-- ci/do_ci.sh | 2 +- test/rate_limiter_test.cc | 24 ++++++++++++------------ test/termination_predicate_test.cc | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 320abc2b8..b198504e9 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -1,7 +1,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -ENVOY_COMMIT = "f84440dc4f95890f14e2e0686b07258f030b54b3" # April 8th, 2020 -ENVOY_SHA = "200477ab552bcaf08415836a67b7e4de5727db42b5a967a3c4232f519fd03cf2" +ENVOY_COMMIT = "8e8209fa75f87ab53d4c78a466c8f927df930e50" # April 10th, 2020 +ENVOY_SHA = "ef9661e7c0c446e4bf600adb9328f5e5e3088cb897380c7e991b7f743f811a10" RULES_PYTHON_COMMIT = "dd7f9c5f01bafbfea08c44092b6b0c8fc8fcb77f" # Feb 22nd, 2020 RULES_PYTHON_SHA = "0aa9ec790a58053e3ab5af397879b267a625955f8297c239b2d8559c6773397b" diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 2d94cb1ae..5a8fb038e 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -73,7 +73,7 @@ function do_asan() { echo "bazel ASAN/UBSAN debug build with tests" echo "Building and testing envoy tests..." cd "${SRCDIR}" - [ -z "$CIRCLECI" ] || export BAZEL_BUILD_OPTIONS="${BAZEL_TEST_OPTIONS} --jobs=6 --local_ram_resources=12288" + [ -z "$CIRCLECI" ] || export BAZEL_BUILD_OPTIONS="${BAZEL_TEST_OPTIONS} --jobs=4 --local_ram_resources=12288" # We build this in steps to avoid running out of memory in CI run_bazel build ${BAZEL_TEST_OPTIONS} -c dbg --config=clang-asan -- //source/exe/... && \ diff --git a/test/rate_limiter_test.cc b/test/rate_limiter_test.cc index 99f659da1..9da8424cc 100644 --- a/test/rate_limiter_test.cc +++ b/test/rate_limiter_test.cc @@ -25,11 +25,11 @@ TEST_F(RateLimiterTest, LinearRateLimiterTest) { EXPECT_FALSE(rate_limiter.tryAcquireOne()); - time_system.sleep(100ms); + time_system.advanceTimeWait(100ms); EXPECT_TRUE(rate_limiter.tryAcquireOne()); EXPECT_FALSE(rate_limiter.tryAcquireOne()); - time_system.sleep(1s); + time_system.advanceTimeWait(1s); for (int i = 0; i < 10; i++) { EXPECT_TRUE(rate_limiter.tryAcquireOne()); } @@ -91,13 +91,13 @@ TEST_F(RateLimiterTest, ScheduledStartingRateLimiterTest) { .WillRepeatedly(Return(true)); if (starting_late) { - time_system.sleep(schedule_delay); + time_system.advanceTimeWait(schedule_delay); } // We should expect zero releases until it is time to start. while (time_system.monotonicTime() < scheduled_starting_time) { EXPECT_FALSE(rate_limiter->tryAcquireOne()); - time_system.sleep(1ms); + time_system.advanceTimeWait(1ms); } // Now that is time to start, the rate limiter should propagate to the mock rate limiter. @@ -140,7 +140,7 @@ class BurstingRateLimiterIntegrationTest : public Test { EXPECT_EQ(burst_acquired, burst_size); EXPECT_EQ(i % (burst_interval_ms.count() - first_burst), 0); } - time_system.sleep(1ms); + time_system.advanceTimeWait(1ms); } } }; @@ -213,16 +213,16 @@ TEST_F(RateLimiterTest, DistributionSamplingRateLimiterImplSchedulingTest) { // The distribution first yields a 1 ns offset. So we don't expect to be green lighted. EXPECT_FALSE(rate_limiter->tryAcquireOne()); - time_system.sleep(1ns); + time_system.advanceTimeWait(1ns); EXPECT_TRUE(rate_limiter->tryAcquireOne()); // We expect releaseOne to be propagated. rate_limiter->releaseOne(); // The distribution will yield an offset of 0ns, we expect success. EXPECT_TRUE(rate_limiter->tryAcquireOne()); - // We don't sleep, and the distribution will yield a 1ns offset. No green light. + // We don't advanceTimeWait, and the distribution will yield a 1ns offset. No green light. EXPECT_FALSE(rate_limiter->tryAcquireOne()); - time_system.sleep(1ns); + time_system.advanceTimeWait(1ns); EXPECT_TRUE(rate_limiter->tryAcquireOne()); } @@ -259,7 +259,7 @@ class LinearRampingRateLimiterImplTest : public Test { if (expected_count > control_timings.size()) { control_timings.push_back(total_us_elapsed.count()); } - time_system.sleep(clock_tick); + time_system.advanceTimeWait(clock_tick); total_us_elapsed += clock_tick; } while (total_us_elapsed <= duration); @@ -368,12 +368,12 @@ class GraduallyOpeningRateLimiterFilterTest : public Test { acquisition_timings.push_back(total_ms_elapsed.count()); EXPECT_FALSE(rate_limiter->tryAcquireOne()); } - time_system.sleep(clock_tick); + time_system.advanceTimeWait(clock_tick); total_ms_elapsed += clock_tick; } while (total_ms_elapsed <= duration); EXPECT_FALSE(rate_limiter->tryAcquireOne()); - time_system.sleep(1s); + time_system.advanceTimeWait(1s); // Verify that after the rampup the expected constant pacing is maintained. // Calls should be forwarded to the regular linear rate limiter algorithm with its // corrective behavior so we can expect to acquire a series with that. @@ -410,7 +410,7 @@ TEST_F(ZipfRateLimiterImplTest, TimingVerificationTest) { if (rate_limiter->tryAcquireOne()) { aquisition_timings.push_back(total_ms_elapsed.count()); } - time_system.sleep(clock_tick); + time_system.advanceTimeWait(clock_tick); total_ms_elapsed += clock_tick; } while (total_ms_elapsed <= duration); EXPECT_EQ(aquisition_timings, diff --git a/test/termination_predicate_test.cc b/test/termination_predicate_test.cc index 687e62f76..79bff05b0 100644 --- a/test/termination_predicate_test.cc +++ b/test/termination_predicate_test.cc @@ -28,10 +28,10 @@ TEST_F(TerminationPredicateTest, DurationTerminationPredicateImplTest) { DurationTerminationPredicateImpl pred(time_system, duration, time_system.monotonicTime()); EXPECT_EQ(pred.evaluate(), TerminationPredicate::Status::PROCEED); // move to the edge. - time_system.sleep(duration); + time_system.advanceTimeWait(duration); EXPECT_EQ(pred.evaluate(), TerminationPredicate::Status::PROCEED); // move past the edge, we expect the predicate to return TERMINATE. - time_system.sleep(1us); + time_system.advanceTimeWait(1us); EXPECT_EQ(pred.evaluate(), TerminationPredicate::Status::TERMINATE); }