fix(e2e): address flakiness for internal/events test#7804
Conversation
The events e2e test asserted events at fixed positions in a list sorted by .metadata.creationTimestamp. KEDA emits several events for a single ScaledObject/ScaledJob within the same second, and events.k8s.io creationTimestamp only has 1s granularity, so same-second events sort non-deterministically. After kedacore#7781 migrated event recording to events.k8s.io, "Started scalers watch" [1] and "ScaledJob is ready for scaling" [2] started swapping positions, failing the test every night. Match the expected reason/note pair against any event emitted for the resource instead of a fixed index, removing the ordering dependency. Signed-off-by: Jan Wozniak <[email protected]>
|
Thank you for your contribution! 🙏 Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected. While you are waiting, make sure to:
Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient. Learn more about our contribution guide. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
/run-e2e internals/events passed tests: 1failed tests: 0 |
There was a problem hiding this comment.
Pull request overview
This PR fixes flakiness in the events e2e test by removing the dependence on event ordering. Previously, the test asserted events at fixed indices in a list sorted by creationTimestamp, but since events.k8s.io events emitted within the same second sort non-deterministically (creationTimestamp has 1s granularity), the test became unreliable after the migration to events.k8s.io in #7781. The test now scans all matching events for the expected reason/note pair.
Changes:
- Removed the
indexparameter fromcheckingEventand updated all call sites. - Replaced the
jsonpathindex-based query with a JSON dump and a scan over allitems. - Added
encoding/jsonimport for unmarshaling event lists.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
) The events e2e test asserted events at fixed positions in a list sorted by .metadata.creationTimestamp. KEDA emits several events for a single ScaledObject/ScaledJob within the same second, and events.k8s.io creationTimestamp only has 1s granularity, so same-second events sort non-deterministically. After kedacore#7781 migrated event recording to events.k8s.io, "Started scalers watch" [1] and "ScaledJob is ready for scaling" [2] started swapping positions, failing the test every night. Match the expected reason/note pair against any event emitted for the resource instead of a fixed index, removing the ordering dependency. Signed-off-by: Jan Wozniak <[email protected]> Signed-off-by: Yurii Shcherbak <[email protected]>
The events e2e test asserted events at fixed positions in a list sorted by
.metadata.creationTimestamp. KEDA emits several events for a singleScaledObject/ScaledJobwithin the same second, andevents.k8s.iocreationTimestamponly has 1s granularity, so same-second events sort non-deterministically. After #7781 migrated event recording toevents.k8s.io, the already flaky test became failing almost always.Match the expected reason/note pair against any event emitted for the resource instead of a fixed index, removing the ordering dependency.