diff --git a/rules/manager_test.go b/rules/manager_test.go index 11d1282bd..d31bfc07a 100644 --- a/rules/manager_test.go +++ b/rules/manager_test.go @@ -1910,18 +1910,12 @@ func TestDependencyMapUpdatesOnGroupUpdate(t *testing.T) { } func TestAsyncRuleEvaluation(t *testing.T) { - storage := teststorage.New(t) - t.Cleanup(func() { storage.Close() }) - - var ( - inflightQueries atomic.Int32 - maxInflight atomic.Int32 - ) - t.Run("synchronous evaluation with independent rules", func(t *testing.T) { - // Reset. - inflightQueries.Store(0) - maxInflight.Store(0) + t.Parallel() + storage := teststorage.New(t) + t.Cleanup(func() { storage.Close() }) + inflightQueries := atomic.Int32{} + maxInflight := atomic.Int32{} ctx, cancel := context.WithCancel(context.Background()) 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) { - // Reset. - inflightQueries.Store(0) - maxInflight.Store(0) + t.Parallel() + storage := teststorage.New(t) + t.Cleanup(func() { storage.Close() }) + inflightQueries := atomic.Int32{} + maxInflight := atomic.Int32{} ctx, cancel := context.WithCancel(context.Background()) 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) { - // Reset. - inflightQueries.Store(0) - maxInflight.Store(0) + t.Parallel() + storage := teststorage.New(t) + t.Cleanup(func() { storage.Close() }) + inflightQueries := atomic.Int32{} + maxInflight := atomic.Int32{} ctx, cancel := context.WithCancel(context.Background()) 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) { - // Reset. - inflightQueries.Store(0) - maxInflight.Store(0) + t.Parallel() + storage := teststorage.New(t) + t.Cleanup(func() { storage.Close() }) + inflightQueries := atomic.Int32{} + maxInflight := atomic.Int32{} ctx, cancel := context.WithCancel(context.Background()) t.Cleanup(cancel) @@ -2098,7 +2098,7 @@ func TestBoundedRuleEvalConcurrency(t *testing.T) { 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 { var inflightMu sync.Mutex