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 7, 2020
1 parent 43b110a commit 6b59a9a
Show file tree
Hide file tree
Showing 12 changed files with 267 additions and 243 deletions.
9 changes: 6 additions & 3 deletions test/integration/autonomous_upstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ AutonomousStream::~AutonomousStream() {

// By default, automatically send a response when the request is complete.
void AutonomousStream::setEndStream(bool end_stream) {
FakeStream::setEndStream(end_stream);
{
absl::MutexLock lock(&lock_);
FakeStream::setEndStream(end_stream);
}
if (end_stream) {
sendResponse();
}
}

// Check all the special headers and send a customized response based on them.
void AutonomousStream::sendResponse() {
Http::TestResponseHeaderMapImpl headers(*headers_);
upstream_.setLastRequestHeaders(*headers_);
Http::TestResponseHeaderMapImpl headers(this->headers());
upstream_.setLastRequestHeaders(this->headers());

int32_t request_body_length = -1;
HeaderToInt(EXPECT_REQUEST_SIZE_BYTES, request_body_length, headers);
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 6b59a9a

Please sign in to comment.