MCPcopy Index your code
hub / github.com/cortexproject/cortex / TestQueryFrontendQueryRejection

Function TestQueryFrontendQueryRejection

integration/query_frontend_test.go:622–870  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

620}
621
622func TestQueryFrontendQueryRejection(t *testing.T) {
623 configFileName := "runtime-config.yaml"
624
625 s, err := e2e.NewScenario(networkName)
626 require.NoError(t, err)
627 defer s.Close()
628
629 // Start dependencies.
630 consul := e2edb.NewConsul()
631 minio := e2edb.NewMinio(9000, bucketName, rulestoreBucketName)
632 require.NoError(t, s.StartAndWaitReady(consul, minio))
633
634 // Configure the blocks storage to frequently compact TSDB head
635 // and ship blocks to the storage.
636 flags := mergeFlags(BlocksStorageFlags(), map[string]string{
637 "-runtime-config.backend": "s3",
638 "-runtime-config.s3.access-key-id": e2edb.MinioAccessKey,
639 "-runtime-config.s3.secret-access-key": e2edb.MinioSecretKey,
640 "-runtime-config.s3.bucket-name": bucketName,
641 "-runtime-config.s3.endpoint": fmt.Sprintf("%s-minio-9000:9000", networkName),
642 "-runtime-config.s3.insecure": "true",
643 "-runtime-config.file": configFileName,
644 "-runtime-config.reload-period": "1s",
645 })
646
647 client, err := s3.NewBucketWithConfig(nil, s3.Config{
648 Endpoint: minio.HTTPEndpoint(),
649 Insecure: true,
650 Bucket: bucketName,
651 AccessKey: e2edb.MinioAccessKey,
652 SecretKey: e2edb.MinioSecretKey,
653 }, "runtime-config-test", nil)
654
655 require.NoError(t, err)
656
657 // update runtime config
658 newRuntimeConfig := []byte(`overrides:
659 user-1:
660 query_rejection:
661 enabled: true
662 query_attributes:
663 - api_type: "query"
664 regex: .*rate.*
665 query_step_limit:
666 min: 6s
667 max: 20m
668 dashboard_uid: "dash123"
669`)
670 require.NoError(t, client.Upload(context.Background(), configFileName, bytes.NewReader(newRuntimeConfig)))
671 time.Sleep(2 * time.Second)
672
673 queryFrontend := e2ecortex.NewQueryFrontendWithConfigFile("query-frontend", "", flags, "")
674 require.NoError(t, s.Start(queryFrontend))
675
676 flags["-querier.frontend-address"] = queryFrontend.NetworkGRPCEndpoint()
677
678 // Start all other services.
679 ingester := e2ecortex.NewIngesterWithConfigFile("ingester", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), "", flags, "")

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
StartAndWaitReadyMethod · 0.95
StartMethod · 0.95
WaitReadyMethod · 0.95
QueryRawMethod · 0.95
QueryRangeRawMethod · 0.95
SeriesRawMethod · 0.95
LabelNamesRawMethod · 0.95
LabelValuesRawMethod · 0.95
NewScenarioFunction · 0.92

Tested by

no test coverage detected