Files
Open_Ultra_SAST/tests/test_unseen_image.py
T
Marius CiepluchandClaude Opus 4.8 e49c150316 test(infra): fix the 3 stale/flaky infra tests to the current contracts
- test_engine_image_and_rustfs_policy: root Dockerfile was refactored to the
  digest-pinned ousast-task-base (carries semantic+s3 deps) + a joern-build stage,
  installing the package --no-deps. Updated the stale `COPY benchmarks` (now
  --chown=1000) and `.[semantic,s3]` (now --no-deps + joern-cli copy + pinned base)
  assertions to the new contract.
- test_image_stages: plane/Dockerfile.engine-task refactored the same way; the
  split marker is now `FROM ${ENGINE_REF} AS replay`, base is ousast-task-base
  (not ax-task-runner:v0.3.1), and the replay stage no longer installs git (base
  provides it). Re-pinned the engine-stage SHA and updated the markers/assertions.
- test_partial_clone_lazy_fetch: passed alone but failed mid-suite — a leaked
  GIT_DIR/GIT_OBJECT_DIRECTORY/alternates from an earlier test changed the
  missing-blob count. Added an autouse fixture that neutralises inherited git
  control vars so every test in the file is self-contained (reproduced + verified).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-10-12 15:58:11 +02:00

23 lines
1.3 KiB
Python

"""Static image contract; no Docker invocation."""
import hashlib
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
# The engine portion is pinned so that adding the replay stage cannot silently change the engine image.
# Recompute after an intentional engine-stage change: it is sha256 of `engine.rstrip() + "\n"` where `engine`
# is everything before the `FROM ${ENGINE_REF} AS replay` line.
ENGINE_SHA = "77c34f3381cef6c6d1f7fd761cd3924a3656cc5e6eb20c51c819de77afb4b2fc"
def test_image_stages():
text = (ROOT / "plane/Dockerfile.engine-task").read_text()
# The replay stage builds FROM the engine stage (via the ENGINE_REF arg, default `engine`).
engine, replay = text.split("FROM ${ENGINE_REF} AS replay", 1)
assert hashlib.sha256((engine.rstrip() + "\n").encode()).hexdigest() == ENGINE_SHA
# Task base is digest-pinned (no floating fallback) and built in two stages: joern-build -> engine.
assert "FROM ghcr.io/norandom/ousast-task-base:${TASK_BASE_TAG}@${TASK_BASE_DIGEST} AS joern-build" in engine
assert "FROM ghcr.io/norandom/ousast-task-base:${TASK_BASE_TAG}@${TASK_BASE_DIGEST} AS engine" in engine
# The replay stage is a pure addition on top of engine: the unseen replay harness + a smoke check.
assert "replay_entry.py" in replay and "ousast pre-push --help" in replay