@@ -4737,6 +4737,70 @@ TEST_F(GrpcHealthCheckerImplTest, SuccessStartFailedFailFirst) {
4737
4737
expectHostHealthy (true );
4738
4738
}
4739
4739
4740
+ // Verify functionality when a host is removed inline with a failure via RPC that was proceeded
4741
+ // by a GOAWAY.
4742
+ TEST_F (GrpcHealthCheckerImplTest, GrpcHealthFailViaRpcRemoveHostInCallback) {
4743
+ setupHC ();
4744
+ cluster_->prioritySet ().getMockHostSet (0 )->hosts_ = {
4745
+ makeTestHost (cluster_->info_ , " tcp://127.0.0.1:80" , simTime ())};
4746
+
4747
+ expectSessionCreate ();
4748
+ expectHealthcheckStart (0 );
4749
+ EXPECT_CALL (event_logger_, logUnhealthy (_, _, _, true ));
4750
+ health_checker_->start ();
4751
+
4752
+ EXPECT_CALL (*this , onHostStatus (_, HealthTransition::Changed))
4753
+ .WillOnce (Invoke ([&](HostSharedPtr host, HealthTransition) {
4754
+ cluster_->prioritySet ().getMockHostSet (0 )->hosts_ = {};
4755
+ cluster_->prioritySet ().runUpdateCallbacks (0 , {}, {host});
4756
+ }));
4757
+ EXPECT_CALL (event_logger_, logEjectUnhealthy (_, _, _));
4758
+ test_sessions_[0 ]->codec_client_ ->raiseGoAway (Http::GoAwayErrorCode::NoError);
4759
+ respondServiceStatus (0 , grpc::health::v1::HealthCheckResponse::NOT_SERVING);
4760
+ }
4761
+
4762
+ // Verify functionality when a host is removed inline with a failure via an error GOAWAY.
4763
+ TEST_F (GrpcHealthCheckerImplTest, GrpcHealthFailViaGoawayRemoveHostInCallback) {
4764
+ setupHCWithUnhealthyThreshold (/* threshold=*/ 1 );
4765
+ cluster_->prioritySet ().getMockHostSet (0 )->hosts_ = {
4766
+ makeTestHost (cluster_->info_ , " tcp://127.0.0.1:80" , simTime ())};
4767
+
4768
+ expectSessionCreate ();
4769
+ expectHealthcheckStart (0 );
4770
+ EXPECT_CALL (event_logger_, logUnhealthy (_, _, _, true ));
4771
+ health_checker_->start ();
4772
+
4773
+ EXPECT_CALL (*this , onHostStatus (_, HealthTransition::Changed))
4774
+ .WillOnce (Invoke ([&](HostSharedPtr host, HealthTransition) {
4775
+ cluster_->prioritySet ().getMockHostSet (0 )->hosts_ = {};
4776
+ cluster_->prioritySet ().runUpdateCallbacks (0 , {}, {host});
4777
+ }));
4778
+ EXPECT_CALL (event_logger_, logEjectUnhealthy (_, _, _));
4779
+ test_sessions_[0 ]->codec_client_ ->raiseGoAway (Http::GoAwayErrorCode::Other);
4780
+ }
4781
+
4782
+ // Verify functionality when a host is removed inline with by a bad RPC response.
4783
+ TEST_F (GrpcHealthCheckerImplTest, GrpcHealthFailViaBadResponseRemoveHostInCallback) {
4784
+ setupHCWithUnhealthyThreshold (/* threshold=*/ 1 );
4785
+ cluster_->prioritySet ().getMockHostSet (0 )->hosts_ = {
4786
+ makeTestHost (cluster_->info_ , " tcp://127.0.0.1:80" , simTime ())};
4787
+
4788
+ expectSessionCreate ();
4789
+ expectHealthcheckStart (0 );
4790
+ EXPECT_CALL (event_logger_, logUnhealthy (_, _, _, true ));
4791
+ health_checker_->start ();
4792
+
4793
+ EXPECT_CALL (*this , onHostStatus (_, HealthTransition::Changed))
4794
+ .WillOnce (Invoke ([&](HostSharedPtr host, HealthTransition) {
4795
+ cluster_->prioritySet ().getMockHostSet (0 )->hosts_ = {};
4796
+ cluster_->prioritySet ().runUpdateCallbacks (0 , {}, {host});
4797
+ }));
4798
+ EXPECT_CALL (event_logger_, logEjectUnhealthy (_, _, _));
4799
+ std::unique_ptr<Http::TestResponseHeaderMapImpl> response_headers (
4800
+ new Http::TestResponseHeaderMapImpl{{" :status" , " 500" }});
4801
+ test_sessions_[0 ]->stream_response_callbacks_ ->decodeHeaders (std::move (response_headers), false );
4802
+ }
4803
+
4740
4804
// Test host recovery after explicit check failure requires several successful checks.
4741
4805
TEST_F (GrpcHealthCheckerImplTest, GrpcHealthFail) {
4742
4806
setupHC ();
0 commit comments