[Failing Test] Fixes intermittent failures in audit log integration tests #154935
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves #119267
Summary
As discussed in the issue, we believed the issue to be timing between file write and read, however this is not the case. I found that two 'saved_object_find' events were being logged - the expected user one (for a 'dashboard'), and one by the fleet app (for 'epm-packages'). Should the 'epm-packages' event get logged before the 'dashboard' event, the test fails because the first 'saved_object_find' event it finds does not contain the expected user data in the audit. This appears to happen much less frequently in CI than locally for whatever reason.
Fix
I have added additional criteria when looking for the 'saved_object_find' event so it will only find an event for a 'dashboard' object.
Testing
Flaky Test Runner: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2150