wazuh-qa icon indicating copy to clipboard operation
wazuh-qa copied to clipboard

DTT2 - Provision Module - Findings and recommendations

Open mhamra opened this issue 1 year ago • 0 comments

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 import statements that require a PYTHONPATH environment variable of the format [wazuh-qa-repo-path]/deployability. In contrast, the workflow_engine requires the PYTHONPATH format [wazuh-qa-repo-path]/deployability/modules to 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 the ProvisionHandler ._get_templates_order function 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 from ProvisionHandler ._get_templates_order

  • In the Actions class constructor, there is a variable named action_type, and an error message f"Unsupported action_type: {action_type}". The validation and the assignment are related to component types. I suggest changing the variable name to component_type and the error message to Unsupported component_type.

  • The playbook parameter of the Ansible.run_playbook type is str | Path. In the Actions.execute method, I've seen that the run_playbook method has a dict as the playbook parameter. I suggest updating the type to dict | str | Path. Four instance variables are in the ComponentType class, but only two are typed. I suggest typing all the instance variables.

  • The provision.update_status variable is not a dict but a runner instance of the Ansible package.

  • 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 provisionment to 'provisioning' https://github.com/wazuh/wazuh-qa/blob/4110dad96b0190743827913b6cd8d10109a18244/deployability/modules/provision/provision.py#L41

mhamra avatar Apr 03 '24 15:04 mhamra