elastic / elastic/elastic-package
[Policy tests] Allow to run specific policy tests for a given policy template
- Dominant language
- Go
- Stars
- 72
- Forks
- 141
- Avg merge
- 19h 42m
- Merged PRs (30d)
- 55
Description
Currently, policy tests run by `elastic-package` can define in their test configuration files which input should be used to create the required Agent Policy from the package:
https://github.com/elastic/elastic-package/blob/9b25a56489d75571d7b9dd7e97a3e68891e2c396/internal/testrunner/runners/policy/testconfig.go#L19
Example input package policy test configuration:
https://github.com/elastic/integrations/blob/cea5860a9ffadff5d683173f9a5f92766174c92e/packages/o365/data_stream/audit/_dev/test/policy/test-cel-all.yml#L1
Found in https://github.com/elastic/integrations/pull/17117/#issuecomment-3824199231 , that it should be needed also to indicate which policy template to use in the policy test configuration file. In the scenario of that PR, there were two policy templates defined (`prometheusreceiver` and `prometheusreceiver_raw`) in the input package and both policy templates in the manifest declared the same input (`otelcol`).
It would be needed to add support to define (optionally) which policy template is going to be used specifically in the test configuration file, as it is possible to do in system tests:
https://github.com/elastic/elastic-package/blob/9b25a56489d75571d7b9dd7e97a3e68891e2c396/internal/testrunner/runners/system/test_config.go#L37
https://github.com/elastic/elastic-package/blob/9b25a56489d75571d7b9dd7e97a3e68891e2c396/internal/testrunner/runners/system/tester.go#L1049
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with internal/testrunner/runners/policy/testconfig.go and compare it with internal/testrunner/runners/system/test_config.go and tester.go. Review the example policy test YAML and run the relevant policy tests; done means a policy test configuration can optionally select a specific policy template when multiple templates use the same input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100