From c6d860ace6a856f3a89d89275453271456aec242 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Wed, 15 Jul 2020 09:34:37 -0700 Subject: [PATCH] Fix log file rotation test. The test was looking for the wrong file name. Since compression happens asyncronously, sometimes the test would succeed and sometimes fail. This change makes sure to wait for the compressed version of the file since we can't know when the compression is going to occur. Signed-off-by: Brian Goff --- daemon/logger/loggerutils/logfile_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/logger/loggerutils/logfile_test.go b/daemon/logger/loggerutils/logfile_test.go index 9e64e2b678..ab4a542b19 100644 --- a/daemon/logger/loggerutils/logfile_test.go +++ b/daemon/logger/loggerutils/logfile_test.go @@ -265,11 +265,11 @@ func TestCheckCapacityAndRotate(t *testing.T) { assert.Assert(t, os.IsNotExist(err), dirStringer{dir}) assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world!")})) - poll.WaitOn(t, checkFileExists(f.Name()+".1"), poll.WithTimeout(30*time.Second)) + poll.WaitOn(t, checkFileExists(f.Name()+".1.gz"), poll.WithDelay(time.Millisecond), poll.WithTimeout(30*time.Second)) assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world!")})) - poll.WaitOn(t, checkFileExists(f.Name()+".1"), poll.WithTimeout(30*time.Second)) - poll.WaitOn(t, checkFileExists(f.Name()+".2.gz"), poll.WithTimeout(30*time.Second)) + poll.WaitOn(t, checkFileExists(f.Name()+".1.gz"), poll.WithDelay(time.Millisecond), poll.WithTimeout(30*time.Second)) + poll.WaitOn(t, checkFileExists(f.Name()+".2.gz"), poll.WithDelay(time.Millisecond), poll.WithTimeout(30*time.Second)) // Now let's simulate a failed rotation where the file was able to be closed but something else happened elsewhere // down the line.