mirror of
https://github.com/prometheus/prometheus
synced 2024-12-27 09:02:53 +00:00
Add TestCompactHeadWithDeletion to test compaction failure after deletion
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
This commit is contained in:
parent
a07a94a5ab
commit
d0e683e26d
@ -2960,6 +2960,24 @@ func TestCompactHead(t *testing.T) {
|
||||
require.NoError(t, seriesSet.Err())
|
||||
}
|
||||
|
||||
// TestCompactHeadWithDeletion tests https://github.com/prometheus/prometheus/issues/11585.
|
||||
func TestCompactHeadWithDeletion(t *testing.T) {
|
||||
db, err := Open(t.TempDir(), log.NewNopLogger(), prometheus.NewRegistry(), nil, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
app := db.Appender(context.Background())
|
||||
_, err = app.Append(0, labels.FromStrings("a", "b"), 10, rand.Float64())
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, app.Commit())
|
||||
|
||||
err = db.Delete(0, 100, labels.MustNewMatcher(labels.MatchEqual, "a", "b"))
|
||||
require.NoError(t, err)
|
||||
|
||||
// This recreates the bug.
|
||||
require.NoError(t, db.CompactHead(NewRangeHead(db.Head(), 0, 100)))
|
||||
require.NoError(t, db.Close())
|
||||
}
|
||||
|
||||
func deleteNonBlocks(dbDir string) error {
|
||||
dirs, err := os.ReadDir(dbDir)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user