diff --git a/.gitignore b/.gitignore index ba4737d9cf..0d2485c730 100644 --- a/.gitignore +++ b/.gitignore @@ -87,6 +87,8 @@ venv/ ENV/ env.bak/ venv.bak/ +gng_int_testing/ +gng_unit_testing/ .compose.env # Spyder project settings diff --git a/dev/compose/README.md b/dev/compose/README.md index e2d8dd5c0b..f5fb19ec54 100644 --- a/dev/compose/README.md +++ b/dev/compose/README.md @@ -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** diff --git a/docs/dev/integration_tests.md b/docs/dev/integration_tests.md index c4dc48bc01..1a5faaa029 100644 --- a/docs/dev/integration_tests.md +++ b/docs/dev/integration_tests.md @@ -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 diff --git a/galaxy_ng/tests/integration/README.md b/galaxy_ng/tests/integration/README.md index 9b2bb3cb22..ac2e749e33 100644 --- a/galaxy_ng/tests/integration/README.md +++ b/galaxy_ng/tests/integration/README.md @@ -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 diff --git a/galaxy_ng/tests/unit/README.md b/galaxy_ng/tests/unit/README.md new file mode 100644 index 0000000000..0ae517a583 --- /dev/null +++ b/galaxy_ng/tests/unit/README.md @@ -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 +``` + diff --git a/lint_requirements.txt b/lint_requirements.txt index 484bef93d5..7c41d673c8 100644 --- a/lint_requirements.txt +++ b/lint_requirements.txt @@ -1,4 +1,4 @@ check-manifest flake8 yamllint -ruff +ruff==0.7.1 diff --git a/setup.py b/setup.py index ebc5e7803e..f00bbeb4f3 100644 --- a/setup.py +++ b/setup.py @@ -89,7 +89,7 @@ def run(self): django_ansible_base_branch = os.getenv('DJANGO_ANSIBLE_BASE_BRANCH', '2024.10.17') django_ansible_base_dependency = ( - 'django-ansible-base[jwt_consumer] @ ' + 'django-ansible-base[jwt-consumer] @ ' f'git+https://github.com/ansible/django-ansible-base@{django_ansible_base_branch}' )