Skip to content

Commit

Permalink
Attempt to fix flaky filestream parser tests. (#31773)
Browse files Browse the repository at this point in the history
Poll on the registry having the expected state instead of just looking
once after the expected number of events were propagated through the
pipeline. Fixes the flakiness that could be reproduced locally.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit b502a78)
  • Loading branch information
cmacknz authored and mergify[bot] committed Jun 6, 2022
1 parent 1a5e3f1 commit dd6f61f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions filebeat/input/filestream/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,16 @@ func (e *inputTestingEnvironment) requireOffsetInRegistry(filename, inputID stri
}

id := getIDFromPath(filepath, inputID, fi)
entry, err := e.getRegistryState(id)
if err != nil {
e.t.Fatalf(err.Error())
}
var entry registryEntry
require.Eventually(e.t, func() bool {
entry, err = e.getRegistryState(id)
if err != nil {
return true
}

return expectedOffset == entry.Cursor.Offset
}, time.Second, time.Millisecond)
require.NoError(e.t, err)
require.Equal(e.t, expectedOffset, entry.Cursor.Offset)
}

Expand Down

0 comments on commit dd6f61f

Please sign in to comment.