Skip to content

[SO] Fix non-deterministic ordering in nested find API integration tests#256447

Merged
gsoldevila merged 3 commits intoelastic:mainfrom
gsoldevila:fix/saved-object-find-ordering
Mar 11, 2026
Merged

[SO] Fix non-deterministic ordering in nested find API integration tests#256447
gsoldevila merged 3 commits intoelastic:mainfrom
gsoldevila:fix/saved-object-find-ordering

Conversation

@gsoldevila
Copy link
Copy Markdown
Member

Summary

Fixes an intermittent test failure in the saved object low-level find API integration tests caused by non-deterministic ES result ordering.

Elasticsearch does not guarantee a stable sort order when multiple documents have equal relevance scores. The nested search tests relied on a specific ordering of results, which varied across runs and ES versions, causing expected 'frank' to equal 'bob'-style failures.

The fix sorts results by title before making assertions, ensuring a reproducible and stable comparison in all three test cases.

Closes #244041

Made with Cursor

Elasticsearch does not guarantee a stable sort order when multiple
documents have equal relevance scores. The nested field search tests
relied on a specific result ordering that was non-deterministic,
causing intermittent failures when ES returned results in a different
order than expected.

Fix by sorting results by title before asserting, producing a stable
and reproducible order across all three test cases.

Closes elastic#244041

Made-with: Cursor
@gsoldevila gsoldevila added Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Mar 6, 2026
@gsoldevila gsoldevila marked this pull request as ready for review March 6, 2026 13:11
@gsoldevila gsoldevila requested a review from a team as a code owner March 6, 2026 13:11
@gsoldevila gsoldevila requested a review from jeramysoucy March 6, 2026 13:11
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-core (Team:Core)

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

@gsoldevila gsoldevila enabled auto-merge (squash) March 9, 2026 10:03
Copy link
Copy Markdown
Contributor

@jeramysoucy jeramysoucy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gsoldevila
Copy link
Copy Markdown
Member Author

/sync-ci

@gsoldevila gsoldevila merged commit d1aa33c into elastic:main Mar 11, 2026
18 checks passed
mbondyra added a commit to mbondyra/kibana that referenced this pull request Mar 11, 2026
…e_fix

* commit '565f7545c422192218b803874fbdf93e8d8f08ee': (27 commits)
  [Lens API] ESQL schema for XY separately for Agent and some small token optimizations (elastic#256885)
  Fix "Accessing resource attributes before async attributes settled" telemetry error (elastic#256880)
  [Security Solution][Attacks/Alerts][Attacks page][Table section] Preserver "Sort by" state on Attacks page (elastic#256717) (elastic#256795)
  [APM] Improve redirect with default date range guard (elastic#256887)
  [Security Solution][Attacks/Alerts][Attacks page][Table section] Add assignees avatars to the group component (elastic#250126) (elastic#256901)
  [Docs] add xpack.alerting.rules.maxScheduledPerMinute setting description (elastic#257041)
  [SO] Fix non-deterministic ordering in nested find API integration tests (elastic#256447)
  [Write-restricted dashboards] Update user profile retrieval for getShouldAddAccessControl (elastic#255065)
  [One Workflow] Add Scout API test scaffold and execution tests (elastic#256300)
  [Fleet] add use_apm if dynamic_signal_types are enabled (elastic#256429)
  [Fleet] ignore data streams starting with `.` in Fleet API (elastic#256625)
  [ES|QL] METRICS_INFO support: columns_after & summary (elastic#256758)
  [Agent Builder] Agent plugins: initial installation support (elastic#256478)
  [Streams] Add field descriptions and documentation-only field overrides (elastic#255136)
  [api-docs] 2026-03-11 Daily api_docs build (elastic#257023)
  [Security Solution] fix alerts page infinite loading state due to data view error (elastic#256983)
  [Logging] Add `service.*` global fields (elastic#256878)
  [Canvas] Apply embeddable transforms to embeddable elements (elastic#252191)
  [table_list_view_table] stabilize jest test (elastic#254991)
  [Obs AI] get_index_info: add unit tests (elastic#256802)
  ...
sorenlouv pushed a commit that referenced this pull request Mar 17, 2026
…sts (#256447)

## Summary

Fixes an intermittent test failure in the saved object low-level find
API integration tests caused by non-deterministic ES result ordering.

Elasticsearch does not guarantee a stable sort order when multiple
documents have equal relevance scores. The nested search tests relied on
a specific ordering of results, which varied across runs and ES
versions, causing `expected 'frank' to equal 'bob'`-style failures.

The fix sorts results by `title` before making assertions, ensuring a
reproducible and stable comparison in all three test cases.

Closes #244041

Made with [Cursor](https://cursor.com)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v9.4.0

Projects

None yet

4 participants