mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
fix potential deadlock in test (#9010)
* fix potential deadlock Signed-off-by: Shihao Xia <charlesxsh@hotmail.com> * fix deadlock Signed-off-by: Shihao Xia <charlesxsh@hotmail.com> * Update promql/engine_test.go Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com> Signed-off-by: Shihao Xia <charlesxsh@hotmail.com> Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com>
This commit is contained in:
parent
e63b85be4f
commit
0e82a96e2f
|
@ -58,10 +58,19 @@ func TestQueryConcurrency(t *testing.T) {
|
||||||
|
|
||||||
block := make(chan struct{})
|
block := make(chan struct{})
|
||||||
processing := make(chan struct{})
|
processing := make(chan struct{})
|
||||||
|
done := make(chan int)
|
||||||
|
defer close(done)
|
||||||
|
|
||||||
f := func(context.Context) error {
|
f := func(context.Context) error {
|
||||||
processing <- struct{}{}
|
select {
|
||||||
<-block
|
case processing <- struct{}{}:
|
||||||
|
case <-done:
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-block:
|
||||||
|
case <-done:
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +379,6 @@ func TestSelectHintsSetCorrectly(t *testing.T) {
|
||||||
{Start: -45000, End: 80000, Func: "count_over_time"},
|
{Start: -45000, End: 80000, Func: "count_over_time"},
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
|
|
||||||
query: "foo", start: 10000, end: 20000,
|
query: "foo", start: 10000, end: 20000,
|
||||||
expected: []*storage.SelectHints{
|
expected: []*storage.SelectHints{
|
||||||
{Start: 5000, End: 20000, Step: 1000},
|
{Start: 5000, End: 20000, Step: 1000},
|
||||||
|
|
Loading…
Reference in a new issue