Skip to content

Policy tests: order-independent OTel ID normalization#3318

Merged
mrodm merged 4 commits intoelastic:mainfrom
mrodm:fix_ordering_clean_policy_tests
Mar 2, 2026
Merged

Policy tests: order-independent OTel ID normalization#3318
mrodm merged 4 commits intoelastic:mainfrom
mrodm:fix_ordering_clean_policy_tests

Conversation

@mrodm
Copy link
Copy Markdown
Contributor

@mrodm mrodm commented Feb 27, 2026

Relates #3295

This PR replaces the regex-based OTel component ID replacement with a tree-based normalization (normalizePolicyToCanonical).

This new process normalizes the OTel sections (extensions, receivers, processors, etc.) by sorting variable keys so equivalent policies with different map key order compare equal.

Add tests for the new normalization behavior.

Author's Checklist


Generated PR with the assistance of Cursor AI.

Implement normalizePolicyToCanonical that rewrites OTel component IDs to
deterministic type/componentid-N on the decoded YAML tree. Variable keys
in extensions, receivers, processors, connectors, exporters, and
service.pipelines are sorted by canonical value before assignment so
equivalent policies with different map key order produce the same output.
Eliminate the replaceOTelComponentIDs function and integrate its logic into cleanPolicy. This change simplifies the policy cleaning process by directly normalizing the policy YAML to a canonical format, ensuring consistent output regardless of map key order. The updated implementation enhances readability and maintainability of the code.
@mrodm mrodm self-assigned this Feb 27, 2026
@mrodm
Copy link
Copy Markdown
Contributor Author

mrodm commented Feb 27, 2026

test integrations

@elastic-vault-github-plugin-prod
Copy link
Copy Markdown

Created or updated PR in integrations repository to test this version. Check elastic/integrations#17598

@elasticmachine
Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

cc @mrodm

Copy link
Copy Markdown
Contributor

@teresaromero teresaromero left a comment

Choose a reason for hiding this comment

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

👍🏻 thanks!

@mrodm mrodm merged commit c8d48ae into elastic:main Mar 2, 2026
3 checks passed
@mrodm mrodm deleted the fix_ordering_clean_policy_tests branch March 2, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants