Skip to content

Commit

Permalink
test: optimize waitForNextUpstreamRequest() (envoyproxy#11026) (envoy…
Browse files Browse the repository at this point in the history
…proxy#222)

Commit Message:
//test/integration:protocol_integration_test
After:
Stats over 50 runs: max = 11.8s, min = 1.2s, avg = 4.0s, dev = 4.3s
Before:
Stats over 50 runs: max = 2.6s, min = 1.4s, avg = 2.4s, dev = 0.3s

Signed-off-by: Yuchen Dai silentdai@gmail.com

Additional Description:
Risk Level: LOW
Testing: test
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Yuchen Dai <silentdai@gmail.com>
  • Loading branch information
lambdai authored Jun 11, 2020
1 parent 47ffc76 commit c28b73f
Showing 1 changed file with 13 additions and 5 deletions.
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;
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

0 comments on commit c28b73f

Please sign in to comment.