github.com/thanos-io/thanos@v0.32.5/pkg/verifier/duplicated_compaction_test.go (about) 1 // Copyright (c) The Thanos Authors. 2 // Licensed under the Apache License 2.0. 3 4 package verifier 5 6 import ( 7 "testing" 8 9 "github.com/efficientgo/core/testutil" 10 "github.com/oklog/ulid" 11 "github.com/prometheus/prometheus/tsdb" 12 ) 13 14 func TestDuplicatedBlocks(t *testing.T) { 15 b1 := tsdb.BlockMeta{ 16 MaxTime: 0, 17 MinTime: 10, 18 Compaction: tsdb.BlockMetaCompaction{ 19 Sources: []ulid.ULID{ 20 ulid.MustNew(0, nil), 21 ulid.MustNew(1, nil), 22 ulid.MustNew(2, nil), 23 }, 24 Level: 2, 25 }, 26 Stats: tsdb.BlockStats{ 27 NumChunks: 941384, 28 NumSamples: 112567234, 29 NumSeries: 60915, 30 NumTombstones: 0, 31 }, 32 } 33 34 dupB1 := b1 35 36 b2 := b1 37 b2.MinTime = 1 38 39 b3 := b1 40 b3.Stats.NumTombstones = 1 41 42 b4 := b1 43 b4.Compaction.Sources = b4.Compaction.Sources[1:] 44 45 b5 := b1 46 47 testutil.Equals(t, [][]tsdb.BlockMeta{ 48 {b1, dupB1, b5}, 49 }, duplicatedBlocks([]tsdb.BlockMeta{b1, dupB1, b2, b3, b4, b5})) 50 }