-
Notifications
You must be signed in to change notification settings - Fork 175
fix(test/e2e): rewrite assert_events
to avoid ending too soon sinsp-example log matching
#2395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…-example log matching. Signed-off-by: Federico Di Pierro <nierro92@gmail.com> Co-authored-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
/milestone 0.21.0 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Perf diff from master - unit tests
Heap diff from master - unit tests
Heap diff from master - scap file
Benchmarks diff from master
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2395 +/- ##
=======================================
Coverage 77.18% 77.18%
=======================================
Files 231 231
Lines 30361 30368 +7
Branches 4658 4657 -1
=======================================
+ Hits 23434 23441 +7
Misses 6927 6927
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
for event in expected_events: | ||
success = False | ||
received_event = None | ||
start = datetime.now() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea is:
- make use of timeout
- for each log line, try to match it against all expected events
- every time an event gets matched, remove it from the
expected_events
list - if we reach the timeout before matching all events, throw an assert failure
Previously, the code was error prone:
- imagine
len(expected_events) == 2
- imagine
sinsp.read()
returned 50 lines - we matched
expected_events[0]
- but in the remaining read lines there was also
expected_events[1]
- we did not try to match it against all the remaining lines, basically throwing them in the trash
- next for iteration, we try to match
expected_events[1]
against a new read of sinsp-example output that won't contain the requested event (because we already consumed the log lines where the event was present)
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area tests
Does this PR require a change in the driver versions?
What this PR does / why we need it:
Finally fixes e2e tests CI flakiness :)
Already restarted the CI many times; all failures i see come from container plugin 0.2.1 bug with podman, that will be solved with 0.2.2 (#2394); see CI runs: https://github.com/falcosecurity/libs/actions/runs/14865106080
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: