File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,13 @@ services:
33 netbox :
44 image : ${IMAGE-netboxcommunity/netbox:latest}
55 depends_on :
6- - postgres
7- - redis
8- - redis-cache
6+ postgres :
7+ condition : service_healthy
8+ redis :
9+ condition : service_started
10+ redis-cache :
11+ condition : service_started
912 env_file : env/netbox.env
10- environment :
11- SKIP_STARTUP_SCRIPTS : ${SKIP_STARTUP_SCRIPTS-false}
1213 user : ' unit:root'
1314 volumes :
1415 - ./configuration:/etc/netbox/config:z,ro
@@ -19,6 +20,11 @@ services:
1920 postgres :
2021 image : postgres:15-alpine
2122 env_file : env/postgres.env
23+ healthcheck :
24+ test : ["CMD-SHELL", "pg_isready"]
25+ interval : 10s
26+ timeout : 5s
27+ retries : 5
2228 redis :
2329 image : redis:7-alpine
2430 command :
Original file line number Diff line number Diff line change @@ -35,20 +35,29 @@ if [ -z "${IMAGE}" ]; then
3535fi
3636
3737# The docker compose command to use
38- doco=" docker- compose --file docker-compose.test.yml --project-name netbox_docker_test_ ${1} "
38+ doco=" docker compose --file docker-compose.test.yml --project-name netbox_docker_test "
3939
4040test_setup () {
4141 echo " π Setup up test environment"
42+ $doco up --detach --quiet-pull --wait --force-recreate --renew-anon-volumes --no-start
43+ $doco start postgres
44+ $doco start redis
45+ $doco start redis-cache
4246}
4347
4448test_netbox_unit_tests () {
4549 echo " β± Running NetBox Unit Tests"
4650 $doco run --rm netbox /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py test
4751}
4852
53+ test_compose_db_setup () {
54+ echo " β± Running NetBox DB migrations"
55+ $doco run --rm netbox /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py migrate
56+ }
57+
4958test_cleanup () {
5059 echo " π£ Cleaning Up"
51- $doco down -v
60+ $doco down --volumes
5261}
5362
5463echo " π³π³π³ Start testing '${IMAGE} '"
@@ -58,5 +67,6 @@ trap test_cleanup EXIT ERR
5867test_setup
5968
6069test_netbox_unit_tests
70+ test_compose_db_setup
6171
6272echo " π³π³π³ Done testing '${IMAGE} '"
You canβt perform that action at this time.
0 commit comments