MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestRuler_QueryOffset

Function TestRuler_QueryOffset

pkg/ruler/ruler_test.go:3106–3136  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3104}
3105
3106func TestRuler_QueryOffset(t *testing.T) {
3107 store := newMockRuleStore(mockRulesQueryOffset, nil)
3108 cfg := defaultRulerConfig(t)
3109
3110 r := newTestRuler(t, cfg, store, nil)
3111 defer services.StopAndAwaitTerminated(context.Background(), r) //nolint:errcheck
3112
3113 ctx := user.InjectOrgID(context.Background(), "user1")
3114 rls, err := r.Rules(ctx, &RulesRequest{MaxRuleGroups: -1})
3115 require.NoError(t, err)
3116 require.Len(t, rls.Groups, 1)
3117 rg := rls.Groups[0]
3118 expectedRg := mockRulesQueryOffset["user1"][0]
3119 compareRuleGroupDescToStateDesc(t, expectedRg, rg)
3120
3121 // test default query offset=0 when not defined at group level
3122 gotOffset := rg.GetGroup().QueryOffset
3123 require.Equal(t, time.Duration(0), *gotOffset)
3124
3125 ctx = user.InjectOrgID(context.Background(), "user2")
3126 rls, err = r.Rules(ctx, &RulesRequest{MaxRuleGroups: -1})
3127 require.NoError(t, err)
3128 require.Len(t, rls.Groups, 1)
3129 rg = rls.Groups[0]
3130 expectedRg = mockRules["user2"][0]
3131 compareRuleGroupDescToStateDesc(t, expectedRg, rg)
3132
3133 // test group query offset is set
3134 gotOffset = rg.GetGroup().QueryOffset
3135 require.Equal(t, time.Minute*2, *gotOffset)
3136}
3137
3138func TestGetShardSizeForUser(t *testing.T) {
3139 tests := []struct {

Callers

nothing calls this directly

Calls 9

StopAndAwaitTerminatedFunction · 0.92
newMockRuleStoreFunction · 0.85
defaultRulerConfigFunction · 0.85
newTestRulerFunction · 0.85
GetGroupMethod · 0.80
RulesMethod · 0.65
EqualMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected