diff --git a/tests/configs/nginx.py b/tests/configs/nginx.py index d49a033..75d1bab 100644 --- a/tests/configs/nginx.py +++ b/tests/configs/nginx.py @@ -7,14 +7,21 @@ from steps.git import GitClone, CheckoutMerged, GitUnmerge from steps.shared_state import SharedStateHolderInMemory REPO_ROOT = Path(__file__).resolve().parents[2] -CURRENT_BRANCH = subprocess.check_output( - ["git", "-C", str(REPO_ROOT), "rev-parse", "--abbrev-ref", "HEAD"], - text=True, -).strip() -CURRENT_COMMIT = subprocess.check_output( - ["git", "-C", str(REPO_ROOT), "rev-parse", "HEAD"], - text=True, -).strip() + + +def _git_output(*args: str) -> str: + try: + return subprocess.check_output( + ["git", "-C", str(REPO_ROOT), *args], + text=True, + stderr=subprocess.STDOUT, + ).strip() + except subprocess.CalledProcessError as exc: + raise RuntimeError(f"Unable to read git metadata for nginx test config: {' '.join(args)}\n{exc.output}") from exc + + +CURRENT_BRANCH = _git_output("rev-parse", "--abbrev-ref", "HEAD") +CURRENT_COMMIT = _git_output("rev-parse", "HEAD") clone = GitClone(url="https://github.com/rudolf1/brencher.git") diff --git a/tests/test_dry_run_playwright.py b/tests/test_dry_run_playwright.py index 85d5649..564c0c8 100644 --- a/tests/test_dry_run_playwright.py +++ b/tests/test_dry_run_playwright.py @@ -79,11 +79,8 @@ class TestDryRunPlaywright: # Wait for the real container to be created and started. eventually( - lambda: assert_equal( - {container.status for container in docker_client.containers.list(filters={"name": CONTAINER_NAME}, all=True)}, - {"running"}, - "Container should exist and be running after deploy", - ), + lambda: _assert_container_running(docker_client), + # Allow time for a cold image build and first container start on CI runners. timeout=180, interval=5.0, ) @@ -99,3 +96,9 @@ class TestDryRunPlaywright: server_thread.join(timeout=30) if server_thread.is_alive(): logger.warning("App server thread did not stop within 30 seconds") + + +def _assert_container_running(docker_client: docker.DockerClient) -> None: + containers = docker_client.containers.list(filters={"name": CONTAINER_NAME}, all=True) + assert len(containers) > 0, "Container should exist after deploy" + assert_equal({container.status for container in containers}, {"running"}, "Container should be running after deploy")