Skip to content

Commit db89d13

Browse files
authored
add docker cleanup to integration tests (#2465)
related to #2425 # Rationale for this change This PR updates the Makefile's test-integration target to cleanup the docker containers by default. Also, adds a variable (`KEEP_COMPOSE`) that can ignore the cleanup for development purposes. but the setup ## Are these changes tested? yes ## Are there any user-facing changes? no
1 parent 642f9fc commit db89d13

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@
2121
PYTEST_ARGS ?= -v # Override with e.g. PYTEST_ARGS="-vv --tb=short"
2222
COVERAGE ?= 0 # Set COVERAGE=1 to enable coverage: make test COVERAGE=1
2323
COVERAGE_FAIL_UNDER ?= 85 # Minimum coverage % to pass: make coverage-report COVERAGE_FAIL_UNDER=70
24+
KEEP_COMPOSE ?= 0 # Set KEEP_COMPOSE=1 to keep containers after integration tests
2425

2526
ifeq ($(COVERAGE),1)
2627
TEST_RUNNER = poetry run coverage run --parallel-mode --source=pyiceberg -m
2728
else
2829
TEST_RUNNER = poetry run
2930
endif
3031

32+
ifeq ($(KEEP_COMPOSE),1)
33+
CLEANUP_COMMAND = echo "Keeping containers running for debugging (KEEP_COMPOSE=1)"
34+
else
35+
CLEANUP_COMMAND = docker compose -f dev/docker-compose-integration.yml down -v --remove-orphans 2>/dev/null || true
36+
endif
37+
3138
POETRY_VERSION = 2.1.4
3239

3340
# ============
@@ -85,7 +92,7 @@ lint: ## Run code linters via pre-commit
8592
test: ## Run all unit tests (excluding integration)
8693
$(TEST_RUNNER) pytest tests/ -m "(unmarked or parametrize) and not integration" $(PYTEST_ARGS)
8794

88-
test-integration: test-integration-setup test-integration-exec ## Run integration tests
95+
test-integration: test-integration-setup test-integration-exec test-integration-cleanup ## Run integration tests
8996

9097
test-integration-setup: ## Start Docker services for integration tests
9198
docker compose -f dev/docker-compose-integration.yml kill
@@ -98,6 +105,12 @@ test-integration-setup: ## Start Docker services for integration tests
98105
test-integration-exec: ## Run integration tests (excluding provision)
99106
$(TEST_RUNNER) pytest tests/ -m integration $(PYTEST_ARGS)
100107

108+
test-integration-cleanup: ## Clean up integration test environment
109+
@if [ "${KEEP_COMPOSE}" != "1" ]; then \
110+
echo "Cleaning up Docker containers..."; \
111+
fi
112+
$(CLEANUP_COMMAND)
113+
101114
test-integration-rebuild: ## Rebuild integration Docker services from scratch
102115
docker compose -f dev/docker-compose-integration.yml kill
103116
docker compose -f dev/docker-compose-integration.yml rm -f

0 commit comments

Comments
 (0)