Files
gps-denied-onboard/tests/unit/test_ac3_compose_files.py
Oleksandr Bezdieniezhnykh 5fe67023b2 [AZ-329] [AZ-330] [AZ-523] [AZ-524] Batch 44 atomic refactor
Implements two new C12 services and rebalances the C11/C12 boundary
in one atomic commit:

* AZ-329 PostLandingUploadOrchestrator — gates C11 upload on the
  `flight_footer` FDR record's `clean_shutdown` field; 4 refusal
  modes; new FdrFooterReader Protocol + LocalFdrFooterReader.
* AZ-330 OperatorReLocService — AC-3.4 visual-loss re-localization
  hint; reuses shared LatLonAlt; OperatorCommandTransport Protocol
  cut (E-C8 owns the future pymavlink concrete); new FDR record
  kind `c12.reloc.requested`; log redaction (lat/lon 5 decimals,
  reason 200 chars).
* AZ-523 C11 internal flight-state gate removed (SRP refactor):
  `confirm_flight_state` / `FlightStateSignal` use /
  `FlightStateNotOnGroundError` deleted from C11; TileUploader
  contract bumped to v2.0.0 (frozen) with migration note; AZ-317
  superseded.
* AZ-524 Package rename `c12_operator_tooling` →
  `c12_operator_orchestrator` across source, tests, pyproject,
  CMake, Dockerfile, compose, CI, runtime-root services class
  (`OperatorOrchestratorServices`) + factory function
  (`build_operator_orchestrator`), logger namespaces, config slug,
  docs, and the E-C12 epic title.

Tests: 1543 passed, 80 skipped (all environment gates). Targeted
AC suite (AZ-329 + AZ-330 + FdrFooterReader): 37 passed. Cold-start
NFR-perf still ≤ 500 ms p99.

Tracker: AZ-317 → Done (superseded); AZ-319 v2.0.0 contract bump
comment; AZ-329/AZ-330 → In Testing; AZ-253 epic renamed; AZ-523
+ AZ-524 created and closed as audit-trail tickets.

See `_docs/03_implementation/batch_44_cycle1_report.md`.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 19:42:46 +03:00

79 lines
2.5 KiB
Python

"""AC-3: docker-compose.yml and docker-compose.test.yml are valid.
YAML syntactic validity always runs. The `docker compose ... config --quiet`
shape validation requires the Docker daemon and the v2 plugin; when those are
not present, that test skips with the prerequisite reason.
"""
from __future__ import annotations
import shutil
import subprocess
from pathlib import Path
import pytest
import yaml
REPO_ROOT = Path(__file__).resolve().parents[2]
COMPOSE_FILES = (
REPO_ROOT / "docker-compose.yml",
REPO_ROOT / "docker-compose.test.yml",
)
@pytest.mark.parametrize("compose_path", COMPOSE_FILES)
def test_compose_yaml_parses(compose_path: Path) -> None:
# Act
parsed = yaml.safe_load(compose_path.read_text())
# Assert
assert isinstance(parsed, dict), f"{compose_path.name} must parse to a mapping"
assert "services" in parsed, f"{compose_path.name} must declare a services block"
def test_compose_yml_declares_required_services() -> None:
# Arrange
data = yaml.safe_load((REPO_ROOT / "docker-compose.yml").read_text())
services = data["services"]
# Assert
for required in ("companion", "operator-orchestrator", "mock-sat", "db"):
assert required in services, f"docker-compose.yml missing service: {required}"
def test_compose_test_yml_extends_base() -> None:
# Arrange
data = yaml.safe_load((REPO_ROOT / "docker-compose.test.yml").read_text())
# Assert
assert "services" in data, "docker-compose.test.yml must declare services"
assert "e2e-runner" in data["services"], (
"docker-compose.test.yml must declare the e2e-runner sidecar"
)
@pytest.mark.parametrize("compose_path", COMPOSE_FILES)
def test_compose_config_quiet(compose_path: Path) -> None:
# Arrange
docker = shutil.which("docker")
if docker is None:
pytest.skip("docker CLI not on PATH; Tier-1 CI image installs Docker")
plugin_check = subprocess.run(
[docker, "compose", "version"], capture_output=True, text=True, check=False
)
if plugin_check.returncode != 0:
pytest.skip("docker compose v2 plugin unavailable; Tier-1 CI image installs it")
# Act
result = subprocess.run(
[docker, "compose", "-f", str(compose_path), "config", "--quiet"],
cwd=REPO_ROOT,
capture_output=True,
text=True,
check=False,
)
# Assert
assert result.returncode == 0, (
f"docker compose config --quiet failed for {compose_path.name}:\n"
f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}"
)