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

Function TestRulerMetricsForInvalidQueries

integration/ruler_test.go:1106–1240  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1104}
1105
1106func TestRulerMetricsForInvalidQueries(t *testing.T) {
1107 s, err := e2e.NewScenario(networkName)
1108 require.NoError(t, err)
1109 defer s.Close()
1110
1111 // Start dependencies.
1112 consul := e2edb.NewConsul()
1113 minio := e2edb.NewMinio(9000, bucketName, rulestoreBucketName)
1114 require.NoError(t, s.StartAndWaitReady(consul, minio))
1115
1116 // Configure the ruler.
1117 flags := mergeFlags(
1118 BlocksStorageFlags(),
1119 RulerFlags(),
1120 map[string]string{
1121 // Since we're not going to run any rule (our only rule is invalid), we don't need the
1122 // store-gateway to be configured to a valid address.
1123 "-querier.store-gateway-addresses": "localhost:12345",
1124 // Enable the bucket index so we can skip the initial bucket scan.
1125 "-blocks-storage.bucket-store.bucket-index.enabled": "true",
1126 // Evaluate rules often, so that we don't need to wait for metrics to show up.
1127 "-ruler.evaluation-interval": "2s",
1128 "-ruler.poll-interval": "2s",
1129 // No delay
1130 "-ruler.evaluation-delay-duration": "0",
1131
1132 "-blocks-storage.tsdb.block-ranges-period": "1h",
1133 "-blocks-storage.bucket-store.sync-interval": "1s",
1134 "-blocks-storage.tsdb.retention-period": "2h",
1135
1136 // We run single ingester only, no replication.
1137 "-distributor.replication-factor": "1",
1138
1139 // Very low limit so that ruler hits it.
1140 "-querier.max-fetched-chunks-per-query": "5",
1141 },
1142 )
1143
1144 const namespace = "test"
1145 const user = "user"
1146
1147 distributor := e2ecortex.NewDistributor("distributor", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), flags, "")
1148 ruler := e2ecortex.NewRuler("ruler", consul.NetworkHTTPEndpoint(), flags, "")
1149 ingester := e2ecortex.NewIngester("ingester", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), flags, "")
1150 require.NoError(t, s.StartAndWaitReady(distributor, ingester, ruler))
1151
1152 // Wait until both the distributor and ruler have updated the ring. The querier will also watch
1153 // the store-gateway ring if blocks sharding is enabled.
1154 require.NoError(t, distributor.WaitSumMetrics(e2e.Equals(512), "cortex_ring_tokens_total"))
1155 require.NoError(t, ruler.WaitSumMetrics(e2e.Equals(512), "cortex_ring_tokens_total"))
1156
1157 c, err := e2ecortex.NewClient(distributor.HTTPEndpoint(), "", "", ruler.HTTPEndpoint(), user)
1158 require.NoError(t, err)
1159
1160 // Push some series to Cortex -- enough so that we can hit some limits.
1161 for i := 0; i < 10; i++ {
1162 series, _ := generateSeries("metric", time.Now(), prompb.Label{Name: "foo", Value: fmt.Sprintf("%d", i)})
1163

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
StartAndWaitReadyMethod · 0.95
PushMethod · 0.95
SetRuleGroupMethod · 0.95
DeleteRuleGroupMethod · 0.95
StopMethod · 0.95
NewScenarioFunction · 0.92
NewDistributorFunction · 0.92
NewRulerFunction · 0.92
NewIngesterFunction · 0.92
EqualsFunction · 0.92
NewClientFunction · 0.92

Tested by

no test coverage detected