@@ -86,7 +86,6 @@ class LoadBalancerBaseTest : public LoadBalancerTestBase {
8686 }
8787
8888 for (; i < (num_healthy_hosts + num_degraded_hosts + num_excluded_hosts); ++i) {
89- host_set.degraded_hosts_ .push_back (host_set.hosts_ [i]);
9089 host_set.excluded_hosts_ .push_back (host_set.hosts_ [i]);
9190 }
9291 host_set.runCallbacks ({}, {});
@@ -310,7 +309,6 @@ TEST_P(LoadBalancerBaseTest, GentleFailover) {
310309 ASSERT_THAT (getPanic (), ElementsAre (false , false ));
311310
312311 // Health P=0 == 100*1.4 == 35 P=1 == 35
313- // Since 4 hosts are excluded and are unhealthy, P=0 should be considered fully unavailable.
314312 // Total health = 35% is less than 100%.
315313 // All priorities are in panic mode (situation called TotalPanic)
316314 // Load is distributed based on number of hosts regardless of their health status.
@@ -320,6 +318,19 @@ TEST_P(LoadBalancerBaseTest, GentleFailover) {
320318 updateHostSet (failover_host_set_, 4 /* num_hosts */ , 1 /* num_healthy_hosts */ );
321319 ASSERT_THAT (getLoadPercentage (), ElementsAre (50 , 50 ));
322320 ASSERT_THAT (getPanic (), ElementsAre (true , true ));
321+
322+ // Make sure that in TotalPanic mode (all levels are in Panic),
323+ // load distribution depends only on number of hosts.
324+ // excluded_hosts should not be taken into account.
325+ // P=0 has 4 hosts with 1 excluded, P=1 has 6 hosts with 2 excluded.
326+ // P=0 should receive 4/(4+6)=40% of traffic
327+ // P=1 should receive 6/(4+6)=60% of traffic
328+ updateHostSet (host_set_, 4 /* num_hosts */ , 0 /* num_healthy_hosts */ , 0 /* num_degraded_hosts */ ,
329+ 1 /* num_excluded_hosts */ );
330+ updateHostSet (failover_host_set_, 6 /* num_hosts */ , 1 /* num_healthy_hosts */ ,
331+ 0 /* num_degraded_hosts */ , 2 /* num_excluded_hosts */ );
332+ ASSERT_THAT (getLoadPercentage (), ElementsAre (40 , 60 ));
333+ ASSERT_THAT (getPanic (), ElementsAre (true , true ));
323334}
324335
325336TEST_P (LoadBalancerBaseTest, GentleFailoverWithExtraLevels) {
0 commit comments