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:
3
3
netbox :
4
4
image : ${IMAGE-netboxcommunity/netbox:latest}
5
5
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
9
12
env_file : env/netbox.env
10
- environment :
11
- SKIP_STARTUP_SCRIPTS : ${SKIP_STARTUP_SCRIPTS-false}
12
13
user : ' unit:root'
13
14
volumes :
14
15
- ./configuration:/etc/netbox/config:z,ro
@@ -19,6 +20,11 @@ services:
19
20
postgres :
20
21
image : postgres:15-alpine
21
22
env_file : env/postgres.env
23
+ healthcheck :
24
+ test : ["CMD-SHELL", "pg_isready"]
25
+ interval : 10s
26
+ timeout : 5s
27
+ retries : 5
22
28
redis :
23
29
image : redis:7-alpine
24
30
command :
Original file line number Diff line number Diff line change @@ -35,20 +35,29 @@ if [ -z "${IMAGE}" ]; then
35
35
fi
36
36
37
37
# 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 "
39
39
40
40
test_setup () {
41
41
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
42
46
}
43
47
44
48
test_netbox_unit_tests () {
45
49
echo " β± Running NetBox Unit Tests"
46
50
$doco run --rm netbox /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py test
47
51
}
48
52
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
+
49
58
test_cleanup () {
50
59
echo " π£ Cleaning Up"
51
- $doco down -v
60
+ $doco down --volumes
52
61
}
53
62
54
63
echo " π³π³π³ Start testing '${IMAGE} '"
@@ -58,5 +67,6 @@ trap test_cleanup EXIT ERR
58
67
test_setup
59
68
60
69
test_netbox_unit_tests
70
+ test_compose_db_setup
61
71
62
72
echo " π³π³π³ Done testing '${IMAGE} '"
You canβt perform that action at this time.
0 commit comments