diff --git a/operator/builtin/input/file/rotation_test.go b/operator/builtin/input/file/rotation_test.go index b9ae15df..846d0d26 100644 --- a/operator/builtin/input/file/rotation_test.go +++ b/operator/builtin/input/file/rotation_test.go @@ -11,7 +11,6 @@ import ( "testing" "time" - "github.com/observiq/nanojack" "github.com/observiq/stanza/entry" "github.com/observiq/stanza/operator/helper" "github.com/observiq/stanza/testutil" @@ -191,7 +190,6 @@ type rotationTest struct { writeInterval time.Duration pollInterval time.Duration ephemeralLines bool - waitInterval time.Duration } /* @@ -255,16 +253,13 @@ func (rt rotationTest) run(tc rotationTest, copyTruncate, sequential bool) func( time.Sleep(tc.writeInterval) } - // Close the logger's writer to force a sync to disk - require.NoError(t, logger.Writer().(*nanojack.Logger).Close()) - received := make([]string, 0, tc.totalLines) LOOP: for { select { case e := <-logReceived: received = append(received, e.Record.(string)) - case <-time.After(tc.waitInterval): + case <-time.After(200 * time.Millisecond): break LOOP } } @@ -282,82 +277,41 @@ func (rt rotationTest) run(tc rotationTest, copyTruncate, sequential bool) func( } func TestRotation(t *testing.T) { - cases := []rotationTest{ { - name: "Fast/NoRotation", + name: "NoRotation", totalLines: 10, maxLinesPerFile: 10, maxBackupFiles: 1, writeInterval: time.Millisecond, pollInterval: 10 * time.Millisecond, - waitInterval: 500 * time.Millisecond, }, { - name: "Fast/NoDeletion", + name: "NoDeletion", totalLines: 20, maxLinesPerFile: 10, maxBackupFiles: 1, writeInterval: time.Millisecond, pollInterval: 10 * time.Millisecond, - waitInterval: 500 * time.Millisecond, }, { - name: "Fast/Deletion", + name: "Deletion", totalLines: 30, maxLinesPerFile: 10, maxBackupFiles: 1, writeInterval: time.Millisecond, pollInterval: 10 * time.Millisecond, - waitInterval: 500 * time.Millisecond, ephemeralLines: true, }, { - name: "Fast/Deletion/ExceedFingerprint", + name: "Deletion/ExceedFingerprint", totalLines: 300, maxLinesPerFile: 100, maxBackupFiles: 1, writeInterval: time.Millisecond, pollInterval: 10 * time.Millisecond, - waitInterval: 500 * time.Millisecond, ephemeralLines: true, }, - { - name: "Slow/NoRotation", - totalLines: 10, - maxLinesPerFile: 10, - maxBackupFiles: 1, - writeInterval: 3 * time.Millisecond, - pollInterval: 10 * time.Millisecond, - waitInterval: 500 * time.Millisecond, - }, - { - name: "Slow/NoDeletion", - totalLines: 20, - maxLinesPerFile: 10, - maxBackupFiles: 1, - writeInterval: 3 * time.Millisecond, - pollInterval: 10 * time.Millisecond, - waitInterval: 500 * time.Millisecond, - }, - { - name: "Slow/Deletion", - totalLines: 30, - maxLinesPerFile: 10, - maxBackupFiles: 1, - writeInterval: 3 * time.Millisecond, - pollInterval: 10 * time.Millisecond, - waitInterval: 500 * time.Millisecond, - }, - { - name: "Slow/Deletion/ExceedFingerprint", - totalLines: 100, - maxLinesPerFile: 25, // ~20 is just enough to exceed 1000 bytes fingerprint at 50 chars per line - maxBackupFiles: 2, - writeInterval: 3 * time.Millisecond, - pollInterval: 10 * time.Millisecond, - waitInterval: 500 * time.Millisecond, - }, } for _, tc := range cases {