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

Add docs to run integration and unit tests with docker compose #2362

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Changes from 1 commit
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
Next Next commit
run integration and unit tests with docker compose
jerabekjiri committed Nov 22, 2024
commit 343aa0aba7c3f9735511ab857843a8d532ec9dec
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -87,6 +87,8 @@ venv/
ENV/
env.bak/
venv.bak/
gng_int_testing/
gng_unit_testing/
.compose.env

# Spyder project settings
10 changes: 10 additions & 0 deletions dev/compose/README.md
Original file line number Diff line number Diff line change
@@ -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**
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

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
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
```

Loading