@@ -2,15 +2,16 @@ HAS_DOCKER_COMPOSE_V2 := $(shell docker compose version >/dev/null 2>&1 && echo
22HAS_DOCKER_COMPOSE_V1 := $(shell command -v docker-compose 2>/dev/null)
33
44ifeq ($(HAS_DOCKER_COMPOSE_V2 ) ,1)
5- # docker compose cannot deal with default veriables?
5+ CCMD := docker
66 CMD := docker compose
77else ifneq ($(HAS_DOCKER_COMPOSE_V1),)
88 CMD := docker-compose
99else
10+ CCMD := podman
1011 CMD := podman-compose
1112endif
1213
13- TEST_ENVIRONMENTS := -f base.yaml -f mtls.yaml -f tests/victim.yaml
14+ TEST_ENVIRONMENTS := -f base.yaml -f mtls.yaml -f tests/victim.yaml -f local-registry.yaml
1415
1516ifndef OPENVAS_IMAGE
1617 OPENVAS_IMAGE := ghcr.io/greenbone/openvas-scanner:stable
@@ -37,9 +38,8 @@ test-environment-down:
3738
3839.PHONY : test-environment-logs
3940test-environment-logs :
40- ${CMD} ${TEST_ENVIRONMENTS} logs openvasd
41-
42-
41+ ${CMD} ${TEST_ENVIRONMENTS} logs
42+
4343.PHONY : test-environment-up
4444test-environment-up : openvasd-server.key client-certs/client1.pem
4545 OPENVAS_IMAGE=${OPENVAS_IMAGE} ${CMD} ${TEST_ENVIRONMENTS} up -d
@@ -49,6 +49,32 @@ local-test-environment-up: openvasd-server.key client-certs/client1.pem
4949 cd .. && podman build -f .docker/prod.Dockerfile -t localhost/openvas:latest --build-arg BIN_VERSION=0.0.1 .
5050 OPENVAS_IMAGE=localhost/openvas:latest ${CMD} ${TEST_ENVIRONMENTS} up
5151
52+ define check_container_status
53+ $(CCMD ) ps -a --format '{{.Names}}' \
54+ | grep '$(1 ) ' \
55+ | xargs $(CCMD ) inspect -f '{{.State.Status}}' \
56+ | grep -qx '$(2 ) '
57+ endef
58+
59+ define wait_for_status
60+ @printf "Waiting for $(1 ) to be $(2 ) : "
61+ while ! $(call check_container_status,$(1 ) ,$(2 ) ) ; do \
62+ sleep 1; \
63+ done
64+ @printf "$(2 ) \n"
65+ endef
66+
67+ .PHONY : wait-for-services
68+ wait-for-services :
69+ @$(call wait_for_status,openvasd,running)
70+ @$(call wait_for_status,registry_seed,exited)
71+
72+ .PHONY : test-environment-up
73+ test-environment-running : test-environment-up wait-for-services
74+
75+ .PHONY : local-test-environment-up
76+ local-test-environment-running : local-test-environment-up wait-for-services
77+
5278.PHONY : smoketests
53- smoketests : test-environment-up
79+ smoketests : wait-for-images
5480 cd tests && make smoketests
0 commit comments