From 636224f6cda5507a52b6db621de215e54a6db3fd Mon Sep 17 00:00:00 2001 From: Julien Duchesne Date: Fri, 13 Dec 2024 12:42:16 -0500 Subject: [PATCH] Linting --- pkg/ruler/rule_concurrency_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/ruler/rule_concurrency_test.go b/pkg/ruler/rule_concurrency_test.go index 2bebb782db..64be33715c 100644 --- a/pkg/ruler/rule_concurrency_test.go +++ b/pkg/ruler/rule_concurrency_test.go @@ -270,6 +270,8 @@ func TestGroupAtRisk(t *testing.T) { createAndEvalTestGroup := func(interval time.Duration, evalConcurrently bool) *rules.Group { st := teststorage.New(t) defer st.Close() + + // Create 100 rules that all take 1ms to evaluate. var createdRules []rules.Rule ruleCt := 100 ruleWaitTime := 1 * time.Millisecond @@ -282,11 +284,12 @@ func TestGroupAtRisk(t *testing.T) { createdRules = append(createdRules, rule) } + // Create the group and evaluate it opts := rules.GroupOptions{ Interval: interval, Opts: &rules.ManagerOptions{ Appendable: st, - QueryFunc: func(ctx context.Context, q string, t time.Time) (promql.Vector, error) { + QueryFunc: func(_ context.Context, _ string, _ time.Time) (promql.Vector, error) { time.Sleep(ruleWaitTime) return promql.Vector{}, nil }, @@ -299,8 +302,9 @@ func TestGroupAtRisk(t *testing.T) { g := rules.NewGroup(opts) rules.DefaultEvalIterationFunc(context.Background(), g, time.Now()) + // Sanity check that we're actually running the rules concurrently. + // The group should take less time than the sum of all rules if we're running them concurrently, more otherwise. if evalConcurrently { - // Sanity check that we're actually running the rules concurrently. require.Less(t, g.GetEvaluationTime(), time.Duration(ruleCt)*ruleWaitTime) } else { require.Greater(t, g.GetEvaluationTime(), time.Duration(ruleCt)*ruleWaitTime)