Merge pull request #13197 from bboreham/tsdb-lint
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Build Prometheus for common architectures (0) (push) Waiting to run
CI / Build Prometheus for common architectures (1) (push) Waiting to run
CI / Build Prometheus for common architectures (2) (push) Waiting to run
CI / Build Prometheus for all architectures (0) (push) Waiting to run
CI / Build Prometheus for all architectures (1) (push) Waiting to run
CI / Build Prometheus for all architectures (10) (push) Waiting to run
CI / Build Prometheus for all architectures (11) (push) Waiting to run
CI / Build Prometheus for all architectures (2) (push) Waiting to run
CI / Build Prometheus for all architectures (3) (push) Waiting to run
CI / Build Prometheus for all architectures (4) (push) Waiting to run
CI / Build Prometheus for all architectures (5) (push) Waiting to run
CI / Build Prometheus for all architectures (6) (push) Waiting to run
CI / Build Prometheus for all architectures (7) (push) Waiting to run
CI / Build Prometheus for all architectures (8) (push) Waiting to run
CI / Build Prometheus for all architectures (9) (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run

Clean up some issues in tsdb tests
This commit is contained in:
Jan Fajerski 2025-01-27 21:18:09 +01:00 committed by GitHub
commit 2ae706be8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 185 additions and 180 deletions

View file

@ -1575,12 +1575,13 @@ func TestHeadCompactionWithHistograms(t *testing.T) {
func TestSparseHistogramSpaceSavings(t *testing.T) { func TestSparseHistogramSpaceSavings(t *testing.T) {
t.Skip() t.Skip()
cases := []struct { type testcase struct {
numSeriesPerSchema int numSeriesPerSchema int
numBuckets int numBuckets int
numSpans int numSpans int
gapBetweenSpans int gapBetweenSpans int
}{ }
cases := []testcase{
{1, 15, 1, 0}, {1, 15, 1, 0},
{1, 50, 1, 0}, {1, 50, 1, 0},
{1, 100, 1, 0}, {1, 100, 1, 0},
@ -1692,7 +1693,7 @@ func TestSparseHistogramSpaceSavings(t *testing.T) {
}() }()
wg.Add(1) wg.Add(1)
go func() { go func(c testcase) {
defer wg.Done() defer wg.Done()
// Ingest histograms the old way. // Ingest histograms the old way.
@ -1740,7 +1741,7 @@ func TestSparseHistogramSpaceSavings(t *testing.T) {
oldULIDs, err = compactor.Write(oldHead.opts.ChunkDirRoot, oldHead, mint, maxt, nil) oldULIDs, err = compactor.Write(oldHead.opts.ChunkDirRoot, oldHead, mint, maxt, nil)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, oldULIDs, 1) require.Len(t, oldULIDs, 1)
}() }(c)
wg.Wait() wg.Wait()

View file

@ -426,8 +426,8 @@ func TestDeleteSimple(t *testing.T) {
}, },
} }
Outer:
for _, c := range cases { for _, c := range cases {
t.Run("", func(t *testing.T) {
db := openTestDB(t, nil, nil) db := openTestDB(t, nil, nil)
defer func() { defer func() {
require.NoError(t, db.Close()) require.NoError(t, db.Close())
@ -471,7 +471,7 @@ Outer:
if !eok { if !eok {
require.Empty(t, res.Warnings()) require.Empty(t, res.Warnings())
continue Outer break
} }
sexp := expss.At() sexp := expss.At()
sres := res.At() sres := res.At()
@ -484,6 +484,7 @@ Outer:
require.Equal(t, errExp, errRes) require.Equal(t, errExp, errRes)
require.Equal(t, smplExp, smplRes) require.Equal(t, smplExp, smplRes)
} }
})
} }
} }
@ -759,8 +760,8 @@ func TestDB_SnapshotWithDelete(t *testing.T) {
}, },
} }
Outer:
for _, c := range cases { for _, c := range cases {
t.Run("", func(t *testing.T) {
// TODO(gouthamve): Reset the tombstones somehow. // TODO(gouthamve): Reset the tombstones somehow.
// Delete the ranges. // Delete the ranges.
for _, r := range c.intervals { for _, r := range c.intervals {
@ -795,7 +796,7 @@ Outer:
if len(expSamples) == 0 { if len(expSamples) == 0 {
require.False(t, res.Next()) require.False(t, res.Next())
continue return
} }
for { for {
@ -804,7 +805,7 @@ Outer:
if !eok { if !eok {
require.Empty(t, res.Warnings()) require.Empty(t, res.Warnings())
continue Outer break
} }
sexp := expss.At() sexp := expss.At()
sres := res.At() sres := res.At()
@ -817,6 +818,7 @@ Outer:
require.Equal(t, errExp, errRes) require.Equal(t, errExp, errRes)
require.Equal(t, smplExp, smplRes) require.Equal(t, smplExp, smplRes)
} }
})
} }
} }
@ -2250,6 +2252,7 @@ func TestDB_LabelNames(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
} }
for _, tst := range tests { for _, tst := range tests {
t.Run("", func(t *testing.T) {
ctx := context.Background() ctx := context.Background()
db := openTestDB(t, nil, nil) db := openTestDB(t, nil, nil)
defer func() { defer func() {
@ -2293,6 +2296,7 @@ func TestDB_LabelNames(t *testing.T) {
require.Empty(t, ws) require.Empty(t, ws)
require.NoError(t, q.Close()) require.NoError(t, q.Close())
require.Equal(t, tst.exp2, labelNames) require.Equal(t, tst.exp2, labelNames)
})
} }
} }

View file

@ -1594,7 +1594,6 @@ func TestDelete_e2e(t *testing.T) {
for i := 0; i < numRanges; i++ { for i := 0; i < numRanges; i++ {
q, err := NewBlockQuerier(hb, 0, 100000) q, err := NewBlockQuerier(hb, 0, 100000)
require.NoError(t, err) require.NoError(t, err)
defer q.Close()
ss := q.Select(context.Background(), true, nil, del.ms...) ss := q.Select(context.Background(), true, nil, del.ms...)
// Build the mockSeriesSet. // Build the mockSeriesSet.
matchedSeries := make([]storage.Series, 0, len(matched)) matchedSeries := make([]storage.Series, 0, len(matched))
@ -1635,6 +1634,7 @@ func TestDelete_e2e(t *testing.T) {
} }
require.NoError(t, ss.Err()) require.NoError(t, ss.Err())
require.Empty(t, ss.Warnings()) require.Empty(t, ss.Warnings())
require.NoError(t, q.Close())
} }
} }
} }

View file

@ -694,9 +694,9 @@ func (h *Head) loadWBL(r *wlog.Reader, syms *labels.SymbolTable, multiRef map[ch
go func() { go func() {
defer close(decodedCh) defer close(decodedCh)
var err error
dec := record.NewDecoder(syms) dec := record.NewDecoder(syms)
for r.Next() { for r.Next() {
var err error
rec := r.Record() rec := r.Record()
switch dec.Type(rec) { switch dec.Type(rec) {
case record.Samples: case record.Samples:

View file

@ -2633,6 +2633,8 @@ func BenchmarkSetMatcher(b *testing.B) {
} }
for _, c := range cases { for _, c := range cases {
benchMsg := fmt.Sprintf("nSeries=%d,nBlocks=%d,cardinality=%d,pattern=\"%s\"", c.numSeries, c.numBlocks, c.cardinality, c.pattern)
b.Run(benchMsg, func(b *testing.B) {
dir := b.TempDir() dir := b.TempDir()
var ( var (
@ -2667,8 +2669,6 @@ func BenchmarkSetMatcher(b *testing.B) {
sq := storage.NewMergeQuerier(qblocks, nil, storage.ChainedSeriesMerge) sq := storage.NewMergeQuerier(qblocks, nil, storage.ChainedSeriesMerge)
defer sq.Close() defer sq.Close()
benchMsg := fmt.Sprintf("nSeries=%d,nBlocks=%d,cardinality=%d,pattern=\"%s\"", c.numSeries, c.numBlocks, c.cardinality, c.pattern)
b.Run(benchMsg, func(b *testing.B) {
b.ResetTimer() b.ResetTimer()
b.ReportAllocs() b.ReportAllocs()
for n := 0; n < b.N; n++ { for n := 0; n < b.N; n++ {