mirror of
https://github.com/Donkie/Spoolman.git
synced 2026-10-21 09:39:46 -05:00
Running tests_integration against rootless Podman surfaced three issues; none affect the Docker/CI path: - run.py: add a SPOOLMAN_CONTAINER_ENGINE env var (defaults to "docker") so the build/compose commands can be driven by podman instead. - Dockerfile: drop `--chown=app:app` from the builder-stage COPYs. The "app" user only exists in the runner stage; Docker/BuildKit tolerated the dangling reference but Podman rejects it. Final ownership is unchanged — it is set when the files are copied into the runner stage. - docker-compose-postgres.yml: add a pg_isready healthcheck and gate spoolman on `condition: service_healthy`, matching the mariadb/cockroachdb compose files. Without it spoolman raced postgres' initdb and died on connection-refused before running migrations. Verified: full 4-DB suite (sqlite/postgres/mariadb/cockroachdb) green via `SPOOLMAN_CONTAINER_ENGINE=podman uv run poe itest` — 223 tests each.
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
"""Build and run the integration tests."""
|
|
|
|
# ruff: noqa: S605, T201
|
|
|
|
import os
|
|
import sys
|
|
|
|
# Container engine to use. Defaults to "docker"; set SPOOLMAN_CONTAINER_ENGINE=podman
|
|
# to run the suite with rootless Podman (both expose a compatible `build` and
|
|
# `compose` CLI).
|
|
ENGINE = os.environ.get("SPOOLMAN_CONTAINER_ENGINE", "docker")
|
|
|
|
if __name__ == "__main__":
|
|
print(f"Building and running integration tests (engine: {ENGINE})...")
|
|
print("Building Spoolman...")
|
|
if os.system(f"{ENGINE} build -t donkie/spoolman:test .") > 0:
|
|
print("Failed to build Spoolman!")
|
|
sys.exit(1)
|
|
print("Building Spoolman tester...")
|
|
if os.system(f"{ENGINE} build -t donkie/spoolman-tester:latest tests_integration") > 0:
|
|
print("Failed to build Spoolman tester!")
|
|
sys.exit(1)
|
|
|
|
# Support input arguments for running only specific tests
|
|
if len(sys.argv) > 1:
|
|
targets = sys.argv[1:]
|
|
# Check that all targets are valid
|
|
for target in targets:
|
|
if target not in ["postgres", "sqlite", "mariadb", "cockroachdb"]:
|
|
print(f"Unknown target: {target}")
|
|
sys.exit(1)
|
|
else:
|
|
print("No targets specified, running all tests...")
|
|
targets = [
|
|
"postgres",
|
|
"sqlite",
|
|
"mariadb",
|
|
"cockroachdb",
|
|
]
|
|
|
|
for target in targets:
|
|
print(f"Running integration tests against {target}...")
|
|
os.system(f"{ENGINE} compose -f tests_integration/docker-compose-{target}.yml down -v")
|
|
if (
|
|
os.system(f"{ENGINE} compose -f tests_integration/docker-compose-{target}.yml up --abort-on-container-exit")
|
|
> 0
|
|
):
|
|
print(f"Integration tests against {target} failed!")
|
|
sys.exit(1)
|
|
|
|
print("Integration tests passed!")
|