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

Function TestQuerierRemoteRead

integration/querier_remote_read_test.go:28–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestQuerierRemoteRead(t *testing.T) {
29 for _, thanosEngine := range []bool{false, true} {
30 t.Run(fmt.Sprintf("thanosEngine=%t", thanosEngine), func(t *testing.T) {
31 s, err := e2e.NewScenario(networkName)
32 require.NoError(t, err)
33 defer s.Close()
34
35 flags := mergeFlags(BlocksStorageFlags(), map[string]string{
36 "-querier.thanos-engine": strconv.FormatBool(thanosEngine),
37 })
38
39 // Start dependencies.
40 minio := e2edb.NewMinio(9000, bucketName)
41 consul := e2edb.NewConsul()
42 require.NoError(t, s.StartAndWaitReady(consul, minio))
43
44 // Start Cortex components for the write path.
45 distributor := e2ecortex.NewDistributor("distributor", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), flags, "")
46 ingester := e2ecortex.NewIngester("ingester", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), flags, "")
47 require.NoError(t, s.StartAndWaitReady(distributor, ingester))
48
49 // Wait until the distributor has updated the ring.
50 require.NoError(t, distributor.WaitSumMetrics(e2e.Equals(512), "cortex_ring_tokens_total"))
51
52 // Push a series for each user to Cortex.
53 now := time.Now()
54
55 c, err := e2ecortex.NewClient(distributor.HTTPEndpoint(), "", "", "", "user-1")
56 require.NoError(t, err)
57
58 series, expectedVectors := generateSeries("series_1", now)
59 res, err := c.Push(series)
60 require.NoError(t, err)
61 require.Equal(t, 200, res.StatusCode)
62
63 storeGateway := e2ecortex.NewStoreGateway("store-gateway", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), flags, "")
64 require.NoError(t, s.StartAndWaitReady(storeGateway))
65 querier := e2ecortex.NewQuerier("querier", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), flags, "")
66 require.NoError(t, s.StartAndWaitReady(querier))
67
68 // Wait until the querier has updated the ring.
69 require.NoError(t, querier.WaitSumMetrics(e2e.Equals(2*512), "cortex_ring_tokens_total"))
70
71 matcher, err := labels.NewMatcher(labels.MatchEqual, "__name__", "series_1")
72 require.NoError(t, err)
73
74 startMs := now.Add(-1*time.Minute).Unix() * 1000
75 endMs := now.Add(time.Minute).Unix() * 1000
76
77 q, err := remote.ToQuery(startMs, endMs, []*labels.Matcher{matcher}, &storage.SelectHints{
78 Step: 1,
79 Start: startMs,
80 End: endMs,
81 })
82 require.NoError(t, err)
83
84 req := &prompb.ReadRequest{
85 Queries: []*prompb.Query{q},

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
StartAndWaitReadyMethod · 0.95
PushMethod · 0.95
NewScenarioFunction · 0.92
NewDistributorFunction · 0.92
NewIngesterFunction · 0.92
EqualsFunction · 0.92
NewClientFunction · 0.92
NewStoreGatewayFunction · 0.92
NewQuerierFunction · 0.92
NetworkHTTPEndpointMethod · 0.80
HTTPEndpointMethod · 0.80

Tested by

no test coverage detected