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: track simulated timers per dispatcher to simplify thread interactions and locking. #12609

Merged
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ class ActiveQuicListenerTest : public QuicMultiVersionTest {
auto proof_source = std::make_unique<TestProofSource>();
filter_chain_ = &proof_source->filterChain();
crypto_config_peer.ResetProofSource(std::move(proof_source));
simulated_time_system_.advanceTimeWait(std::chrono::milliseconds(100));
simulated_time_system_.advanceTimeAsync(std::chrono::milliseconds(100));
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
}

Network::ActiveUdpListenerFactoryPtr createQuicListenerFactory(const std::string& yaml) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class EnvoyQuicDispatcherTest : public QuicMultiVersionTest,

void SetUp() override {
// Advance time a bit because QuicTime regards 0 as uninitialized timestamp.
time_system_.advanceTimeWait(std::chrono::milliseconds(100));
time_system_.advanceTimeAsync(std::chrono::milliseconds(100));
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
EXPECT_CALL(listener_config_, perConnectionBufferLimitBytes())
.WillRepeatedly(Return(1024 * 1024));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ class EnvoyQuicServerSessionTest : public testing::TestWithParam<bool> {

// Advance time and trigger update of Dispatcher::approximateMonotonicTime()
// because zero QuicTime is considered uninitialized.
time_system_.advanceTimeWait(std::chrono::milliseconds(1));
time_system_.advanceTimeAsync(std::chrono::milliseconds(1));
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
connection_helper_.GetClock()->Now();

ON_CALL(writer_, WritePacket(_, _, _, _, _))
Expand Down Expand Up @@ -669,7 +670,8 @@ TEST_P(EnvoyQuicServerSessionTest, FlushAndWaitForCloseWithTimeout) {
EXPECT_EQ(Network::Connection::State::Open, envoy_quic_session_.state());
// Unblocking the stream shouldn't close the connection as it should be
// delayed.
time_system_.advanceTimeWait(std::chrono::milliseconds(10));
time_system_.advanceTimeAsync(std::chrono::milliseconds(10));
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
envoy_quic_session_.OnCanWrite();
// delay close alarm should have been rescheduled.
time_system_.advanceTimeAsync(std::chrono::milliseconds(90));
Expand Down Expand Up @@ -700,7 +702,8 @@ TEST_P(EnvoyQuicServerSessionTest, FlusWriteTransitToFlushWriteWithDelay) {
envoy_quic_session_.close(Network::ConnectionCloseType::FlushWrite);
EXPECT_EQ(Network::Connection::State::Open, envoy_quic_session_.state());

time_system_.advanceTimeWait(std::chrono::milliseconds(10));
time_system_.advanceTimeAsync(std::chrono::milliseconds(10));
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
// The closing behavior should be changed.
envoy_quic_session_.close(Network::ConnectionCloseType::FlushWriteAndDelay);
// Unblocking the stream shouldn't close the connection as it should be
Expand Down Expand Up @@ -732,7 +735,8 @@ TEST_P(EnvoyQuicServerSessionTest, FlushAndWaitForCloseWithNoPendingData) {

// Advance the time a bit and try to close again. The delay close timer
// shouldn't be rescheduled by this call.
time_system_.advanceTimeWait(std::chrono::milliseconds(10));
time_system_.advanceTimeAsync(std::chrono::milliseconds(10));
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
envoy_quic_session_.close(Network::ConnectionCloseType::FlushWriteAndDelay);
EXPECT_EQ(Network::Connection::State::Open, envoy_quic_session_.state());

Expand Down
1 change: 1 addition & 0 deletions test/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ envoy_cc_test(

envoy_cc_test(
name = "guarddog_impl_test",
size = "small",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explanation of this change:
Before other changes in this PR this test occasionally times out due to flaky alarm behavior as seen in #12638

This test usually runs in about 5s to 10s in standard confirgurations, and 20 seconds under clang-tsan. It may make sense to reduce the configured timeout for this test to small which has an associated timeout of 60 secs in order to get faster feedback when this test fails due to timeout.

srcs = ["guarddog_impl_test.cc"],
tags = ["flaky_on_windows"],
deps = [
Expand Down
Loading