test:Fix two potential goroutine leaks (#8964)

Signed-off-by: lzhfromustc <lzhfromustc@gmail.com>
This commit is contained in:
lzhfromustc 2021-10-29 15:44:32 -07:00 committed by GitHub
parent 5afa606ecb
commit d42be7be76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -1371,7 +1371,11 @@ func (tp mockdiscoveryProvider) Run(ctx context.Context, upCh chan<- []*targetgr
for i := range u.targetGroups {
tgs[i] = &u.targetGroups[i]
}
upCh <- tgs
select {
case <-ctx.Done():
return
case upCh <- tgs:
}
}
<-ctx.Done()
}

View File

@ -408,6 +408,7 @@ func TestReleaseNoninternedString(t *testing.T) {
c := NewTestWriteClient()
m := NewQueueManager(metrics, nil, nil, nil, "", newEWMARate(ewmaWeight, shardUpdateDuration), cfg, mcfg, nil, nil, c, defaultFlushDeadline, newPool(), newHighestTimestampMetric(), nil, false)
m.Start()
defer m.Stop()
for i := 1; i < 1000; i++ {
m.StoreSeries([]record.RefSeries{