From 92c9be35f03439dfe9e7dd219ed007dbf650378b Mon Sep 17 00:00:00 2001 From: Brandon Johnson Date: Wed, 16 Feb 2022 18:24:24 -0500 Subject: [PATCH] try tweaking some times to reduce flakiness --- operator/builtin/input/file/rotation_test.go | 16 ++++++++-------- operator/flusher/flusher_test.go | 6 +++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/operator/builtin/input/file/rotation_test.go b/operator/builtin/input/file/rotation_test.go index 93738e589..761d01d60 100644 --- a/operator/builtin/input/file/rotation_test.go +++ b/operator/builtin/input/file/rotation_test.go @@ -285,7 +285,7 @@ func TestRotation(t *testing.T) { maxLinesPerFile: 10, maxBackupFiles: 1, writeInterval: time.Millisecond, - pollInterval: 20 * time.Millisecond, + pollInterval: 10 * time.Millisecond, }, { name: "Fast/NoDeletion", @@ -293,7 +293,7 @@ func TestRotation(t *testing.T) { maxLinesPerFile: 10, maxBackupFiles: 1, writeInterval: time.Millisecond, - pollInterval: 20 * time.Millisecond, + pollInterval: 10 * time.Millisecond, }, { name: "Fast/Deletion", @@ -301,7 +301,7 @@ func TestRotation(t *testing.T) { maxLinesPerFile: 10, maxBackupFiles: 1, writeInterval: time.Millisecond, - pollInterval: 20 * time.Millisecond, + pollInterval: 10 * time.Millisecond, ephemeralLines: true, }, { @@ -310,7 +310,7 @@ func TestRotation(t *testing.T) { maxLinesPerFile: 100, maxBackupFiles: 1, writeInterval: time.Millisecond, - pollInterval: 20 * time.Millisecond, + pollInterval: 10 * time.Millisecond, ephemeralLines: true, }, { @@ -319,7 +319,7 @@ func TestRotation(t *testing.T) { maxLinesPerFile: 10, maxBackupFiles: 1, writeInterval: 3 * time.Millisecond, - pollInterval: 20 * time.Millisecond, + pollInterval: 10 * time.Millisecond, }, { name: "Slow/NoDeletion", @@ -327,7 +327,7 @@ func TestRotation(t *testing.T) { maxLinesPerFile: 10, maxBackupFiles: 1, writeInterval: 3 * time.Millisecond, - pollInterval: 20 * time.Millisecond, + pollInterval: 10 * time.Millisecond, }, { name: "Slow/Deletion", @@ -335,7 +335,7 @@ func TestRotation(t *testing.T) { maxLinesPerFile: 10, maxBackupFiles: 1, writeInterval: 3 * time.Millisecond, - pollInterval: 20 * time.Millisecond, + pollInterval: 10 * time.Millisecond, }, { name: "Slow/Deletion/ExceedFingerprint", @@ -343,7 +343,7 @@ func TestRotation(t *testing.T) { maxLinesPerFile: 25, // ~20 is just enough to exceed 1000 bytes fingerprint at 50 chars per line maxBackupFiles: 2, writeInterval: 3 * time.Millisecond, - pollInterval: 20 * time.Millisecond, + pollInterval: 10 * time.Millisecond, }, } diff --git a/operator/flusher/flusher_test.go b/operator/flusher/flusher_test.go index c371da389..0186e65db 100644 --- a/operator/flusher/flusher_test.go +++ b/operator/flusher/flusher_test.go @@ -44,7 +44,7 @@ func TestFlusher(t *testing.T) { func TestMaxElapsedTime(t *testing.T) { // Override setting for test - maxElapsedTime = 100 * time.Millisecond + maxElapsedTime = 1 * time.Second flusherCfg := NewConfig() flusher := flusherCfg.Build(zaptest.NewLogger(t).Sugar()) @@ -55,3 +55,7 @@ func TestMaxElapsedTime(t *testing.T) { }) require.WithinDuration(t, start.Add(maxElapsedTime), time.Now(), maxElapsedTime) } + +func TestTime(t *testing.T) { + require.WithinDuration(t, time.Now(), time.Now().Add(10*time.Second), time.Second) +}