Skip to content

Commit

Permalink
testing: fix multiple race conditions in simulated time tests
Browse files Browse the repository at this point in the history
Fixes #12480
Fixes #10568

Signed-off-by: Matt Klein <mklein@lyft.com>
  • Loading branch information
mattklein123 committed Aug 10, 2020
1 parent cce07c0 commit 30c6ef4
Show file tree
Hide file tree
Showing 29 changed files with 378 additions and 436 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ TEST_P(RatelimitIntegrationTest, ConnectImmediateDisconnect) {
initiateClientConnection();
ASSERT_TRUE(fake_upstreams_[1]->waitForHttpConnection(*dispatcher_, fake_ratelimit_connection_));
ASSERT_TRUE(fake_ratelimit_connection_->close());
ASSERT_TRUE(fake_ratelimit_connection_->waitForDisconnect(true));
ASSERT_TRUE(fake_ratelimit_connection_->waitForDisconnect());
fake_ratelimit_connection_ = nullptr;
// Rate limiter fails open
waitForSuccessfulUpstreamResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ name: ratelimit
ASSERT_TRUE(fake_upstream_connection->write("world"));
tcp_client->waitForData("world");
tcp_client->close();
ASSERT_TRUE(fake_upstream_connection->waitForDisconnect(true));
ASSERT_TRUE(fake_upstream_connection->waitForDisconnect());

EXPECT_EQ(0,
test_server_->counter("local_rate_limit.local_rate_limit_stats.rate_limited")->value());
Expand Down
2 changes: 1 addition & 1 deletion test/integration/autonomous_upstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void AutonomousStream::sendResponse() {
int32_t request_body_length = -1;
HeaderToInt(EXPECT_REQUEST_SIZE_BYTES, request_body_length, headers);
if (request_body_length >= 0) {
EXPECT_EQ(request_body_length, bodyLength());
EXPECT_EQ(request_body_length, body_.length());
}

if (!headers.get_(RESET_AFTER_REQUEST).empty()) {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/autonomous_upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class AutonomousStream : public FakeStream {
AutonomousUpstream& upstream, bool allow_incomplete_streams);
~AutonomousStream() override;

void setEndStream(bool set) override;
void setEndStream(bool set) EXCLUSIVE_LOCKS_REQUIRED(lock_) override;

private:
AutonomousUpstream& upstream_;
void sendResponse();
void sendResponse() EXCLUSIVE_LOCKS_REQUIRED(lock_);
const bool allow_incomplete_streams_{false};
};

Expand Down
2 changes: 1 addition & 1 deletion test/integration/cluster_filter_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ TEST_P(ClusterFilterIntegrationTest, TestClusterFilter) {
ASSERT_TRUE(tcp_client->write("", true));
ASSERT_TRUE(fake_upstream_connection->waitForHalfClose());
ASSERT_TRUE(fake_upstream_connection->write("", true));
ASSERT_TRUE(fake_upstream_connection->waitForDisconnect(true));
ASSERT_TRUE(fake_upstream_connection->waitForDisconnect());
tcp_client->waitForDisconnect();
}

Expand Down
2 changes: 1 addition & 1 deletion test/integration/cx_limit_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ConnectionLimitIntegrationTest : public testing::TestWithParam<Network::Ad
if (Network::AcceptedSocketImpl::acceptedSocketCount() == expected_connections) {
return AssertionSuccess();
}
timeSystem().advanceTimeWait(std::chrono::milliseconds(500));
timeSystem().advanceTimeWait(std::chrono::milliseconds(500), true);
}
if (Network::AcceptedSocketImpl::acceptedSocketCount() == expected_connections) {
return AssertionSuccess();
Expand Down
Loading

0 comments on commit 30c6ef4

Please sign in to comment.