Merge pull request #10038 from charlesxsh/fix-TestReshardRaceWithStop

add proper exit for loop
This commit is contained in:
Chris Marchbanks 2022-01-03 09:02:45 -07:00 committed by GitHub
commit dfa5cb7462
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -356,6 +356,7 @@ func TestReshardRaceWithStop(t *testing.T) {
cfg := config.DefaultQueueConfig cfg := config.DefaultQueueConfig
mcfg := config.DefaultMetadataConfig mcfg := config.DefaultMetadataConfig
exitCh := make(chan struct{})
go func() { go func() {
for { for {
metrics := newQueueManagerMetrics(nil, "", "") metrics := newQueueManagerMetrics(nil, "", "")
@ -364,6 +365,12 @@ func TestReshardRaceWithStop(t *testing.T) {
h.Unlock() h.Unlock()
h.Lock() h.Lock()
m.Stop() m.Stop()
select {
case exitCh <- struct{}{}:
return
default:
}
} }
}() }()
@ -372,6 +379,7 @@ func TestReshardRaceWithStop(t *testing.T) {
m.reshardChan <- i m.reshardChan <- i
h.Unlock() h.Unlock()
} }
<-exitCh
} }
func TestReleaseNoninternedString(t *testing.T) { func TestReleaseNoninternedString(t *testing.T) {