diff --git a/README.md b/README.md index 16d422d3..032f51da 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,88 @@ An integration layer allowing Ansible Rulebook to use Drools as rule engine for rules evaluation. Drools can be invoked from Ansible either via a REST API or natively through [jpy](https://pypi.org/project/jpy/). +## Manual end-to-end testing with `drools_jpy` and `ansible-rulebook` + +Assuming the following local setup: + +``` +. +├── ansible-rulebook +├── drools-ansible-rulebook-integration +└── drools_jpy +``` + +For the Python projects, creating a common, shared [virtual environment](https://packaging.python.org/en/latest/glossary/#term-Virtual-Environment) instance is strongly advised, in order to be shared between `drools_jpy` and `ansible-rulebook`. +You can opt for ansible-rulebook to "borrow" the venv from drools_jpy. +Another strategy is to use a venv strategically placed (personally used `~/venv/bin/activate`). + +To create the venv: + +``` +python3 -m venv {destination directory} +``` + +e.g.: + +```sh +python3 -m venv ~/venv +``` + +Ref: https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments + +Assuming the Python requirements were already installed for the projects: + +- https://ansible.readthedocs.io/projects/rulebook/en/stable/development_environment.html +- https://github.com/ansible/drools_jpy#setup-and-testing + +The following steps illustrate how to perform end-to-end testing. + +### Step 1 (drools-ansible-rulebook-integration) + +Build locally with Maven, then copy the runtime JAR to drools_jpy: + +(from `drools-ansible-rulebook-integration`) + +```sh +mvn clean install +cp drools-ansible-rulebook-integration-runtime/target/drools-ansible-rulebook-integration-runtime-1.0.3-SNAPSHOT.jar ../drools_jpy/src/drools/jars/ +``` + +### Step 2 (drools_jpy) + +Use the shared venv, run the test with very-verbose and non-caputuring output, following by building (in venv site): + +(from `drools_jpy`) + +```sh +source ~/venv/bin/activate +pytest -vv -s +python3 -m pip install . +``` + +### Step 3 (ansible-rulebook) + +Use the same shared venv (so to find the specific version of drools_jpy), run the tests: + +(from `ansible-rulebook`) + +```sh +pip install -e . +pip install -r requirements_dev.txt +pytest -m "e2e" -n auto +pytest -m "not e2e and not long_run" -vv -n auto +``` + +You can always run all the tests with: + +```sh +pytest +``` + +### Notes + +An example of the strategy in practice: https://github.com/kiegroup/drools-ansible-rulebook-integration/pull/64 + ## Installing and Running REST API service ### Prerequisites