Skip to content

Commit

Permalink
Update Envoy to 8e8209fa75f87ab53d4c78a466c8f927df930e50
Browse files Browse the repository at this point in the history
Make unit tests to use advanceTimeWait in favor of sleep

(see envoyproxy/envoy#10551)

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
  • Loading branch information
oschaaf committed Apr 10, 2020
1 parent adc3df5 commit 2ad7859
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/... && \
Expand Down
24 changes: 12 additions & 12 deletions test/rate_limiter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
}
};
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions test/termination_predicate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 2ad7859

Please sign in to comment.