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

Validate that DTT allows using the live and pre-release repository to install #5392

Merged
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ __pycache__
venv
wazuh_testing.egg-info
dist
deployability/modules/build
deployability/modules/workflow_engine.egg-info

# Python bytecode files
*.pyc
Expand Down
2 changes: 1 addition & 1 deletion deployability/modules/testing/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def parse_arguments():
parser.add_argument("--wazuh-version", required=True)
parser.add_argument("--wazuh-revision", required=True)
parser.add_argument("--wazuh-branch", required=False)
parser.add_argument("--live", required=False)
parser.add_argument("--live", required=False, default=False)

return parser.parse_args()

Expand Down
4 changes: 2 additions & 2 deletions deployability/modules/testing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class ExtraVars(BaseModel):
wazuh_revision: str
wazuh_branch: str | None = None
working_dir: str = '/tmp/tests'
live: bool = True
live: bool = False

class InputPayload(ExtraVars):
"""Input payload for testing module."""
tests: list[str]
targets: list[str]
dependencies: list[str] | None = None
cleanup: bool = True
live: bool = True
live: bool = False


@field_validator('tests', mode='before')
Expand Down
9 changes: 5 additions & 4 deletions deployability/modules/testing/tests/helpers/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ class WazuhAgent:
@staticmethod
def install_agent(inventory_path, agent_name, wazuh_version, wazuh_revision, live) -> None:

if live:
s3_url = 'packages'
release = wazuh_version[:1] + ".x"
else:
if live == "False":
s3_url = 'packages-dev'
release = 'pre-release'
else:
s3_url = 'packages'
release = wazuh_version[:1] + ".x"


os_type = HostInformation.get_os_type(inventory_path)
architecture = HostInformation.get_architecture(inventory_path)
Expand Down
20 changes: 14 additions & 6 deletions deployability/modules/testing/tests/helpers/central.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class WazuhCentralComponents:

@staticmethod
def install_aio(inventory_path, wazuh_version) -> None:
def install_aio(inventory_path, wazuh_version, live) -> None:
"""
Installs Wazuh central components (AIO) in the host

Expand All @@ -19,23 +19,31 @@ def install_aio(inventory_path, wazuh_version) -> None:
wazuh_version (str): major.minor.patch

"""
wazuh_version = '.'.join(wazuh_version.split('.')[:2])
os_name = HostInformation.get_os_name_from_inventory(inventory_path)

if live == "False":
s3_url = 'packages-dev.wazuh.com'
else:
s3_url = 'packages.wazuh.com'

rauldpm marked this conversation as resolved.
Show resolved Hide resolved
release = '.'.join(wazuh_version.split('.')[:2])


logger.info(f'Installing the Wazuh manager with https://{s3_url}/{release}/wazuh-install.sh')

if HostInformation.has_curl(inventory_path):
commands = [
f"curl -sO https://packages.wazuh.com/{wazuh_version}/wazuh-install.sh && sudo bash ./wazuh-install.sh -a --ignore-check"
f"curl -sO https://{s3_url}/{release}/wazuh-install.sh && sudo bash ./wazuh-install.sh -a --ignore-check"
]
else:
commands = [
f"wget https://packages.wazuh.com/{wazuh_version}/wazuh-install.sh && sudo bash ./wazuh-install.sh -a --ignore-check"
f"wget https://{s3_url}/{release}/wazuh-install.sh && sudo bash ./wazuh-install.sh -a --ignore-check"
]


logger.info(f'Installing Wazuh central components (AIO) in {HostInformation.get_os_name_and_version_from_inventory(inventory_path)}')
ConnectionManager.execute_commands(inventory_path, commands)


@staticmethod
def uninstall_aio(inventory_path) -> None:
"""
Expand All @@ -53,7 +61,7 @@ def uninstall_aio(inventory_path) -> None:

@staticmethod
def _install_aio_callback(wazuh_params, host_params):
WazuhCentralComponents.install_aio(host_params, wazuh_params['wazuh_version'])
WazuhCentralComponents.install_aio(host_params, wazuh_params['wazuh_version'], wazuh_params['live'])


@staticmethod
Expand Down
20 changes: 13 additions & 7 deletions deployability/modules/testing/tests/helpers/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class WazuhManager:

@staticmethod
def install_manager(inventory_path, node_name, wazuh_version) -> None:
def install_manager(inventory_path, node_name, wazuh_version, live) -> None:
"""
Installs Wazuh Manager in the host

Expand All @@ -25,18 +25,24 @@ def install_manager(inventory_path, node_name, wazuh_version) -> None:
wazuh_version (str): major.minor.patch

"""
wazuh_version = '.'.join(wazuh_version.split('.')[:2])
os_name = HostInformation.get_os_name_from_inventory(inventory_path)

if live == "False":
s3_url = 'packages-dev.wazuh.com'
else:
s3_url = 'packages.wazuh.com'
rauldpm marked this conversation as resolved.
Show resolved Hide resolved

release = '.'.join(wazuh_version.split('.')[:2])

logger.info(f'Installing the Wazuh manager with https://{s3_url}/{release}/wazuh-install.sh')

if os_name == 'debian':
commands = [
f"wget https://packages.wazuh.com/{wazuh_version}/wazuh-install.sh",
f"bash wazuh-install.sh --wazuh-server {node_name} --ignore-check"
f"wget https://{s3_url}/{release}/wazuh-install.sh && bash wazuh-install.sh --wazuh-server {node_name} --ignore-check"
]
else:
commands = [
f"curl -sO https://packages.wazuh.com/{wazuh_version}/wazuh-install.sh",
f"bash wazuh-install.sh --wazuh-server {node_name} --ignore-check"
f"curl -sO https://{s3_url}/{release}/wazuh-install.sh && bash wazuh-install.sh --wazuh-server {node_name} --ignore-check"
]
logger.info(f'Installing Manager in {HostInformation.get_os_name_and_version_from_inventory(inventory_path)}')
ConnectionManager.execute_commands(inventory_path, commands)
Expand Down Expand Up @@ -105,7 +111,7 @@ def uninstall_managers(inventories_paths=[]) -> None:

@staticmethod
def _install_manager_callback(wazuh_params, manager_name, manager_params):
WazuhManager.install_manager(manager_params, manager_name, wazuh_params['wazuh_version'])
WazuhManager.install_manager(manager_params, manager_name, wazuh_params['wazuh_version'], wazuh_params['live'])


@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ def wazuh_params(request):
wazuh_revision = request.config.getoption('--wazuh_revision')
dependencies = request.config.getoption('--dependencies')
targets = request.config.getoption('--targets')
live = request.config.getoption('--live')

return {
'wazuh_version': wazuh_version,
'wazuh_revision': wazuh_revision,
'dependencies': dependencies,
'targets': targets
'targets': targets,
'live': live
}


Expand Down Expand Up @@ -62,7 +64,7 @@ def test_installation(wazuh_params):

# Install central components and perform checkfile testing
for _, manager_params in wazuh_params['managers'].items():
WazuhCentralComponents.install_aio(manager_params, wazuh_params['wazuh_version'])
WazuhCentralComponents.install_aio(manager_params, wazuh_params['wazuh_version'], wazuh_params['live'])

# Validation of directory of the components
for manager in wazuh_params['managers'].values():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ def wazuh_params(request):
wazuh_revision = request.config.getoption('--wazuh_revision')
dependencies = request.config.getoption('--dependencies')
targets = request.config.getoption('--targets')
live = request.config.getoption('--live')

return {
'wazuh_version': wazuh_version,
'wazuh_revision': wazuh_revision,
'dependencies': dependencies,
'targets': targets
'targets': targets,
'live': live
}


Expand Down Expand Up @@ -61,7 +63,7 @@ def test_installation(wazuh_params):

# Install managers and perform checkfile testing
for manager_name, manager_params in wazuh_params['managers'].items():
WazuhManager.install_manager(manager_params, manager_name, wazuh_params['wazuh_version'])
WazuhManager.install_manager(manager_params, manager_name, wazuh_params['wazuh_version'], wazuh_params['live'])

# Validation of activity and directory of the managers
for manager in wazuh_params['managers'].values():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ tasks:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
live: False
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
Expand All @@ -107,7 +107,7 @@ tasks:
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
- live: False
foreach:
- variable: agent-os
as: agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ tasks:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
live: False
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
Expand All @@ -114,7 +114,7 @@ tasks:
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
- live: False
foreach:
- variable: agent-os
as: agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ tasks:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
live: False
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
Expand All @@ -112,7 +112,7 @@ tasks:
- component: wazuh-agent
type: package
version: 4.7.4
live: True
live: False
depends-on:
- "allocate-agent-{agent}"
- "provision-manager-{manager-os}"
Expand All @@ -137,7 +137,7 @@ tasks:
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
- live: False
foreach:
- variable: agent-os
as: agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ tasks:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
live: False
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
Expand All @@ -112,7 +112,7 @@ tasks:
- component: wazuh-agent
type: package
version: 4.7.4
live: True
live: False
depends-on:
- "allocate-agent-{agent}"
- "provision-manager-{manager-os}"
Expand All @@ -137,7 +137,7 @@ tasks:
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
- live: False
foreach:
- variable: agent-os
as: agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ tasks:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
live: False
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
Expand Down Expand Up @@ -126,7 +126,7 @@ tasks:
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
- live: False
foreach:
- variable: agent-os
as: agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ tasks:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
live: False
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
Expand All @@ -112,7 +112,7 @@ tasks:
- component: wazuh-agent
type: package
version: 4.7.4
live: True
live: False
depends-on:
- "allocate-agent-{agent}"
- "provision-manager-{manager-os}"
Expand All @@ -137,7 +137,7 @@ tasks:
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
- live: False
foreach:
- variable: agent-os
as: agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ tasks:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
live: False
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
Expand All @@ -112,7 +112,7 @@ tasks:
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
- live: False
foreach:
- variable: agent-os
as: agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ tasks:
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
- live: False

Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ tasks:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
live: False
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
Expand All @@ -108,7 +108,7 @@ tasks:
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
- live: False
foreach:
- variable: agent-os
as: agent
Expand Down
Loading