Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit a0edb6a

Browse files
cpuguy83thaJeztah
authored andcommitted
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 <cpuguy83@gmail.com> (cherry picked from commit c6d860ace6a856f3a89d89275453271456aec242) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: ec14dc44d13b7cca6f4ac85a094d4d54fe8afad6 Component: engine
1 parent b17b2f0 commit a0edb6a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

components/engine/daemon/logger/loggerutils/logfile_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ func TestCheckCapacityAndRotate(t *testing.T) {
231231
assert.Assert(t, os.IsNotExist(err), dirStringer{dir})
232232

233233
assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world!")}))
234-
poll.WaitOn(t, checkFileExists(f.Name()+".1"), poll.WithTimeout(30*time.Second))
234+
poll.WaitOn(t, checkFileExists(f.Name()+".1.gz"), poll.WithDelay(time.Millisecond), poll.WithTimeout(30*time.Second))
235235

236236
assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world!")}))
237-
poll.WaitOn(t, checkFileExists(f.Name()+".1"), poll.WithTimeout(30*time.Second))
238-
poll.WaitOn(t, checkFileExists(f.Name()+".2.gz"), poll.WithTimeout(30*time.Second))
237+
poll.WaitOn(t, checkFileExists(f.Name()+".1.gz"), poll.WithDelay(time.Millisecond), poll.WithTimeout(30*time.Second))
238+
poll.WaitOn(t, checkFileExists(f.Name()+".2.gz"), poll.WithDelay(time.Millisecond), poll.WithTimeout(30*time.Second))
239239

240240
// Now let's simulate a failed rotation where the file was able to be closed but something else happened elsewhere
241241
// down the line.

0 commit comments

Comments
 (0)