Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test to check the version of the agent database #3768

Merged
merged 6 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Release report: TBD

### Added

- Add integration test to check agent database version ([#3768](https:/wazuh/wazuh-qa/pull/3768)) \- (Tests)
- Fix Yara and VirusTotal E2E basic usage tests ([#3660](https:/wazuh/wazuh-qa/pull/3660))
- Add new test to check if syslog message are parsed correctrly in the `archives.json` file ([#3609](https:/wazuh/wazuh-qa/pull/3609)) \- (Framework + Tests)
- Add new logging tests for analysisd EPS limitation ([#3509](https:/wazuh/wazuh-qa/pull/3509)) \- (Framework + Tests)
Expand Down
55 changes: 55 additions & 0 deletions tests/integration/test_wazuh_db/test_agent_database_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from wazuh_testing.modules import TIER0, LINUX, SERVER
from wazuh_testing.wazuh_db import query_wdb
from wazuh_testing.tools import agent_simulator as ag

# Marks
pytestmark = [TIER0, LINUX, SERVER]

# Variables
expected_database_version = '10'


# Tests
def test_agent_database_version(restart_wazuh_daemon):
'''
description: Check that the agent database version is the expected one. To do this, it performs a query to the agent
database that gets the database version.

test_phases:
- setup:
- Restart wazuh-manager service.
- test:
- Get the version of the manager database through the socket
- Get the version of the agent database through the socket
- Check that the manager database version is the expected one.
- Check that the agent database version is the expected one.

wazuh_min_version: 4.4.0

parameters:
- restart_wazuh_daemon:
type: fixture
brief: Restart the wazuh service.

assertions:
- Verify that database version is the expected one.

expected_output:
- Database version: 10

tags:
- wazuh_db
- wdb_socket
'''
agents = ag.create_agents(1, 'localhost')
ag.connect(agents[0])

manager_version = query_wdb("agent 0 sql SELECT value FROM metadata WHERE key='db_version'")[0]['value']
agent_version = query_wdb(f"agent {agents[0].id} sql SELECT value FROM metadata WHERE key='db_version'")[0]['value']

assert manager_version == expected_database_version, 'The manager database version is not the expected one. \n' \
f'Expected version: {expected_database_version}\n'\
f'Obtained version: {manager_version}'
assert agent_version == expected_database_version, 'The agent database version is not the expected one. \n' \
f'Expected version: {expected_database_version}\n'\
f'Obtained version: {agent_version}'