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

Function TestPrometheusCompatibilityQueryFuzz

integration/query_fuzz_test.go:1604–1702  ·  view source on GitHub ↗

TestPrometheusCompatibilityQueryFuzz compares Cortex with latest Prometheus release.

(t *testing.T)

Source from the content-addressed store, hash-verified

1602
1603// TestPrometheusCompatibilityQueryFuzz compares Cortex with latest Prometheus release.
1604func TestPrometheusCompatibilityQueryFuzz(t *testing.T) {
1605 s, err := e2e.NewScenario(networkName)
1606 require.NoError(t, err)
1607 defer s.Close()
1608
1609 // Start dependencies.
1610 consul := e2edb.NewConsulWithName("consul")
1611 require.NoError(t, s.StartAndWaitReady(consul))
1612
1613 baseFlags := mergeFlags(AlertmanagerLocalFlags(), BlocksStorageFlags())
1614 flags := mergeFlags(
1615 baseFlags,
1616 map[string]string{
1617 "-blocks-storage.tsdb.head-compaction-interval": "4m",
1618 "-blocks-storage.tsdb.block-ranges-period": "2h",
1619 "-blocks-storage.tsdb.ship-interval": "1h",
1620 "-blocks-storage.bucket-store.sync-interval": "1s",
1621 "-blocks-storage.tsdb.retention-period": "24h",
1622 "-blocks-storage.bucket-store.index-cache.backend": tsdb.IndexCacheBackendInMemory,
1623 // Ingester.
1624 "-ring.store": "consul",
1625 "-consul.hostname": consul.NetworkHTTPEndpoint(),
1626 // Distributor.
1627 "-distributor.replication-factor": "1",
1628 // Store-gateway.
1629 "-store-gateway.sharding-enabled": "false",
1630 // alert manager
1631 "-alertmanager.web.external-url": "http://localhost/alertmanager",
1632 "-frontend.query-vertical-shard-size": "2",
1633 "-frontend.max-cache-freshness": "1m",
1634 // Compactor.
1635 "-compactor.cleanup-interval": "1s",
1636 },
1637 )
1638 // make alert manager config dir
1639 require.NoError(t, writeFileToSharedDir(s, "alertmanager_configs", []byte{}))
1640
1641 minio := e2edb.NewMinio(9000, flags["-blocks-storage.s3.bucket-name"])
1642 require.NoError(t, s.StartAndWaitReady(minio))
1643
1644 cortex := e2ecortex.NewSingleBinary("cortex", flags, "")
1645 require.NoError(t, s.StartAndWaitReady(cortex))
1646
1647 // Wait until Cortex replicas have updated the ring state.
1648 require.NoError(t, cortex.WaitSumMetrics(e2e.Equals(float64(512)), "cortex_ring_tokens_total"))
1649
1650 now := time.Now()
1651 start := now.Add(-time.Hour * 2)
1652 end := now.Add(-time.Hour)
1653 numSeries := 10
1654 numSamples := 60
1655 lbls := make([]labels.Labels, 0, numSeries*2)
1656 scrapeInterval := time.Minute
1657 statusCodes := []string{"200", "400", "404", "500", "502"}
1658 for i := 0; i < numSeries; i++ {
1659 lbls = append(lbls, labels.FromStrings(labels.MetricName, "test_series_a", "job", "test", "series", strconv.Itoa(i%3), "status_code", statusCodes[i%5]))
1660 lbls = append(lbls, labels.FromStrings(labels.MetricName, "test_series_b", "job", "test", "series", strconv.Itoa((i+1)%3), "status_code", statusCodes[(i+1)%5]))
1661 }

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
StartAndWaitReadyMethod · 0.95
SharedDirMethod · 0.95
NewScenarioFunction · 0.92
NewSingleBinaryFunction · 0.92
EqualsFunction · 0.92
NewS3ClientForMinioFunction · 0.92
NewUserBucketClientFunction · 0.92
CreateBlockFunction · 0.92
WithLabelMatchersFunction · 0.92
NewClientFunction · 0.92
NewPromQueryClientFunction · 0.92

Tested by

no test coverage detected