Improved testing
After the initializer scripts were removed, we didn't test the actual compose setup anymore. This adds new tests to run the database migrations.
This commit is contained in:
parent
1779ba790d
commit
9441be459c
@ -3,12 +3,13 @@ services:
|
||||
netbox:
|
||||
image: ${IMAGE-netboxcommunity/netbox:latest}
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
- redis-cache
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_started
|
||||
redis-cache:
|
||||
condition: service_started
|
||||
env_file: env/netbox.env
|
||||
environment:
|
||||
SKIP_STARTUP_SCRIPTS: ${SKIP_STARTUP_SCRIPTS-false}
|
||||
user: 'unit:root'
|
||||
volumes:
|
||||
- ./configuration:/etc/netbox/config:z,ro
|
||||
@ -19,6 +20,11 @@ services:
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
env_file: env/postgres.env
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
command:
|
||||
|
14
test.sh
14
test.sh
@ -35,10 +35,14 @@ if [ -z "${IMAGE}" ]; then
|
||||
fi
|
||||
|
||||
# The docker compose command to use
|
||||
doco="docker-compose --file docker-compose.test.yml --project-name netbox_docker_test_${1}"
|
||||
doco="docker compose --file docker-compose.test.yml --project-name netbox_docker_test"
|
||||
|
||||
test_setup() {
|
||||
echo "🏗 Setup up test environment"
|
||||
$doco up --detach --quiet-pull --wait --force-recreate --renew-anon-volumes --no-start
|
||||
$doco start postgres
|
||||
$doco start redis
|
||||
$doco start redis-cache
|
||||
}
|
||||
|
||||
test_netbox_unit_tests() {
|
||||
@ -46,9 +50,14 @@ test_netbox_unit_tests() {
|
||||
$doco run --rm netbox /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py test
|
||||
}
|
||||
|
||||
test_compose_db_setup() {
|
||||
echo "⏱ Running NetBox DB migrations"
|
||||
$doco run --rm netbox /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py migrate
|
||||
}
|
||||
|
||||
test_cleanup() {
|
||||
echo "💣 Cleaning Up"
|
||||
$doco down -v
|
||||
$doco down --volumes
|
||||
}
|
||||
|
||||
echo "🐳🐳🐳 Start testing '${IMAGE}'"
|
||||
@ -58,5 +67,6 @@ trap test_cleanup EXIT ERR
|
||||
test_setup
|
||||
|
||||
test_netbox_unit_tests
|
||||
test_compose_db_setup
|
||||
|
||||
echo "🐳🐳🐳 Done testing '${IMAGE}'"
|
||||
|
Loading…
Reference in New Issue
Block a user