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 Windows native support for qa-ctl tool #1961

Merged
merged 44 commits into from
Oct 1, 2021

Conversation

jmv74211
Copy link
Contributor

@jmv74211 jmv74211 commented Oct 1, 2021

Related issue
close #1900

Hello team,

The aim of this PR is to allow to run the qa-ctl tool in a Windows host. At the beggining this was a problem, since ansible, that is a main dependency used by qa-ctl, is not compatible with Windows. To solve this, I have delegated the provisioning and running stages (which are the ones that use the ansible dependency) in a docker container tasks. In summary:

  • Deployment stage: Windows can run it successfully.
  • Provision stage: Windows run a Linux docker container to run qa-ctl provision stage.
  • Running tests stage: Windows run a Linux docker container to run qa-ctl running tests stage.

Note: All the test results files are available on Windows file system.

This PR adds the following changes:

  • Add Windows support for theqa-ctl tool.
  • Add Dockerfile for running the qa-ctl tool
  • Update deployment IPs configuration range. Now it starts from x.x.x.2 instead of x.x.x.1
  • Add debug mode qa-ctl parameter
  • Improve some logs messages
  • Update Ubuntu vagrant box URL
  • Changed virtual box groups name to qa-ctl
  • Add new ansible utils module
  • Add new utils function in local_actions module
  • Add new custom exceptions classes
  • Improve custom logging class
  • Update requirements file to update Windows dependencies

Next, I show an example output of a qa-ctl Windows run:

C:\Users\jmv74211
(venv) λ qa-ctl -r test_general_settings_enabled
2021-10-01 12:03:50,279 - INFO - Validating input parameters
2021-10-01 12:03:51,207 - INFO - Pulling remote repository changes in C:\Users\jmv74211\AppData\Local\Temp\wazuh-qa local repository
2021-10-01 12:03:53,609 - INFO - Input parameters validation has passed successfully
2021-10-01 12:03:55,061 - INFO - Starting 1 instances deployment
2021-10-01 12:06:29,044 - INFO - The instances deployment has finished sucessfully
2021-10-01 12:06:29,052 - INFO - Building docker image for provisioning the instances
2021-10-01 12:06:31,941 - INFO - Running the Linux container for provisioning the instances
The Vagrant executable cannot be found. Please check if it is in the system path.
2021-10-01 10:06:40,721 - INFO - Checking hosts SSH connection
2021-10-01 10:07:01,928 - INFO - Hosts connection OK. The instances are accessible via ssh
2021-10-01 10:07:01,928 - INFO - Provisioning 1 instances
2021-10-01 10:08:51,362 - INFO - Performing a Wazuh installation healthcheck in 10.150.50.2 host
2021-10-01 10:09:30,622 - INFO - Provisioning the 10.150.50.2 host with the Wazuh QA framework using 4.2 branch.
2021-10-01 10:11:00,774 - INFO - The instances have been provisioned sucessfully
2021-10-01 12:11:01,462 - INFO - Building docker image for launching the tests
2021-10-01 12:11:03,978 - INFO - Running the Linux container for launching the tests
The Vagrant executable cannot be found. Please check if it is in the system path.
2021-10-01 10:11:13,469 - INFO - Launching 1 tests
2021-10-01 10:11:13,470 - INFO - Waiting for tests to finish
2021-10-01 10:11:28,379 - INFO - Running /tmp/wazuh-qa/tests/integration/test_vulnerability_detector/test_general_settings/test_general_settings_enabled.py test on ['10.150.50.2'] hosts
2021-10-01 10:11:40,977 - INFO -

============================= test session starts ==============================
platform linux -- Python 3.6.8, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
rootdir: /tmp/wazuh-qa/tests/integration, configfile: pytest.ini
plugins: metadata-1.11.0, testinfra-5.0.0, html-2.0.1
collected 4 items

../../tmp/wazuh-qa/tests/integration/test_vulnerability_detector/test_general_settings/test_general_settings_enabled.py . [ 25%]
ss.                                                                      [100%]

- generated html file: file:///tmp/wazuh-qa/test/integration/reports/test_report_2021_10_01_10_11_28_378781.html -
========================= 2 passed, 2 skipped in 2.70s =========================


2021-10-01 10:11:40,981 - INFO - The test run is finished
2021-10-01 12:11:41,545 - INFO - The results of /tmp/wazuh-qa/tests/integration/test_vulnerability_detector/test_general_settings/test_general_settings_enabled.py tests have been saved in C:\Users\jmv74211\AppData\Local\Temp/test_general_settings_enabled_1633082635.035109/
2021-10-01 12:11:41,551 - INFO - Destroying 1 instances
2021-10-01 12:11:53,343 - INFO - The instances have been destroyed sucessfully

jmv74211 and others added 30 commits September 17, 2021 15:41
Some extra temporary files has been added to test new changes
Necessary for running instance deployments in Windows hosts.
In addition, it improves the Logging class
Add `qa-ctl` debug mode and unifty the loggers
Replace backslash with the slash in the paths where
the input or output directory is specified.
It seems that from Python version 3.7 onwards
backslashes are interpreted as escape characters
by the re module.
This causes problems in Windows paths.

Closes: #1930
It seems that from Python version 3.7 onwards
backslashes are interpreted as escape characters
by the re module.
This causes problems in Windows paths.

Closes: #1930
@jmv74211 jmv74211 self-assigned this Oct 1, 2021
@fernandolojano fernandolojano merged commit b1cac62 into 1533-qa-ctl Oct 1, 2021
@fernandolojano fernandolojano deleted the 1900-qa-ctl-windows branch October 1, 2021 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants