mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Fix flaky test
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
bf8d88f326
commit
0f01d4b336
|
@ -21,6 +21,7 @@ import (
|
|||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -94,9 +95,14 @@ func TestQueryConcurrency(t *testing.T) {
|
|||
return nil
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < maxConcurrency; i++ {
|
||||
q := engine.NewTestQuery(f)
|
||||
go q.Exec(ctx)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
q.Exec(ctx)
|
||||
wg.Done()
|
||||
}()
|
||||
select {
|
||||
case <-processing:
|
||||
// Expected.
|
||||
|
@ -106,7 +112,11 @@ func TestQueryConcurrency(t *testing.T) {
|
|||
}
|
||||
|
||||
q := engine.NewTestQuery(f)
|
||||
go q.Exec(ctx)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
q.Exec(ctx)
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-processing:
|
||||
|
@ -129,6 +139,8 @@ func TestQueryConcurrency(t *testing.T) {
|
|||
for i := 0; i < maxConcurrency; i++ {
|
||||
block <- struct{}{}
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
// contextDone returns an error if the context was canceled or timed out.
|
||||
|
|
Loading…
Reference in a new issue