How to run the tests
This section explains how to run the Wazuh Indexer Plugins tests at various levels.
Full suite
To execute all tests and code quality checks (linting, documentation, formatting):
./gradlew check
This runs unit tests, integration tests, and static analysis tasks.
Unit tests
Run all unit tests across the entire project:
./gradlew test
Run unit tests for a specific plugin:
./gradlew :wazuh-indexer-content-manager:test
Integration tests
Run integration tests for a specific plugin:
./gradlew :wazuh-indexer-content-manager:integTest
YAML REST tests
Plugins can define REST API tests using YAML test specs. To run them:
./gradlew :wazuh-indexer-content-manager:yamlRestTest
Reproducible test runs
Tests use randomized seeds. When a test fails, the output includes the seed that was used. To reproduce the exact same run:
./gradlew :wazuh-indexer-content-manager:test -Dtests.seed=DEADBEEF
Replace DEADBEEF with the actual seed from the failure output.
Viewing test reports
After running tests, HTML reports are generated at:
plugins/<plugin-name>/build/reports/tests/test/index.html
Open this file in a browser to see detailed results with pass/fail status, stack traces, and timing.
For integration tests:
plugins/<plugin-name>/build/reports/tests/integTest/index.html
Code coverage
Code coverage is measured with JaCoCo. The configuration lives in gradle/coverage.gradle, which both plugins apply.
Coverage of the unit tests:
./gradlew :wazuh-indexer-content-manager:jacocoTestReport
jacocoTestReport runs the unit tests first if needed. To also measure the plugin code that runs inside the integration test cluster, add -Dtests.coverage=true. This runs integTest as well:
./gradlew :wazuh-indexer-content-manager:jacocoTestReport -Dtests.coverage=true
The reports are written in three formats:
plugins/<plugin-name>/build/reports/jacoco/test/html/index.html
plugins/<plugin-name>/build/reports/jacoco/test/jacocoTestReport.xml
plugins/<plugin-name>/build/reports/jacoco/test/jacocoTestReport.csv
Open the HTML report in a browser to browse the coverage per package, class and source line.
In CI, the Gradle check workflow runs ./gradlew check jacocoTestReport -PnumNodes=1 -Dtests.coverage=true for each modified plugin. It adds a coverage table to the job summary and uploads the reports as the coverage-<plugin-name> workflow artifact.
The workflow also runs on every push to main or to a release branch (<major>.<minor>.<patch>) that changes plugin code. There it measures both plugins, and its coverage-badge job generates the coverage and branches badges from the two CSV reports and commits them to the badges branch, in a folder named after the pushed branch (for example 5.0.0/jacoco.svg). It creates the badges branch on the first run. The README’s coverage badge shows main/jacoco.svg, the default branch’s.
The integration test nodes are stopped with
SIGKILL, so the JaCoCo agent on each node cannot write its data on exit. Instead, each node’s agent serves its data over TCP on a free port, andintegTestpulls it intobuild/jacoco/integTestCluster.execafter the last test, before the cluster stops.
Running a single test class
To run a specific test class:
./gradlew :wazuh-indexer-content-manager:test --tests "com.wazuh.contentmanager.rest.service.RestPostRuleActionTests"
Test cluster (Vagrant)
For end-to-end testing on a real Wazuh Indexer service, the repository includes a Vagrant-based test cluster at tools/test-cluster/. This provisions a virtual machine with Wazuh Indexer installed and configured.
Refer to its README.md for setup and usage instructions.
Package testing
Built packages are tested by the package builder Workflow, each test in a throwaway container:
- DEB packages — an Ubuntu 22.04 container running systemd, started by
build-scripts/run_in_systemd_container.sh. - RPM packages — Red Hat UBI 9 containers:
redhat/ubi9, orredhat/ubi9-initwhen the test needs systemd, through the same script withSYSTEMD_IMAGEset.
The tests cover:
- Installation and removal — the package installs, and removes (DEB: purges) without errors.
- Removal leftovers —
build-scripts/ci/test_purge.sh: a purge always removes thewazuh-indexeruser and group; what the service account owned in the package’s four directories belongs to root and keeps its mode, and the directories are closed to everyone but root; only a directory that still holds files is listed as kept; the engine’s runtime files and the JVM’s performance data in/tmpdo not outlive the purge; the certificates issued from the removed CA go with it, and an operator’s own pair stays; a custompath.repois left exactly as it was; a directory that cannot be handed over is reported and not listed as kept; a reinstall restores every owner and mode, and the node’s certificates chain to its CA; and the resolver refuses a pair the CA did not issue. See When the package is purged. - Credential and TLS resolution —
build-scripts/ci/test_credentials.sh. See Credential and TLS resolution. - Host tools —
build-scripts/ci/test_host_tools.sh: the maintainer scripts and the scripts the package ships run no host tool outside the declared dependencies. See Host dependencies. - Upgrades — from the previous version, with the indexer stopped and running. Only when a previous version exists.
- 4.x upgrade block —
build-scripts/ci/test_upgrade_block.sh: the package refuses to upgrade a 4.x installation.
Each script documents its requirements in its header and can also be run on a throwaway VM.
Useful test flags
-Dtests.seed=<seed>— reproduce a specific randomized test run.-Dtests.verbose=true— print test output to stdout.--tests "ClassName"— run a single test class.--tests "ClassName.methodName"— run a single test method.-x test— skip unit tests in a build.