(t *testing.T, lbls labels.Labels, value int64, timestampMs int64, float bool)
| 4341 | } |
| 4342 | |
| 4343 | func mockHistogramWriteRequest(t *testing.T, lbls labels.Labels, value int64, timestampMs int64, float bool) (*cortexpb.WriteRequest, *client.QueryStreamResponse) { |
| 4344 | var ( |
| 4345 | histograms []cortexpb.WrappedHistogram |
| 4346 | h *histogram.Histogram |
| 4347 | fh *histogram.FloatHistogram |
| 4348 | c chunkenc.Chunk |
| 4349 | ) |
| 4350 | if float { |
| 4351 | fh = tsdbutil.GenerateTestFloatHistogram(value) |
| 4352 | histograms = []cortexpb.WrappedHistogram{ |
| 4353 | cortexpb.WrapHistogram(cortexpb.FloatHistogramToHistogramProto(timestampMs, fh)), |
| 4354 | } |
| 4355 | c = chunkenc.NewFloatHistogramChunk() |
| 4356 | } else { |
| 4357 | h = tsdbutil.GenerateTestHistogram(value) |
| 4358 | histograms = []cortexpb.WrappedHistogram{ |
| 4359 | cortexpb.WrapHistogram(cortexpb.HistogramToHistogramProto(timestampMs, h)), |
| 4360 | } |
| 4361 | c = chunkenc.NewHistogramChunk() |
| 4362 | } |
| 4363 | |
| 4364 | app, err := c.Appender() |
| 4365 | require.NoError(t, err) |
| 4366 | if float { |
| 4367 | _, _, _, err = app.AppendFloatHistogram(nil, timestampMs, fh, true) |
| 4368 | } else { |
| 4369 | _, _, _, err = app.AppendHistogram(nil, timestampMs, h, true) |
| 4370 | } |
| 4371 | require.NoError(t, err) |
| 4372 | c.Compact() |
| 4373 | |
| 4374 | req := cortexpb.ToWriteRequest([]labels.Labels{lbls}, nil, nil, histograms, cortexpb.API) |
| 4375 | enc := int32(encoding.PrometheusHistogramChunk) |
| 4376 | if float { |
| 4377 | enc = int32(encoding.PrometheusFloatHistogramChunk) |
| 4378 | } |
| 4379 | expectedQueryStreamResChunks := &client.QueryStreamResponse{ |
| 4380 | Chunkseries: []client.TimeSeriesChunk{ |
| 4381 | { |
| 4382 | Labels: cortexpb.FromLabelsToLabelAdapters(lbls), |
| 4383 | Chunks: []client.Chunk{ |
| 4384 | { |
| 4385 | StartTimestampMs: timestampMs, |
| 4386 | EndTimestampMs: timestampMs, |
| 4387 | Encoding: enc, |
| 4388 | Data: c.Bytes(), |
| 4389 | }, |
| 4390 | }, |
| 4391 | }, |
| 4392 | }, |
| 4393 | } |
| 4394 | |
| 4395 | return req, expectedQueryStreamResChunks |
| 4396 | } |
| 4397 | |
| 4398 | func prepareIngesterWithBlocksStorage(t testing.TB, ingesterCfg Config, registerer prometheus.Registerer) (*Ingester, error) { |
| 4399 | limits := defaultLimitsTestConfig() |
no test coverage detected