Skip to content

Commit

Permalink
fix(#5229): Fixes around install validation and test yamls
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-akim committed Apr 22, 2024
1 parent 0062465 commit ddd25c4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 13 deletions.
14 changes: 10 additions & 4 deletions deployability/modules/testing/tests/helpers/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,16 @@ def install_agents(inventories_paths=[], wazuh_versions=[], wazuh_revisions=[],
def register_agent(inventory_path, manager_path):

with open(manager_path, 'r') as yaml_file:
manager_path = yaml.safe_load(yaml_file)
manager_path_yaml = yaml.safe_load(yaml_file)
manager_host = manager_path_yaml.get('ansible_host')

host = manager_path.get('ansible_host')
with open(inventory_path, 'r') as yaml_file:
inventory_path_yaml = yaml.safe_load(yaml_file)
agent_host = inventory_path_yaml.get('ansible_host')

os_type = HostInformation.get_os_type(inventory_path)
if os_type == 'linux':
host_ip = HostInformation.get_internal_ip_from_aws_dns(host) if 'amazonaws' in host else host
host_ip = HostInformation.get_internal_ip_from_aws_dns(manager_host) if 'amazonaws' in manager_host else manager_host
commands = [
f"sed -i 's/<address>MANAGER_IP<\/address>/<address>{host_ip}<\/address>/g' {WAZUH_CONF}",
"systemctl restart wazuh-agent"
Expand All @@ -108,7 +111,10 @@ def register_agent(inventory_path, manager_path):
assert host_ip in Executor.execute_command(inventory_path, f'cat {WAZUH_CONF}'), logger.error(f'Error configuring the Manager IP ({host_ip}) in: {HostInformation.get_os_name_and_version_from_inventory(inventory_path)} agent')

elif os_type == 'macos':
host_ip = HostInformation.get_internal_ip_from_aws_dns(host) if 'amazonaws' in host else HostInformation.get_public_ip_from_aws_dns(host)
if 'amazonaws' in manager_host and 'amazonaws' in agent_host:
host_ip = HostInformation.get_internal_ip_from_aws_dns(manager_host)
else:
host_ip = HostInformation.get_public_ip_from_aws_dns(manager_host)
commands = [
f"sed -i '.bak' 's/<address>MANAGER_IP<\/address>/<address>{host_ip}<\/address>/g' /Library/Ossec/etc/ossec.conf",
"/Library/Ossec/bin/wazuh-control restart"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def test_wazuh_os_version(wazuh_params):
expected_condition_func = lambda: 'active' == WazuhAgent.get_agent_status(wazuh_api, agent_names)
Waits.dynamic_wait(expected_condition_func, cycles=20, waiting_time=30)
assert HostInformation.get_os_version_from_inventory(agent_params) in WazuhAgent.get_agent_os_version_by_name(wazuh_api, agent_names), logger.error('There is a mismatch between the OS version and the OS version of the installed agent')
assert HostInformation.get_os_name_from_inventory(agent_params) in WazuhAgent.get_agent_os_name_by_name(wazuh_api, agent_names).replace(' ', ''), logger.error('There is a mismatch between the OS name and the OS name of the installed agent')
if HostInformation.get_os_type(agent_params) == 'linux':
assert HostInformation.get_os_name_from_inventory(agent_params) in WazuhAgent.get_agent_os_name_by_name(wazuh_api, agent_names).replace(' ', ''), logger.error('There is a mismatch between the OS name and the OS name of the installed agent')
elif HostInformation.get_os_type(agent_params) == 'macos':
assert 'macos' in WazuhAgent.get_agent_os_name_by_name(wazuh_api, agent_names).replace(' ', ''), logger.error('There is a mismatch between the OS name and the OS name of the installed agent')


def test_wazuh_version(wazuh_params):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def setup_test_environment(wazuh_params):
updated_agents = {}
for agent_name, agent_params in wazuh_params['agents'].items():
Utils.check_inventory_connection(agent_params)

if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params):
if HostInformation.get_client_keys(agent_params) != []:
client_name = HostInformation.get_client_keys(agent_params)[0]['name']
Expand Down Expand Up @@ -85,7 +84,6 @@ def test_installation(wazuh_params):
for agent_names, agent_params in wazuh_params['agents'].items():
WazuhAgent.perform_install_and_scan_for_agent(agent_params, agent_names, wazuh_params)


# Testing installation directory
for agent_names, agent_params in wazuh_params['agents'].items():
if HostInformation.get_os_type(agent_params) == 'linux':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ version: 0.1
description: This workflow is used to test agents' deployment for DDT1 PoC
variables:
agent-os:
- linux-oracle-9-amd64
- macos-sonoma-14.3-arm64

# Run one at a time as there are limitations on the number of hosts
#- macos-ventura-13.6.4-arm64
#- macos-sonoma-14.3-amd64
#- macos-ventura-13.6.4-amd64
manager-os: linux-ubuntu-22.04-amd64
infra-provider: vagrant
infra-provider: aws
working-dir: /tmp/dtt1-poc

tasks:
Expand Down Expand Up @@ -53,6 +57,7 @@ tasks:
- track-output: "{working-dir}/agent-{agent}/track.yaml"
- label-termination-date: "1d"
- label-team: "qa"
on-error: "abort-all"
foreach:
- variable: agent-os
as: agent
Expand Down Expand Up @@ -84,6 +89,7 @@ tasks:
live: True
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"


# Generic agent test task
Expand All @@ -98,7 +104,7 @@ tasks:
- targets:
- wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml"
- agent: "{working-dir}/agent-{agent}/inventory.yaml"
- tests: "install,registration,restart,stop,uninstall"
- tests: "install,registration,basic_info,connection,restart,stop,uninstall"
- component: "agent"
- wazuh-version: "4.7.3"
- wazuh-revision: "40714"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ tasks:
- targets:
- wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml"
- agent: "{working-dir}/agent-{agent}/inventory.yaml"
- tests: "install,registration,restart,stop,uninstall"
- tests: "install,registration,basic_info,connection,restart,stop,uninstall"
- component: "agent"
- wazuh-version: "4.7.3"
- wazuh-revision: "40714"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ version: 0.1
description: This workflow is used to test agents' deployment for DDT1 PoC
variables:
agent-os:
- macos-sonoma-14.3-arm64
- macos-sonoma-14.0-arm64

# Run one at a time as there are limitations on the number of hosts
#- macos-ventura-13.4.1-arm64
manager-os: linux-ubuntu-22.04-amd64
infra-provider: aws
infra-provider: vagrant
working-dir: /tmp/dtt1-poc

tasks:
Expand Down

0 comments on commit ddd25c4

Please sign in to comment.