wazuh-qa
wazuh-qa copied to clipboard
DTT1 - Testing module. Agent's OS version check procedure.
Target version | Related issue | Related PR/dev branch |
---|---|---|
4.9.0 | #5191 | 4495-dtt1-release |
Description
The current implementation of the testing module compares the result of the Wazuh agent API endpoint with the OS version reported by the inventory file.
The testing module should obtain the OS version using OS native commands.
Tasks
- [ ] Modify the module's procedure to obtain the OS version using Linux commands.
- [ ] Modify the module's procedure to obtain the OS version using Windows commands.
- [ ] Modify the module's procedure to obtain the OS version using MacOS commands.
- [ ] Run the existing tests to verify this new feature in all the platforms.
UPDATE
I'm verifying the commands to use on each platform
Ubuntu | Debian
cat /etc/os-release
marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wcontainer$ docker run -ti ubuntu:18.04
root@d5df3d3529be:/# cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.6 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.6 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wcontainer$ docker run -ti ubuntu:20.04
Unable to find image 'ubuntu:20.04' locally
20.04: Pulling from library/ubuntu
d4c3c94e5e10: Pull complete
Digest: sha256:874aca52f79ae5f8258faff03e10ce99ae836f6e7d2df6ecd3da5c1cad3a912b
Status: Downloaded newer image for ubuntu:20.04
root@b7c458033099:/# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
root@b7c458033099:/# exit
exit
marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wcontainer$ docker run -ti ubuntu:22.04
root@f15c275915c0:/# cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
root@f15c275915c0:/# exit
marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wcontainer$ docker run -ti debian:10
Unable to find image 'debian:10' locally
10: Pulling from library/debian
dbd6422b1b97: Already exists
Digest: sha256:bce46a1c39574f98c845df4a5acc6c70c211df5a6182e428c1155c33317d4920
Status: Downloaded newer image for debian:10
root@9237406da839:/# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wcontainer$ docker run -ti debian:11
Unable to find image 'debian:11' locally
11: Pulling from library/debian
646e886fa3cf: Pull complete
Digest: sha256:f860cec7ccaf31b42cd60b6a409f9dad9510ea27fca9c2864741087b4298a1e3
Status: Downloaded newer image for debian:11
root@0c7000d7527a:/# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@0c7000d7527a:/#
marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wcontainer$ docker run -ti debian:12
Unable to find image 'debian:12' locally
12: Pulling from library/debian
1468e7ff95fc: Pull complete
Digest: sha256:1aadfee8d292f64b045adb830f8a58bfacc15789ae5f489a0fedcd517a862cb9
Status: Downloaded newer image for debian:12
root@9fccf773c282:/# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@9fccf773c282:/#
Amazon Linux
cat /etc/system-release
(dtt-test) marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wazuh-qa/deployability$ docker run -ti amazonlinux:2 bash
Unable to find image 'amazonlinux:2' locally
2: Pulling from library/amazonlinux
0b2952a75473: Pull complete
Digest: sha256:3bc2191fa2d5f467217e5ca947485bc203b73c02b9a23b164818fa6e37647625
Status: Downloaded newer image for amazonlinux:2
bash-4.2# cat /etc/system-release
Amazon Linux release 2 (Karoo)
bash-4.2# exit
exit
(dtt-test) marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wazuh-qa/deployability$ docker run -ti amazonlinux:2023 bash
Unable to find image 'amazonlinux:2023' locally
2023: Pulling from library/amazonlinux
6f59c9417334: Pull complete
Digest: sha256:5478f82c47e435ed988fa12a00b623ef3c920fadd669d40c596249cf81960c4c
Status: Downloaded newer image for amazonlinux:2023
bash-5.2# cat /etc/system-release
Amazon Linux release 2023.4.20240416 (Amazon Linux)
bash-5.2# exit
exit
RedHat | Oracle | Centos
cat /etc/redhat-release
(dtt-test) marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wazuh-qa/deployability$ docker run -ti redhat/ubi9 bash
Unable to find image 'redhat/ubi9:latest' locally
latest: Pulling from redhat/ubi9
6b20e0c6c1e1: Pull complete
Digest: sha256:ed84f34cd929ea6b0c247b6daef54dd79602804a32480a052951021caf429494
Status: Downloaded newer image for redhat/ubi9:latest
[root@09792c738fc3 /]# cat /etc/redhat-release
Red Hat Enterprise Linux release 9.4 (Plow)
[root@09792c738fc3 /]# exit
exit
(dtt-test) marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wazuh-qa/deployability$ docker run -ti redhat/ubi8 bash
Unable to find image 'redhat/ubi8:latest' locally
latest: Pulling from redhat/ubi8
2efec45cd878: Pull complete
Digest: sha256:edc34f89cf9c818c2fb28b8ea1780f384db563ce4293dc0ab8e73ec01791e5af
Status: Downloaded newer image for redhat/ubi8:latest
[root@4787131b4ded /]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.9 (Ootpa)
marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wcontainerdocker run -ti oraclelinux:9
Unable to find image 'oraclelinux:9' locally
9: Pulling from library/oraclelinux
3dd1469a0b0b: Pull complete
Digest: sha256:2c8e7831ba7d71ba78094f331018bc1760ea7c02c4a9f0b59864b5f2a2055189
Status: Downloaded newer image for oraclelinux:9
[root@f89947940493 /]# cat /etc/redhat-release
Red Hat Enterprise Linux release 9.3 (Plow)
marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wcontainer$ docker run -ti centos:7
[root@b402a32e372a /]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
marcelo@marcelo-B460-AORUS-PRO-AC:~/wazuh/wcontainer$ docker run -ti centos:8
Unable to find image 'centos:8' locally
8: Pulling from library/centos
a1d0c7532777: Pull complete
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for centos:8
[root@31cbc406c150 /]# cat /etc/redhat-release
CentOS Linux release 8.4.2105
Windows
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
UPDATE
I've investigated the agent's C++ source code to define how to get the OS version on each platform.
The source code is in the src/data_provider/src/osinfo
folder in the wazuh/wazuh
repository.
I've started coding the logic to replace the current testing logic based on the info obtained from the inventory of the VM instance provided by the allocation module.
UPDATE
I've investigated the /etc/os-release
file. It is standardized and usually found in all systems
Unix systems. It will be used as the first source of information for OS version detection.
I've used Vagrant for development and committed the first version of the modifications to the repo after checking runs and fixing errors. I've launched a workflow in AWS with all the UNIX agent versions.
UPDATE
I've run a workflow file testing all Linux amd64
agents. All of the agents worked with the systemd
method (by checking the content of the /etc/os-release
file).
Tested versions
- linux-redhat-7-amd64
- linux-redhat-8-amd64
- linux-redhat-9-amd64
- linux-centos-7-amd64
- linux-centos-8-amd64
- linux-debian-10-amd64
- linux-debian-11-amd64
- linux-debian-12-amd64
- linux-ubuntu-22.04-amd64
- linux-ubuntu-18.04-amd64
- linux-ubuntu-20.04-amd64
- linux-oracle-9-amd64
- linux-amazon-2-amd64
- linux-amazon-2023-amd64
Log file: workflow.log
UPDATE
I've found a bug in the installation of the wazuh agent in rmp arm
platform.
New issue reported https://github.com/wazuh/wazuh-qa/issues/5380
Update report
Modification made to all linux system.
Test with two linux agents :green_circle: :
Input yaml:
version: 0.1
description: This workflow is used to test agents deployment for DDT1 PoC
variables:
agent-os:
- linux-redhat-7-amd64
#- linux-redhat-7-arm64
#- linux-redhat-8-amd64
#- linux-redhat-8-arm64
#- linux-redhat-9-amd64
#- linux-redhat-9-arm64
#- linux-centos-7-amd64
#- linux-centos-7-arm64
#- linux-centos-8-amd64
#- linux-centos-8-arm64
#- linux-debian-10-amd64
#- linux-debian-10-arm64
#- linux-debian-11-amd64
#- linux-debian-11-arm64
#- linux-debian-12-amd64
#- linux-debian-12-arm64
- linux-ubuntu-22.04-amd64
#- linux-ubuntu-22.04-arm64
#- linux-ubuntu-18.04-amd64
#- linux-ubuntu-18.04-arm64
#- linux-ubuntu-20.04-amd64
#- linux-ubuntu-20.04-arm64
#- linux-oracle-9-amd64
#- linux-amazon-2-amd64
#- linux-amazon-2-arm64
#- linux-amazon-2023-amd64
#- linux-amazon-2023-arm64
#- windows-desktop-10-amd64
#- windows-server-2012r2-amd64
#- windows-server-2016-amd64
#- windows-server-2019-amd64
#- windows-server-2022-amd64
macos-agent-os:
- macos-ventura-13.4.1-amd64
- macos-sonoma-14.4.1-amd64
manager-os: linux-ubuntu-22.04-amd64
infra-provider: aws
macos-infra-provider: vagrant
working-dir: /tmp/dtt1-poc
tasks:
# Unique manager allocate task
- task: "allocate-manager-{manager-os}"
description: "Allocate resources for the manager."
do:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: create
- provider: "{infra-provider}"
- size: large
- composite-name: "{manager-os}"
- inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml"
- track-output: "{working-dir}/manager-{manager-os}/track.yaml"
- label-termination-date: "1d"
- label-team: "qa"
- label-issue: "https://github.com/wazuh/wazuh-qa/issues/5191"
on-error: "abort-all"
cleanup:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: delete
- track-output: "{working-dir}/manager-{manager-os}/track.yaml"
# Unique agent allocate task
- task: "allocate-agent-{agent}"
description: "Allocate resources for the agent."
do:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: create
- provider: "{infra-provider}"
- size: small
- composite-name: "{agent}"
- inventory-output: "{working-dir}/agent-{agent}/inventory.yaml"
- track-output: "{working-dir}/agent-{agent}/track.yaml"
- label-termination-date: "1d"
- label-team: "qa"
- label-issue: "https://github.com/wazuh/wazuh-qa/issues/5191"
on-error: "abort-all"
foreach:
- variable: agent-os
as: agent
cleanup:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: delete
- track-output: "{working-dir}/agent-{agent}/track.yaml"
# Unique macOS agent allocate task
#- task: "allocate-macos-agent-{agent}"
# description: "Allocate resources for the agent."
# do:
# this: process
# with:
# path: python3
# args:
# - modules/allocation/main.py
# - action: create
# - provider: "{macos-infra-provider}"
# - size: small
# - composite-name: "{agent}"
# - inventory-output: "{working-dir}/agent-{agent}/inventory.yaml"
# - track-output: "{working-dir}/agent-{agent}/track.yaml"
# - label-termination-date: "1d"
# - label-team: "qa"
# - label-issue: "https://github.com/wazuh/wazuh-qa/issues/5191"
# on-error: "abort-all"
# foreach:
# - variable: macos-agent-os
# as: agent
# cleanup:
# this: process
# with:
# path: python3
# args:
# - modules/allocation/main.py
# - action: delete
# - track-output: "{working-dir}/agent-{agent}/track.yaml"
# Unique manager provision task
- task: "provision-manager-{manager-os}"
description: "Provision the manager."
do:
this: process
with:
path: python3
args:
- modules/provision/main.py
- inventory: "{working-dir}/manager-{manager-os}/inventory.yaml"
- install:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
# Generic agent test task
- task: "run-agent-{agent}-tests"
description: "Run tests install for the agent {agent}."
do:
this: process
with:
path: python3
args:
- modules/testing/main.py
- targets:
- wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml"
- agent: "{working-dir}/agent-{agent}/inventory.yaml"
- tests: "install,registration,basic_info"
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
foreach:
- variable: agent-os
as: agent
depends-on:
- "allocate-agent-{agent}"
- "provision-manager-{manager-os}"
# Generic macOS agent test task
#- task: "run-agent-{agent}-tests"
# description: "Run tests install for the agent {agent}."
# do:
# this: process
# with:
# path: python3
# args:
# - modules/testing/main.py
# - targets:
# - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml"
# - agent: "{working-dir}/agent-{agent}/inventory.yaml"
# - tests: "install,registration,basic_info,connection,restart,stop,uninstall"
# - component: "agent"
# - wazuh-version: "4.7.4"
# - wazuh-revision: "40717"
# - live: "True"
# foreach:
# - variable: macos-agent-os
# as: agent
# depends-on:
# - "allocate-macos-agent-{agent}"
# - "provision-manager-{manager-os}"
Result:
Test with all linux agents :green_circle: :
Input yaml:
version: 0.1
description: This workflow is used to test agents deployment for DDT1 PoC
variables:
agent-os:
- linux-redhat-7-amd64
- linux-redhat-7-arm64
- linux-redhat-8-amd64
- linux-redhat-8-arm64
- linux-redhat-9-amd64
- linux-redhat-9-arm64
- linux-centos-7-amd64
- linux-centos-7-arm64
- linux-centos-8-amd64
- linux-centos-8-arm64
- linux-debian-10-amd64
- linux-debian-10-arm64
- linux-debian-11-amd64
- linux-debian-11-arm64
- linux-debian-12-amd64
- linux-debian-12-arm64
- linux-ubuntu-22.04-amd64
- linux-ubuntu-22.04-arm64
- linux-ubuntu-18.04-amd64
- linux-ubuntu-18.04-arm64
- linux-ubuntu-20.04-amd64
- linux-ubuntu-20.04-arm64
- linux-oracle-9-amd64
- linux-amazon-2-amd64
- linux-amazon-2-arm64
- linux-amazon-2023-amd64
- linux-amazon-2023-arm64
#- windows-desktop-10-amd64
#- windows-server-2012r2-amd64
#- windows-server-2016-amd64
#- windows-server-2019-amd64
#- windows-server-2022-amd64
macos-agent-os:
- macos-ventura-13.4.1-amd64
- macos-sonoma-14.4.1-amd64
manager-os: linux-ubuntu-22.04-amd64
infra-provider: aws
macos-infra-provider: vagrant
working-dir: /tmp/dtt1-poc
tasks:
# Unique manager allocate task
- task: "allocate-manager-{manager-os}"
description: "Allocate resources for the manager."
do:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: create
- provider: "{infra-provider}"
- size: large
- composite-name: "{manager-os}"
- inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml"
- track-output: "{working-dir}/manager-{manager-os}/track.yaml"
- label-termination-date: "1d"
- label-team: "qa"
- label-issue: "https://github.com/wazuh/wazuh-qa/issues/5191"
on-error: "abort-all"
cleanup:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: delete
- track-output: "{working-dir}/manager-{manager-os}/track.yaml"
# Unique agent allocate task
- task: "allocate-agent-{agent}"
description: "Allocate resources for the agent."
do:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: create
- provider: "{infra-provider}"
- size: small
- composite-name: "{agent}"
- inventory-output: "{working-dir}/agent-{agent}/inventory.yaml"
- track-output: "{working-dir}/agent-{agent}/track.yaml"
- label-termination-date: "1d"
- label-team: "qa"
- label-issue: "https://github.com/wazuh/wazuh-qa/issues/5191"
on-error: "abort-all"
foreach:
- variable: agent-os
as: agent
cleanup:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: delete
- track-output: "{working-dir}/agent-{agent}/track.yaml"
# Unique macOS agent allocate task
#- task: "allocate-macos-agent-{agent}"
# description: "Allocate resources for the agent."
# do:
# this: process
# with:
# path: python3
# args:
# - modules/allocation/main.py
# - action: create
# - provider: "{macos-infra-provider}"
# - size: small
# - composite-name: "{agent}"
# - inventory-output: "{working-dir}/agent-{agent}/inventory.yaml"
# - track-output: "{working-dir}/agent-{agent}/track.yaml"
# - label-termination-date: "1d"
# - label-team: "qa"
# - label-issue: "https://github.com/wazuh/wazuh-qa/issues/5191"
# on-error: "abort-all"
# foreach:
# - variable: macos-agent-os
# as: agent
# cleanup:
# this: process
# with:
# path: python3
# args:
# - modules/allocation/main.py
# - action: delete
# - track-output: "{working-dir}/agent-{agent}/track.yaml"
# Unique manager provision task
- task: "provision-manager-{manager-os}"
description: "Provision the manager."
do:
this: process
with:
path: python3
args:
- modules/provision/main.py
- inventory: "{working-dir}/manager-{manager-os}/inventory.yaml"
- install:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
# Generic agent test task
- task: "run-agent-{agent}-tests"
description: "Run tests install for the agent {agent}."
do:
this: process
with:
path: python3
args:
- modules/testing/main.py
- targets:
- wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml"
- agent: "{working-dir}/agent-{agent}/inventory.yaml"
- tests: "install,registration,basic_info"
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
foreach:
- variable: agent-os
as: agent
depends-on:
- "allocate-agent-{agent}"
- "provision-manager-{manager-os}"
# Generic macOS agent test task
#- task: "run-agent-{agent}-tests"
# description: "Run tests install for the agent {agent}."
# do:
# this: process
# with:
# path: python3
# args:
# - modules/testing/main.py
# - targets:
# - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml"
# - agent: "{working-dir}/agent-{agent}/inventory.yaml"
# - tests: "install,registration,basic_info,connection,restart,stop,uninstall"
# - component: "agent"
# - wazuh-version: "4.7.4"
# - wazuh-revision: "40717"
# - live: "True"
# foreach:
# - variable: macos-agent-os
# as: agent
# depends-on:
# - "allocate-macos-agent-{agent}"
# - "provision-manager-{manager-os}"
Result:
Update report
The modifications were made to obtain the Windows version.
The unit tests were satisfactory.
Then when performing a full test, I encounter the following problem:
The agent is installed correctly, but for some reason winrm is now returning empty std_out and std_err, and the pytest validations fail. An example:
Logs:
Inside Windows agent:
The agent was installed successfully:
I continue analyzing the problem
Update report
The problem was due to the winrm version. It was updated and the unit tests were successful:
Full test:
Input yaml:
version: 0.1
description: This workflow is used to test agents deployment for DDT1 PoC
variables:
agent-os:
- windows-desktop-10-amd64
- windows-server-2012r2-amd64
- windows-server-2016-amd64
- windows-server-2019-amd64
- windows-server-2022-amd64
macos-agent-os:
- macos-ventura-13.4.1-amd64
- macos-sonoma-14.4.1-amd64
manager-os: linux-ubuntu-22.04-amd64
infra-provider: aws
macos-infra-provider: vagrant
working-dir: /tmp/dtt1-poc
tasks:
# Unique manager allocate task
- task: "allocate-manager-{manager-os}"
description: "Allocate resources for the manager."
do:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: create
- provider: "{infra-provider}"
- size: large
- composite-name: "{manager-os}"
- inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml"
- track-output: "{working-dir}/manager-{manager-os}/track.yaml"
- label-termination-date: "1d"
- label-team: "qa"
- label-issue: "https://github.com/wazuh/wazuh-qa/issues/5191"
on-error: "abort-all"
cleanup:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: delete
- track-output: "{working-dir}/manager-{manager-os}/track.yaml"
# Unique agent allocate task
- task: "allocate-agent-{agent}"
description: "Allocate resources for the agent."
do:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: create
- provider: "{infra-provider}"
- size: small
- composite-name: "{agent}"
- inventory-output: "{working-dir}/agent-{agent}/inventory.yaml"
- track-output: "{working-dir}/agent-{agent}/track.yaml"
- label-termination-date: "1d"
- label-team: "qa"
- label-issue: "https://github.com/wazuh/wazuh-qa/issues/5191"
on-error: "abort-all"
foreach:
- variable: agent-os
as: agent
cleanup:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: delete
- track-output: "{working-dir}/agent-{agent}/track.yaml"
# Unique manager provision task
- task: "provision-manager-{manager-os}"
description: "Provision the manager."
do:
this: process
with:
path: python3
args:
- modules/provision/main.py
- inventory: "{working-dir}/manager-{manager-os}/inventory.yaml"
- install:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
# Generic agent test task
- task: "run-agent-{agent}-tests"
description: "Run tests install for the agent {agent}."
do:
this: process
with:
path: python3
args:
- modules/testing/main.py
- targets:
- wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml"
- agent: "{working-dir}/agent-{agent}/inventory.yaml"
- tests: "install,registration,basic_info"
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
foreach:
- variable: agent-os
as: agent
depends-on:
- "allocate-agent-{agent}"
- "provision-manager-{manager-os}"
Result :green_circle: :
Update report
Obtaining the version from the agent was implemented based on dict_detect.sh:
#Darwin
elif [ "$(uname)" = "Darwin" ]; then
DIST_NAME="darwin"
DIST_VER=$(uname -r | sed -En 's/[^0-9]*([0-9]+).*/\1/p')
DIST_SUBVER=$(uname -r | sed -En 's/[^0-9]*[0-9]+\.([0-9]+).*/\1/p')
But for Somona it brings the wrong version and produces a failure in the test due to disparity of versions.
The following command was used, obtaining the correct version from the agent:
sw_vers -productVersion
Unit test:
Full macOS test :green_circle: :
Input yaml:
version: 0.1
description: This workflow is used to test agents deployment for DDT1 PoC
variables:
macos-agent-os:
- macos-ventura-13-amd64
- macos-ventura-13-arm64
- macos-sonoma-14-amd64
- macos-sonoma-14-arm64
manager-os: linux-ubuntu-22.04-amd64
infra-provider: aws
macos-infra-provider: vagrant
working-dir: /tmp/dtt1-poc
tasks:
# Unique manager allocate task
- task: "allocate-manager-{manager-os}"
description: "Allocate resources for the manager."
do:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: create
- provider: "{infra-provider}"
- size: large
- composite-name: "{manager-os}"
- inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml"
- track-output: "{working-dir}/manager-{manager-os}/track.yaml"
- label-termination-date: "1d"
- label-team: "qa"
- label-issue: "https://github.com/wazuh/wazuh-qa/issues/5191"
on-error: "abort-all"
cleanup:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: delete
- track-output: "{working-dir}/manager-{manager-os}/track.yaml"
# Unique macOS agent allocate task
- task: "allocate-macos-agent-{agent}"
description: "Allocate resources for the agent."
do:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: create
- provider: "{macos-infra-provider}"
- size: small
- composite-name: "{agent}"
- inventory-output: "{working-dir}/agent-{agent}/inventory.yaml"
- track-output: "{working-dir}/agent-{agent}/track.yaml"
- label-termination-date: "1d"
- label-team: "qa"
- label-issue: "https://github.com/wazuh/wazuh-qa/issues/5191"
on-error: "abort-all"
foreach:
- variable: macos-agent-os
as: agent
cleanup:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: delete
- track-output: "{working-dir}/agent-{agent}/track.yaml"
# Unique manager provision task
- task: "provision-manager-{manager-os}"
description: "Provision the manager."
do:
this: process
with:
path: python3
args:
- modules/provision/main.py
- inventory: "{working-dir}/manager-{manager-os}/inventory.yaml"
- install:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
# Generic agent test task
- task: "run-agent-{agent}-tests"
description: "Run tests install for the agent {agent}."
do:
this: process
with:
path: python3
args:
- modules/testing/main.py
- targets:
- wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml"
- agent: "{working-dir}/agent-{agent}/inventory.yaml"
- tests: "install,registration,basic_info"
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
foreach:
- variable: macos-agent-os
as: agent
depends-on:
- "allocate-macos-agent-{agent}"
- "provision-manager-{manager-os}"
Result:
Review Notes
Windows test's log has errors that should be reviewed
Update report
The tests that failed were for the Windows systems windows-desktop-10-amd64 and windows-server-2016-amd64 because instances of the small type were used to create the VMs. This causes the allocator and consequently, the test to fail because the VMs are not instantiated. The logs display:
[33m[2024-05-20 09:59:20] [WARNING] ALLOCATOR: Error on attempt 28 of 30: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))[0m
[33m[2024-05-20 10:00:12] [WARNING] ALLOCATOR: Error on attempt 29 of 30: [0m
[33m[2024-05-20 10:01:05] [WARNING] ALLOCATOR: Error on attempt 30 of 30: [0m
The maximum waiting time was exceeded and then the instance was deleted due to failure from the allocator.
Tests were carried out with instances of the large type, to verify that the PR changes had no impact on this failure and the tests were satisfactory:
Intput yaml:
version: 0.1
description: This workflow is used to test agents deployment for DDT1 PoC
variables:
agent-os:
- windows-desktop-10-amd64
- windows-server-2016-amd64
manager-os: linux-ubuntu-22.04-amd64
infra-provider: aws
working-dir: /tmp/dtt1-poc
tasks:
# Unique manager allocate task
- task: "allocate-manager-{manager-os}"
description: "Allocate resources for the manager."
do:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: create
- provider: "{infra-provider}"
- size: large
- composite-name: "{manager-os}"
- inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml"
- track-output: "{working-dir}/manager-{manager-os}/track.yaml"
- label-termination-date: "1d"
- label-team: "qa"
- label-issue: "https://github.com/wazuh/wazuh-qa/issues/5191"
on-error: "abort-all"
cleanup:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: delete
- track-output: "{working-dir}/manager-{manager-os}/track.yaml"
# Unique agent allocate task
- task: "allocate-agent-{agent}"
description: "Allocate resources for the agent."
do:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: create
- provider: "{infra-provider}"
- size: large
- composite-name: "{agent}"
- inventory-output: "{working-dir}/agent-{agent}/inventory.yaml"
- track-output: "{working-dir}/agent-{agent}/track.yaml"
- label-termination-date: "1d"
- label-team: "qa"
- label-issue: "https://github.com/wazuh/wazuh-qa/issues/5191"
on-error: "abort-all"
foreach:
- variable: agent-os
as: agent
cleanup:
this: process
with:
path: python3
args:
- modules/allocation/main.py
- action: delete
- track-output: "{working-dir}/agent-{agent}/track.yaml"
# Unique manager provision task
- task: "provision-manager-{manager-os}"
description: "Provision the manager."
do:
this: process
with:
path: python3
args:
- modules/provision/main.py
- inventory: "{working-dir}/manager-{manager-os}/inventory.yaml"
- install:
- component: wazuh-manager
type: assistant
version: 4.7.4
live: True
depends-on:
- "allocate-manager-{manager-os}"
on-error: "abort-all"
# Generic agent test task
- task: "run-agent-{agent}-tests"
description: "Run tests install for the agent {agent}."
do:
this: process
with:
path: python3
args:
- modules/testing/main.py
- targets:
- wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml"
- agent: "{working-dir}/agent-{agent}/inventory.yaml"
- tests: "install,registration,basic_info"
- component: "agent"
- wazuh-version: "4.7.4"
- wazuh-revision: "40717"
- live: "True"
foreach:
- variable: agent-os
as: agent
depends-on:
- "allocate-agent-{agent}"
- "provision-manager-{manager-os}"
Result :green_circle: :
Review Notes
LGTM
LGTM