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

Adding workflow as library function #4925

Conversation

pro-akim
Copy link
Member

@pro-akim pro-akim commented Feb 7, 2024

Description

Adding setup file and changing directories in order to create Workflow as a library option


Testing performed

(wf_test) akim@akim-PC:~/Desktop$ pip3 list
Package    Version
---------- -------
pip        22.0.2
setuptools 59.6.0

(wf_test) akim@akim-PC:~/Desktop/wazuh-qa/deployability/modules$ pip3 install .
Processing /home/akim/Desktop/wazuh-qa/deployability/modules
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for workflow-engine, since package 'wheel' is not installed.
Installing collected packages: workflow-engine
  Running setup.py install for workflow-engine ... done
Successfully installed workflow-engine-1.0


(wf_test) akim@akim-PC:~/Desktop/venvs/wf_test/bin$ python3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from workflow_engine import models
>>> from workflow_engine import schema_validator
>>> from workflow_engine import task
>>> from workflow_engine import workflow_processor
>>> from workflow_engine import main
>>> from workflow_engine import logging


(wf_test) akim@akim-PC:~/Desktop/venvs/wf_test/lib/python3.10/site-packages/workflow_engine$ tree
.
├── examples
│   ├── dtt1-agents-poc.yaml
│   ├── dtt1-agents.yaml
│   └── dtt1-managers.yaml
├── __init__.py
├── logging
│   ├── config.yaml
│   ├── filter.py
│   ├── __init__.py
│   ├── logger.py
│   └── __pycache__
│       ├── filter.cpython-310.pyc
│       ├── __init__.cpython-310.pyc
│       └── logger.cpython-310.pyc
├── main.py
├── models.py
├── __pycache__
│   ├── __init__.cpython-310.pyc
│   ├── main.cpython-310.pyc
│   ├── models.cpython-310.pyc
│   ├── schema_validator.cpython-310.pyc
│   ├── task.cpython-310.pyc
│   ├── utils.cpython-310.pyc
│   └── workflow_processor.cpython-310.pyc
├── README.md
├── schemas
│   └── schema_v1.json
├── schema_validator.py
├── task.py
└── workflow_processor.py

5 directories, 25 files


(deplo_test) akim@akim-PC:~/Desktop/wazuh-qa/deployability$ python3 -m workflow_engine  /home/akim/Desktop/wazuh-qa/deployability/modules/workflow_engine/examples/dtt1-agents-poc.yaml
[2024-02-07 19:35:14] [INFO] [1271970] [MainThread] [workflow_engine]: Starting workflow execution.
[2024-02-07 19:35:14] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Initiating execution of task "allocate-manager".
[2024-02-07 19:38:14] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Task "allocate-manager" completed succesfully in 179.54 seconds.
[2024-02-07 19:38:14] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Initiating execution of task "allocate-linux-ubuntu-22.04-amd64".
[2024-02-07 19:41:05] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Task "allocate-linux-ubuntu-22.04-amd64" completed succesfully in 170.53 seconds.
[2024-02-07 19:41:05] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Initiating execution of task "provision-manager".
[2024-02-07 19:43:50] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Task "provision-manager" completed succesfully in 165.88 seconds.
[2024-02-07 19:43:50] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Initiating execution of task "provision-install-linux-ubuntu-22.04-amd64".
[2024-02-07 19:45:37] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Task "provision-install-linux-ubuntu-22.04-amd64" completed succesfully in 106.15 seconds.
[2024-02-07 19:45:37] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Initiating execution of task "run-agent-tests-linux-ubuntu-22.04-amd64".
[2024-02-07 19:45:38] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Task "run-agent-tests-linux-ubuntu-22.04-amd64" completed succesfully in 1.18 seconds.
[2024-02-07 19:45:38] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Initiating execution of task "provision-uninstall-linux-ubuntu-22.04-amd64".
[2024-02-07 19:45:57] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Task "provision-uninstall-linux-ubuntu-22.04-amd64" completed succesfully in 18.73 seconds.
[2024-02-07 19:45:57] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Initiating execution of task "run-agent-tests-uninstall-linux-ubuntu-22.04-amd64".
[2024-02-07 19:45:58] [INFO] [1271970] [ThreadPoolExecutor-0_0] [workflow_engine]: Task "run-agent-tests-uninstall-linux-ubuntu-22.04-amd64" completed succesfully in 1.14 seconds.
[2024-02-07 19:45:58] [INFO] [1271970] [MainThread] [workflow_engine]: Executing cleanup tasks.

Paths of playbooks were added inside of each module and relative paths were fixed.

@pro-akim pro-akim linked an issue Feb 7, 2024 that may be closed by this pull request
3 tasks
Copy link
Member

@QU3B1M QU3B1M left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -77,7 +77,7 @@ def _run_tests(cls, test_list: list[str], ansible: Ansible, extra_vars: ExtraVar
"""
for test in test_list:
rendering_var = {**extra_vars, 'test': test}
template = str(ansible.playbooks_path / cls._test_template)
template = str(ansible.testing_playbook_path / cls._test_template)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the playbooks are inside the test module I think the playbooks path should be defined in the module itself. The same applies for the provision

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done af65f61

@@ -19,7 +19,7 @@ tasks:
with:
path: python3
args:
- test.py
- /home/akim/Desktop/wazuh-qa/deployability/modules/testing/main.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove personal paths from the example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 0c156f8

@pro-akim pro-akim requested a review from fcaffieri February 8, 2024 10:00
@fcaffieri fcaffieri merged commit 9b87195 into enhancement/4905-dtt1-iteration-3-workflow Feb 8, 2024
@fcaffieri fcaffieri deleted the enhancement/4909-Install-module-as-Python-library branch February 8, 2024 12:24
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.

DTT1 - Iteration 3 - WorkFlow engine module - Install module as Python lib
3 participants