Skip to content

Commit cf60e5a

Browse files
authoredFeb 13, 2025··
test: Remove fake petiole in health tests (#8082)
1 parent 0003b4f commit cf60e5a

File tree

1 file changed

+12
-54
lines changed

1 file changed

+12
-54
lines changed
 

‎test/healthcheck_test.go

+12-54
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ import (
3030
"google.golang.org/grpc"
3131
"google.golang.org/grpc/balancer"
3232
"google.golang.org/grpc/balancer/pickfirst"
33-
"google.golang.org/grpc/balancer/pickfirst/pickfirstleaf"
33+
"google.golang.org/grpc/balancer/roundrobin"
3434
"google.golang.org/grpc/codes"
3535
"google.golang.org/grpc/connectivity"
3636
"google.golang.org/grpc/credentials/insecure"
3737
"google.golang.org/grpc/health"
3838
"google.golang.org/grpc/internal"
3939
"google.golang.org/grpc/internal/balancer/stub"
4040
"google.golang.org/grpc/internal/channelz"
41-
"google.golang.org/grpc/internal/envconfig"
4241
"google.golang.org/grpc/internal/grpctest"
4342
"google.golang.org/grpc/internal/testutils"
4443
"google.golang.org/grpc/resolver"
@@ -51,47 +50,6 @@ import (
5150
testpb "google.golang.org/grpc/interop/grpc_testing"
5251
)
5352

54-
const healthCheckingPetiolePolicyName = "health_checking_petiole_policy"
55-
56-
var (
57-
// healthCheckTestPolicyName is the LB policy used for testing the health check
58-
// service.
59-
healthCheckTestPolicyName = "round_robin"
60-
)
61-
62-
func init() {
63-
balancer.Register(&healthCheckingPetiolePolicyBuilder{})
64-
// Till dualstack changes are not implemented and round_robin doesn't
65-
// delegate to pickfirst, test a fake petiole policy that delegates to
66-
// the new pickfirst balancer.
67-
// TODO: https://github.com/grpc/grpc-go/issues/7906 - Remove the fake
68-
// petiole policy one round robin starts delegating to pickfirst.
69-
if envconfig.NewPickFirstEnabled {
70-
healthCheckTestPolicyName = healthCheckingPetiolePolicyName
71-
}
72-
}
73-
74-
type healthCheckingPetiolePolicyBuilder struct{}
75-
76-
func (bb *healthCheckingPetiolePolicyBuilder) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer {
77-
return &healthCheckingPetiolePolicy{
78-
Balancer: balancer.Get(pickfirstleaf.Name).Build(cc, opts),
79-
}
80-
}
81-
82-
func (bb *healthCheckingPetiolePolicyBuilder) Name() string {
83-
return healthCheckingPetiolePolicyName
84-
}
85-
86-
func (b *healthCheckingPetiolePolicy) UpdateClientConnState(state balancer.ClientConnState) error {
87-
state.ResolverState = pickfirstleaf.EnableHealthListener(state.ResolverState)
88-
return b.Balancer.UpdateClientConnState(state)
89-
}
90-
91-
type healthCheckingPetiolePolicy struct {
92-
balancer.Balancer
93-
}
94-
9553
func newTestHealthServer() *testHealthServer {
9654
return newTestHealthServerWithWatchFunc(defaultWatchFunc)
9755
}
@@ -312,7 +270,7 @@ func (s) TestHealthCheckHealthServerNotRegistered(t *testing.T) {
312270
"serviceName": "foo"
313271
},
314272
"loadBalancingConfig": [{"%s":{}}]
315-
}`, healthCheckTestPolicyName))})
273+
}`, roundrobin.Name))})
316274

317275
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
318276
defer cancel()
@@ -339,7 +297,7 @@ func (s) TestHealthCheckWithGoAway(t *testing.T) {
339297
"serviceName": "foo"
340298
},
341299
"loadBalancingConfig": [{"%s":{}}]
342-
}`, healthCheckTestPolicyName))})
300+
}`, roundrobin.Name))})
343301

344302
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
345303
defer cancel()
@@ -417,7 +375,7 @@ func (s) TestHealthCheckWithConnClose(t *testing.T) {
417375
"serviceName": "foo"
418376
},
419377
"loadBalancingConfig": [{"%s":{}}]
420-
}`, healthCheckTestPolicyName))})
378+
}`, roundrobin.Name))})
421379

422380
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
423381
defer cancel()
@@ -465,7 +423,7 @@ func (s) TestHealthCheckWithAddrConnDrain(t *testing.T) {
465423
"serviceName": "foo"
466424
},
467425
"loadBalancingConfig": [{"%s":{}}]
468-
}`, healthCheckTestPolicyName))
426+
}`, roundrobin.Name))
469427
r.UpdateState(resolver.State{
470428
Addresses: []resolver.Address{{Addr: lis.Addr().String()}},
471429
ServiceConfig: sc,
@@ -547,7 +505,7 @@ func (s) TestHealthCheckWithClientConnClose(t *testing.T) {
547505
"serviceName": "foo"
548506
},
549507
"loadBalancingConfig": [{"%s":{}}]
550-
}`, healthCheckTestPolicyName)))})
508+
}`, roundrobin.Name)))})
551509

552510
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
553511
defer cancel()
@@ -614,7 +572,7 @@ func (s) TestHealthCheckWithoutSetConnectivityStateCalledAddrConnShutDown(t *tes
614572
"serviceName": "delay"
615573
},
616574
"loadBalancingConfig": [{"%s":{}}]
617-
}`, healthCheckTestPolicyName))
575+
}`, roundrobin.Name))
618576
r.UpdateState(resolver.State{
619577
Addresses: []resolver.Address{{Addr: lis.Addr().String()}},
620578
ServiceConfig: sc,
@@ -679,7 +637,7 @@ func (s) TestHealthCheckWithoutSetConnectivityStateCalled(t *testing.T) {
679637
"serviceName": "delay"
680638
},
681639
"loadBalancingConfig": [{"%s":{}}]
682-
}`, healthCheckTestPolicyName))})
640+
}`, roundrobin.Name))})
683641

684642
select {
685643
case <-hcExitChan:
@@ -717,7 +675,7 @@ func testHealthCheckDisableWithDialOption(t *testing.T, addr string) {
717675
"serviceName": "foo"
718676
},
719677
"loadBalancingConfig": [{"%s":{}}]
720-
}`, healthCheckTestPolicyName))})
678+
}`, roundrobin.Name))})
721679

722680
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
723681
defer cancel()
@@ -823,7 +781,7 @@ func (s) TestHealthCheckChannelzCountingCallSuccess(t *testing.T) {
823781
"serviceName": "channelzSuccess"
824782
},
825783
"loadBalancingConfig": [{"%s":{}}]
826-
}`, healthCheckTestPolicyName))})
784+
}`, roundrobin.Name))})
827785

828786
if err := verifyResultWithDelay(func() (bool, error) {
829787
cm, _ := channelz.GetTopChannels(0, 0)
@@ -872,7 +830,7 @@ func (s) TestHealthCheckChannelzCountingCallFailure(t *testing.T) {
872830
"serviceName": "channelzFailure"
873831
},
874832
"loadBalancingConfig": [{"%s":{}}]
875-
}`, healthCheckTestPolicyName))})
833+
}`, roundrobin.Name))})
876834

877835
if err := verifyResultWithDelay(func() (bool, error) {
878836
cm, _ := channelz.GetTopChannels(0, 0)
@@ -985,7 +943,7 @@ func (s) TestHealthCheckFailure(t *testing.T) {
985943
name: "tcp-tls",
986944
network: "tcp",
987945
security: "tls",
988-
balancer: healthCheckTestPolicyName,
946+
balancer: roundrobin.Name,
989947
}
990948
te := newTest(t, e)
991949
te.declareLogNoise(

0 commit comments

Comments
 (0)
Please sign in to comment.