Skip to content

Add new policy_api_format setting in system tests to force the use of an specific policy API format#1103

Merged
jsoriano merged 5 commits intoelastic:mainfrom
jsoriano:policy-api-format
Mar 5, 2026
Merged

Add new policy_api_format setting in system tests to force the use of an specific policy API format#1103
jsoriano merged 5 commits intoelastic:mainfrom
jsoriano:policy-api-format

Conversation

@jsoriano
Copy link
Copy Markdown
Member

@jsoriano jsoriano commented Mar 4, 2026

elastic/elastic-package#3307 adds a new setting that allows to select per test the format used in policy API requests.

This change includes the definition for this setting.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e597720f-06fa-46fb-a25a-26121f50e47f

📥 Commits

Reviewing files that changed from the base of the PR and between 8683f28 and 3f65298.

📒 Files selected for processing (6)
  • code/go/pkg/validator/validator_test.go
  • spec/changelog.yml
  • spec/integration/data_stream/_dev/test/config.spec.yml
  • spec/integration/data_stream/_dev/test/policy/config.spec.yml
  • spec/integration/data_stream/_dev/test/system/config.spec.yml
  • test/packages/good_v3/data_stream/foo/_dev/test/policy/test-default.yml
🚧 Files skipped from review as they are similar to previous changes (2)
  • spec/changelog.yml
  • code/go/pkg/validator/validator_test.go

📝 Walkthrough

Walkthrough

Adds an optional data_stream test configuration property policy_api_format (enum: "legacy", "simplified") to test schema files and policy config schema. Introduces validation that rejects other values, a failing validator test case for an invalid value, a new bad test package (test/packages/bad_policy_api_format) with invalid policy_api_format, and a passing example in test/packages/good_v3. Also adds a changelog entry for version 3.6.0-next.

Possibly related PRs

  • elastic/package-spec PR 1102: Modifies the same validator test (code/go/pkg/validator/validator_test.go) by updating TestValidateFile entries, indicating a strong code-level overlap.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@test/packages/bad_policy_api_format/data_stream/foo/elasticsearch/ingest_pipeline/default.yml`:
- Around line 3-10: The ingest pipeline fixture is invalid because the processor
lacks a tag and the on_failure handler does not set event.kind or the required
failure context fields; update the processors entry (the "- set" that sets
field: sample_field) to include a tag (e.g., tag: sample_set) and replace the
on_failure block (the "- set" that sets field: error.message value: '{{
_ingest.on_failure_message }}' ) with handlers that set event.kind:
pipeline_error and set error.message and other fields to include '{{
_ingest.on_failure_processor_type }}', '{{ _ingest.on_failure_processor_tag }}',
and '{{ _ingest.pipeline }}' per the required contract so the pipeline is valid
and only triggers the intended policy_api_format error.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4f9a8f56-57ee-4e6e-8f59-fc892bad9151

📥 Commits

Reviewing files that changed from the base of the PR and between 5f23052 and 9d7647d.

⛔ Files ignored due to path filters (2)
  • test/packages/bad_policy_api_format/img/sample-logo.svg is excluded by !**/*.svg
  • test/packages/bad_policy_api_format/img/sample-screenshot.png is excluded by !**/*.png
📒 Files selected for processing (13)
  • code/go/pkg/validator/validator_test.go
  • spec/changelog.yml
  • spec/integration/data_stream/_dev/test/system/config.spec.yml
  • test/packages/bad_policy_api_format/LICENSE.txt
  • test/packages/bad_policy_api_format/changelog.yml
  • test/packages/bad_policy_api_format/data_stream/foo/_dev/test/system/test-default-config.yml
  • test/packages/bad_policy_api_format/data_stream/foo/agent/stream/stream.yml.hbs
  • test/packages/bad_policy_api_format/data_stream/foo/elasticsearch/ingest_pipeline/default.yml
  • test/packages/bad_policy_api_format/data_stream/foo/fields/base-fields.yml
  • test/packages/bad_policy_api_format/data_stream/foo/manifest.yml
  • test/packages/bad_policy_api_format/docs/README.md
  • test/packages/bad_policy_api_format/manifest.yml
  • test/packages/good_v3/data_stream/foo/_dev/test/system/test-default-config.yml

Comment on lines +170 to +181
policy_api_format:
description: |-
Tests can create policies using the Fleet APIs with different formats. The "legacy" format requires to
send variables with hints about their type, and defaults are not managed automatically.
The newer, "simplified" format has better format support for variables and don't allow to include hints,
it also uses defaults automatically, and requires explicit enablement or disablement of inputs and streams.
In most cases tests should not set this value. The main use case is to set it to "legacy" for cases that
cannot be fully supported with the newer "simplified" format.
type: string
enum:
- legacy
- simplified
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR adds this new setting just for system tests, would it be helpful to add this same setting to the configuration of policy tests?

It looks to me that they could have the same issues that you have found in system tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I haven't found any package having problems with this in policy tests, so I decided to add it only to system tests. But it is true that we have much less policy than system tests. Let me try to reproduce it...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Confirmed with a test package, I will add it, just in case it is needed when adding policy tests to some package.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added in 3ecb3d8

@elasticmachine
Copy link
Copy Markdown

💚 Build Succeeded

History

cc @jsoriano

@jsoriano jsoriano merged commit 0887128 into elastic:main Mar 5, 2026
4 checks passed
@jsoriano jsoriano deleted the policy-api-format branch March 5, 2026 12:59
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.

3 participants