|
| 1 | +# Local Express pause and snapshot acceptance |
| 2 | + |
| 3 | +Keep credentials in ignored local configuration. Native project commands read |
| 4 | +ABX_SANDBOX_API_KEY/BASE_URL/DOMAIN; the standard entry additionally maps |
| 5 | +E2B_API_KEY/API_URL/DOMAIN. Never send an Express key to another provider. |
| 6 | +Official template operations separately need ALICLOUD_ACCESS_KEY_ID and |
| 7 | +ALICLOUD_ACCESS_KEY_SECRET; a runtime key cannot replace that authorization. |
| 8 | + |
| 9 | +## Design and prerequisites |
| 10 | + |
| 11 | +Pause/resume and snapshot tests use separate selectors. Prefer an isolated |
| 12 | +MicroVM generation2 fixture. Generation1 pause may need enablement; snapshots |
| 13 | +require MicroVM and account/region access. Provisioning or admission errors remain |
| 14 | +failures, not evidence that a local API key is absent. The public-image fixture |
| 15 | +needs no local Docker build or private registry credentials. |
| 16 | + |
| 17 | +## Provision a uniquely named fixture |
| 18 | + |
| 19 | +Choose the same region/Team as the runtime key. Set REGION and TEAM_ID from local |
| 20 | +configuration; NAME must be unique and at most36 characters. From a checkout with |
| 21 | +the standard CLI entry use this existing project extension: |
| 22 | + |
| 23 | +```bash |
| 24 | +REGION=cn-hangzhou |
| 25 | +NAME="conditional-$(date +%s)" |
| 26 | +abx template from-image \ |
| 27 | + "fc-e2b-registry.${REGION}.cr.aliyuncs.com/runtime-v2/base:v0.0.53" \ |
| 28 | + --name "$NAME" --team-id "$TEAM_ID" --region "$REGION" \ |
| 29 | + --generation 2 --cpu 2 --memory 2048 --disk-size 15360 --no-envd-inject |
| 30 | +abx template info "$TEMPLATE_ID" |
| 31 | +``` |
| 32 | + |
| 33 | +The create result supplies TEMPLATE_ID. Poll info until build state is ready; |
| 34 | +creation is asynchronous. Accepted native CLI builds use `template create` for |
| 35 | +this image-registration operation; inspect installed help before choosing it. |
| 36 | +Do not pass --force or update existing templates for this test. |
| 37 | + |
| 38 | +## Run and verify |
| 39 | + |
| 40 | +Use local environment selectors without committing their values: |
| 41 | + |
| 42 | +```bash |
| 43 | +export E2E_PAUSE_TEMPLATE="$TEMPLATE_ID" |
| 44 | +export E2E_SNAPSHOT_TEMPLATE="$TEMPLATE_ID" |
| 45 | +``` |
| 46 | + |
| 47 | +The SDK suite verifies a nonce held only in a running Python process, files, |
| 48 | +paused-state observation, connect/resume, snapshot list/restore, clone isolation |
| 49 | +and deletion. Paused-list and snapshot indexing are eventually consistent. |
| 50 | +Deletion may return409 during pausing/resuming/snapshotting; wait for that known |
| 51 | +transition only, with a deadline. Do not retry snapshot creation after an ambiguous |
| 52 | +timeout: reconcile snapshots by the uniquely owned source sandbox first. |
| 53 | +This backend returned204 even on repeated snapshot deletion, so assert list |
| 54 | +absence rather than expecting a second delete to return false. |
| 55 | + |
| 56 | +## Cleanup and evidence |
| 57 | + |
| 58 | +Delete restored/source sandboxes before their occupied snapshot. Delete only |
| 59 | +resources created by this run. Verify exact resource absence after cleanup, then |
| 60 | +remove the owned fixture with `abx template delete "$TEMPLATE_ID" --yes`. |
| 61 | +Record source/artifact SHA, actual passes/failures/skips, admission errors and |
| 62 | +owned residual count; omit keys, account identifiers and private endpoint details. |
| 63 | +Do not upload credentials or dispatch cloud/model acceptance in Actions. |
| 64 | + |
| 65 | +[Official template setup](https://help.aliyun.com/zh/agent-sandbox/build-and-manage-custom-templates-with-code), |
| 66 | +[compatibility](https://www.alibabacloud.com/help/en/agent-sandbox/e2b-compatibility-explanation), |
| 67 | +[snapshot limits](https://help.aliyun.com/zh/functioncompute/snapshots). |
| 68 | + |
| 69 | +## SDK test / SDK 测试 |
| 70 | + |
| 71 | +```bash |
| 72 | +cd e2e |
| 73 | +python -m pytest test_standard_contract.py -q -ra |
| 74 | +``` |
| 75 | + |
| 76 | +E2E_PAUSE_TEMPLATE independently selects pause and can fall back to the snapshot |
| 77 | +fixture. E2E_SNAPSHOT_TEMPLATE selects snapshot restoration. Conditional skips |
| 78 | +never count as passes. Provisioning and CLI artifact verification belong to |
| 79 | +[CLI40](https://github.com/Alibaba-Agent-Sandbox/agent-sandbox/pull/40). |
| 80 | +E2E_PAUSE_TEMPLATE 独立选择暂停模板,也可回退到快照模板; |
| 81 | +E2E_SNAPSHOT_TEMPLATE 选择快照恢复模板。未配置时基础场景仍执行,条件性跳过不算通过。 |
0 commit comments