From 9f8195a6318309995a172de83d7212b8a03eb540 Mon Sep 17 00:00:00 2001 From: Aaron Beitch Date: Tue, 10 Oct 2023 19:33:06 -0700 Subject: [PATCH] Get rid of leaked goroutine in TestConcurrentRetryableError TestConcurrentRetryableError leaks an establishRegion goroutine trying to discover the meta region. It repeats endlessly in a loop because zookeeper is mocked to always return an error. This leaked goroutine breaks a test I add in the next change. --- rpc_test.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/rpc_test.go b/rpc_test.go index 300f64d3..1d9c0375 100644 --- a/rpc_test.go +++ b/rpc_test.go @@ -717,15 +717,6 @@ func TestConcurrentRetryableError(t *testing.T) { nil, nil, ) - // fake region to make sure we don't close the client - whateverRegion := region.NewInfo( - 0, - nil, - []byte("test2"), - []byte("test2,,1234567890042.56f833d5569a27c7a43fbf547b4924a4."), - nil, - nil, - ) rc := mockRegion.NewMockRegionClient(ctrl) rc.EXPECT().String().Return("mock region client").AnyTimes() @@ -733,12 +724,11 @@ func TestConcurrentRetryableError(t *testing.T) { newRC := func() hrpc.RegionClient { return rc } + c.clients.put("host:1234", c.metaRegionInfo, newRC) + c.metaRegionInfo.SetClient(rc) c.regions.put(origlReg) - c.regions.put(whateverRegion) c.clients.put("host:1234", origlReg, newRC) - c.clients.put("host:1234", whateverRegion, newRC) origlReg.SetClient(rc) - whateverRegion.SetClient(rc) numCalls := 100 rc.EXPECT().QueueRPC(gomock.Any()).MinTimes(1)