From 457534d5c415a4854eef3626313d5dd97911f676 Mon Sep 17 00:00:00 2001 From: Krasi Georgiev Date: Fri, 8 Feb 2019 11:36:30 +0200 Subject: [PATCH] simplify nesting. Signed-off-by: Krasi Georgiev --- compact_test.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/compact_test.go b/compact_test.go index 9141be0e1e..fa977879dd 100644 --- a/compact_test.go +++ b/compact_test.go @@ -772,21 +772,16 @@ func TestCancelCompactions(t *testing.T) { testutil.Equals(t, 0.0, prom_testutil.ToFloat64(db.compactor.(*LeveledCompactor).metrics.ran), "initial compaction counter mismatch") db.compactc <- struct{}{} // Trigger a compaction. var start time.Time - for { - if prom_testutil.ToFloat64(db.compactor.(*LeveledCompactor).metrics.populatingBlocks) > 0 { - start = time.Now() - break - } + for prom_testutil.ToFloat64(db.compactor.(*LeveledCompactor).metrics.populatingBlocks) <= 0 { time.Sleep(3 * time.Millisecond) } + start = time.Now() - for { - if prom_testutil.ToFloat64(db.compactor.(*LeveledCompactor).metrics.ran) == 1 { - timeCompactionUninterrupted = time.Since(start) - break - } + for prom_testutil.ToFloat64(db.compactor.(*LeveledCompactor).metrics.ran) != 1 { time.Sleep(3 * time.Millisecond) } + timeCompactionUninterrupted = time.Since(start) + testutil.Ok(t, db.Close()) } // Measure the compaction time when closing the db in the middle of compaction.