fix potential goroutine leaks (#10057)

Signed-off-by: Shihao Xia <charlesxsh@hotmail.com>
pull/10119/head
Shihao Xia 3 years ago committed by GitHub
parent 701545286d
commit d26fd5c97b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -668,13 +668,16 @@ func TestTargetUpdatesOrder(t *testing.T) {
discoveryManager.updatert = 100 * time.Millisecond discoveryManager.updatert = 100 * time.Millisecond
var totalUpdatesCount int var totalUpdatesCount int
provUpdates := make(chan []*targetgroup.Group)
for _, up := range tc.updates { for _, up := range tc.updates {
go newMockDiscoveryProvider(up...).Run(ctx, provUpdates)
if len(up) > 0 { if len(up) > 0 {
totalUpdatesCount += len(up) totalUpdatesCount += len(up)
} }
} }
provUpdates := make(chan []*targetgroup.Group, totalUpdatesCount)
for _, up := range tc.updates {
go newMockDiscoveryProvider(up...).Run(ctx, provUpdates)
}
for x := 0; x < totalUpdatesCount; x++ { for x := 0; x < totalUpdatesCount; x++ {
select { select {

@ -668,13 +668,16 @@ func TestTargetUpdatesOrder(t *testing.T) {
discoveryManager.updatert = 100 * time.Millisecond discoveryManager.updatert = 100 * time.Millisecond
var totalUpdatesCount int var totalUpdatesCount int
provUpdates := make(chan []*targetgroup.Group)
for _, up := range tc.updates { for _, up := range tc.updates {
go newMockDiscoveryProvider(up...).Run(ctx, provUpdates)
if len(up) > 0 { if len(up) > 0 {
totalUpdatesCount += len(up) totalUpdatesCount += len(up)
} }
} }
provUpdates := make(chan []*targetgroup.Group, totalUpdatesCount)
for _, up := range tc.updates {
go newMockDiscoveryProvider(up...).Run(ctx, provUpdates)
}
for x := 0; x < totalUpdatesCount; x++ { for x := 0; x < totalUpdatesCount; x++ {
select { select {

Loading…
Cancel
Save