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

Define and adapt the QA team repositories #5475

Closed
6 tasks done
Tracked by #5527
damarisg opened this issue Jun 7, 2024 · 7 comments
Closed
6 tasks done
Tracked by #5527

Define and adapt the QA team repositories #5475

damarisg opened this issue Jun 7, 2024 · 7 comments
Assignees

Comments

@damarisg
Copy link
Member

damarisg commented Jun 7, 2024

Description

To improve the structure and maintainability of the wazuh-qa and wazuh-jenkins repositories, we need to define and adapt the current design. This will help organize tests and improve practices.

Functional requirements

  • The structure should be organized according to the types of tests.
  • The structure must adapt to continuous growth, allowing the incorporation of new features.
  • The structure must maintain consistency to ensure uniformity.
  • Each section should include appropriate documentation to assist quality control tasks.
  • The structure should make automated tests easy to implement and run.
  • The new design must integrate with supported build systems and pipelines.

Tasks


Wazuh QA automation repository

This repository will store the Wazuh QA framework, the different test suites, and the QA Jenkins environment code. In the initial version, only some basic tools of the different repositories will be developed/migrated, with the Deployability tests suite, and the new Jenkins environment with the approach of Everything-as-a-code.

Repository structure

After analyzing the current repository's structure, and the different proposals, we can conclude that our new structure must follow the next key points:

  • It must be scalable.
  • Tooling and test suite must be easy to understand and maintain.
  • Tools and utils must have unit tests.
  • Test types must be well-defined and separated.
  • Tests-specific helpers or tools must be in the same directory as the tests.

Taking into account the previous points, we propose the following structure:

.
├── README.md
├── tests
│   ├── test_functional
│   │   ├── test_end_to_end
│   │   │   ├── helpers
│   │   └── test_system
│   │       ├── helpers
│   │       └── test_deployability
│   └── test_non_functional
│       ├── test_performance
│       └── test_stress
│           └── test_sca
│               └── helpers
└── tools
    ├── src
    │   ├── generic
    │   │   ├── logger
    │   │   └── monitoring
    │   ├── jenkins
    │   │   ├── bootstrap
    │   │   ├── jenkins-ui
    │   │   └── procedures
    │   ├── jobflow
    │   ├── provision
    │   ├── publishing
    │   └── wazuh_qa_framework              # Name to be discussed
    └── tests
        ├── generic
        ├── jenkins
        ├── jobflow
        ├── provision
        ├── publishing
        └── wazuh_qa_framework
Other option
.
├── README.md
├── tests
│   ├── test_functional
│   │   └── test_system
│   │       └── test_deployability
│   └── test_non_functional
│       └── test_stress
│           └── test_sca
└── tools
    ├── generic
    │   ├── logger
    │   └── monitoring
    ├── jenkins
    │   ├── src
    │   │   ├── bootstrap
    │   │   ├── jenkins-ui
    │   │   └── procedures
    │   └── tests
    ├── jobflow
    │   ├── src
    │   └── test
    ├── provision
    │   ├── src
    │   └── test
    └── wazuh_qa_framework
        ├── src
        │   ├── api_client
        │   ├── constants
        │   └── utils
        └── tests

Proposed structure documentation and justification

Currently, we are facing two issues. First, our main wazuh-qa repository has a lot of useful code, but as its structure is not well defined, it is difficult to maintain and scale, the test types are not well defined, and the tools and utils are all part of a big framework that does everything (its scope is not well defined). Second, we have other repositories with useful code, but they are not part of the main repository, so we have content spread across different repositories making it hard to maintain.
So, the idea is to avoid this situation by creating a new structure that allows us to scale and maintain the code easily, having a well-defined scope for each tool and test type. It also includes code from the other repositories owned by QA

To achieve this goal, the proposed structure is divided into two main directories: tests/ and tools/ which at the same time are divided into subdirectories with more subdirectories, going from a generic scope to a more specific one.

The tests/ directory is divided into the main tests categories functional and non-functional, from that point the categories can be divided into more specific test types, such as end-to-end, and system for the functional tests, and performance and stress for the non-functional tests. Each of these directories could contain helpers or fixtures used only by the tests in that scope and its subdirectories.

For the tools/ directory, the structure is different, we don't have 'categories', in this directory resides all the tools that we use in our QA process, such as Jenkins, JobFlow, Provision, and wazuh_qa_framework, alongside all the unit tests for each tool. Its basic structure is divided into src/ and tests/, where the src/ directory contains the source code of the tools, and the tests/ directory contains the unit tests for the tools.
Another thing to consider is that the wazuh_qa_framework is defined only to be a 'wazuh components handler' tool, this way we can have a well-defined scope for this tool, and avoid making it 'infinite' as it is now.

Proposal, process, and good practices documentation

Initial migration process

In this first approach, we will only migrate the newly developed tools and tests by the QA team, which are DTT1 and the new Jenkins environment. This migration flow consists of the following simple steps:
1. Review the current code
2. Analyze and propose an adaptation for the new structure
3. Migrate the code with the pertinent modifications

As the code is recently developed, we don't expect to have many issues during the migration process, but if we find any, we must document them and propose a solution.

Tests development process

The development of new tests must follow a well-defined process to ensure that the tests are well-developed and maintained. A proposal for this process is defined as follows:
1. Analyze and define the scope and type of the test scenario. (could use a guide like this)
2. Define a proposal set of Test Cases
3. Develop the approved test cases with the required helpers or fixtures

Other Recommendations

  • The tests must be written using the Gherkin syntax. (pytest-bdd)
  • The E2E tests must be developed using the Page Object Model pattern.
  • Use the pytest framework to develop the tests.
  • Use playwright to interact with the browser in the E2E tests.

Tools development process

The tools development process must also follow a well-defined process to ensure its correct development. A proposal for this process is defined as follows:
1. Analyze the requested feature or tool
2. Define the structure of the tool and technologies to use
3. Develop the tool with the required unit tests

Good practices

  • Gherkin syntax: All the tests must be written using the Gherkin syntax. (pytest-bdd)
  • Code review: All the code must be reviewed by at least one other team member before merging it into the main branch.
  • Unit tests: All the tools and tests must have unit tests.
  • Documentation: All the code must be documented, and the documentation must be updated with the code.
  • Code style: All the code must follow the same code style, and the code style must be defined in the documentation. (In the case of Python, we must follow PEP8)
  • Continuous Integration: All the code must pass through a series of defined GitHub Actions to ensure:
    • The code style is correct
    • The unit tests pass
    • The code is well documented
    • The code and documentation are typos-free

Useful sources

Development

QA Automation

@damarisg
Copy link
Member Author

damarisg commented Jul 10, 2024

Generic Summary

Migration

Structure

[wazuh-qa]
|─ dependencies
|    ├ requirements
|    ├ generic
|          ├ constants
|          ├ requests
|          ├ file
|          ├ exceptions
|          ├ threading
|          ├ time
|          ├ utils
|               └ commands
|          ├ tools
|               └ wazuh_api
|               └ monitors
|               └ database
|               └ certificates
|─ tests
|    ├ non_functional
|          ├ footprint
|              └── sca
|    └ functional
|          ├ utils
|          ├ component
|          ├ integration
|          ├ systems
|          └ e2e
|─ Jenkins
|─ Documentation with changelog, versioning and Readme.

@damarisg damarisg added level/subtask Subtask issue and removed level/task Task issue labels Jul 11, 2024
@QU3B1M
Copy link
Member

QU3B1M commented Jul 15, 2024

Update report

Working with @pcapellan in parallel to define possible structures and technologies for the new QA repository that will store the QA framework, Jenkins, and test code.

Two boilerplate versions were currently presented in a quick sync through the Slack chat, but they are still Work in Progress.


QU3B1M proposal (WIP)

Wazuh QA Repo

This repository will store the Wazuh QA framework, the different tests suites, and the QA Jenkins environment code. In the initial version only some basic tools of the framework will be developed/migrated, with the Deployability tests suite, and the new Jenkins environment with the approach of Everything-as-a-code.

Wazuh QA Framework

The QA framework is a Python package with all the required tools and utilities to easily interact with the Wazuh components, the idea for it is to be a "cypress" for Wazuh, this framework must be easy to use, understand, and maintain.
To successfully achieve this, we have to follow the next set of rules:

  • The framework should be a set of tools to help the QA team to test the Wazuh components, a kind of selenium/cypress for wazuh.
  • All the tools must have their Unit Tests so we can be sure of their correct behavior.
  • The tools must be easy to use and understand.
  • The tools must be easy to maintain and update (follow good practices.)
  • The framework must be well documented.

Tests suites

We must clearly define the different types of tests in a way that anyone can identify the kind of test to develop, which suite it belongs and where to store it. The idea is to have a clear structure for the tests, so it's easier to maintain and update them.
These are the recommendations to follow in order to achieve this:

  • There must be clear definitions for each type of test so it's easier to know where a new test belongs.
  • The tests must be defined using BDD (pytest-bdd or behave)

    pytest-bdd could be the best option as it is compatible with playwright, and currently is the most complete and used python test runner

  • E2E suite could be developed using playwright with pytest.
  • The tests must be clear and easy to understand.
  • The test-specific helpers must be stored in the the /helpers/ subfolder of the corresponding test.
  • Fixturize everything that can be fixturized (doc about fixtures)

Basic structure proposal

.
├── LICENSE
├── README.md
├── changelog
├── framework
│   ├── README.md
│   ├── src
│   │   ├── README.md
│   │   ├── tools
│   │   │   ├── README.md
│   │   │   ├── jobflow
│   │   │   │   └── README.md
│   │   │   ├── monitors
│   │   │   │   └── README.md
│   │   │   └── provisioner
│   │   │       └── README.md
│   │   └── utils
│   │       └── README.md
│   └── tests
│       └── README.md
├── jenkins
│   └── README.md
└── tests
    ├── README.md
    ├── functional
    │   └── README.md
    └── non_functional
        └── README.md

@damarisg
Copy link
Member Author

damarisg commented Jul 15, 2024

18/07/2024

Research the list of issues to remove from `wazuh-jenkins`.

To migrate:

To remove: (The issues are obsolete and must be open to another approach. For now, I consider it necessary to delete this list.)

Move to Core:

Move to DevOps:

15/07/2024

Research the list of issues to remove from `wazuh-qa`.

To migrate:

To remove: (It is necessary to define new cases with the new changes.)

Move to Core:

Move to DevOps:

@jnasselle
Copy link
Member

Review

Great job @wazuh/devel-qa-div3 ! some comments based on what we've spoken:

  • GHA directory to enforce whatever we need and execute UT
  • tools should contain self-contained structure for better comprehension i.e rather than having src/generic/jobflow and tests/jobflow, i suggest tools/jobflow/src and /tools/jobflow/tests
  • Tests development process, Other recommendations, Tools development process and Good practices are critical information in order to improve Wazuh quality standards, and should be taken into account, but is out of scope of the current issue goal.
  • tests/test_functional and tests/test_no_functional could be simplified by removing test prefix

@pcapellan
Copy link

pcapellan commented Jul 18, 2024

Review

I think it's important to define if we are going to write the tests with the gherkin syntax and if we are going to use the page object model pattern for e2e test cases. If this were the case I would suggest, for the testing section, a structure like this:

qa-wazuh/

├── features/
│   ├── feature_files/		# contains gherkin files and test steps
│   │   ├── logcollector.feature
│   │   └── syscheck.feature
│   └── steps/			# contains the python files that implement the steps defined in feature_files
│       ├── __init__.py
│       ├── logcollector_steps.py
│       └── syscheck_steps.py

├── pages/			# applies for e2e tests
│   ├── __init__.py
│   ├── events_page.py
│   └── dashboard_page.py
│   └── inventory_page.py


└── tests/
    ├── __init__.py
    ├── test_cases/		#  contains the test files written with pytest
    │   ├── __init__.py
    │   ├── test_logcollector.py
    │   └── test_syscheck.py

    └── resources/		# contains resources for testing: data generation, configurations, etc.
 

@QU3B1M
Copy link
Member

QU3B1M commented Jul 19, 2024

Structure Update

Considering the previous recommendations, a possible structure could look something like this

.
├── .github
│   └── workflows
│       ├── run_unitests.yaml
│       └── tools_coverage.yaml
├── README.md
├── tests
│   ├── test_functional
│   │   ├── test_e2e
│   │   │   ├── features
│   │   │   ├── page_objects
│   │   │   └── tests               # Or steps_definitions/
│   │   └── test_system
│   │       └── test_deployability
│   │           ├── features
│   │           └── tests           # Or steps_definitions/
│   └── test_non_functional
│       └── test_stress
│           ├── features
│           └── tests               # Or steps_definitions/
└── tools
    ├── generic
    │   ├── src
    │   │   ├── logger
    │   │   └── monitors
    │   └── tests
    │       ├── logger
    │       └── monitors
    ├── jenkins
    │   ├── src
    │   └── tests
    ├── jobflow
    │   ├── src
    │   └── test
    ├── provision
    │   ├── src
    │   └── test
    └── wazuh_qa_framework
        ├── src
        │   ├── api_client
        │   ├── constants
        │   └── utils
        └── tests
            ├── api_client
            ├── constants
            └── utils

tests/test_functional and tests/test_no_functional could be simplified by removing test prefix

I would prefer to keep the "test"_ prefix, as it helps pytest to identify these directories.
This can be useful if we want to run a specific selection of tests, some functional and some non-functional altogether, by only marking them with the same tag. Something like:

pytest  -m <tag>

@damarisg
Copy link
Member Author

GJ!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

4 participants