From c3e7bfb81303b3636de737ff7dc7833f251c9b91 Mon Sep 17 00:00:00 2001 From: Shihao Xia Date: Wed, 29 Dec 2021 23:48:11 -0500 Subject: [PATCH] add proper exit for loop Signed-off-by: Shihao Xia --- storage/remote/queue_manager_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/storage/remote/queue_manager_test.go b/storage/remote/queue_manager_test.go index f55c4b472..e0b056e5b 100644 --- a/storage/remote/queue_manager_test.go +++ b/storage/remote/queue_manager_test.go @@ -356,6 +356,7 @@ func TestReshardRaceWithStop(t *testing.T) { cfg := config.DefaultQueueConfig mcfg := config.DefaultMetadataConfig + exitCh := make(chan struct{}) go func() { for { metrics := newQueueManagerMetrics(nil, "", "") @@ -364,6 +365,12 @@ func TestReshardRaceWithStop(t *testing.T) { h.Unlock() h.Lock() m.Stop() + + select { + case exitCh <- struct{}{}: + return + default: + } } }() @@ -372,6 +379,7 @@ func TestReshardRaceWithStop(t *testing.T) { m.reshardChan <- i h.Unlock() } + <-exitCh } func TestReleaseNoninternedString(t *testing.T) {