#!/bin/sh # Run inside the idle trusted agent from a non-secret preparation snapshot. # This is a capacity/tool trial, never a reviewed release or registry push. set -eu export TRIVY_CACHE_DIR=/home/jenkins/agent/.cache/trivy mkdir -p build/delivery/reports date -u python3 -B -m unittest discover -s delivery/ci -p 'test_controls.py' -v sh delivery/ci/test-app.sh python3 delivery/ci/security.py source : "${DELIVERY_BUILDER:?use the limited remote builder}" docker buildx build --builder "$DELIVERY_BUILDER" --load --platform linux/amd64 \ --build-arg APP_COMMIT=uncommitted-remote-preflight \ -t ssw590-pricing:remote-preflight-v1 delivery/app python3 delivery/ci/security.py image --image ssw590-pricing:remote-preflight-v1 name=ssw590-delivery-capacity-smoke cleanup() { docker rm -f "$name" >/dev/null 2>&1 || true; } # Refuse to replace any existing container, even one from an interrupted trial. if docker container inspect "$name" >/dev/null 2>&1; then echo 'Inspect the existing trial container before retrying' >&2 exit 1 fi trap cleanup EXIT docker run -d --name "$name" --network gitea_web --read-only \ --tmpfs /tmp:rw,nosuid,noexec,size=16m --memory 64m --memory-swap 96m \ --cpus .25 --pids-limit 64 --cap-drop ALL --security-opt no-new-privileges \ ssw590-pricing:remote-preflight-v1 python3 - <<'PY' import json, time, urllib.request, urllib.error url = 'http://ssw590-delivery-capacity-smoke:8000' for attempt in range(30): try: with urllib.request.urlopen(url + '/health', timeout=2) as response: health = json.load(response) break except (OSError, ValueError): time.sleep(1) else: raise RuntimeError('Application failed to start') def get(path): with urllib.request.urlopen(url + path, timeout=5) as response: return json.load(response) identity, price = get('/'), get('/price?quantity=3') assert health['status'] == 'ok' and health['version'] == 'v1', health assert identity['commit'] == 'uncommitted-remote-preflight', identity assert price['total'] == 30, price try: get('/price?quantity=-1') raise AssertionError('Invalid quantity accepted') except urllib.error.HTTPError as error: assert error.code == 400, error.code print(json.dumps({'health': health, 'identity': identity, 'price': price, 'invalid_quantity_status': 400}, indent=2)) PY docker inspect "$name" --format 'smoke OOMKilled={{.State.OOMKilled}} memory={{.HostConfig.Memory}}' date -u echo 'PASS: remote capacity preparation; no image published or assessed environment deployed'