From 67fd42835448172d08616589f1473e7153cc0902 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 22 Feb 2019 11:49:08 +0400 Subject: [PATCH] fix TestWALPeriodicSync (#3342) The test was sometimes failing due to processFlushTicks being called too early. The solution is to call wal#Start later in the test. --- consensus/wal_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/consensus/wal_test.go b/consensus/wal_test.go index a2c80be3e..0bb750567 100644 --- a/consensus/wal_test.go +++ b/consensus/wal_test.go @@ -156,18 +156,19 @@ func TestWALPeriodicSync(t *testing.T) { wal.SetFlushInterval(walTestFlushInterval) wal.SetLogger(log.TestingLogger()) - require.NoError(t, wal.Start()) - defer func() { - wal.Stop() - wal.Wait() - }() - + // Generate some data err = WALGenerateNBlocks(t, wal.Group(), 5) require.NoError(t, err) // We should have data in the buffer now assert.NotZero(t, wal.Group().Buffered()) + require.NoError(t, wal.Start()) + defer func() { + wal.Stop() + wal.Wait() + }() + time.Sleep(walTestFlushInterval + (10 * time.Millisecond)) // The data should have been flushed by the periodic sync