Skip to content

Commit

Permalink
readme notes e2e testings (#69)
Browse files Browse the repository at this point in the history
mark down notes from
#64
in readme

(cherry picked from commit 408a112)
  • Loading branch information
tarilabs authored and mariofusco committed Aug 21, 2023
1 parent 0e3629a commit c358f99
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c358f99

Please sign in to comment.