#!/usr/bin/env bash # Test: argo-train.sh --profile renders an Argo workflow that contains the # `nsys profile` wrapper and the foxhunt-training-artifacts upload step. # # Validation surface for Plan 5 Task 3 (A.4.1) — nsys profile harness. # Verifies the harness without running the workflow against a live cluster # (the dry-run path renders the multi-seed template file directly when # --profile is set). set -euo pipefail # Resolve repo root from this script's location so the test runs from any cwd. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" cd "${REPO_ROOT}" DRY_OUT=$(mktemp -t nsys-dry.XXXXXX.yaml) trap 'rm -f "$DRY_OUT"' EXIT # 1) --profile --multi-seed 1 --folds 1 --dry-run must render YAML containing: # - the `nsys profile` wrapper string (training-side instrumentation) # - the `foxhunt-training-artifacts` MinIO bucket reference (artefact upload) ./scripts/argo-train.sh dqn --profile --multi-seed 1 --folds 1 --dry-run \ > "$DRY_OUT" 2>&1 if ! grep -q "nsys profile" "$DRY_OUT"; then echo "FAIL: --profile flag does not produce nsys wrapper in rendered YAML" echo "--- dry-run output (first 80 lines) ---" head -n 80 "$DRY_OUT" exit 1 fi echo "PASS: --profile renders nsys profile wrapper" if ! grep -q "foxhunt-training-artifacts" "$DRY_OUT"; then echo "FAIL: --profile flag does not produce foxhunt-training-artifacts upload step" echo "--- dry-run output (first 80 lines) ---" head -n 80 "$DRY_OUT" exit 1 fi echo "PASS: --profile renders foxhunt-training-artifacts upload step" # 2) Backward-compat: a default-flag run (no --profile) must NOT contain the # nsys wrapper or artefact bucket — these are gated by the new flag only. DRY_OUT_NO_PROF=$(mktemp -t nsys-dry-noprof.XXXXXX.yaml) trap 'rm -f "$DRY_OUT" "$DRY_OUT_NO_PROF"' EXIT ./scripts/argo-train.sh dqn --multi-seed 2 --folds 1 --dry-run \ > "$DRY_OUT_NO_PROF" 2>&1 # The template DOES contain the literal `profile` parameter declaration with # default value "false" (template-level conditional gate). Assert that the # rendered workflow defaults to profile=false so a production no-profile run # does not accidentally trigger nsys + upload. if ! grep -q 'name: profile' "$DRY_OUT_NO_PROF"; then echo "FAIL: profile parameter not declared in multi-seed template" exit 1 fi echo "PASS: multi-seed template declares profile parameter (default off)" echo "ALL PASS: nsys profile harness wired correctly"