Skip to content

Commit c9cca95

Browse files
authored
clusterimpl: remove unused code in tests (#8634)
RELEASE NOTES: NONE
1 parent b22a27f commit c9cca95

File tree

2 files changed

+3
-33
lines changed

2 files changed

+3
-33
lines changed

internal/xds/balancer/clusterimpl/balancer_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ func init() {
6767
// are handled in the run() goroutine, which exits before Close() returns, we
6868
// expect the above picker update to be dropped.
6969
func (s) TestPickerUpdateAfterClose(t *testing.T) {
70-
defer xdsclient.ClearCounterForTesting(testClusterName, testServiceName)
71-
xdsC := fakeclient.NewClient()
72-
7370
builder := balancer.Get(Name)
7471
cc := testutils.NewBalancerClientConn(t)
7572
b := builder.Build(cc, balancer.BuildOptions{})
@@ -104,6 +101,7 @@ func (s) TestPickerUpdateAfterClose(t *testing.T) {
104101
})
105102

106103
var maxRequest uint32 = 50
104+
xdsC := fakeclient.NewClient()
107105
if err := b.UpdateClientConnState(balancer.ClientConnState{
108106
ResolverState: xdsclient.SetClient(resolver.State{Endpoints: testBackendEndpoints}, xdsC),
109107
BalancerConfig: &LBConfig{
@@ -140,14 +138,12 @@ func (s) TestClusterNameInAddressAttributes(t *testing.T) {
140138
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
141139
defer cancel()
142140

143-
defer xdsclient.ClearCounterForTesting(testClusterName, testServiceName)
144-
xdsC := fakeclient.NewClient()
145-
146141
builder := balancer.Get(Name)
147142
cc := testutils.NewBalancerClientConn(t)
148143
b := builder.Build(cc, balancer.BuildOptions{})
149144
defer b.Close()
150145

146+
xdsC := fakeclient.NewClient()
151147
if err := b.UpdateClientConnState(balancer.ClientConnState{
152148
ResolverState: xdsclient.SetClient(resolver.State{Endpoints: testBackendEndpoints}, xdsC),
153149
BalancerConfig: &LBConfig{
@@ -237,9 +233,6 @@ func (s) TestPickerUpdatedSynchronouslyOnConfigUpdate(t *testing.T) {
237233
}
238234
defer func() { clientConnUpdateHook = origClientConnUpdateHook }()
239235

240-
defer xdsclient.ClearCounterForTesting(testClusterName, testServiceName)
241-
xdsC := fakeclient.NewClient()
242-
243236
builder := balancer.Get(Name)
244237
cc := testutils.NewBalancerClientConn(t)
245238
b := builder.Build(cc, balancer.BuildOptions{})
@@ -257,6 +250,7 @@ func (s) TestPickerUpdatedSynchronouslyOnConfigUpdate(t *testing.T) {
257250
},
258251
})
259252

253+
xdsC := fakeclient.NewClient()
260254
if err := b.UpdateClientConnState(balancer.ClientConnState{
261255
ResolverState: xdsclient.SetClient(resolver.State{Endpoints: testBackendEndpoints}, xdsC),
262256
BalancerConfig: &LBConfig{

internal/xds/xdsclient/requests_counter.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -81,27 +81,3 @@ func (c *ClusterRequestsCounter) StartRequest(max uint32) error {
8181
func (c *ClusterRequestsCounter) EndRequest() {
8282
atomic.AddUint32(&c.numRequests, ^uint32(0))
8383
}
84-
85-
// ClearCounterForTesting clears the counter for the service. Should be only
86-
// used in tests.
87-
func ClearCounterForTesting(clusterName, edsServiceName string) {
88-
src.mu.Lock()
89-
defer src.mu.Unlock()
90-
k := clusterNameAndServiceName{
91-
clusterName: clusterName,
92-
edsServiceName: edsServiceName,
93-
}
94-
c, ok := src.clusters[k]
95-
if !ok {
96-
return
97-
}
98-
c.numRequests = 0
99-
}
100-
101-
// ClearAllCountersForTesting clears all the counters. Should be only used in
102-
// tests.
103-
func ClearAllCountersForTesting() {
104-
src.mu.Lock()
105-
defer src.mu.Unlock()
106-
src.clusters = make(map[clusterNameAndServiceName]*ClusterRequestsCounter)
107-
}

0 commit comments

Comments
 (0)