MCPcopy
hub / github.com/prometheus/prometheus / TestStreamReadEndpoint

Function TestStreamReadEndpoint

storage/remote/read_handler_test.go:230–464  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

228}
229
230func TestStreamReadEndpoint(t *testing.T) {
231 // First with 120 float samples. We expect 1 frame with 1 chunk.
232 // Second with 121 float samples, We expect 1 frame with 2 chunks.
233 // Third with 241 float samples. We expect 1 frame with 2 chunks, and 1 frame with 1 chunk for the same series due to bytes limit.
234 // Fourth with 25 histogram samples. We expect 1 frame with 1 chunk.
235 store := promqltest.LoadedStorage(t, `
236 load 1m
237 test_metric1{foo="bar1",baz="qux"} 0+100x119
238 test_metric1{foo="bar2",baz="qux"} 0+100x120
239 test_metric1{foo="bar3",baz="qux"} 0+100x240
240 `)
241 defer store.Close()
242
243 addNativeHistogramsToTestSuite(t, store, 25)
244
245 api := NewReadHandler(nil, nil, store, func() config.Config {
246 return config.Config{
247 GlobalConfig: config.GlobalConfig{
248 // We expect external labels to be added, with the source labels honored.
249 ExternalLabels: labels.FromStrings("baz", "a", "b", "c", "d", "e"),
250 },
251 }
252 },
253 1e6, 1,
254 // Labelset has 57 bytes. Full chunk in test data has roughly 240 bytes. This allows us to have at max 2 chunks in this test.
255 57+480,
256 )
257
258 // Encode the request.
259 matcher1, err := labels.NewMatcher(labels.MatchEqual, "__name__", "test_metric1")
260 require.NoError(t, err)
261
262 matcher2, err := labels.NewMatcher(labels.MatchEqual, "d", "e")
263 require.NoError(t, err)
264
265 matcher3, err := labels.NewMatcher(labels.MatchEqual, "foo", "bar1")
266 require.NoError(t, err)
267
268 matcher4, err := labels.NewMatcher(labels.MatchEqual, "__name__", "test_histogram_metric1")
269 require.NoError(t, err)
270
271 query1, err := ToQuery(0, 14400001, []*labels.Matcher{matcher1, matcher2}, &storage.SelectHints{
272 Step: 1,
273 Func: "avg",
274 Start: 0,
275 End: 14400001,
276 })
277 require.NoError(t, err)
278
279 query2, err := ToQuery(0, 14400001, []*labels.Matcher{matcher1, matcher3}, &storage.SelectHints{
280 Step: 1,
281 Func: "avg",
282 Start: 0,
283 End: 14400001,
284 })
285 require.NoError(t, err)
286
287 query3, err := ToQuery(0, 14400001, []*labels.Matcher{matcher4}, &storage.SelectHints{

Callers

nothing calls this directly

Calls 15

NextProtoMethod · 0.95
LoadedStorageFunction · 0.92
FromStringsFunction · 0.92
NewMatcherFunction · 0.92
NewReadHandlerFunction · 0.85
ToQueryFunction · 0.85
NewChunkedReaderFunction · 0.85
CloseMethod · 0.65
EncodeMethod · 0.65
GetMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…