wazuh / wazuh-qa

Wazuh - Quality Assurance
GNU General Public License v2.0
61 stars 30 forks source link

Investigate and document tests - Check Files #4277

Closed Deblintrake09 closed 5 months ago

Deblintrake09 commented 10 months ago
Parent issue https://github.com/wazuh/wazuh-qa/issues/4241
Pipeline state :yellow_circle:
Tests state :yellow_circle:
Jenkins link
Branch used 4.4

Description

This issue aims to analyze and document all about the Check Files test suite, located in wazuh-qa/tests/check_files. Also Jenkins automation state, Jenkins parameters, pytest location, steps in the test and current state of it.

The wazuh-jenkins repository contains a different version of the Check Files located in https://github.com/wazuh/wazuh-jenkins/blob/master/quality/tests/generic/common_files/check_files.py. This test will also be researched as part of this issue.

State of check_files in wazuh-qa :red_circle:

State of check_files in wazuh-jenkins :green_circle:

Deblintrake09 commented 10 months ago

Research on Check Files in wazuh-qa

What is being tested

The tests located in the Wazuh-qa repository check the files in the system and the difference of files after a given install, update or uninstall process.

State

How to run tests

To check Installation files:

To check file changes during upgrade:

To check uninstallation files:

Parameters for check_files script

Parameters for the test

NOTES: Both parameters are required as this is the data used by the test to validate the changes.

Local testing result :red_circle:

Testing could not be completed:

Testing results - Check wazuh is not installed ``` # ls /var/ossec ls: cannot access '/var/ossec': No such file or directory ``` - Launch check_files.py ``` # cd /vagrant/wazuh-qa/deps/wazuh_testing/wazuh_testing/scripts/ #python3 check_files.py -o /vagrant/pre-install.json -d 2023-07-04 16:24:30,904 - INFO - Ignoring the following paths: [] 2023-07-04 16:24:30,904 - INFO - Getting check-files data from / ```
Deblintrake09 commented 10 months ago

Research on Check Files in wazuh-jenkins

What is tested

This check_files script is a Python script that checks that with a given installed version of wazuh, the expected file structure and permissions are found.

The script uses a series of JSON files that list the expected files, permissions in the different versions of wazuh.

State :green_circle:

Usage status

Used files

JSON data structure format

Failure example:

When failing, the error will state what was expected and what was found, displayed in the following way:

17:22:07
17:22:07 Different:
17:22:07 /var/ossec/.ssh [Wrong: mode]
17:22:07 Expected: root ossec 0700 # drwx------
17:22:07 Found: root ossec 0750 # drwxr-x---
17:22:07

17:22:07 Please review your files.

Parameters

rauldpm commented 10 months ago

Review notes

Deblintrake09 commented 10 months ago

Applied requested changes

rauldpm commented 10 months ago

Review notes

wazuh-jenkins

Pipeline Example: https://ci.wazuh.info/view/Tests/job/Test_install/129733

The Test_install pipelines do not use the check-files.py script nor check the file's properties, they are used only for upgrade tests

As part of Installation test suite: wazuh-jenkins/quality/tests/generic/02-installation/linux/test/conf/test_agent.yaml wazuh-jenkins/quality/tests/generic/02-installation/linux/test/conf/test_manager.yaml

Yes, the Python script is referenced but it is not used in the playbooks

In terms of Pipelines it is used in:

  • PR_Wazuh
  • Nightly
  • Test_install
  • Test_upgrade
  • Test_service

Where is the Test_service pipeline using the check-files?


Shouldn't this knowledge be reflected in the Google Sites documentation?

Deblintrake09 commented 9 months ago
rauldpm commented 9 months ago

Review notes

Updated test_install to note it is only referenced, but not used.

It must be clear that the Test_install pipeline does not use the check-files


In terms of Pipelines it is used in: Test_install - only referenced but not actually used. Test_upgrade - tests are actually executed in this pipeline PR_Wazuh Nightly

Add a note in PR_wazuh and test_nightly stating that the check-files are launched in the Tests_ugrade pipeline and not in the PR_wazuh or test_nightly pipelines. Also, refer to the pipelines with their actual names (Nightly -> test_nightly)


Please check the grammar of the entire comment

VERSION: Vversion of Installation this (these) tests are passing


Deblintrake09 commented 9 months ago

Applied requested changes.

rauldpm commented 9 months ago

Review notes

mauromalara commented 9 months ago

Review comment No.5

Great research and description 👏🏻 👏🏻

Only a few changes are required:

Check_files on wazuh-qa

What is test

Change the title to “What is being tested”

How to run tests

You mention this in “What is tested”:

[the tests] check the files in the system and the difference of files after a given install, update or uninstall process.

But then you only explain how to check files before/after an install process. Please, add more detail to understand how the tool is used in all the cases.

Parameters for check_files script

PATH: Path base to inspect files recursively. Arg: "--path", default='/'

I don’t quite understand what is this parameter about

Parameters for

I think the title is incomplete, am I right?

BEFORE_FILE: Python Arg. --before-file. Path to check_file.py report before install/upgrade/uninstall.

I would change this “Path to check_file.py report…” By this “Path where the script will report….”

AFTER_FILE: Python Arg. --after-file. Path to check_file.py report after install/upgrade/uninstall.

IDEM above.

Deblintrake09 commented 9 months ago

Response to review Comment No. 5

mauromalara commented 9 months ago

Review comment No.6

BEFORE_FILE and AFTER_FILE are the paths to the files created by the script before, not where the test will report. These files should exist before launching the tests.

I'm still seeing the previous description, you explained it well in the previous comment. Please, expand the following descriptions for everyone to understand:

BEFORE_FILE: Python Arg. --before-file. Path to check_file.py report before install/upgrade/uninstall. AFTER_FILE: Python Arg. --after-file. Path to check_file.py report after install/upgrade/uninstall.

Note: Please, check the QA project's fields, especially the ETA cannot be empty.

mauromalara commented 9 months ago

LGTM

davidjiglesias commented 5 months ago

LGTM!