Skip to content

Commit

Permalink
Merge pull request #2409 from wazuh/1821-migrate-doc-wpk
Browse files Browse the repository at this point in the history
Add wpk test documentation
  • Loading branch information
snaow committed Jan 27, 2022
2 parents 14ad005 + 80525c7 commit 92a8bfe
Show file tree
Hide file tree
Showing 3 changed files with 303 additions and 12 deletions.
110 changes: 106 additions & 4 deletions tests/integration/test_wpk/test_wpk_agent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,68 @@
# Copyright (C) 2015-2021, Wazuh Inc.
# Created by Wazuh, Inc. <info@wazuh.com>.
# This program is free software; you can redistribute it and/or modify it under the terms of GPLv2

'''
copyright: Copyright (C) 2015-2021, Wazuh Inc.
Created by Wazuh, Inc. <info@wazuh.com>.
This program is free software; you can redistribute it and/or modify it under the terms of GPLv2
type: integration
brief: Agents can be upgraded remotely. This upgrade is performed by the manager which
sends each registered agent a WPK (Wazuh signed package) file that contains the files
needed to upgrade the agent to the new version. These tests ensure, on the agent side,
that the WPK upgrade works correctly.
tier: 0
modules:
- wpk
components:
- agent
daemons:
- wazuh-authd
- wazuh-remoted
os_platform:
- linux
- windows
os_version:
- Arch Linux
- Amazon Linux 2
- Amazon Linux 1
- CentOS 8
- CentOS 7
- CentOS 6
- Ubuntu Focal
- Ubuntu Bionic
- Ubuntu Xenial
- Ubuntu Trusty
- Debian Buster
- Debian Stretch
- Debian Jessie
- Debian Wheezy
- Red Hat 8
- Red Hat 7
- Red Hat 6
- Windows 10
- Windows 8
- Windows 7
- Windows Server 2016
- Windows Server 2012
- Windows Server 2003
references:
- https://documentation.wazuh.com/current/user-manual/agents/remote-upgrading/upgrading-agent.html
pytest_args:
- wpk_version: Specify the version to upgrade
- wpk_package_path: Specify the path to the wpk package
tags:
- wpk
'''
import hashlib
import os
import platform
Expand Down Expand Up @@ -358,6 +419,47 @@ def prepare_agent_version(get_configuration):
@mark_skip_agentLinux
def test_wpk_agent(get_configuration, prepare_agent_version, download_wpk,
configure_environment, start_agent):
'''
description: Upgrade the agent by WPK package, checking
the expected messages are correct.
wazuh_min_version: 4.2.0
parameters:
- get_configuration:
type: fixture
brief: Get configurations from the module.
- prepare_agent_version:
type: fixture
brief: Prepare the initial agent version to match the expected.
- download_wpk:
type: fixture
brief: Download the WPK package to upgrade the agent.
- configure_environment:
type: fixture
brief: Configure a custom environment for testing.
- start_agent:
type: fixture
brief: Start the agent, as well as the remoted and authd simulators.
input_description: Test case metadata
assertions:
- Verify that initial agent version matches the expected
- Verify the successful upgrade proccess
- Verify the upgrade result code is the expected or the error message is the expected
- Verify notification status was the expected
- Verify the end version matches the expected
expected_output:
- r'Upgrade process result'
- r'Upgrade result code'
- r'Notification status'
- r'End version'
tags:
- wpk
'''
metadata = get_configuration['metadata']
expected = metadata['results']

Expand Down
103 changes: 99 additions & 4 deletions tests/integration/test_wpk/test_wpk_manager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,64 @@
# Copyright (C) 2015-2021, Wazuh Inc.
# Created by Wazuh, Inc. <info@wazuh.com>.
# This program is free software; you can redistribute it and/or modify it under the terms of GPLv2

'''
copyright: Copyright (C) 2015-2021, Wazuh Inc.
Created by Wazuh, Inc. <info@wazuh.com>.
This program is free software; you can redistribute it and/or modify it under the terms of GPLv2
type: integration
brief: Agents can be upgraded remotely. This upgrade is performed by the manager which
sends each registered agent a WPK (Wazuh signed package) file that contains the files
needed to upgrade the agent to the new version. These tests ensure, on the manager side,
that the WPK upgrade works correctly.
tier: 0
modules:
- wpk
components:
- manager
daemons:
- wazuh-monitord
- wazuh-remoted
- wazuh-modulesd
- wazuh-db
os_platform:
- linux
- windows
os_version:
- Arch Linux
- Amazon Linux 2
- Amazon Linux 1
- CentOS 8
- CentOS 7
- CentOS 6
- Ubuntu Focal
- Ubuntu Bionic
- Ubuntu Xenial
- Ubuntu Trusty
- Debian Buster
- Debian Stretch
- Debian Jessie
- Debian Wheezy
- Red Hat 8
- Red Hat 7
- Red Hat 6
references:
- https://documentation.wazuh.com/current/user-manual/agents/remote-upgrading/upgrading-agent.html
pytest_args:
- wpk_version: Specify the version to upgrade
- wpk_package_path: Specify the path to the wpk package
tags:
- wpk
'''
import os
import pytest
import time
Expand Down Expand Up @@ -875,6 +932,44 @@ def remove_current_wpk():
@pytest.mark.skip(reason="Blocked by issue wazuh-qa#2203, when is fixed we can enable this test again")
def test_wpk_manager(remove_current_wpk, set_debug_mode, get_configuration, configure_environment,
restart_service, configure_agents):
'''
description: Prepare an environment with different agents to test WPK upgrade,
with different scenarios containing agents already updated, agents that
can not be updated, repository not reachable, disconnected agents, etc.
wazuh_min_version: 4.2.0
parameters:
- set_debug_mode:
type: fixture
brief: Set the debug mode in the manager.
- get_configuration:
type: fixture
brief: Get configurations from the module.
- configure_environment:
type: fixture
brief: Configure a custom environment for testing.
- restart_service:
type: fixture
brief: Restart Wazuh manager.
- configure_agents:
type: fixture
brief: Configure all simulated agents.
input_description: Test case metadata
assertions:
- Verify that version and HTTP are the expected
- Verify that successful upgrade proccess
- Verify the first attemp is successful
- Verify the results are the expected
expected_output:
- r'Upgrade process result'
tags:
- wpk
'''
metadata = get_configuration.get('metadata')
protocol = metadata['protocol']
expected_status = metadata['status']
Expand Down
102 changes: 98 additions & 4 deletions tests/integration/test_wpk/test_wpk_manager_task_states.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,64 @@
# Copyright (C) 2015-2021, Wazuh Inc.
# Created by Wazuh, Inc. <info@wazuh.com>.
# This program is free software; you can redistribute it and/or modify it under the terms of GPLv2

'''
copyright: Copyright (C) 2015-2021, Wazuh Inc.
Created by Wazuh, Inc. <info@wazuh.com>.
This program is free software; you can redistribute it and/or modify it under the terms of GPLv2
type: integration
brief: Agents can be upgraded remotely. This upgrade is performed by the manager which
sends each registered agent a WPK (Wazuh signed package) file that contains the files
needed to upgrade the agent to the new version. These tests ensure, the behaviour of
the WPK upgrade on the manager side, in case of the manager stopped before finishing
the upgrade.
tier: 0
modules:
- wpk
components:
- manager
daemons:
- wazuh-monitord
- wazuh-remoted
- wazuh-modulesd
- wazuh-db
os_platform:
- linux
os_version:
- Arch Linux
- Amazon Linux 2
- Amazon Linux 1
- CentOS 8
- CentOS 7
- CentOS 6
- Ubuntu Focal
- Ubuntu Bionic
- Ubuntu Xenial
- Ubuntu Trusty
- Debian Buster
- Debian Stretch
- Debian Jessie
- Debian Wheezy
- Red Hat 8
- Red Hat 7
- Red Hat 6
references:
- https://documentation.wazuh.com/current/user-manual/agents/remote-upgrading/upgrading-agent.html
pytest_args:
- wpk_version: Specify the version to upgrade
- wpk_package_path: Specify the path to the wpk package
tags:
- wpk
'''
import json
import os
import socket
Expand Down Expand Up @@ -204,6 +261,43 @@ def overwrite_node_name(value):
@pytest.mark.skip(reason="Blocked by issue wazuh-qa#2203, when is fixed we can enable this test again")
def test_wpk_manager_task_states(get_configuration, configure_environment,
restart_service, configure_agents):
'''
description: Agents can be upgraded remotely. This upgrade is performed by the manager which
sends each registered agent a WPK (Wazuh signed package) file that contains the files
needed to upgrade the agent to the new version. These tests ensure, the behaviour of
the WPK upgrade on the manager side, in case of the manager stopped before finishing
the upgrade.
wazuh_min_version: 4.2.0
parameters:
- get_configuration:
type: fixture
brief: Get configurations from the module.
- configure_environment:
type: fixture
brief: Configure a custom environment for testing.
- restart_service:
type: fixture
brief: Restart Wazuh manager.
- configure_agents:
type: fixture
brief: Configure all simulated agents.
input_description: Test case metadata
assertions:
- Verify that the first attemp is success
- Verify the upgrade status matches the expected
- Verify the upgrade status after restarting
- Verify the upgrade response matches the expected
expected_output:
- r'Upgrade process result'
tags:
- wpk
'''
metadata = get_configuration.get('metadata')
protocol = metadata['protocol']
first_status = metadata['first_status']
Expand Down

0 comments on commit 92a8bfe

Please sign in to comment.