Skip to content

Commit

Permalink
Revert "Fix flaky test - increase file lifespan in rotation tests (#1384
Browse files Browse the repository at this point in the history
)"

This reverts commit 68d65d7.
  • Loading branch information
Bogdan Drutu authored Oct 29, 2020
1 parent 1b51650 commit 3115f9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions receiver/stanzareceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ It can also be easily configured to tail and parse any structured or unstructure
- [timestamp](https://github.com/observIQ/stanza/blob/master/docs/types/timestamp.md) parsing is available as a block within all parser operators, and also as a standalone operator. Many common timestamp layouts are supported.
- [severity](https://github.com/observIQ/stanza/blob/master/docs/types/severity.md) parsing is available as a block within all parser operators, and also as a standalone operator. Stanza uses a flexible severity representation which is automatically interpreted by the stanza receiver.


## Example - Tailing a simple json file

Receiver Configuration
Expand Down
19 changes: 7 additions & 12 deletions receiver/stanzareceiver/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"log"
"os"
"path/filepath"
"runtime"
"testing"
"time"

Expand Down Expand Up @@ -108,6 +109,10 @@ func TestReadStaticFile(t *testing.T) {
}

func TestReadRotatingFiles(t *testing.T) {
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/1382
if runtime.GOOS == "windows" {
t.Skip()
}

tests := []rotationTest{
{
Expand Down Expand Up @@ -191,20 +196,10 @@ func (rt *rotationTest) Run(t *testing.T) {

for _, line := range lines {
logger.Print(line)
// At a high enough rate of file rotation, it is possible for a file to be deleted
// before all lines can be read from it. In production settings, this is far less
// likely because log files will exists for much longer durations, except in the
// most extreme scenarios. This test attempts to establish a stable scenario that
// does not consume much time by balancing the max lines per file with a duration
// of existence that is low enough to be practical in a unit test. The following
// sleep provides a level of consistency to file lifespan.
time.Sleep(2 * time.Millisecond)
time.Sleep(time.Millisecond)
}

missingMsg := func(exp, act int) string { return fmt.Sprintf("%d out of expected %d received", act, exp) }

waitFor, tick := 2*time.Second, time.Millisecond
require.Eventually(t, expectNLogs(sink, numLogs), waitFor, tick, missingMsg(numLogs, sink.LogRecordsCount()))
require.Eventually(t, expectNLogs(sink, numLogs), 2*time.Second, time.Millisecond)
require.ElementsMatch(t, expectedLogs, sink.AllLogs())
require.NoError(t, rcvr.Shutdown(context.Background()))
}
Expand Down

0 comments on commit 3115f9c

Please sign in to comment.