diff --git a/test/extensions/load_balancing_policies/client_side_weighted_round_robin/integration_test.cc b/test/extensions/load_balancing_policies/client_side_weighted_round_robin/integration_test.cc index 1c7eedd43fa96..0115eb9ef79ba 100644 --- a/test/extensions/load_balancing_policies/client_side_weighted_round_robin/integration_test.cc +++ b/test/extensions/load_balancing_policies/client_side_weighted_round_robin/integration_test.cc @@ -123,7 +123,7 @@ class ClientSideWeightedRoundRobinIntegrationTest for (uint64_t i = 0; i < number_of_requests; i++) { ENVOY_LOG(trace, "Before request {}.", i); - + absl::SleepFor(absl::Milliseconds(10)); codec_client_ = makeHttpConnection(lookupPort("http")); Http::TestRequestHeaderMapImpl request_headers{ @@ -131,7 +131,7 @@ class ClientSideWeightedRoundRobinIntegrationTest auto response = codec_client_->makeRequestWithBody(request_headers, 0); - auto upstream_index = waitForNextUpstreamRequest({0, 1, 2}); + auto upstream_index = waitForNextUpstreamRequest({0, 1, 2}, std::chrono::seconds(15)); ASSERT(upstream_index.has_value()); upstream_usage[upstream_index.value()]++; @@ -146,8 +146,8 @@ class ClientSideWeightedRoundRobinIntegrationTest EXPECT_TRUE(upstream_request_->complete()); EXPECT_TRUE(response->complete()); - cleanupUpstreamAndDownstream(); + ASSERT_TRUE(codec_client_->waitForDisconnect()); ENVOY_LOG(trace, "After request {}.", i); } } @@ -541,6 +541,7 @@ class ClientSideWeightedRoundRobinEdsIntegrationTest for (uint64_t i = 0; i < number_of_requests; i++) { ENVOY_LOG(trace, "Before request {}.", i); + absl::SleepFor(absl::Milliseconds(10)); codec_client_ = makeHttpConnection(lookupPort("http")); @@ -550,8 +551,9 @@ class ClientSideWeightedRoundRobinEdsIntegrationTest {":authority", "example.com"}}; auto response = codec_client_->makeRequestWithBody(request_headers, 0); + absl::SleepFor(absl::Milliseconds(10)); - auto upstream_index = waitForNextUpstreamRequest(upstream_indices); + auto upstream_index = waitForNextUpstreamRequest(upstream_indices, std::chrono::seconds(30)); ASSERT(upstream_index.has_value()); upstream_usage[upstream_index.value()]++; @@ -568,6 +570,8 @@ class ClientSideWeightedRoundRobinEdsIntegrationTest EXPECT_TRUE(response->complete()); cleanupUpstreamAndDownstream(); + ASSERT_TRUE(codec_client_->waitForDisconnect()); + ENVOY_LOG(trace, "After request {}.", i); } } @@ -724,19 +728,21 @@ TEST_P(ClientSideWeightedRoundRobinEdsIntegrationTest, AddRemoveLocality) { Config::getTypeUrl(), {current_endpoints}, {}, {"cluster_1"}, "2"); + ENVOY_LOG(error, "before initial_usage"); + // Upstream QPS for ORCA load reports. All hosts report the same QPS. const std::vector upstream_qps = {100, 100, 100, 100}; - // Send 100 requests to cluster1 so host weights are updated. + // Send 10 requests to cluster1 so host weights are updated. std::vector initial_usage; sendRequestsAndTrackUpstreamUsage(FirstUpstreamIndex, upstream_qps, 10, initial_usage); - ENVOY_LOG(trace, "initial_usage {}", initial_usage); + ENVOY_LOG(error, "initial_usage {}", initial_usage); EXPECT_EQ(i + 1, test_server_->counter("cluster.cluster_1.membership_change")->value()); - // Send another 100 requests to cluster1, expecting weights to be used. + // Send another 20 requests to cluster1, expecting weights to be used. std::vector upstream_usage; - sendRequestsAndTrackUpstreamUsage(FirstUpstreamIndex, upstream_qps, 100, upstream_usage); - ENVOY_LOG(trace, "upstream_usage {}", upstream_usage); + sendRequestsAndTrackUpstreamUsage(FirstUpstreamIndex, upstream_qps, 20, upstream_usage); + ENVOY_LOG(error, "upstream_usage {}", upstream_usage); // Expect the usage of first locality to be non-zero. EXPECT_GT(upstream_usage[0], 0); EXPECT_GT(upstream_usage[1], 0);