From aadffd1360473073140e1e50868e981e4c7e0060 Mon Sep 17 00:00:00 2001 From: Bartlomiej Plotka Date: Mon, 10 Feb 2020 16:19:58 +0000 Subject: [PATCH] Finally found a fix for the bug I was chasing for 2h... Signed-off-by: Bartlomiej Plotka --- tsdb/compact_test.go | 2 +- util/teststorage/storage.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tsdb/compact_test.go b/tsdb/compact_test.go index 71b1ab48c..c525eee95 100644 --- a/tsdb/compact_test.go +++ b/tsdb/compact_test.go @@ -991,7 +991,7 @@ func TestCancelCompactions(t *testing.T) { } // Measure the compaction time when closing the db in the middle of compaction. { - db, err := open(tmpdirCopy, log.NewNopLogger(), nil, nil, []int64{1, 2000}) + db, err := open(tmpdirCopy, log.NewNopLogger(), nil, DefaultOptions(), []int64{1, 2000}) testutil.Ok(t, err) testutil.Equals(t, 3, len(db.Blocks()), "initial block count mismatch") testutil.Equals(t, 0.0, prom_testutil.ToFloat64(db.compactor.(*LeveledCompactor).metrics.ran), "initial compaction counter mismatch") diff --git a/util/teststorage/storage.go b/util/teststorage/storage.go index 633112d01..9489308b8 100644 --- a/util/teststorage/storage.go +++ b/util/teststorage/storage.go @@ -16,7 +16,9 @@ package teststorage import ( "io/ioutil" "os" + "time" + "github.com/prometheus/common/model" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb" "github.com/prometheus/prometheus/util/testutil" @@ -32,7 +34,10 @@ func New(t testutil.T) storage.Storage { // Tests just load data for a series sequentially. Thus we // need a long appendable window. - db, err := tsdb.Open(dir, nil, nil, nil) + db, err := tsdb.Open(dir, nil, nil, &tsdb.Options{ + MinBlockDuration: model.Duration(24 * time.Hour), + MaxBlockDuration: model.Duration(24 * time.Hour), + }) if err != nil { t.Fatalf("Opening test storage failed: %s", err) }