Skip to content

Commit bbf65d7

Browse files
authored
fix flaky log rotation test (#1544)
* fix flaky log rotation test * fix lint
1 parent ba7e163 commit bbf65d7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/integration_tests/log_rotation/logrotate_logfile_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func runOperationsOnFileTillLogRotation(t *testing.T, wg *sync.WaitGroup, fileNa
5252

5353
// Keep performing operations in mounted directory until log file is rotated.
5454
var lastLogFileSize int64 = 0
55+
var retryStatLogFile = true
5556
for {
5657
// Perform Read operation to generate logs.
5758
_, err = operations.ReadFile(filePath)
@@ -62,7 +63,12 @@ func runOperationsOnFileTillLogRotation(t *testing.T, wg *sync.WaitGroup, fileNa
6263
// Break the loop when log file is rotated.
6364
fi, err := operations.StatFile(logFilePath)
6465
if err != nil {
65-
t.Errorf("stat operation on file %s: %v", logFilePath, err)
66+
t.Logf("stat operation on file %s failed: %v", logFilePath, err)
67+
if !retryStatLogFile {
68+
t.Errorf("Stat retry exhausted on log file: %s", logFilePath)
69+
}
70+
retryStatLogFile = false
71+
continue
6672
}
6773
if (*fi).Size() < lastLogFileSize {
6874
// Log file got rotated as current log file size < last log file size.

0 commit comments

Comments
 (0)