mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-07 06:37:17 +02: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"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -94,9 +95,14 @@ func TestQueryConcurrency(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
for i := 0; i < maxConcurrency; i++ {
|
for i := 0; i < maxConcurrency; i++ {
|
||||||
q := engine.NewTestQuery(f)
|
q := engine.NewTestQuery(f)
|
||||||
go q.Exec(ctx)
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
q.Exec(ctx)
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
select {
|
select {
|
||||||
case <-processing:
|
case <-processing:
|
||||||
// Expected.
|
// Expected.
|
||||||
@ -106,7 +112,11 @@ func TestQueryConcurrency(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
q := engine.NewTestQuery(f)
|
q := engine.NewTestQuery(f)
|
||||||
go q.Exec(ctx)
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
q.Exec(ctx)
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-processing:
|
case <-processing:
|
||||||
@ -129,6 +139,8 @@ func TestQueryConcurrency(t *testing.T) {
|
|||||||
for i := 0; i < maxConcurrency; i++ {
|
for i := 0; i < maxConcurrency; i++ {
|
||||||
block <- struct{}{}
|
block <- struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
// contextDone returns an error if the context was canceled or timed out.
|
// contextDone returns an error if the context was canceled or timed out.
|
||||||
|
Loading…
Reference in New Issue
Block a user