Skip to content

Commit

Permalink
try tweaking some times to reduce flakiness (#558)
Browse files Browse the repository at this point in the history
* try tweaking some times to reduce flakiness

* try upping wait interval when reading entries

* close writer to force sync to disk in rotation tests

* try otel test cases

* Equalize some of the timeouts
  • Loading branch information
BinaryFissionGames authored Feb 23, 2022
1 parent cd2849f commit 5ff3f35
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 45 deletions.
51 changes: 9 additions & 42 deletions operator/builtin/input/file/rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (rt rotationTest) run(tc rotationTest, copyTruncate, sequential bool) func(
select {
case e := <-logReceived:
received = append(received, e.Record.(string))
case <-time.After(100 * time.Millisecond):
case <-time.After(3 * time.Second):
break LOOP
}
}
Expand All @@ -277,74 +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: 20 * time.Millisecond,
pollInterval: 10 * time.Millisecond,
},
{
name: "Fast/NoDeletion",
name: "NoDeletion",
totalLines: 20,
maxLinesPerFile: 10,
maxBackupFiles: 1,
writeInterval: time.Millisecond,
pollInterval: 20 * time.Millisecond,
pollInterval: 10 * time.Millisecond,
},
{
name: "Fast/Deletion",
name: "Deletion",
totalLines: 30,
maxLinesPerFile: 10,
maxBackupFiles: 1,
writeInterval: time.Millisecond,
pollInterval: 20 * time.Millisecond,
pollInterval: 10 * time.Millisecond,
ephemeralLines: true,
},
{
name: "Fast/Deletion/ExceedFingerprint",
name: "Deletion/ExceedFingerprint",
totalLines: 300,
maxLinesPerFile: 100,
maxBackupFiles: 1,
writeInterval: time.Millisecond,
pollInterval: 20 * time.Millisecond,
pollInterval: 10 * time.Millisecond,
ephemeralLines: true,
},
{
name: "Slow/NoRotation",
totalLines: 10,
maxLinesPerFile: 10,
maxBackupFiles: 1,
writeInterval: 3 * time.Millisecond,
pollInterval: 20 * time.Millisecond,
},
{
name: "Slow/NoDeletion",
totalLines: 20,
maxLinesPerFile: 10,
maxBackupFiles: 1,
writeInterval: 3 * time.Millisecond,
pollInterval: 20 * time.Millisecond,
},
{
name: "Slow/Deletion",
totalLines: 30,
maxLinesPerFile: 10,
maxBackupFiles: 1,
writeInterval: 3 * time.Millisecond,
pollInterval: 20 * 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: 20 * time.Millisecond,
},
}

for _, tc := range cases {
Expand Down
4 changes: 2 additions & 2 deletions operator/builtin/input/file/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ LOOP:
select {
case e := <-c:
receivedMessages = append(receivedMessages, e.Record.(string))
case <-time.After(time.Second):
case <-time.After(3 * time.Second):
break LOOP
}
}
Expand All @@ -152,7 +152,7 @@ LOOP:
}

func expectNoMessages(t *testing.T, c chan *entry.Entry) {
expectNoMessagesUntil(t, c, 200*time.Millisecond)
expectNoMessagesUntil(t, c, 3*time.Second)
}

func expectNoMessagesUntil(t *testing.T, c chan *entry.Entry, d time.Duration) {
Expand Down
2 changes: 1 addition & 1 deletion operator/flusher/flusher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 5ff3f35

Please sign in to comment.