MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestMergeSampleStreams

Function TestMergeSampleStreams

pkg/querier/tripperware/merge_test.go:64–370  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62)
63
64func TestMergeSampleStreams(t *testing.T) {
65 t.Parallel()
66 lbls := labels.FromMap(map[string]string{
67 "foo": "bar",
68 "cluster": "test",
69 })
70 lbls1 := labels.FromMap(map[string]string{
71 "foo": "zoo",
72 "cluster": "test",
73 })
74 for _, tc := range []struct {
75 name string
76 sampleStreams []SampleStream
77 expectedOutput map[string]SampleStream
78 }{
79 {
80 name: "one sample stream",
81 sampleStreams: []SampleStream{
82 {
83 Labels: cortexpb.FromLabelsToLabelAdapters(lbls),
84 Samples: []cortexpb.Sample{
85 {Value: 0, TimestampMs: 0},
86 },
87 },
88 },
89 expectedOutput: map[string]SampleStream{
90 ingester_client.LabelsToKeyString(lbls): {
91 Labels: cortexpb.FromLabelsToLabelAdapters(lbls),
92 Samples: []cortexpb.Sample{
93 {Value: 0, TimestampMs: 0},
94 },
95 },
96 },
97 },
98 {
99 name: "one sample stream with histograms",
100 sampleStreams: []SampleStream{
101 {
102 Labels: cortexpb.FromLabelsToLabelAdapters(lbls),
103 Histograms: []SampleHistogramPair{
104 {Histogram: testHistogram1, TimestampMs: 0},
105 },
106 },
107 },
108 expectedOutput: map[string]SampleStream{
109 ingester_client.LabelsToKeyString(lbls): {
110 Labels: cortexpb.FromLabelsToLabelAdapters(lbls),
111 Histograms: []SampleHistogramPair{
112 {Histogram: testHistogram1, TimestampMs: 0},
113 },
114 },
115 },
116 },
117 {
118 name: "one sample stream with both samples and histograms",
119 sampleStreams: []SampleStream{
120 {
121 Labels: cortexpb.FromLabelsToLabelAdapters(lbls),

Callers

nothing calls this directly

Calls 4

mergeSampleStreamsFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected