From 5f767cff096b86d977baa712d1115756f20d3d28 Mon Sep 17 00:00:00 2001 From: Antonio Vicente Date: Tue, 29 Dec 2020 16:35:07 -0500 Subject: [PATCH] fix flakiness in hds_integration_test Signed-off-by: Antonio Vicente --- test/integration/hds_integration_test.cc | 26 ++++++++++-------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/test/integration/hds_integration_test.cc b/test/integration/hds_integration_test.cc index c473226d73f1..9d857629c11e 100644 --- a/test/integration/hds_integration_test.cc +++ b/test/integration/hds_integration_test.cc @@ -438,11 +438,9 @@ TEST_P(HdsIntegrationTest, SingleEndpointTimeoutHttp) { hds_stream_->sendGrpcMessage(server_health_check_specifier_); test_server_->waitForCounterGe("hds_delegate.requests", ++hds_requests_); - // Envoy sends a health check message to an endpoint - ASSERT_TRUE(host_upstream_->waitForRawConnection(host_fake_raw_connection_)); - - // Endpoint doesn't respond to the health check - ASSERT_TRUE(host_fake_raw_connection_->waitForDisconnect()); + // Envoy sends a health check message to an endpoint, but the endpoint doesn't respond to the + // health check + ASSERT_TRUE(host_upstream_->waitForAndConsumeDisconnectedConnection()); // Receive updates until the one we expect arrives waitForEndpointHealthResponse(envoy::config::core::v3::TIMEOUT); @@ -515,11 +513,9 @@ TEST_P(HdsIntegrationTest, SingleEndpointTimeoutTcp) { hds_stream_->sendGrpcMessage(server_health_check_specifier_); test_server_->waitForCounterGe("hds_delegate.requests", ++hds_requests_); - // Envoys asks the endpoint if it's healthy - ASSERT_TRUE(host_upstream_->waitForRawConnection(host_fake_raw_connection_)); - - // No response from the endpoint - ASSERT_TRUE(host_fake_raw_connection_->waitForDisconnect()); + // Envoy sends a health check message to an endpoint, but the endpoint doesn't respond to the + // health check + ASSERT_TRUE(host_upstream_->waitForAndConsumeDisconnectedConnection()); // Receive updates until the one we expect arrives waitForEndpointHealthResponse(envoy::config::core::v3::TIMEOUT); @@ -1031,6 +1027,8 @@ TEST_P(HdsIntegrationTest, SingleEndpointUnhealthyTlsMissingSocketMatch) { tls_hosts_ = true; initialize(); + // Allow the fake upstreams to detect an error and disconnect during the TLS handshake. + host_upstream_->setReadDisableOnNewConnection(false); // Server <--> Envoy waitForHdsStream(); @@ -1046,11 +1044,9 @@ TEST_P(HdsIntegrationTest, SingleEndpointUnhealthyTlsMissingSocketMatch) { hds_stream_->sendGrpcMessage(server_health_check_specifier_); test_server_->waitForCounterGe("hds_delegate.requests", ++hds_requests_); - // Envoy sends a health check message to an endpoint - ASSERT_TRUE(host_upstream_->waitForRawConnection(host_fake_raw_connection_)); - - // Endpoint doesn't respond to the health check - ASSERT_TRUE(host_fake_raw_connection_->waitForDisconnect()); + // Envoy sends a health check message to an endpoint, but the endpoint doesn't respond to the + // health check + ASSERT_TRUE(host_upstream_->waitForAndConsumeDisconnectedConnection()); // Receive updates until the one we expect arrives. This should be UNHEALTHY and not TIMEOUT, // because TIMEOUT occurs in the situation where there is no response from the endpoint. In this