-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Making //test/integration:hds_integration_test test faster and more robust #4164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1d1d77a
Making hds_integration test faster and more robust
markatou b7d94d4
Addressing comments
markatou 6040189
Addressing comments
markatou 02687d9
Merge remote-tracking branch 'upstream/master' into less_fragile
markatou a851f9d
Addressing comments
markatou a4dd166
Addressing comments
markatou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,7 +118,7 @@ class HdsIntegrationTest : public HttpIntegrationTest, | |
| // one HTTP health_check | ||
| envoy::service::discovery::v2::HealthCheckSpecifier makeHttpHealthCheckSpecifier() { | ||
| envoy::service::discovery::v2::HealthCheckSpecifier server_health_check_specifier_; | ||
| server_health_check_specifier_.mutable_interval()->set_seconds(1); | ||
| server_health_check_specifier_.mutable_interval()->set_nanos(100000000); | ||
|
|
||
| auto* health_check = server_health_check_specifier_.add_cluster_health_checks(); | ||
|
|
||
|
|
@@ -130,8 +130,8 @@ class HdsIntegrationTest : public HttpIntegrationTest, | |
| health_check->mutable_locality_endpoints(0)->mutable_locality()->set_zone("some_zone"); | ||
| health_check->mutable_locality_endpoints(0)->mutable_locality()->set_sub_zone("crete"); | ||
|
|
||
| health_check->add_health_checks()->mutable_timeout()->set_seconds(2); | ||
| health_check->mutable_health_checks(0)->mutable_interval()->set_seconds(1); | ||
| health_check->add_health_checks()->mutable_timeout()->set_seconds(100); | ||
| health_check->mutable_health_checks(0)->mutable_interval()->set_seconds(100); | ||
| health_check->mutable_health_checks(0)->mutable_unhealthy_threshold()->set_value(2); | ||
| health_check->mutable_health_checks(0)->mutable_healthy_threshold()->set_value(2); | ||
| health_check->mutable_health_checks(0)->mutable_grpc_health_check(); | ||
|
|
@@ -145,7 +145,7 @@ class HdsIntegrationTest : public HttpIntegrationTest, | |
| // one TCP health_check | ||
| envoy::service::discovery::v2::HealthCheckSpecifier makeTcpHealthCheckSpecifier() { | ||
| envoy::service::discovery::v2::HealthCheckSpecifier server_health_check_specifier_; | ||
| server_health_check_specifier_.mutable_interval()->set_seconds(1); | ||
| server_health_check_specifier_.mutable_interval()->set_nanos(100000000); | ||
|
|
||
| auto* health_check = server_health_check_specifier_.add_cluster_health_checks(); | ||
|
|
||
|
|
@@ -157,8 +157,8 @@ class HdsIntegrationTest : public HttpIntegrationTest, | |
| health_check->mutable_locality_endpoints(0)->mutable_locality()->set_zone("some_zone"); | ||
| health_check->mutable_locality_endpoints(0)->mutable_locality()->set_sub_zone("crete"); | ||
|
|
||
| health_check->add_health_checks()->mutable_timeout()->set_seconds(2); | ||
| health_check->mutable_health_checks(0)->mutable_interval()->set_seconds(1); | ||
| health_check->add_health_checks()->mutable_timeout()->set_seconds(100); | ||
| health_check->mutable_health_checks(0)->mutable_interval()->set_seconds(100); | ||
| health_check->mutable_health_checks(0)->mutable_unhealthy_threshold()->set_value(2); | ||
| health_check->mutable_health_checks(0)->mutable_healthy_threshold()->set_value(2); | ||
| auto* tcp_hc = health_check->mutable_health_checks(0)->mutable_tcp_health_check(); | ||
|
|
@@ -234,6 +234,9 @@ TEST_P(HdsIntegrationTest, SingleEndpointHealthyHttp) { | |
| host_stream_->encodeHeaders(Http::TestHeaderMapImpl{{":status", "200"}}, false); | ||
| host_stream_->encodeData(1024, true); | ||
|
|
||
| // Make sure the cluster processed the endpoint's response | ||
| test_server_->waitForCounterGe("cluster.anna.health_check.success", 1); | ||
|
|
||
| // Envoy reports back to server | ||
| ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, response_)); | ||
|
|
||
|
|
@@ -253,14 +256,16 @@ TEST_P(HdsIntegrationTest, SingleEndpointHealthyHttp) { | |
| TEST_P(HdsIntegrationTest, SingleEndpointTimeoutHttp) { | ||
| initialize(); | ||
| server_health_check_specifier_ = makeHttpHealthCheckSpecifier(); | ||
|
|
||
| server_health_check_specifier_.mutable_cluster_health_checks(0) | ||
| ->mutable_health_checks(0) | ||
| ->mutable_timeout() | ||
| ->set_seconds(0); | ||
| server_health_check_specifier_.mutable_cluster_health_checks(0) | ||
| ->mutable_health_checks(0) | ||
| ->mutable_timeout() | ||
| ->set_nanos(800000000); | ||
| ->set_nanos(100000000); | ||
|
|
||
| // Server <--> Envoy | ||
| waitForHdsStream(); | ||
| ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, envoy_msg_)); | ||
|
|
@@ -275,6 +280,9 @@ TEST_P(HdsIntegrationTest, SingleEndpointTimeoutHttp) { | |
|
|
||
| // Endpoint doesn't repond to the health check | ||
|
|
||
| // Make sure the cluster processed the endpoint's (lack of) response | ||
| test_server_->waitForCounterGe("cluster.anna.health_check.failure", 1); | ||
|
|
||
| // Envoy reports back to server | ||
| ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, response_)); | ||
|
|
||
|
|
@@ -312,6 +320,9 @@ TEST_P(HdsIntegrationTest, SingleEndpointUnhealthyHttp) { | |
| host_stream_->encodeHeaders(Http::TestHeaderMapImpl{{":status", "404"}}, false); | ||
| host_stream_->encodeData(1024, true); | ||
|
|
||
| // Make sure the cluster processed the endpoint's response | ||
| test_server_->waitForCounterGe("cluster.anna.health_check.failure", 1); | ||
|
|
||
| // Envoy reports back to server | ||
| ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, response_)); | ||
|
|
||
|
|
@@ -346,7 +357,7 @@ TEST_P(HdsIntegrationTest, SingleEndpointTimeoutTcp) { | |
| server_health_check_specifier_.mutable_cluster_health_checks(0) | ||
| ->mutable_health_checks(0) | ||
| ->mutable_timeout() | ||
| ->set_nanos(800000000); | ||
| ->set_nanos(100000000); | ||
| hds_stream_->startGrpcStream(); | ||
| hds_stream_->sendGrpcMessage(server_health_check_specifier_); | ||
| test_server_->waitForCounterGe("hds_delegate.requests", ++hds_requests_); | ||
|
|
@@ -355,10 +366,13 @@ TEST_P(HdsIntegrationTest, SingleEndpointTimeoutTcp) { | |
| ASSERT_TRUE(host_upstream_->waitForRawConnection(host_fake_raw_connection_)); | ||
| ASSERT_TRUE( | ||
| host_fake_raw_connection_->waitForData(FakeRawConnection::waitForInexactMatch("Ping"))); | ||
|
|
||
| host_upstream_->set_allow_unexpected_disconnects(true); | ||
|
|
||
| // No response from the endpoint | ||
|
|
||
| // Make sure the cluster processed the endpoint's (lack of) response | ||
| test_server_->waitForCounterGe("cluster.anna.health_check.failure", 1); | ||
|
|
||
| // Envoy reports back to server | ||
| ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, response_)); | ||
|
|
||
|
|
@@ -396,6 +410,9 @@ TEST_P(HdsIntegrationTest, SingleEndpointHealthyTcp) { | |
| RELEASE_ASSERT(result, result.message()); | ||
| host_upstream_->set_allow_unexpected_disconnects(true); | ||
|
|
||
| // Make sure the cluster processed the endpoint's response | ||
| test_server_->waitForCounterGe("cluster.anna.health_check.success", 1); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit unclear to me what the win with some of the waits is. We will need to wait for the gRPC response from Envoy to the HDS server below, and those messages are sent independently of what we're doing here wait wise. |
||
|
|
||
| // Envoy reports back to server | ||
| ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, response_)); | ||
|
|
||
|
|
@@ -433,6 +450,9 @@ TEST_P(HdsIntegrationTest, SingleEndpointUnhealthyTcp) { | |
| RELEASE_ASSERT(result, result.message()); | ||
| host_upstream_->set_allow_unexpected_disconnects(true); | ||
|
|
||
| // TODO(lilika): TcpHealthchecker is not incrementing the stats in failure | ||
| // so we can't wait for the cluster to process the endpoint's response | ||
|
|
||
| // Envoy reports back to server | ||
| ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, response_)); | ||
|
|
||
|
|
@@ -476,6 +496,10 @@ TEST_P(HdsIntegrationTest, TwoEndpointsSameLocality) { | |
| host2_stream_->encodeHeaders(Http::TestHeaderMapImpl{{":status", "200"}}, false); | ||
| host2_stream_->encodeData(1024, true); | ||
|
|
||
| // Make sure the cluster processed the endpoints' response | ||
| test_server_->waitForCounterGe("cluster.anna.health_check.failure", 1); | ||
| test_server_->waitForCounterGe("cluster.anna.health_check.success", 1); | ||
|
|
||
| // Envoy reports back to server | ||
| ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, response_)); | ||
|
|
||
|
|
@@ -527,6 +551,10 @@ TEST_P(HdsIntegrationTest, TwoEndpointsDifferentLocality) { | |
| host2_stream_->encodeHeaders(Http::TestHeaderMapImpl{{":status", "200"}}, false); | ||
| host2_stream_->encodeData(1024, true); | ||
|
|
||
| // Make sure the cluster processed the endpoints' response | ||
| test_server_->waitForCounterGe("cluster.anna.health_check.failure", 1); | ||
| test_server_->waitForCounterGe("cluster.anna.health_check.success", 1); | ||
|
|
||
| // Envoy reports back to server | ||
| ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, response_)); | ||
|
|
||
|
|
@@ -561,8 +589,8 @@ TEST_P(HdsIntegrationTest, TwoEndpointsDifferentClusters) { | |
| health_check->mutable_locality_endpoints(0)->mutable_locality()->set_zone("peculiar_zone"); | ||
| health_check->mutable_locality_endpoints(0)->mutable_locality()->set_sub_zone("paris"); | ||
|
|
||
| health_check->add_health_checks()->mutable_timeout()->set_seconds(2); | ||
| health_check->mutable_health_checks(0)->mutable_interval()->set_seconds(1); | ||
| health_check->add_health_checks()->mutable_timeout()->set_seconds(100); | ||
| health_check->mutable_health_checks(0)->mutable_interval()->set_seconds(100); | ||
| health_check->mutable_health_checks(0)->mutable_unhealthy_threshold()->set_value(2); | ||
| health_check->mutable_health_checks(0)->mutable_healthy_threshold()->set_value(2); | ||
| health_check->mutable_health_checks(0)->mutable_grpc_health_check(); | ||
|
|
@@ -587,6 +615,10 @@ TEST_P(HdsIntegrationTest, TwoEndpointsDifferentClusters) { | |
| host2_stream_->encodeHeaders(Http::TestHeaderMapImpl{{":status", "200"}}, false); | ||
| host2_stream_->encodeData(1024, true); | ||
|
|
||
| // Make sure the cluster processed the endpoints' response | ||
| test_server_->waitForCounterGe("cluster.anna.health_check.failure", 1); | ||
| test_server_->waitForCounterGe("cluster.cat.health_check.success", 1); | ||
|
|
||
| // Envoy reports back to server | ||
| ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, response_)); | ||
|
|
||
|
|
@@ -628,6 +660,9 @@ TEST_P(HdsIntegrationTest, TestUpdateMessage) { | |
| host_stream_->encodeHeaders(Http::TestHeaderMapImpl{{":status", "200"}}, false); | ||
| host_stream_->encodeData(1024, true); | ||
|
|
||
| // Make sure the cluster processed the endpoint's response | ||
| test_server_->waitForCounterGe("cluster.anna.health_check.success", 1); | ||
|
|
||
| // Envoy reports back to server | ||
| ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, response_)); | ||
|
|
||
|
|
@@ -641,7 +676,7 @@ TEST_P(HdsIntegrationTest, TestUpdateMessage) { | |
|
|
||
| // New HealthCheckSpecifier message | ||
| envoy::service::discovery::v2::HealthCheckSpecifier new_message; | ||
| new_message.mutable_interval()->set_seconds(1); | ||
| new_message.mutable_interval()->set_nanos(100000000); | ||
|
|
||
| auto* health_check = new_message.add_cluster_health_checks(); | ||
|
|
||
|
|
@@ -654,8 +689,8 @@ TEST_P(HdsIntegrationTest, TestUpdateMessage) { | |
| health_check->mutable_locality_endpoints(0)->mutable_locality()->set_zone("peculiar_zone"); | ||
| health_check->mutable_locality_endpoints(0)->mutable_locality()->set_sub_zone("paris"); | ||
|
|
||
| health_check->add_health_checks()->mutable_timeout()->set_seconds(2); | ||
| health_check->mutable_health_checks(0)->mutable_interval()->set_seconds(1); | ||
| health_check->add_health_checks()->mutable_timeout()->set_seconds(100); | ||
| health_check->mutable_health_checks(0)->mutable_interval()->set_seconds(100); | ||
| health_check->mutable_health_checks(0)->mutable_unhealthy_threshold()->set_value(2); | ||
| health_check->mutable_health_checks(0)->mutable_healthy_threshold()->set_value(2); | ||
| health_check->mutable_health_checks(0)->mutable_grpc_health_check(); | ||
|
|
@@ -671,10 +706,14 @@ TEST_P(HdsIntegrationTest, TestUpdateMessage) { | |
| ASSERT_TRUE(host2_fake_connection_->waitForNewStream(*dispatcher_, host2_stream_)); | ||
| ASSERT_TRUE(host2_stream_->waitForEndStream(*dispatcher_)); | ||
| host2_upstream_->set_allow_unexpected_disconnects(true); | ||
|
|
||
| // Endpoint responds to the health check | ||
| host2_stream_->encodeHeaders(Http::TestHeaderMapImpl{{":status", "404"}}, false); | ||
| host2_stream_->encodeData(1024, true); | ||
|
|
||
| // Make sure the cluster processed the endpoint's response | ||
| test_server_->waitForCounterGe("cluster.cat.health_check.failure", 1); | ||
|
|
||
| // Envoy reports back to server | ||
| ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, response_)); | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not still use seconds here for readability? Same elsewhere? Or perhaps a constant such as MaxTimeout to make it clear that we don't care about the timeout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interval specifies how often the HdsDelegate sends a message with health checking information back to the management server. Before these changes, I was using time to make sure that the cluster updated before a response was sent. Now, I check the stats to make sure that the cluster processed the change, before I look at what the HdsDelegate sends to the server.
In order to make the interval less than a second, I need to use nanos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok. Alright, some type of constant or comment might still be nice here since it's hard to read how much time this is.