TestInconsistentHistogramCount is testing for https://github.com/prometheus/prometheus/issues/16681 which needs mixed integer and float histograms. The promql test framework only uses float histograms, so we cannot move this to promql tests.
(t *testing.T)
| 4591 | // integer and float histograms. The promql test framework only uses float |
| 4592 | // histograms, so we cannot move this to promql tests. |
| 4593 | func TestInconsistentHistogramCount(t *testing.T) { |
| 4594 | dir := t.TempDir() |
| 4595 | |
| 4596 | opts := tsdb.DefaultHeadOptions() |
| 4597 | opts.ChunkDirRoot = dir |
| 4598 | // We use TSDB head only. By using full TSDB DB, and appending samples to it, closing it would cause unnecessary HEAD compaction, which slows down the test. |
| 4599 | head, err := tsdb.NewHead(nil, nil, nil, nil, opts, nil) |
| 4600 | require.NoError(t, err) |
| 4601 | t.Cleanup(func() { |
| 4602 | _ = head.Close() |
| 4603 | }) |
| 4604 | |
| 4605 | app := head.Appender(context.Background()) |
| 4606 | |
| 4607 | l := labels.FromStrings("__name__", "series_1") |
| 4608 | |
| 4609 | mint := time.Now().Add(-time.Hour).UnixMilli() |
| 4610 | maxt := mint |
| 4611 | dT := int64(15 * 1000) // 15 seconds in milliseconds. |
| 4612 | inHs := []*histogram.Histogram{ |
| 4613 | { |
| 4614 | Count: 2, |
| 4615 | Sum: 100, |
| 4616 | PositiveSpans: []histogram.Span{ |
| 4617 | {Offset: 0, Length: 1}, |
| 4618 | }, |
| 4619 | PositiveBuckets: []int64{2}, |
| 4620 | }, |
| 4621 | { |
| 4622 | Count: 4, |
| 4623 | Sum: 200, |
| 4624 | PositiveSpans: []histogram.Span{ |
| 4625 | {Offset: 0, Length: 1}, |
| 4626 | }, |
| 4627 | PositiveBuckets: []int64{4}, |
| 4628 | }, |
| 4629 | {}, // Empty histogram to trigger counter reset. |
| 4630 | } |
| 4631 | |
| 4632 | for i, h := range inHs { |
| 4633 | maxt = mint + dT*int64(i) |
| 4634 | _, err = app.AppendHistogram(0, l, maxt, h, nil) |
| 4635 | require.NoError(t, err) |
| 4636 | } |
| 4637 | |
| 4638 | require.NoError(t, app.Commit()) |
| 4639 | queryable := storage.QueryableFunc(func(mint, maxt int64) (storage.Querier, error) { |
| 4640 | return tsdb.NewBlockQuerier(head, mint, maxt) |
| 4641 | }) |
| 4642 | |
| 4643 | engine := promql.NewEngine(promql.EngineOpts{ |
| 4644 | MaxSamples: 1000000, |
| 4645 | Timeout: 10 * time.Second, |
| 4646 | LookbackDelta: 5 * time.Minute, |
| 4647 | }) |
| 4648 | |
| 4649 | var ( |
| 4650 | query promql.Query |
nothing calls this directly
no test coverage detected
searching dependent graphs…