Skip to content

Commit

Permalink
Use test logger in Ruler API tests (#10296)
Browse files Browse the repository at this point in the history
Extra information to debug #10294

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
  • Loading branch information
56quarters authored Dec 20, 2024
1 parent 79c32ab commit 80e4d6b
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions pkg/ruler/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"gopkg.in/yaml.v3"

"github.com/grafana/mimir/pkg/ruler/rulespb"
mimirtest "github.com/grafana/mimir/pkg/util/test"
"github.com/grafana/mimir/pkg/util/validation"
)

Expand Down Expand Up @@ -1123,7 +1124,7 @@ func TestRuler_PrometheusRules(t *testing.T) {
return len(rls.Groups)
})

a := NewAPI(r, r.store, log.NewNopLogger())
a := NewAPI(r, r.store, mimirtest.NewTestingLogger(t))

req := requestFor(t, http.MethodGet, "https://localhost:8080/prometheus/api/v1/rules"+tc.queryParams, nil, userID)
w := httptest.NewRecorder()
Expand Down Expand Up @@ -1180,7 +1181,7 @@ func TestRuler_PrometheusAlerts(t *testing.T) {
return len(rls.Groups)
})

a := NewAPI(r, r.store, log.NewNopLogger())
a := NewAPI(r, r.store, mimirtest.NewTestingLogger(t))

req := requestFor(t, http.MethodGet, "https://localhost:8080/prometheus/api/v1/alerts", nil, "user1")
w := httptest.NewRecorder()
Expand Down Expand Up @@ -1359,7 +1360,7 @@ rules:

reg := prometheus.NewPedanticRegistry()
r := prepareRuler(t, rulerCfg, newMockRuleStore(make(map[string]rulespb.RuleGroupList)), withStart(), withRulerAddrAutomaticMapping(), withPrometheusRegisterer(reg))
a := NewAPI(r, r.store, log.NewNopLogger())
a := NewAPI(r, r.store, mimirtest.NewTestingLogger(t))

router := mux.NewRouter()
router.Path("/prometheus/config/v1/rules/{namespace}").Methods("POST").HandlerFunc(a.CreateRuleGroup)
Expand Down Expand Up @@ -1429,7 +1430,7 @@ rules:
defaults.RulerMaxRuleGroupsPerTenant = 2
defaults.RulerMaxRulesPerRuleGroup = 2
})))
a := NewAPI(r, r.store, log.NewNopLogger())
a := NewAPI(r, r.store, mimirtest.NewTestingLogger(t))

router := mux.NewRouter()
router.Path("/prometheus/config/v1/rules/{namespace}/{groupName}").Methods(http.MethodGet).HandlerFunc(a.GetRuleGroup)
Expand Down Expand Up @@ -1510,7 +1511,7 @@ func TestAPI_DeleteNamespace(t *testing.T) {

reg := prometheus.NewPedanticRegistry()
r := prepareRuler(t, cfg, newMockRuleStore(mockRulesNamespaces), withStart(), withRulerAddrAutomaticMapping(), withPrometheusRegisterer(reg))
a := NewAPI(r, r.store, log.NewNopLogger())
a := NewAPI(r, r.store, mimirtest.NewTestingLogger(t))

router := mux.NewRouter()
router.Path("/prometheus/config/v1/rules/{namespace}").Methods(http.MethodDelete).HandlerFunc(a.DeleteNamespace)
Expand Down Expand Up @@ -1567,7 +1568,7 @@ func TestAPI_DeleteRuleGroup(t *testing.T) {

reg := prometheus.NewPedanticRegistry()
r := prepareRuler(t, cfg, newMockRuleStore(mockRulesNamespaces), withStart(), withRulerAddrAutomaticMapping(), withPrometheusRegisterer(reg))
a := NewAPI(r, r.store, log.NewNopLogger())
a := NewAPI(r, r.store, mimirtest.NewTestingLogger(t))

router := mux.NewRouter()
router.Path("/prometheus/config/v1/rules/{namespace}/{groupName}").Methods(http.MethodDelete).HandlerFunc(a.DeleteRuleGroup)
Expand Down Expand Up @@ -1609,7 +1610,7 @@ func TestRuler_LimitsPerGroup(t *testing.T) {
defaults.RulerMaxRulesPerRuleGroup = 1
})))

a := NewAPI(r, r.store, log.NewNopLogger())
a := NewAPI(r, r.store, mimirtest.NewTestingLogger(t))

tc := []struct {
name string
Expand Down Expand Up @@ -1662,7 +1663,7 @@ func TestRuler_RulerGroupLimits(t *testing.T) {
defaults.RulerMaxRulesPerRuleGroup = 1
})))

a := NewAPI(r, r.store, log.NewNopLogger())
a := NewAPI(r, r.store, mimirtest.NewTestingLogger(t))

tc := []struct {
name string
Expand Down Expand Up @@ -1722,7 +1723,7 @@ func TestRuler_RulerGroupLimitsDisabled(t *testing.T) {
defaults.RulerMaxRulesPerRuleGroup = 0
})))

a := NewAPI(r, r.store, log.NewNopLogger())
a := NewAPI(r, r.store, mimirtest.NewTestingLogger(t))

tc := []struct {
name string
Expand Down Expand Up @@ -1823,7 +1824,7 @@ func TestAPIRoutesCorrectlyHandleInvalidTenantID(t *testing.T) {
cfg.TenantFederation.Enabled = true

r := prepareRuler(t, cfg, newMockRuleStore(map[string]rulespb.RuleGroupList{}), withStart())
a := NewAPI(r, r.store, log.NewNopLogger())
a := NewAPI(r, r.store, mimirtest.NewTestingLogger(t))

router := mux.NewRouter()
router.Path("/api/v1/rules").Methods(http.MethodGet).HandlerFunc(a.PrometheusRules)
Expand Down

0 comments on commit 80e4d6b

Please sign in to comment.