@@ -356,66 +356,25 @@ func setAllSecrets(v reflect.Value, sentinel string) {
356356
357357func TestCortexFeatures (t * testing.T ) {
358358 tests := []struct {
359- name string
360- configFn func (* Config )
361- expectedFeatures []string
359+ name string
360+ configFn func (* Config )
361+ experimentalExpected bool
362+ queryStatsExpected bool
362363 }{
363364 {
364- name : "no features enabled" ,
365- configFn : func (cfg * Config ) {},
366- expectedFeatures : nil ,
365+ name : "default features" ,
366+ configFn : func (cfg * Config ) {},
367+ experimentalExpected : false ,
368+ queryStatsExpected : false ,
367369 },
368370 {
369- name : "remote_write_v2 enabled" ,
370- configFn : func (cfg * Config ) {
371- cfg .Distributor .RemoteWriteV2Enabled = true
372- },
373- expectedFeatures : []string {"remote_write_v2" },
374- },
375- {
376- name : "streaming_ingestion enabled" ,
377- configFn : func (cfg * Config ) {
378- cfg .Distributor .UseStreamPush = true
379- },
380- expectedFeatures : []string {"streaming_ingestion" },
381- },
382- {
383- name : "parquet_queryable enabled" ,
384- configFn : func (cfg * Config ) {
385- cfg .Querier .EnableParquetQueryable = true
386- },
387- expectedFeatures : []string {"parquet_queryable" },
388- },
389- {
390- name : "tenant_federation enabled" ,
391- configFn : func (cfg * Config ) {
392- cfg .TenantFederation .Enabled = true
393- },
394- expectedFeatures : []string {"tenant_federation" },
395- },
396- {
397- name : "distributed_execution enabled" ,
398- configFn : func (cfg * Config ) {
399- cfg .Querier .DistributedExecEnabled = true
400- },
401- expectedFeatures : []string {"distributed_execution" },
402- },
403- {
404- name : "promql_experimental_functions enabled" ,
371+ name : "experimental functions and query stats enabled" ,
405372 configFn : func (cfg * Config ) {
406373 cfg .Querier .EnablePromQLExperimentalFunctions = true
374+ cfg .Querier .EnablePerStepStats = true
407375 },
408- expectedFeatures : []string {"promql_experimental_functions" },
409- },
410- {
411- name : "multiple features enabled" ,
412- configFn : func (cfg * Config ) {
413- cfg .Distributor .RemoteWriteV2Enabled = true
414- cfg .Distributor .UseStreamPush = true
415- cfg .TenantFederation .Enabled = true
416- cfg .Querier .EnableParquetQueryable = true
417- },
418- expectedFeatures : []string {"remote_write_v2" , "streaming_ingestion" , "parquet_queryable" , "tenant_federation" },
376+ experimentalExpected : true ,
377+ queryStatsExpected : true ,
419378 },
420379 }
421380
@@ -424,7 +383,27 @@ func TestCortexFeatures(t *testing.T) {
424383 cfg := Config {}
425384 tc .configFn (& cfg )
426385 features := cortexFeatures (cfg )
427- assert .Equal (t , tc .expectedFeatures , features )
386+
387+ // Check API category
388+ require .Contains (t , features , "api" )
389+ assert .Equal (t , tc .queryStatsExpected , features ["api" ]["query_stats" ])
390+ assert .True (t , features ["api" ]["label_values_match" ])
391+
392+ // Check PromQL category
393+ require .Contains (t , features , "promql" )
394+ assert .Equal (t , tc .queryStatsExpected , features ["promql" ]["per_step_stats" ])
395+ assert .True (t , features ["promql" ]["subqueries" ])
396+
397+ // Check PromQL Operators
398+ require .Contains (t , features , "promql_operators" )
399+ assert .True (t , features ["promql_operators" ]["+" ])
400+ assert .False (t , features ["promql_operators" ]["limitk" ])
401+
402+ // Check PromQL Functions
403+ require .Contains (t , features , "promql_functions" )
404+ assert .True (t , features ["promql_functions" ]["abs" ])
405+ assert .Equal (t , tc .experimentalExpected , features ["promql_functions" ]["info" ])
428406 })
429407 }
430408}
409+
0 commit comments