Skip to content

Commit

Permalink
Simplify unit testing.
Browse files Browse the repository at this point in the history
No-Issue

Signed-off-by: James Tanner <[email protected]>
  • Loading branch information
jctanner committed Oct 4, 2024
1 parent b2ddd87 commit 2815be0
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,13 @@ oci/dab:
.PHONY: oci/dab_jwt
oci/dab_jwt:
dev/oci_start dab_jwt

################################################
# UNIT TESTING
################################################

postgres/up:
docker compose -f local_dev.yml up -d postgres

postgres/down:
docker compose -f local_dev.yml down -v postgres
73 changes: 73 additions & 0 deletions local_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
x-common-env: &common-env

DJANGO_SUPERUSER_USERNAME: admin
DJANGO_SUPERUSER_EMAIL: [email protected]
DJANGO_SUPERUSER_PASSWORD: admin

POSTGRES_USER: galaxy_ng
POSTGRES_PASSWORD: galaxy_ng
POSTGRES_DB: galaxy_ng

# no spying
PULP_ANALYTICS: 'false'

# normally goes into settings.py ...
PULP_DATABASES__default__ENGINE: django.db.backends.postgresql
PULP_DATABASES__default__NAME: galaxy_ng
PULP_DATABASES__default__USER: galaxy_ng
PULP_DATABASES__default__PASSWORD: galaxy_ng
PULP_DATABASES__default__HOST: postgres
PULP_DATABASES__default__PORT: 5432

PULP_DEBUG: 1
PULP_GALAXY_DEPLOYMENT_MODE: 'standalone'
PULP_DEFAULT_FILE_STORAGE: "pulpcore.app.models.storage.FileSystem"
PULP_REDIRECT_TO_OBJECT_STORAGE: 'false'

# Hostname and prefix has to be correct
PULP_GALAXY_API_PATH_PREFIX: '/api/galaxy/'
PULP_CONTENT_PATH_PREFIX: '/pulp/content/'
PULP_ANSIBLE_API_HOSTNAME: 'https://localhost'
PULP_ANSIBLE_CONTENT_HOSTNAME: "https://localhost"
PULP_CONTENT_ORIGIN: "https://localhost"
PULP_CSRF_TRUSTED_ORIGINS: "['https://localhost']"

# signing ...
ENABLE_SIGNING: 0
PULP_GALAXY_AUTO_SIGN_COLLECTIONS: 'false'
PULP_GALAXY_REQUIRE_CONTENT_APPROVAL: 'true'
PULP_GALAXY_REQUIRE_SIGNATURE_FOR_APPROVAL: 'false'
PULP_GALAXY_COLLECTION_SIGNING_SERVICE: 'ansible-default'
PULP_GALAXY_CONTAINER_SIGNING_SERVICE: 'container-default'

# pulp container ...
PULP_TOKEN_AUTH_DISABLED: 'false'
PULP_TOKEN_SERVER: 'https://localhost/token/'
PULP_TOKEN_SIGNATURE_ALGORITHM: 'ES256'
PULP_PUBLIC_KEY_PATH: '/src/galaxy_ng/dev/common/container_auth_public_key.pem'
PULP_PRIVATE_KEY_PATH: '/src/galaxy_ng/dev/common/container_auth_private_key.pem'

# auth ...
PULP_GALAXY_AUTHENTICATION_CLASSES: "['galaxy_ng.app.auth.session.SessionAuthentication', 'ansible_base.jwt_consumer.hub.auth.HubJWTAuth', 'rest_framework.authentication.TokenAuthentication', 'rest_framework.authentication.BasicAuthentication']"
PULP_ANSIBLE_BASE_JWT_VALIDATE_CERT: 'false'
PULP_ANSIBLE_BASE_JWT_KEY: 'https://localhost'
PULP_GALAXY_FEATURE_FLAGS__external_authentication: 'true'

# disable user/group modifications
PULP_ALLOW_LOCAL_RESOURCE_MANAGEMENT: 'false'

# role content workaround ..
PULP_ANSIBLE_BASE_ROLES_REQUIRE_VIEW: 'false'


services:
postgres:
image: "postgres:13"
ports:
- '5432:5432'
environment:
<<: *common-env
healthcheck:
test: ["CMD", "pg_isready", "-U", "galaxy_ng"]
interval: 10s
retries: 5
37 changes: 37 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,40 @@ ignore = [
"profiles/**",
"galaxy_ng/_vendor/**",
]

[tool.tox]
legacy_tox_ini = """
[tox]
min_version = 4.0
no_package = true
env_list =
py311
[testenv]
allowlist_externals = sh
usedevelop = True
deps =
-r unittest_requirements.txt
setenv =
LOCK_REQUIREMENTS=0
DJANGO_SETTINGS_MODULE=pulpcore.app.settings
PULP_DATABASES__default__ENGINE=django.db.backends.postgresql
PULP_DATABASES__default__NAME=galaxy_ng
PULP_DATABASES__default__USER=galaxy_ng
PULP_DATABASES__default__PASSWORD=galaxy_ng
PULP_DATABASES__default__HOST=localhost
PULP_DATABASES__default__PORT=5432
#PULP_INSTALLED_APPS="[galaxy_ng]"
PULP_DB_ENCRYPTION_KEY=/tmp/database_fields.symmetric.key
PULP_RH_ENTITLEMENT_REQUIRED=true
PULP_DEPLOY_ROOT=/tmp/pulp
commands =
sh -c ' \
rm -rf /tmp/pulp && mkdir -p /tmp/pulp && \
if [ ! -f /tmp/database_fields.symmetric.key ]; then openssl rand -base64 32 > /tmp/database_fields.symmetric.key; fi && \
(pip show galaxy_ng || pip install -e .) && \
if [ -d ../pulpcore ]; then pip install -e ../pulpcore; fi && \
if [ -d ../pulp_ansible ]; then pip install -e ../pulp_ansible; fi && \
if [ -d ../galaxy-importer ]; then pip install -e ../galaxy-importer; fi && \
pytest --capture=no -v --pyargs "galaxy_ng.tests.unit" '
"""

0 comments on commit 2815be0

Please sign in to comment.