src/wazuh_modules/inventory_harvester/qa/Readme.md
These tests verify that after certain operations are performed, the affected indexes in OpenSearch (Wazuh indexer) contain the expected elements or properly exclude unwanted items.
fim, inventory and wazuh_db.000_delete_agent) on the corresponding module component.inputs/: Contains all event JSON files to be injected by the test tool.
delta, rsync) in the filename for clarity. (The JSON content itself does not require this keyword.)result.json: An array of objects defining the expected indexes and the exact documents to be present in each index. Each object has:
{
"index_name": "some_index",
"data": [
{ "field1": "value1", "field2": "value2" },
...
]
}
config.json and template.json: Configuration files used by the inventory_harvester_testtool for that specific test.Docker Requirements Ensure Docker is running on your system since the tests rely on containerized environments.
Source Directory
You must be in the src/ directory when running these tests.
Python Virtual Environment For better isolation, create and activate a virtual environment, then install the required dependencies:
python3 -m venv venv
source venv/bin/activate
pip install -r src/wazuh_modules/inventory_harvester/qa/requirements.txt
Preparation
make clean-internals && make TARGET=server DEBUG=1 -j$(nproc)
TESTS=1 and encounter an AddressSanitizer error, run:
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.8
Executing the Tests
From the src/ directory, run:
echo "{}" > states_update_mappings.json
python -m pytest -vv -rA wazuh_modules/inventory_harvester/qa/ --log-cli-level=DEBUG
You can target a specific test by adding -k <keyword> to the pytest command. For example, to run only the tests in the fim folder:
python -m pytest -vv wazuh_modules/inventory_harvester/qa/ -k fim --log-cli-level=DEBUG
[!TIP] You can list all the available tests with
python3 -m pytest --collect-only wazuh_modules/inventory_harvester/qa/