wazuh-qa
wazuh-qa copied to clipboard
DTT2 - Provision Module - Findings and recommendations
| Target version | Related issue | Related PR/dev branch |
|---|---|---|
| 4.9 | #4994 | https://github.com/wazuh/wazuh-qa/pull/5150 |
Description
While developing the unit tests for DTT1 iteration 3 - Provision Module, I had the opportunity to review the source code thoroughly. I list the findings in this issue for discussion and triage.
-
The provision, testing, and allocation modules use
importstatements that require aPYTHONPATHenvironment variable of the format[wazuh-qa-repo-path]/deployability. In contrast, theworkflow_enginerequires the PYTHONPATH format[wazuh-qa-repo-path]/deployability/modulesto work. I suggest making each module independent from the others or unifying all the modules in a single Python package. -
The ProvisionHandler class constructor compares
method.lower() == 'assistant'. Uppercase method names are rejected by the constructor, so it is not necessary to convert the method variable to lowercase. -
The ProvisionHandler class supports the methods
['package', 'assistant', 'source'], but theProvisionHandler ._get_templates_orderfunction method checks for a method 'aio' that is not supported. The 'aio' method should be supported as a valid method, or it should be removed fromProvisionHandler ._get_templates_order -
In the Actions class constructor, there is a variable named
action_type, and an error messagef"Unsupported action_type: {action_type}". The validation and the assignment are related to component types. I suggest changing the variable name tocomponent_typeand the error message to Unsupported component_type. -
The
playbookparameter of theAnsible.run_playbooktype isstr | Path. In theActions.executemethod, I've seen that therun_playbookmethod has adictas the playbook parameter. I suggest updating the type todict | str | Path.Four instance variables are in theComponentTypeclass, but only two are typed. I suggest typing all the instance variables. -
The
provision.update_statusvariable is not adictbut arunnerinstance of theAnsiblepackage. -
The @classmethods decorator must be added to all the validator functions, for example, here: https://github.com/wazuh/wazuh-qa/blob/4110dad96b0190743827913b6cd8d10109a18244/deployability/modules/provision/models.py#L60-L66
-
The @validator is marked as deprecated and will be removed in the next pydantic version. We must implement @field_validator instead.
-
Fix the typo
recived: https://github.com/wazuh/wazuh-qa/blob/4110dad96b0190743827913b6cd8d10109a18244/deployability/modules/provision/models.py#L35 -
Fix this message, changing
provisionmentto 'provisioning' https://github.com/wazuh/wazuh-qa/blob/4110dad96b0190743827913b6cd8d10109a18244/deployability/modules/provision/provision.py#L41