mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Reduce the flakiness of TestAsyncRuleEvaluation (#14300)
* Reduce the flakiness of TestAsyncRuleEvaluation This tests sleeps for 15 millisecond per rule group, and then comprares the entire execution time to be smaller than a multiple of that delay. The ruleCount is 6, so it assumes that the test will come to the assertions in less than 90ms. Meanwhile, the Github's Windows runner: - ...Huh, oh? What? How much time? milliwhat? Sorry I don't speak that. TL;DR, this increases the delay to 250 millisecond. This won't prevent the test from being flaky, but will reduce the flakiness by several orders of magnitude and hopefully won't be an issue anymore. Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com> * Make tests parallel Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com> --------- Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
This commit is contained in:
parent
5a218708f1
commit
4c1e71fa0b
|
@ -1910,18 +1910,12 @@ func TestDependencyMapUpdatesOnGroupUpdate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAsyncRuleEvaluation(t *testing.T) {
|
func TestAsyncRuleEvaluation(t *testing.T) {
|
||||||
|
t.Run("synchronous evaluation with independent rules", func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
storage := teststorage.New(t)
|
storage := teststorage.New(t)
|
||||||
t.Cleanup(func() { storage.Close() })
|
t.Cleanup(func() { storage.Close() })
|
||||||
|
inflightQueries := atomic.Int32{}
|
||||||
var (
|
maxInflight := atomic.Int32{}
|
||||||
inflightQueries atomic.Int32
|
|
||||||
maxInflight atomic.Int32
|
|
||||||
)
|
|
||||||
|
|
||||||
t.Run("synchronous evaluation with independent rules", func(t *testing.T) {
|
|
||||||
// Reset.
|
|
||||||
inflightQueries.Store(0)
|
|
||||||
maxInflight.Store(0)
|
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
t.Cleanup(cancel)
|
t.Cleanup(cancel)
|
||||||
|
@ -1949,9 +1943,11 @@ func TestAsyncRuleEvaluation(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("asynchronous evaluation with independent and dependent rules", func(t *testing.T) {
|
t.Run("asynchronous evaluation with independent and dependent rules", func(t *testing.T) {
|
||||||
// Reset.
|
t.Parallel()
|
||||||
inflightQueries.Store(0)
|
storage := teststorage.New(t)
|
||||||
maxInflight.Store(0)
|
t.Cleanup(func() { storage.Close() })
|
||||||
|
inflightQueries := atomic.Int32{}
|
||||||
|
maxInflight := atomic.Int32{}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
t.Cleanup(cancel)
|
t.Cleanup(cancel)
|
||||||
|
@ -1985,9 +1981,11 @@ func TestAsyncRuleEvaluation(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("asynchronous evaluation of all independent rules, insufficient concurrency", func(t *testing.T) {
|
t.Run("asynchronous evaluation of all independent rules, insufficient concurrency", func(t *testing.T) {
|
||||||
// Reset.
|
t.Parallel()
|
||||||
inflightQueries.Store(0)
|
storage := teststorage.New(t)
|
||||||
maxInflight.Store(0)
|
t.Cleanup(func() { storage.Close() })
|
||||||
|
inflightQueries := atomic.Int32{}
|
||||||
|
maxInflight := atomic.Int32{}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
t.Cleanup(cancel)
|
t.Cleanup(cancel)
|
||||||
|
@ -2021,9 +2019,11 @@ func TestAsyncRuleEvaluation(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("asynchronous evaluation of all independent rules, sufficient concurrency", func(t *testing.T) {
|
t.Run("asynchronous evaluation of all independent rules, sufficient concurrency", func(t *testing.T) {
|
||||||
// Reset.
|
t.Parallel()
|
||||||
inflightQueries.Store(0)
|
storage := teststorage.New(t)
|
||||||
maxInflight.Store(0)
|
t.Cleanup(func() { storage.Close() })
|
||||||
|
inflightQueries := atomic.Int32{}
|
||||||
|
maxInflight := atomic.Int32{}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
t.Cleanup(cancel)
|
t.Cleanup(cancel)
|
||||||
|
@ -2098,7 +2098,7 @@ func TestBoundedRuleEvalConcurrency(t *testing.T) {
|
||||||
require.EqualValues(t, maxInflight.Load(), int32(maxConcurrency)+int32(groupCount))
|
require.EqualValues(t, maxInflight.Load(), int32(maxConcurrency)+int32(groupCount))
|
||||||
}
|
}
|
||||||
|
|
||||||
const artificialDelay = 15 * time.Millisecond
|
const artificialDelay = 250 * time.Millisecond
|
||||||
|
|
||||||
func optsFactory(storage storage.Storage, maxInflight, inflightQueries *atomic.Int32, maxConcurrent int64) *ManagerOptions {
|
func optsFactory(storage storage.Storage, maxInflight, inflightQueries *atomic.Int32, maxConcurrent int64) *ManagerOptions {
|
||||||
var inflightMu sync.Mutex
|
var inflightMu sync.Mutex
|
||||||
|
|
Loading…
Reference in a new issue