@@ -12,7 +12,6 @@ import (
1212 "net/http"
1313 "os"
1414 "path/filepath"
15- "strconv"
1615 "sync"
1716 "testing"
1817 "time"
@@ -37,7 +36,6 @@ import (
3736type queryFrontendTestConfig struct {
3837 testMissingMetricName bool
3938 querySchedulerEnabled bool
40- queryStatsEnabled bool
4139 remoteReadEnabled bool
4240 testSubQueryStepSize bool
4341 setup func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string )
@@ -60,7 +58,6 @@ func TestQueryFrontendWithBlocksStorageViaFlags(t *testing.T) {
6058func TestQueryFrontendWithBlocksStorageViaFlagsAndQueryStatsEnabled (t * testing.T ) {
6159 runQueryFrontendTest (t , queryFrontendTestConfig {
6260 testMissingMetricName : false ,
63- queryStatsEnabled : true ,
6461 setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
6562 flags = BlocksStorageFlags ()
6663
@@ -91,7 +88,6 @@ func TestQueryFrontendWithBlocksStorageViaFlagsAndWithQuerySchedulerAndQueryStat
9188 runQueryFrontendTest (t , queryFrontendTestConfig {
9289 testMissingMetricName : false ,
9390 querySchedulerEnabled : true ,
94- queryStatsEnabled : true ,
9591 setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
9692 flags = BlocksStorageFlags ()
9793
@@ -167,7 +163,6 @@ func TestQueryFrontendWithVerticalSharding(t *testing.T) {
167163 runQueryFrontendTest (t , queryFrontendTestConfig {
168164 testMissingMetricName : false ,
169165 querySchedulerEnabled : false ,
170- queryStatsEnabled : true ,
171166 setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
172167 require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
173168
@@ -187,7 +182,6 @@ func TestQueryFrontendWithVerticalShardingQueryScheduler(t *testing.T) {
187182 runQueryFrontendTest (t , queryFrontendTestConfig {
188183 testMissingMetricName : false ,
189184 querySchedulerEnabled : true ,
190- queryStatsEnabled : true ,
191185 setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
192186 require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
193187
@@ -207,7 +201,6 @@ func TestQueryFrontendProtobufCodec(t *testing.T) {
207201 runQueryFrontendTest (t , queryFrontendTestConfig {
208202 testMissingMetricName : false ,
209203 querySchedulerEnabled : true ,
210- queryStatsEnabled : true ,
211204 setup : func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string ) {
212205 require .NoError (t , writeFileToSharedDir (s , cortexConfigFile , []byte (BlocksStorageConfig )))
213206
@@ -273,7 +266,7 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
273266 "-querier.split-queries-by-interval" : "24h" ,
274267 "-querier.query-ingesters-within" : "12h" , // Required by the test on query /series out of ingesters time range
275268 "-frontend.memcached.addresses" : "dns+" + memcached .NetworkEndpoint (e2ecache .MemcachedPort ),
276- "-frontend.query-stats-enabled" : strconv . FormatBool ( cfg . queryStatsEnabled ),
269+ "-frontend.query-stats-enabled" : "true" , // Always enable query stats to capture regressions
277270 })
278271
279272 // Start the query-scheduler if enabled.
@@ -361,7 +354,7 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
361354 }
362355
363356 // No need to repeat the test on Server-Timing header for each user.
364- if userID == 0 && cfg . queryStatsEnabled {
357+ if userID == 0 {
365358 res , _ , err := c .QueryRaw ("{instance=~\" hello.*\" }" , time .Now (), map [string ]string {})
366359 require .NoError (t , err )
367360 require .Regexp (t , "querier_wall_time;dur=[0-9.]*, response_time;dur=[0-9.]*$" , res .Header .Values ("Server-Timing" )[0 ])
@@ -412,15 +405,11 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
412405
413406 wg .Wait ()
414407
415- extra := float64 (2 )
408+ extra := float64 (3 ) // Always include query stats test
416409 if cfg .testMissingMetricName {
417410 extra ++
418411 }
419412
420- if cfg .queryStatsEnabled {
421- extra ++
422- }
423-
424413 if cfg .remoteReadEnabled {
425414 extra ++
426415 }
@@ -437,15 +426,11 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
437426 require .NoError (t , querier .WaitSumMetricsWithOptions (e2e .Greater (numUsers * numQueriesPerUser ), []string {"cortex_request_duration_seconds" }, e2e .WithMetricCount ))
438427 require .NoError (t , querier .WaitSumMetricsWithOptions (e2e .Greater (numUsers * numQueriesPerUser ), []string {"cortex_querier_request_duration_seconds" }, e2e .WithMetricCount ))
439428
440- // Ensure query stats metrics are tracked only when enabled.
441- if cfg .queryStatsEnabled {
442- require .NoError (t , queryFrontend .WaitSumMetricsWithOptions (
443- e2e .Greater (0 ),
444- []string {"cortex_query_seconds_total" },
445- e2e .WithLabelMatchers (labels .MustNewMatcher (labels .MatchEqual , "user" , "user-1" ))))
446- } else {
447- require .NoError (t , queryFrontend .WaitRemovedMetric ("cortex_query_seconds_total" ))
448- }
429+ // Ensure query stats metrics are always tracked to capture regressions.
430+ require .NoError (t , queryFrontend .WaitSumMetricsWithOptions (
431+ e2e .Greater (0 ),
432+ []string {"cortex_query_seconds_total" },
433+ e2e .WithLabelMatchers (labels .MustNewMatcher (labels .MatchEqual , "user" , "user-1" ))))
449434
450435 // Ensure no service-specific metrics prefix is used by the wrong service.
451436 assertServiceMetricsPrefixes (t , Distributor , distributor )
0 commit comments