mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-21 08:21:13 +00:00
6599d828d2
Three blackbox-harness tasks landed together — all depend only on
AZ-406 and unblock the FT-* / NFT-* scenario tasks scheduled for
batches 69+.
AZ-407 — Static fixture builders (3pt):
* tile-cache-builder/{builder.py, Dockerfile, build.sh} produces a
deterministic tile-cache-fixture Docker volume from
_docs/00_problem/input_data/. Reproducibility primitives: sorted
iteration, frozen PIL JPEG settings, FAISS HNSW32 built single-
threaded with seeded stub descriptors.
* age-injector/{age_injector.py, inject.sh} clones the volume and
shifts capture_date by N×30.44 days; tile JPEG bytes preserved
bit-identical. Emits synth-age-7mo + synth-age-13mo volumes.
* cold-boot/cold_boot_fixture.json: frozen FC pose snapshot at
Derkachi sector centre, schema v1.
* secrets/mavlink-test-passkey.txt: 64-hex with required
`# TEST ONLY` header line per AC-5. Passkey-equality test now
compares the secret line after stripping the header.
* security/cve-2025-53644.jpg: synthetic 158-byte malformed JPEG
(truncated SOS marker). OpenCV 4.11.x rejects gracefully with
imdecode → None. AZ-439 will sharpen for ASan instrumentation.
* Top-level Makefile with `make fixtures` / `make fixtures-*` /
`make e2e-tier1*` / `make unit-tests` targets.
AZ-444 — Tier-2 Jetson harness wrapper (5pt):
* run-tier2.sh rewritten as orchestrator. Detects local
(aarch64 + TIER2_HOST=localhost) vs remote (ssh into TIER2_HOST).
New flags: -k/--selector, --build-kind production|asan,
--reflash (gated behind TIER2_REFLASH_ACK=1 two-key gate),
--dry-run.
* tier2-on-jetson.sh (new) — on-device delegate. Verifies
gps-denied-onboard{,-asan}.service health; restarts with 5s
tolerance; spawns tegrastats + jtop parallel samplers; tails
ASan unit's journal in asan mode; drives docker compose with
TIER=tier2-jetson; forwards SELECTOR to pytest -k.
* docker/run-tier1.sh (new) — selector-parity sibling.
* AC-1 (selector parity) and AC-6 (reflash gating) unit-tested via
--dry-run output assertions. AC-2/AC-3/AC-4/AC-5 are hardware-
loop ACs verified by the Tier-2 runtime smoke (no Jetson in the
unit-test layer).
AZ-445 — CSV reporter + evidence bundler refinements (2pt):
* reporting/nfr_recorder.py (new) — pytest plugin. Provides the
`nfr_recorder` fixture with record_metric(name, value, ac_id)
and partial(ac_id, reason). At session end emits:
- per-nfr/<scenario_id>.json (AC-1)
- traceability-status.json with every AC ID parsed from
traceability-matrix.md, classified Covered/PARTIAL/NOT
COVERED with source scenario IDs (AC-2)
- regression-baseline.json with all numeric metrics (AC-3)
* csv_reporter.py extended — `_outcome_to_result` consults the
aggregator; rows flip PASS → PARTIAL when an AC was marked
PARTIAL by nfr_recorder (AC-4). Graceful fallback when
aggregator isn't registered (unit-test contexts).
* conftest.py registers nfr_recorder in pytest_plugins.
* New --traceability-matrix CLI flag seeds the NOT COVERED rows.
Build / config:
* pyproject.toml dev extras: added Pillow>=10.4,<13.0 for the
tile-cache-builder unit test (broad enough to keep torchvision's
Pillow 12 pin happy; the production builder runs inside its own
Docker image with its own pin).
* Updated test_directory_layout.py to cover 10 new files + replaced
the byte-equal passkey assertion with the header-stripping
variant.
Test results:
* 157 focused tests pass (was 97 in batch 67; +60 new across this
batch). No regressions.
Module-layout / spec drift:
* AZ-407 spec text says `tests/fixtures/...`; module-layout
blackbox_tests entry (commit d7a17a8) authoritatively places the
harness under `e2e/`. Implementation followed the layout entry.
* AZ-444 spec mentions `e2e/tier2/run-tier2.sh`; AZ-406 placed it
at `e2e/jetson/run-tier2.sh`. Kept at `e2e/jetson/` for
consistency.
* Cold-boot README ownership: corrected from AZ-419 to AZ-407 per
AZ-419's own Dependencies field.
Specs archived to _docs/02_tasks/done/. Jira tickets transitioned to
In Testing on commit.
Co-authored-by: Cursor <cursoragent@cursor.com>
150 lines
5.5 KiB
Bash
Executable File
150 lines
5.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Tier-2 ON-JETSON delegate. NOT invoked directly by humans — `run-tier2.sh`
|
|
# ssh-orchestrates this script onto the configured Jetson host.
|
|
#
|
|
# Responsibilities:
|
|
# * Verify `gps-denied-onboard.service` (or the `*-asan` variant) is healthy.
|
|
# * Spawn tegrastats + jtop parallel samplers; route their output into the
|
|
# evidence bundle.
|
|
# * Drive the e2e-runner image via docker compose against
|
|
# `docker-compose.test.yml + docker-compose.tier2-bridge.yml`.
|
|
# * Tear down samplers cleanly on EXIT / INT / TERM.
|
|
#
|
|
# Required env vars (set by run-tier2.sh):
|
|
# RUN_ID Run identifier (utc-stamp).
|
|
# FC_ADAPTER ardupilot | inav
|
|
# VIO_STRATEGY okvis2 | klt_ransac | vins_mono
|
|
# BUILD_KIND production | asan
|
|
# SELECTOR pytest -k expression (may be empty)
|
|
# ENABLE_CHAMBER 0 | 1
|
|
# JETSON_HOST host alias used by the test for SUT identification
|
|
|
|
set -euo pipefail
|
|
|
|
: "${RUN_ID:?RUN_ID must be set by run-tier2.sh}"
|
|
: "${FC_ADAPTER:?FC_ADAPTER must be set}"
|
|
: "${VIO_STRATEGY:?VIO_STRATEGY must be set}"
|
|
: "${BUILD_KIND:=production}"
|
|
: "${SELECTOR:=}"
|
|
: "${ENABLE_CHAMBER:=0}"
|
|
: "${JETSON_HOST:=localhost}"
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
|
RESULTS_DIR="${REPO_ROOT}/e2e-results/run-${RUN_ID}"
|
|
EVIDENCE_DIR="${RESULTS_DIR}/evidence"
|
|
|
|
mkdir -p "${EVIDENCE_DIR}"
|
|
|
|
# AC-5: the asan build is a separate systemd unit so it can run alongside
|
|
# the production one for control/treatment comparisons.
|
|
case "${BUILD_KIND}" in
|
|
production)
|
|
SUT_UNIT="gps-denied-onboard.service"
|
|
;;
|
|
asan)
|
|
SUT_UNIT="gps-denied-onboard-asan.service"
|
|
# ASan stderr stream is captured into the evidence bundle (see
|
|
# AC-5: "stderr captured into asan-fuzz-${test_id}.log"). We tail
|
|
# the unit's journal into the evidence file via journalctl.
|
|
ASAN_LOG="${EVIDENCE_DIR}/asan-fuzz.log"
|
|
;;
|
|
*)
|
|
echo "[tier2-on-jetson] FATAL: unknown BUILD_KIND=${BUILD_KIND}" >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
# AC-3: systemd lifecycle. Restart on demand; fail loud if it doesn't
|
|
# come back up.
|
|
echo "[tier2-on-jetson] verifying ${SUT_UNIT} is active..."
|
|
if ! systemctl is-active --quiet "${SUT_UNIT}"; then
|
|
echo "[tier2-on-jetson] ${SUT_UNIT} is not active — restarting..." >&2
|
|
sudo systemctl restart "${SUT_UNIT}"
|
|
# AC-3 says "restart within ≤5 s"; we poll up to 5s + 1s safety
|
|
# margin.
|
|
for _ in 1 2 3 4 5 6; do
|
|
sleep 1
|
|
if systemctl is-active --quiet "${SUT_UNIT}"; then
|
|
break
|
|
fi
|
|
done
|
|
if ! systemctl is-active --quiet "${SUT_UNIT}"; then
|
|
echo "[tier2-on-jetson] FATAL: ${SUT_UNIT} failed to start" >&2
|
|
sudo systemctl status "${SUT_UNIT}" --no-pager || true
|
|
exit 3
|
|
fi
|
|
fi
|
|
|
|
# AC-4: tegrastats + jtop parallel capture. Output streams into the
|
|
# evidence bundle.
|
|
TEGRA_CSV="${EVIDENCE_DIR}/tegrastats-${JETSON_HOST}-${RUN_ID}.csv"
|
|
JTOP_CSV="${EVIDENCE_DIR}/jtop-${JETSON_HOST}-${RUN_ID}.csv"
|
|
TEGRA_PID=""
|
|
JTOP_PID=""
|
|
ASAN_TAIL_PID=""
|
|
|
|
if command -v tegrastats >/dev/null 2>&1; then
|
|
# 5 Hz sampling matches the parser's expected cadence.
|
|
tegrastats --interval 200 \
|
|
| python3 "${SCRIPT_DIR}/tegrastats_parser.py" --out "${TEGRA_CSV}" &
|
|
TEGRA_PID=$!
|
|
echo "[tier2-on-jetson] tegrastats sampler pid=${TEGRA_PID} → ${TEGRA_CSV}"
|
|
else
|
|
echo "[tier2-on-jetson] WARNING: tegrastats not in PATH — skipping that evidence channel." >&2
|
|
fi
|
|
|
|
if command -v jtop >/dev/null 2>&1; then
|
|
python3 "${SCRIPT_DIR}/jtop_parser.py" --out "${JTOP_CSV}" --interval 1.0 &
|
|
JTOP_PID=$!
|
|
echo "[tier2-on-jetson] jtop sampler pid=${JTOP_PID} → ${JTOP_CSV}"
|
|
else
|
|
echo "[tier2-on-jetson] WARNING: jtop not in PATH — skipping that evidence channel." >&2
|
|
fi
|
|
|
|
if [[ "${BUILD_KIND}" == "asan" ]]; then
|
|
journalctl -u "${SUT_UNIT}" -f --no-pager > "${ASAN_LOG}" 2>&1 &
|
|
ASAN_TAIL_PID=$!
|
|
echo "[tier2-on-jetson] asan journal tail pid=${ASAN_TAIL_PID} → ${ASAN_LOG}"
|
|
fi
|
|
|
|
cleanup() {
|
|
local rc=$?
|
|
[[ -n "${TEGRA_PID}" ]] && kill "${TEGRA_PID}" 2>/dev/null || true
|
|
[[ -n "${JTOP_PID}" ]] && kill "${JTOP_PID}" 2>/dev/null || true
|
|
[[ -n "${ASAN_TAIL_PID}" ]] && kill "${ASAN_TAIL_PID}" 2>/dev/null || true
|
|
echo "[tier2-on-jetson] cleanup complete (rc=${rc})"
|
|
exit "${rc}"
|
|
}
|
|
trap cleanup EXIT INT TERM
|
|
|
|
# AC-1: selector parity. SELECTOR is forwarded as `-k "<expr>"` to the
|
|
# pytest inside the runner image; empty SELECTOR means "all tests".
|
|
PYTEST_ARGS=("/test-suite")
|
|
PYTEST_ARGS+=("--csv=/e2e-results/run-${RUN_ID}/report.csv")
|
|
PYTEST_ARGS+=("--csv-columns=test_id,test_name,traces_to,fc_adapter,vio_strategy,tier,started_at_utc,execution_time_ms,result,error_message,evidence_paths")
|
|
PYTEST_ARGS+=("--evidence-out=/e2e-results/run-${RUN_ID}/evidence")
|
|
PYTEST_ARGS+=("--build-kind=${BUILD_KIND}")
|
|
[[ "${ENABLE_CHAMBER}" -eq 1 ]] && PYTEST_ARGS+=("--enable-chamber")
|
|
[[ -n "${SELECTOR}" ]] && PYTEST_ARGS+=("-k" "${SELECTOR}")
|
|
|
|
(
|
|
cd "${REPO_ROOT}/e2e/docker"
|
|
RUN_ID="${RUN_ID}" \
|
|
FC_ADAPTER="${FC_ADAPTER}" \
|
|
VIO_STRATEGY="${VIO_STRATEGY}" \
|
|
TIER="tier2-jetson" \
|
|
JETSON_HOST="${JETSON_HOST}" \
|
|
BUILD_KIND="${BUILD_KIND}" \
|
|
docker compose \
|
|
-f docker-compose.test.yml \
|
|
-f docker-compose.tier2-bridge.yml \
|
|
run --rm \
|
|
-e TIER=tier2-jetson \
|
|
-e BUILD_KIND="${BUILD_KIND}" \
|
|
e2e-runner \
|
|
pytest "${PYTEST_ARGS[@]}"
|
|
)
|
|
|
|
echo "[tier2-on-jetson] Suite complete. Report: ${RESULTS_DIR}/report.csv"
|