SHA256
1
0
Files
autogits/integration/Makefile
Andrii Nikitin e1ce27250b t: refactor dedicated container for pytest
- remove test-obs service
- mock OBS calls using pytest-httpserver
- dedicated container for pytest to make sure it is in the same network as the services
- remove restart of obs-staging-bot and use new poll interval for it
- rework Makefile targets
2026-03-09 11:08:14 +01:00

94 lines
2.9 KiB
Makefile

# The topology is defined in podman-compose file and can be spawned in two ways:
# 1. podman-compose on a local machine (needs dependencies as defined in the Dockerfile)
# 2. pytest in a dedicated container (recommended)
# Typical workflow:
# 1. 'make build' - prepares images
# 2. 'make up' - spawns podman-compose
# 3. 'make pytest' - run tests inside the tester container
# 4. 'make down' - once the containers are not needed
#
# OR just run 'make test' to do it all at once.
AUTO_DETECT_MODE := $(shell if test -e ../workflow-pr/workflow-pr; then echo .local; else echo .package; fi)
# Default test target
test: test_b
build_local: AUTO_DETECT_MODE=.local
build_local: build
build_package: AUTO_DETECT_MODE=.package
build_package: build
# parse all service images from podman-compose and build them
# mode B with pytest in container
test_b: AUTO_DETECT_MODE=.local
test_b: build up wait_healthy pytest
# Complete cycle for CI
test-ci: test_b down
wait_healthy:
@echo "Waiting for services to be healthy..."
@echo "Waiting for gitea (max 2m)..."
@start_time=$$(date +%s); \
until podman exec gitea-test curl -f -s http://localhost:3000/api/v1/version >/dev/null 2>&1; do \
current_time=$$(date +%s); \
elapsed=$$((current_time - start_time)); \
if [ $$elapsed -gt 120 ]; then \
echo "ERROR: Gitea failed to start within 2 minutes."; \
echo "--- Troubleshooting Info ---"; \
echo "Diagnostics output (curl):"; \
podman exec gitea-test curl -v http://localhost:3000/api/v1/version || true; \
echo "--- Container Logs ---"; \
podman logs gitea-test --tail 20; \
echo "--- Container Status ---"; \
podman inspect gitea-test --format '{{.State.Status}}'; \
exit 1; \
fi; \
sleep 2; \
done
@echo "Waiting for rabbitmq (max 2m)..."
@start_time=$$(date +%s); \
until podman exec rabbitmq-test rabbitmq-diagnostics check_running -q >/dev/null 2>&1; do \
current_time=$$(date +%s); \
elapsed=$$((current_time - start_time)); \
if [ $$elapsed -gt 120 ]; then \
echo "ERROR: RabbitMQ failed to start within 2 minutes."; \
echo "--- Troubleshooting Info ---"; \
echo "Diagnostics output:"; \
podman exec rabbitmq-test rabbitmq-diagnostics check_running || true; \
echo "--- Container Logs ---"; \
podman logs rabbitmq-test --tail 20; \
echo "--- Container Status ---"; \
podman inspect rabbitmq-test --format '{{.State.Status}}'; \
exit 1; \
fi; \
sleep 2; \
done
@echo "All services are healthy!"
pytest:
podman-compose exec tester pytest -v tests
build:
podman pull docker.io/library/rabbitmq:3.13.7-management
for i in $$(grep -A 1000 services: podman-compose.yml | grep -oE '^ [^: ]+'); do GIWTF_IMAGE_SUFFIX=$(AUTO_DETECT_MODE) podman-compose build $$i || exit 1; done
# this will spawn prebuilt containers
up:
podman-compose up -d
# tear down
down:
podman-compose down
# mode A
up-bots-package:
GIWTF_IMAGE_SUFFIX=.package podman-compose up -d
# mode B
up-bots-local:
GIWTF_IMAGE_SUFFIX=.local podman-compose up -d