Skip to content

Commit

Permalink
run integration and unit tests with docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
jerabekjiri committed Nov 22, 2024
1 parent 28850d4 commit 343aa0a
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ venv/
ENV/
env.bak/
venv.bak/
gng_int_testing/
gng_unit_testing/
.compose.env

# Spyder project settings
Expand Down
10 changes: 10 additions & 0 deletions dev/compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0
```

## Tests

### Unit tests
Run unit tests with docker compose [Running unit tests](../../galaxy_ng//tests/unit/README.md)

### Integration tests
Run integration tests with docker compose, check the [Running integration tests](../../galaxy_ng/tests/integration/README.md)

Run with legacy oci-env, check the [Running oci-env integration tests](../../docs/dev/integration_tests.md)

## Tips and Tricks.

**TBD**
Expand Down
1 change: 1 addition & 0 deletions docs/dev/integration_tests.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Integration tests
(*To run integration tests with docker compose stack, check the [Running integration tests](../galaxy_ng/tests/integration/README.md)*)

## GitHub Actions

Expand Down
59 changes: 54 additions & 5 deletions galaxy_ng/tests/integration/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,58 @@
# Running integration tests
Integration tests are expected to be called via [galaxy_ng/dev/common/RUN_INTEGRATION.sh](https://github.com/ansible/galaxy_ng/blob/master/dev/common/RUN_INTEGRATION.sh)
- `make docker/test/integration`
- `make docker/test/integration/container`
- Run in PR via GitHub Actions ci_standalone.yml for `DEPLOYMENT_MODE=standalone`
- Run in PR via pr_check.sh in an ephemeral environment for `DEPLOYMENT_MODE=insights`
Based on running docker compose stack deployment mode (standalone, community, insights), install requirements, set environment variables and markers on the host:


Install `integration_requirements.txt` in your virtual env
```
python3 -m venv gng_int_testing
source gng_testing/bin/activate
pip install -r integration_requirements.txt
```

## Standalone
```
export HUB_API_ROOT='http://localhost:5001/api/galaxy/'
export HUB_LOCAL=1
```

```python
pytest -v -r sx --color=yes -m 'deployment_standalone' galaxy_ng/tests/integration
```

## Community
```
export HUB_API_ROOT='http://localhost:5001/api/'
export HUB_LOCAL=1
```

run tests:
```python
pytest -v -r sx --color=yes -m 'deployment_community' galaxy_ng/tests/integration
```

## Insights (cloud)
```
export HUB_API_ROOT="http://localhost:8080/api/automation-hub/"
export HUB_AUTH_URL="http://localhost:8080/auth/realms/redhat-external/protocol/openid-connect/token"
export HUB_USE_MOVE_ENDPOINT="true"
export HUB_UPLOAD_SIGNATURES="true"
```

run tests:
```python
pytest -v -r sx --color=yes -m 'deployment_cloud or all' galaxy_ng/tests/integration
```

or specify test you would like to run:
```python
pytest -v -r sx --color=yes -k ' test_delete_collection' galaxy_ng/tests/integration
```

Tests that are intended to pass on any deployment mode should be marked with `all`. By default unmarked tests will receive the `all` mark`.
All `deployment_standalone` tests are also expected to pass when running with ldap or keycloak authentication. If a test is meant to test a specific authentication backend, use the `ldap` or `keycloak` marks, and remove `deployment_standalone`.
List of all marks in [conftest.py](conftest.py)



# Test Data
* Test data is defined in [galaxy_ng/dev/common/setup_test_data.py](https://github.com/ansible/galaxy_ng/blob/master/dev/common/setup_test_data.py) and includes namespaces, users, tokens, and groups
Expand Down
13 changes: 13 additions & 0 deletions galaxy_ng/tests/unit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Unit tests
Unit testing is done with `tox`. All necessary requirements and environment variables are set in the `tox` configuration file [tox.ini](../../tox.ini)

Install and run `tox` tool in your virtual env:
```
python3 -m venv gng_unit_testing
source gng_unit_testing/bin/activate
pip install tox
# run unit tests
tox
```

0 comments on commit 343aa0a

Please sign in to comment.