Skip to content

Commit

Permalink
Get rid of leaked goroutine in TestConcurrentRetryableError
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aaronbee committed Oct 11, 2023
1 parent f750f62 commit 9f8195a
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,28 +717,18 @@ 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()
rc.EXPECT().Addr().Return("host:1234").AnyTimes()
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)
Expand Down

0 comments on commit 9f8195a

Please sign in to comment.