mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 13:44:05 -08:00
fix potential goroutine leaks (#10057)
Signed-off-by: Shihao Xia <charlesxsh@hotmail.com>
This commit is contained in:
parent
701545286d
commit
d26fd5c97b
|
@ -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…
Reference in a new issue