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

Function TestHashCollisionHandling

integration/querier_test.go:646–729  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

644}
645
646func TestHashCollisionHandling(t *testing.T) {
647 s, err := e2e.NewScenario(networkName)
648 require.NoError(t, err)
649 defer s.Close()
650
651 flags := BlocksStorageFlags()
652
653 // Start dependencies.
654 minio := e2edb.NewMinio(9000, bucketName)
655
656 consul := e2edb.NewConsul()
657 require.NoError(t, s.StartAndWaitReady(consul, minio))
658
659 // Start Cortex components for the write path.
660 distributor := e2ecortex.NewDistributor("distributor", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), flags, "")
661 ingester := e2ecortex.NewIngester("ingester", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), flags, "")
662 require.NoError(t, s.StartAndWaitReady(distributor, ingester))
663
664 // Wait until the distributor has updated the ring.
665 require.NoError(t, distributor.WaitSumMetrics(e2e.Equals(512), "cortex_ring_tokens_total"))
666
667 // Push a series for each user to Cortex.
668 now := time.Now()
669
670 c, err := e2ecortex.NewClient(distributor.HTTPEndpoint(), "", "", "", "user-0")
671 require.NoError(t, err)
672
673 var series []prompb.TimeSeries
674 var expectedVector model.Vector
675 // Generate two series which collide on fingerprints and fast fingerprints.
676 tsMillis := e2e.TimeToMilliseconds(now)
677 metric1 := []prompb.Label{
678 {Name: "A", Value: "K6sjsNNczPl"},
679 {Name: labels.MetricName, Value: "fingerprint_collision"},
680 }
681 metric2 := []prompb.Label{
682 {Name: "A", Value: "cswpLMIZpwt"},
683 {Name: labels.MetricName, Value: "fingerprint_collision"},
684 }
685
686 series = append(series, prompb.TimeSeries{
687 Labels: metric1,
688 Samples: []prompb.Sample{
689 {Value: float64(0), Timestamp: tsMillis},
690 },
691 })
692 expectedVector = append(expectedVector, &model.Sample{
693 Metric: prompbLabelsToModelMetric(metric1),
694 Value: model.SampleValue(float64(0)),
695 Timestamp: model.Time(tsMillis),
696 })
697 series = append(series, prompb.TimeSeries{
698 Labels: metric2,
699 Samples: []prompb.Sample{
700 {Value: float64(1), Timestamp: tsMillis},
701 },
702 })
703 expectedVector = append(expectedVector, &model.Sample{

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
StartAndWaitReadyMethod · 0.95
PushMethod · 0.95
QueryMethod · 0.95
NewScenarioFunction · 0.92
NewDistributorFunction · 0.92
NewIngesterFunction · 0.92
EqualsFunction · 0.92
NewClientFunction · 0.92
TimeToMillisecondsFunction · 0.92
NewStoreGatewayFunction · 0.92
NewQuerierFunction · 0.92

Tested by

no test coverage detected