Skip to content
Merged
Changes from all commits
Commits
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
18 changes: 13 additions & 5 deletions test/integration/http_integration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -357,16 +357,24 @@ HttpIntegrationTest::waitForNextUpstreamRequest(const std::vector<uint64_t>& ups
absl::optional<uint64_t> upstream_with_request;
// If there is no upstream connection, wait for it to be established.
if (!fake_upstream_connection_) {

AssertionResult result = AssertionFailure();
for (auto upstream_index : upstream_indices) {
result = fake_upstreams_[upstream_index]->waitForHttpConnection(
*dispatcher_, fake_upstream_connection_, connection_wait_timeout, max_request_headers_kb_,
max_request_headers_count_);
int upstream_index = 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if the test failures are related to the fact that the original only tests upstreams with the given indices, while your version always checks all upstreams? Also, the original is much more likely to return the first member of upstream_indices with a request than the optimized version.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I think you are right. I should iterate over the indexes which is passed. An embarrassing mistake.

Event::TestTimeSystem& time_system = timeSystem();
auto end_time = time_system.monotonicTime() + connection_wait_timeout;
// Loop over the upstreams until the call times out or an upstream request is received.
while (!result) {
upstream_index = upstream_index % upstream_indices.size();
result = fake_upstreams_[upstream_indices[upstream_index]]->waitForHttpConnection(
*dispatcher_, fake_upstream_connection_, std::chrono::milliseconds(5),
max_request_headers_kb_, max_request_headers_count_);
if (result) {
upstream_with_request = upstream_index;
break;
} else if (time_system.monotonicTime() >= end_time) {
result = (AssertionFailure() << "Timed out waiting for new connection.");
break;
}
++upstream_index;
}
RELEASE_ASSERT(result, result.message());
}
Expand Down