MCPcopy Index your code
hub / github.com/cortexproject/cortex / newTestRuler

Function newTestRuler

pkg/ruler/ruler_test.go:366–387  ·  view source on GitHub ↗
(t *testing.T, rulerConfig Config, store rulestore.RuleStore, querierTestConfig *querier.TestConfig)

Source from the content-addressed store, hash-verified

364}
365
366func newTestRuler(t *testing.T, rulerConfig Config, store rulestore.RuleStore, querierTestConfig *querier.TestConfig) *Ruler {
367 ruler, _ := buildRuler(t, rulerConfig, querierTestConfig, store, nil)
368 require.NoError(t, services.StartAndAwaitRunning(context.Background(), ruler))
369 rgs, err := store.ListAllRuleGroups(context.Background())
370 require.NoError(t, err)
371
372 // Wait to ensure syncRules has finished and all rules are loaded before usage
373 deadline := time.Now().Add(3 * time.Second)
374 for {
375 loaded := true
376 for tenantId := range rgs {
377 if len(ruler.manager.GetRules(tenantId)) == 0 {
378 loaded = false
379 }
380 }
381 if time.Now().After(deadline) || loaded {
382 break
383 }
384 time.Sleep(50 * time.Millisecond)
385 }
386 return ruler
387}
388
389var _ MultiTenantManager = &DefaultMultiTenantManager{}
390

Callers 13

TestRuler_TestShutdownFunction · 0.85
TestRuler_RulesFunction · 0.85
TestRuler_ListAllRulesFunction · 0.85
TestRuler_QueryOffsetFunction · 0.85
TestRuler_rulesFunction · 0.85
TestRuler_rules_limitFunction · 0.85
TestRuler_alertsFunction · 0.85
TestRuler_CreateFunction · 0.85
TestRuler_LimitsPerGroupFunction · 0.85

Calls 6

StartAndAwaitRunningFunction · 0.92
buildRulerFunction · 0.85
AfterMethod · 0.80
ListAllRuleGroupsMethod · 0.65
GetRulesMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected