From 80e4d6ba85be6d616cd3468c403a9c45c3b280b7 Mon Sep 17 00:00:00 2001 From: Nick Pillitteri <56quarters@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:20:26 -0500 Subject: [PATCH] Use test logger in Ruler API tests (#10296) Extra information to debug #10294 Signed-off-by: Nick Pillitteri --- pkg/ruler/api_test.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pkg/ruler/api_test.go b/pkg/ruler/api_test.go index ed47be1dd66..e911b19e6d7 100644 --- a/pkg/ruler/api_test.go +++ b/pkg/ruler/api_test.go @@ -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" ) @@ -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() @@ -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() @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 @@ -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 @@ -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 @@ -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)