Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: simulated time block on sleep #10551

Merged
merged 30 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7d3b23e
first cut.
jmarantz Jan 21, 2020
6e6a025
Merge branch 'master' into simtime-block-on-sleep
jmarantz Mar 26, 2020
9d9e104
get all tests working.
jmarantz Mar 27, 2020
4ee85a7
clean up comments.
jmarantz Mar 27, 2020
4767293
remove unused member vars.
jmarantz Mar 27, 2020
8f7ccb0
fix a few tests that were sleeping and the blocking in the same thread.
jmarantz Mar 27, 2020
a661b60
add explicit dependency to hopefully unbreak clang-tidy.
jmarantz Mar 27, 2020
b587221
Merge branch 'master' into simtime-block-on-sleep
jmarantz Mar 27, 2020
c3c58c0
cleanups and convert another flaky integration test to simtime.
jmarantz Mar 27, 2020
9a7261d
shadow the signaled state in a local enum in CondVar.
jmarantz Mar 27, 2020
7d4ee46
use atomic bool for condvar signaled state, use finer-grained condvar…
jmarantz Mar 29, 2020
bcfb1a3
format and comments.
jmarantz Mar 29, 2020
b148b62
Merge branch 'master' into simtime-block-on-sleep
jmarantz Mar 29, 2020
435b660
Decrease real-time polling delay in simulated time to 1ms from 50ms, …
jmarantz Mar 30, 2020
5649e70
move public definition out of anon namespace
jmarantz Mar 30, 2020
4ac4a30
Merge branch 'master' into simtime-block-on-sleep
jmarantz Mar 31, 2020
76ac2f5
Merge branch 'master' into simtime-block-on-sleep
jmarantz Mar 31, 2020
57ad7c5
Merge branch 'master' into simtime-block-on-sleep
jmarantz Apr 1, 2020
2d6aa6e
Merge branch 'master' into simtime-block-on-sleep
jmarantz Apr 5, 2020
5576b7c
cleanup and some of the trickier tests now seem to be working; gave u…
jmarantz Apr 5, 2020
d3aa9c4
rename test helper method.
jmarantz Apr 6, 2020
6a529a8
rename sleep to clarify behavior of both variants.
jmarantz Apr 7, 2020
46325e4
add test for advanceTimeWait
jmarantz Apr 7, 2020
a536cf2
Merge branch 'master' into simtime-block-on-sleep
jmarantz Apr 7, 2020
27a68ca
clang-tidy tweak.
jmarantz Apr 7, 2020
8382a0b
comment-suggestions from review.
jmarantz Apr 8, 2020
9b0be70
Merge branch 'master' into simtime-block-on-sleep
jmarantz Apr 8, 2020
a0b385e
rename sleep to advanceTimeAsync
jmarantz Apr 8, 2020
5267e6d
variable renames per review.
jmarantz Apr 9, 2020
c8ec0ff
Merge branch 'master' into simtime-block-on-sleep
jmarantz Apr 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/common/common/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class CondVar {
void wait(MutexBasicLockable& mutex) noexcept ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) {
condvar_.Wait(&mutex.mutex_);
}
template <class Rep, class Period>

/**
* @return WaitStatus whether the condition timed out or not.
*/
template <class Rep, class Period>
WaitStatus waitFor(
MutexBasicLockable& mutex,
std::chrono::duration<Rep, Period> duration) noexcept ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) {
Expand Down
4 changes: 2 additions & 2 deletions test/common/common/token_bucket_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ TEST_F(TokenBucketImplTest, PartialConsumption) {
TokenBucketImpl token_bucket{16, time_system_, 16};
EXPECT_EQ(16, token_bucket.consume(18, true));
EXPECT_EQ(std::chrono::milliseconds(63), token_bucket.nextTokenAvailable());
time_system_.sleep(std::chrono::milliseconds(62));
time_system_.advanceTimeWait(std::chrono::milliseconds(62));
EXPECT_EQ(0, token_bucket.consume(1, true));
time_system_.sleep(std::chrono::milliseconds(1));
time_system_.advanceTimeWait(std::chrono::milliseconds(1));
EXPECT_EQ(1, token_bucket.consume(2, true));
EXPECT_EQ(std::chrono::milliseconds(63), token_bucket.nextTokenAvailable());
}
Expand Down
2 changes: 1 addition & 1 deletion test/common/event/dispatcher_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class TimerImplTimingTest : public testing::Test {
while (true) {
dispatcher.run(Dispatcher::RunType::NonBlock);
if (timer.enabled()) {
time_system.sleep(std::chrono::microseconds(1));
jmarantz marked this conversation as resolved.
Show resolved Hide resolved
time_system.advanceTimeAsync(std::chrono::microseconds(1));
} else {
break;
}
Expand Down
6 changes: 3 additions & 3 deletions test/common/http/http1/conn_pool_legacy_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,13 @@ TEST_F(Http1ConnPoolImplLegacyTest, MeasureConnectTime) {
ActiveTestRequest r1(*this, 0, ActiveTestRequest::Type::Pending);

// Move time forward and start the second connect attempt.
simulated_time.sleep(std::chrono::milliseconds(sleep1_ms));
simulated_time.advanceTimeWait(std::chrono::milliseconds(sleep1_ms));
conn_pool_.expectClientCreate();
ActiveTestRequest r2(*this, 1, ActiveTestRequest::Type::Pending);

// Move time forward, signal that the first connect completed and verify the time to connect.
uint64_t upstream_cx_connect_ms1 = 0;
simulated_time.sleep(std::chrono::milliseconds(sleep2_ms));
simulated_time.advanceTimeWait(std::chrono::milliseconds(sleep2_ms));
EXPECT_CALL(*conn_pool_.test_clients_[0].connect_timer_, disableTimer());
EXPECT_CALL(cluster_->stats_store_,
deliverHistogramToSinks(Property(&Stats::Metric::name, "upstream_cx_connect_ms"), _))
Expand All @@ -433,7 +433,7 @@ TEST_F(Http1ConnPoolImplLegacyTest, MeasureConnectTime) {

// Move time forward, signal that the second connect completed and verify the time to connect.
uint64_t upstream_cx_connect_ms2 = 0;
simulated_time.sleep(std::chrono::milliseconds(sleep3_ms));
simulated_time.advanceTimeWait(std::chrono::milliseconds(sleep3_ms));
EXPECT_CALL(*conn_pool_.test_clients_[1].connect_timer_, disableTimer());
EXPECT_CALL(cluster_->stats_store_,
deliverHistogramToSinks(Property(&Stats::Metric::name, "upstream_cx_connect_ms"), _))
Expand Down
6 changes: 3 additions & 3 deletions test/common/http/http1/conn_pool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,13 @@ TEST_F(Http1ConnPoolImplTest, MeasureConnectTime) {
ActiveTestRequest r1(*this, 0, ActiveTestRequest::Type::Pending);

// Move time forward and start the second connect attempt.
simulated_time.sleep(std::chrono::milliseconds(sleep1_ms));
simulated_time.advanceTimeWait(std::chrono::milliseconds(sleep1_ms));
conn_pool_.expectClientCreate();
ActiveTestRequest r2(*this, 1, ActiveTestRequest::Type::Pending);

// Move time forward, signal that the first connect completed and verify the time to connect.
uint64_t upstream_cx_connect_ms1 = 0;
simulated_time.sleep(std::chrono::milliseconds(sleep2_ms));
simulated_time.advanceTimeWait(std::chrono::milliseconds(sleep2_ms));
EXPECT_CALL(cluster_->stats_store_,
deliverHistogramToSinks(Property(&Stats::Metric::name, "upstream_cx_connect_ms"), _))
.WillOnce(SaveArg<1>(&upstream_cx_connect_ms1));
Expand All @@ -430,7 +430,7 @@ TEST_F(Http1ConnPoolImplTest, MeasureConnectTime) {

// Move time forward, signal that the second connect completed and verify the time to connect.
uint64_t upstream_cx_connect_ms2 = 0;
simulated_time.sleep(std::chrono::milliseconds(sleep3_ms));
simulated_time.advanceTimeWait(std::chrono::milliseconds(sleep3_ms));
EXPECT_CALL(cluster_->stats_store_,
deliverHistogramToSinks(Property(&Stats::Metric::name, "upstream_cx_connect_ms"), _))
.WillOnce(SaveArg<1>(&upstream_cx_connect_ms2));
Expand Down
2 changes: 1 addition & 1 deletion test/common/memory/heap_shrinker_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class HeapShrinkerTest : public testing::Test {
: api_(Api::createApiForTest(stats_, time_system_)), dispatcher_(*api_, time_system_) {}

void step() {
time_system_.sleep(std::chrono::milliseconds(10000));
time_system_.advanceTimeAsync(std::chrono::milliseconds(10000));
dispatcher_.run(Event::Dispatcher::RunType::NonBlock);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - I assume the non-block is to give time for the callback to run. I guess I'm not sure where we'd advance and not run alarms, and I wonder how many of these cases are holdover from the differences not clearly being spelled out? Most of these tests are doing a "walk forward" and make sure my thing is called" check.
Is it just that pending alarms is not the right list? I had assumed pending alarms were the alarms which are due to fire and have not yet fired. I think I need to understand this PR better before reviewing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no other thread in this test; the callbacks are run by the dispatcher_.run() call below. If we called sleep() here it would deadlock since no thread would be alive to run the callbacks.

}

Expand Down
4 changes: 2 additions & 2 deletions test/common/network/udp_listener_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class UdpListenerImplTest : public ListenerImplTestBase {
public:
UdpListenerImplTest()
: server_socket_(createServerSocket(true)), send_to_addr_(getServerLoopbackAddress()) {
time_system_.sleep(std::chrono::milliseconds(100));
time_system_.advanceTimeWait(std::chrono::milliseconds(100));
}

void SetUp() override {
Expand Down Expand Up @@ -92,7 +92,7 @@ class UdpListenerImplTest : public ListenerImplTestBase {
std::chrono::milliseconds(
(num_packets_received_by_listener_ % num_packet_per_recv) * 100));
// Advance time so that next onData() should have different received time.
time_system_.sleep(std::chrono::milliseconds(100));
time_system_.advanceTimeWait(std::chrono::milliseconds(100));
++num_packets_received_by_listener_;
}

Expand Down
32 changes: 16 additions & 16 deletions test/common/router/router_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,7 @@ TEST_F(RouterTest, TimeoutBudgetHistogramStat) {
Http::ResponseHeaderMapPtr response_headers(
new Http::TestResponseHeaderMapImpl{{":status", "200"}});
response_decoder->decodeHeaders(std::move(response_headers), false);
test_time_.sleep(std::chrono::milliseconds(80));
test_time_.advanceTimeWait(std::chrono::milliseconds(80));
response_decoder->decodeData(data, true);
}

Expand Down Expand Up @@ -1649,7 +1649,7 @@ TEST_F(RouterTest, TimeoutBudgetHistogramStatFailure) {
Http::ResponseHeaderMapPtr response_headers(
new Http::TestResponseHeaderMapImpl{{":status", "500"}});
response_decoder->decodeHeaders(std::move(response_headers), false);
test_time_.sleep(std::chrono::milliseconds(80));
test_time_.advanceTimeWait(std::chrono::milliseconds(80));
response_decoder->decodeData(data, true);
}

Expand Down Expand Up @@ -1689,7 +1689,7 @@ TEST_F(RouterTest, TimeoutBudgetHistogramStatOnlyGlobal) {
Http::ResponseHeaderMapPtr response_headers(
new Http::TestResponseHeaderMapImpl{{":status", "200"}});
response_decoder->decodeHeaders(std::move(response_headers), false);
test_time_.sleep(std::chrono::milliseconds(80));
test_time_.advanceTimeWait(std::chrono::milliseconds(80));
response_decoder->decodeData(data, true);
}

Expand Down Expand Up @@ -1730,7 +1730,7 @@ TEST_F(RouterTest, TimeoutBudgetHistogramStatDuringRetries) {
.Times(0);

// Per-try timeout.
test_time_.sleep(std::chrono::milliseconds(100));
test_time_.advanceTimeWait(std::chrono::milliseconds(100));
router_.retry_state_->expectHeadersRetry();
Http::ResponseHeaderMapPtr response_headers1(
new Http::TestResponseHeaderMapImpl{{":status", "504"}});
Expand Down Expand Up @@ -1772,7 +1772,7 @@ TEST_F(RouterTest, TimeoutBudgetHistogramStatDuringRetries) {
EXPECT_CALL(encoder2.stream_, resetStream(Http::StreamResetReason::LocalReset));
Http::TestResponseHeaderMapImpl response_headers{
{":status", "504"}, {"content-length", "24"}, {"content-type", "text/plain"}};
test_time_.sleep(std::chrono::milliseconds(100));
test_time_.advanceTimeWait(std::chrono::milliseconds(100));
EXPECT_CALL(callbacks_, encodeHeaders_(HeaderMapEqualRef(&response_headers), false));
EXPECT_CALL(callbacks_, encodeData(_, true));
EXPECT_CALL(*router_.retry_state_, shouldRetryReset(_, _)).Times(1);
Expand Down Expand Up @@ -1829,7 +1829,7 @@ TEST_F(RouterTest, TimeoutBudgetHistogramStatDuringGlobalTimeout) {
Http::ResponseHeaderMapPtr response_headers1(
new Http::TestResponseHeaderMapImpl{{":status", "503"}});
EXPECT_CALL(cm_.conn_pool_.host_->outlier_detector_, putHttpResponseCode(503));
test_time_.sleep(std::chrono::milliseconds(160));
test_time_.advanceTimeWait(std::chrono::milliseconds(160));
response_decoder1->decodeHeaders(std::move(response_headers1), true);
EXPECT_TRUE(verifyHostUpstreamStats(0, 1));

Expand Down Expand Up @@ -1868,7 +1868,7 @@ TEST_F(RouterTest, TimeoutBudgetHistogramStatDuringGlobalTimeout) {
EXPECT_CALL(encoder2.stream_, resetStream(Http::StreamResetReason::LocalReset));
Http::TestResponseHeaderMapImpl response_headers{
{":status", "504"}, {"content-length", "24"}, {"content-type", "text/plain"}};
test_time_.sleep(std::chrono::milliseconds(240));
test_time_.advanceTimeWait(std::chrono::milliseconds(240));
EXPECT_CALL(callbacks_, encodeHeaders_(HeaderMapEqualRef(&response_headers), false));
EXPECT_CALL(callbacks_, encodeData(_, true));
EXPECT_CALL(*router_.retry_state_, shouldRetryReset(_, _)).Times(0);
Expand Down Expand Up @@ -4391,7 +4391,7 @@ TEST_F(RouterTest, UpstreamTimingSingleRequest) {
HttpTestUtility::addDefaultHeaders(headers);
router_.decodeHeaders(headers, false);

test_time_.sleep(std::chrono::milliseconds(32));
test_time_.advanceTimeWait(std::chrono::milliseconds(32));
Buffer::OwnedImpl data;
router_.decodeData(data, true);
EXPECT_EQ(1U,
Expand All @@ -4400,7 +4400,7 @@ TEST_F(RouterTest, UpstreamTimingSingleRequest) {
Http::ResponseHeaderMapPtr response_headers(
new Http::TestResponseHeaderMapImpl{{":status", "503"}});
response_decoder->decodeHeaders(std::move(response_headers), false);
test_time_.sleep(std::chrono::milliseconds(43));
test_time_.advanceTimeWait(std::chrono::milliseconds(43));

// Confirm we still have no upstream timing data. It won't be set until after the
// stream has ended.
Expand Down Expand Up @@ -4451,13 +4451,13 @@ TEST_F(RouterTest, UpstreamTimingRetry) {

router_.retry_state_->expectHeadersRetry();

test_time_.sleep(std::chrono::milliseconds(32));
test_time_.advanceTimeWait(std::chrono::milliseconds(32));
Buffer::OwnedImpl data;
router_.decodeData(data, true);
EXPECT_EQ(1U,
callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value());

test_time_.sleep(std::chrono::milliseconds(43));
test_time_.advanceTimeWait(std::chrono::milliseconds(43));

EXPECT_CALL(cm_.conn_pool_, newStream(_, _))
.WillOnce(Invoke(
Expand Down Expand Up @@ -4485,7 +4485,7 @@ TEST_F(RouterTest, UpstreamTimingRetry) {
new Http::TestResponseHeaderMapImpl{{":status", "200"}});
response_decoder->decodeHeaders(std::move(good_response_headers), false);

test_time_.sleep(std::chrono::milliseconds(153));
test_time_.advanceTimeWait(std::chrono::milliseconds(153));

response_decoder->decodeData(data, true);

Expand Down Expand Up @@ -4530,27 +4530,27 @@ TEST_F(RouterTest, UpstreamTimingTimeout) {
ON_CALL(callbacks_, streamInfo()).WillByDefault(ReturnRef(stream_info));

expectResponseTimerCreate();
test_time_.sleep(std::chrono::milliseconds(10));
test_time_.advanceTimeWait(std::chrono::milliseconds(10));

// Check that upstream timing is updated after the first request.
Http::TestRequestHeaderMapImpl headers{{"x-envoy-upstream-rq-timeout-ms", "50"}};
HttpTestUtility::addDefaultHeaders(headers);
router_.decodeHeaders(headers, false);
EXPECT_FALSE(stream_info.lastUpstreamRxByteReceived().has_value());

test_time_.sleep(std::chrono::milliseconds(13));
test_time_.advanceTimeWait(std::chrono::milliseconds(13));
Buffer::OwnedImpl data;
router_.decodeData(data, true);
EXPECT_EQ(1U,
callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value());

test_time_.sleep(std::chrono::milliseconds(33));
test_time_.advanceTimeWait(std::chrono::milliseconds(33));

Http::ResponseHeaderMapPtr response_headers(
new Http::TestResponseHeaderMapImpl{{":status", "200"}});
response_decoder->decodeHeaders(std::move(response_headers), false);

test_time_.sleep(std::chrono::milliseconds(99));
test_time_.advanceTimeWait(std::chrono::milliseconds(99));
response_timeout_->invokeCallback();

EXPECT_TRUE(stream_info.firstUpstreamTxByteSent().has_value());
Expand Down
4 changes: 2 additions & 2 deletions test/common/upstream/cluster_manager_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2473,7 +2473,7 @@ TEST_F(ClusterManagerImplTest, MergedUpdatesOutOfWindow) {
// The first update should be applied immediately, because even though it's mergeable
// it's outside the default merge window of 3 seconds (found in debugger as value of
// cluster.info()->lbConfig().update_merge_window() in ClusterManagerImpl::scheduleUpdate.
time_system_.sleep(std::chrono::seconds(60));
time_system_.advanceTimeWait(std::chrono::seconds(60));
cluster.prioritySet().updateHosts(
0,
updateHostsParams(hosts, hosts_per_locality,
Expand All @@ -2500,7 +2500,7 @@ TEST_F(ClusterManagerImplTest, MergedUpdatesInsideWindow) {
// 3 seconds (found in debugger as value of cluster.info()->lbConfig().update_merge_window()
// in ClusterManagerImpl::scheduleUpdate. Note that initially the update-time is
// default-initialized to a monotonic time of 0, as is SimulatedTimeSystem::monotonic_time_.
time_system_.sleep(std::chrono::seconds(2));
time_system_.advanceTimeWait(std::chrono::seconds(2));
cluster.prioritySet().updateHosts(
0,
updateHostsParams(hosts, hosts_per_locality,
Expand Down
4 changes: 2 additions & 2 deletions test/extensions/common/aws/credentials_provider_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ TEST_F(InstanceProfileCredentialsProviderTest, CredentialExpiration) {
EXPECT_EQ("akid", credentials.accessKeyId().value());
EXPECT_EQ("secret", credentials.secretAccessKey().value());
EXPECT_EQ("token", credentials.sessionToken().value());
time_system_.sleep(std::chrono::hours(2));
time_system_.advanceTimeWait(std::chrono::hours(2));
expectCredentialListing("doc1");
expectDocument(R"EOF(
{
Expand Down Expand Up @@ -280,7 +280,7 @@ TEST_F(TaskRoleCredentialsProviderTest, NormalCredentialExpiration) {
EXPECT_EQ("akid", credentials.accessKeyId().value());
EXPECT_EQ("secret", credentials.secretAccessKey().value());
EXPECT_EQ("token", credentials.sessionToken().value());
time_system_.sleep(std::chrono::hours(2));
time_system_.advanceTimeWait(std::chrono::hours(2));
expectDocument(R"EOF(
{
"AccessKeyId": "new_akid",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ TEST_F(DnsCacheImplTest, TTL) {
1 /* added */, 0 /* removed */, 1 /* num hosts */);

// Re-resolve with ~60s passed. TTL should still be OK at default of 5 minutes.
simTime().sleep(std::chrono::milliseconds(60001));
simTime().advanceTimeWait(std::chrono::milliseconds(60001));
EXPECT_CALL(*resolver_, resolve("foo.com", _, _))
.WillOnce(DoAll(SaveArg<2>(&resolve_cb), Return(&resolver_->active_query_)));
resolve_timer->invokeCallback();
Expand All @@ -280,7 +280,7 @@ TEST_F(DnsCacheImplTest, TTL) {

// Re-resolve with ~5m passed. This is not realistic as we would have re-resolved many times
// during this period but it's good enough for the test.
simTime().sleep(std::chrono::milliseconds(300000));
simTime().advanceTimeWait(std::chrono::milliseconds(300000));
EXPECT_CALL(update_callbacks_, onDnsHostRemove("foo.com"));
resolve_timer->invokeCallback();
checkStats(2 /* attempt */, 2 /* success */, 0 /* failure */, 1 /* address changed */,
Expand Down Expand Up @@ -321,7 +321,7 @@ TEST_F(DnsCacheImplTest, TTLWithCustomParameters) {
TestUtility::makeDnsResponse({"10.0.0.1"}, std::chrono::seconds(0)));

// Re-resolve with ~30s passed. TTL should still be OK at 60s.
simTime().sleep(std::chrono::milliseconds(30001));
simTime().advanceTimeWait(std::chrono::milliseconds(30001));
EXPECT_CALL(*resolver_, resolve("foo.com", _, _))
.WillOnce(DoAll(SaveArg<2>(&resolve_cb), Return(&resolver_->active_query_)));
resolve_timer->invokeCallback();
Expand All @@ -330,7 +330,7 @@ TEST_F(DnsCacheImplTest, TTLWithCustomParameters) {
TestUtility::makeDnsResponse({"10.0.0.1"}));

// Re-resolve with ~30s passed. TTL should expire.
simTime().sleep(std::chrono::milliseconds(30001));
simTime().advanceTimeWait(std::chrono::milliseconds(30001));
EXPECT_CALL(update_callbacks_, onDnsHostRemove("foo.com"));
resolve_timer->invokeCallback();
}
Expand Down Expand Up @@ -392,7 +392,7 @@ TEST_F(DnsCacheImplTest, ResolveFailure) {

// Re-resolve with ~5m passed. This is not realistic as we would have re-resolved many times
// during this period but it's good enough for the test.
simTime().sleep(std::chrono::milliseconds(300001));
simTime().advanceTimeWait(std::chrono::milliseconds(300001));
// Because resolution failed for the host, onDnsHostAddOrUpdate was not called.
// Therefore, onDnsHostRemove should not be called either.
EXPECT_CALL(update_callbacks_, onDnsHostRemove(_)).Times(0);
Expand Down Expand Up @@ -435,7 +435,7 @@ TEST_F(DnsCacheImplTest, ResolveFailureWithFailureRefreshRate) {

// Re-resolve with ~5m passed. This is not realistic as we would have re-resolved many times
// during this period but it's good enough for the test.
simTime().sleep(std::chrono::milliseconds(300001));
simTime().advanceTimeWait(std::chrono::milliseconds(300001));
// Because resolution failed for the host, onDnsHostAddOrUpdate was not called.
// Therefore, onDnsHostRemove should not be called either.
EXPECT_CALL(update_callbacks_, onDnsHostRemove(_)).Times(0);
Expand Down Expand Up @@ -474,7 +474,7 @@ TEST_F(DnsCacheImplTest, ResolveSuccessWithEmptyResult) {

// Re-resolve with ~5m passed. This is not realistic as we would have re-resolved many times
// during this period but it's good enough for the test.
simTime().sleep(std::chrono::milliseconds(300001));
simTime().advanceTimeWait(std::chrono::milliseconds(300001));
// Because resolution failed for the host, onDnsHostAddOrUpdate was not called.
// Therefore, onDnsHostRemove should not be called either.
EXPECT_CALL(update_callbacks_, onDnsHostRemove(_)).Times(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void AdaptiveConcurrencyIntegrationTest::respondToAllRequests(uint32_t forwarded
std::chrono::milliseconds latency) {
ASSERT_GE(responses_.size(), static_cast<size_t>(forwarded_count));

timeSystem().sleep(latency);
timeSystem().advanceTimeWait(latency);

for (uint32_t idx = 0; idx < forwarded_count; ++idx) {
respondToRequest(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ TEST_F(AdaptiveConcurrencyFilterTest, OnDestroyCleanupTest) {
EXPECT_EQ(Http::FilterHeadersStatus::Continue, filter_->decodeHeaders(request_headers, true));

const auto advance_time = std::chrono::nanoseconds(42);
time_system_.sleep(advance_time);
time_system_.advanceTimeWait(advance_time);

Http::TestResponseHeaderMapImpl response_headers;
EXPECT_EQ(Http::FilterHeadersStatus::Continue, filter_->encodeHeaders(response_headers, true));
Expand Down
Loading