Skip to content

Commit

Permalink
try otel test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
BinaryFissionGames committed Feb 18, 2022
1 parent 6a61f82 commit c028270
Showing 1 changed file with 5 additions and 51 deletions.
56 changes: 5 additions & 51 deletions operator/builtin/input/file/rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -191,7 +190,6 @@ type rotationTest struct {
writeInterval time.Duration
pollInterval time.Duration
ephemeralLines bool
waitInterval time.Duration
}

/*
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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 {
Expand Down

0 comments on commit c028270

Please sign in to comment.