Secure, Fast, and Extensible Sandbox runtime for AI agents.
fix(tests): parameterize the template origin in the fsb SDK e2e
高然612f4fe56601
diff --git a/scripts/fast-sandbox-env/integration-env.sh b/scripts/fast-sandbox-env/integration-env.shindex fe3686976..d0e37f9ff 100755--- a/scripts/fast-sandbox-env/integration-env.sh+++ b/scripts/fast-sandbox-env/integration-env.sh@@ -2695,18 +2695,19 @@ sdk_e2e() {|| die "server $SERVER_URL is not reachable (run up first)"command -v uv >/dev/null 2>&1 \|| die "uv is required on PATH (https://docs.astral.sh/uv/ — curl -LsSf https://astral.sh/uv/install.sh | sh)"- local -a template_ids=()+ local -a template_ids=() template_origins=()local template_idtemplate_id="$(cat "$WORK/template-id" 2>/dev/null || true)"[[ -n "$template_id" ]] || die "no template id at $WORK/template-id (run up first; template_up stores it there)"template_ids+=("$template_id")+ template_origins+=("fast-sandbox-env")if [[ "$OCI_STACK" == 1 ]]; thenlocal oci_template_idoci_template_id="$(cat "$WORK/overlaybd-template-id" 2>/dev/null || true)"# The suite runs once per template: the overlaybd pass exercises the# SDK contract on the on-demand path (the server resolves the OCI# template's status.manifestRef on template-mode creates).- [[ -n "$oci_template_id" ]] && template_ids+=("$oci_template_id")+ [[ -n "$oci_template_id" ]] && template_ids+=("$oci_template_id") template_origins+=("fast-sandbox-env-oci")fiexport OPENSANDBOX_TEST_DOMAIN="127.0.0.1:$SERVER_HOST_PORT"export OPENSANDBOX_TEST_PROTOCOL="http"@@ -2715,9 +2716,11 @@ sdk_e2e() {# No exec: the ERR trap (and the failure dump) must survive a pytest# failure, and exec replaces the shell. One pytest run per template so a# failure names its template.- for template_id in "${template_ids[@]}"; do- export OPENSANDBOX_TEST_FSB_TEMPLATE_ID="$template_id"- log "sdk e2e: template=$template_id server=$SERVER_URL -> tests/python/tests/test_fsb_e2e.py"+ local index+ for index in "${!template_ids[@]}"; do+ export OPENSANDBOX_TEST_FSB_TEMPLATE_ID="${template_ids[$index]}"+ export OPENSANDBOX_TEST_FSB_TEMPLATE_ORIGIN="${template_origins[$index]}"+ log "sdk e2e: template=${template_ids[$index]} (origin=${template_origins[$index]}) server=$SERVER_URL -> tests/python/tests/test_fsb_e2e.py"uv run pytest tests/test_fsb_e2e.pydone}diff --git a/tests/python/tests/test_fsb_e2e.py b/tests/python/tests/test_fsb_e2e.pyindex 6e6d283ae..f43f0067e 100644--- a/tests/python/tests/test_fsb_e2e.py+++ b/tests/python/tests/test_fsb_e2e.py@@ -66,6 +66,10 @@ from opensandbox.sandbox import Sandboxlogger = logging.getLogger(__name__)FSB_TEMPLATE_ID = os.getenv("OPENSANDBOX_TEST_FSB_TEMPLATE_ID", "")+# The suite runs once per template in the integration env (native first,+# then the overlaybd one); each carries a different origin metadata value,+# so the catalog assertions key off what the env actually passed in.+FSB_TEMPLATE_ORIGIN = os.getenv("OPENSANDBOX_TEST_FSB_TEMPLATE_ORIGIN", "fast-sandbox-env")# alpine ships busybox wget: a real HTTPS request, so egress probes# exercise both gates of the fsb dns+nft chain (DNS resolution and# transport). Override with e.g. curlimages/curl if cert-verified curl@@ -221,10 +225,10 @@ class TestFsbE2E:info = await manager.get_template(FSB_TEMPLATE_ID)assert info.status.phase == TemplatePhase.SUCCEEDEDassert info.status.manifest_ref, "template manifestRef is empty"- assert info.metadata.get("origin") == "fast-sandbox-env"+ assert info.metadata.get("origin") == FSB_TEMPLATE_ORIGINpaged = await manager.list_templates(- TemplateFilter(metadata={"origin": "fast-sandbox-env"})+ TemplateFilter(metadata={"origin": FSB_TEMPLATE_ORIGIN}))assert FSB_TEMPLATE_ID in [t.template_id for t in paged.template_infos]