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

readme notes e2e testings #69

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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