feat(api-client, sdk): track sandbox snapshot captures by ID#73
feat(api-client, sdk): track sandbox snapshot captures by ID#73mu-hashmi wants to merge 10 commits into
Conversation
Signed-off-by: Muhammad Hashmi <mhashmi@berkeley.edu>
Signed-off-by: Muhammad Hashmi <mhashmi@berkeley.edu>
Signed-off-by: Muhammad Hashmi <mhashmi@berkeley.edu>
Signed-off-by: Muhammad Hashmi <mhashmi@berkeley.edu>
Signed-off-by: Muhammad Hashmi <mhashmi@berkeley.edu>
Signed-off-by: Muhammad Hashmi <mhashmi@berkeley.edu>
Signed-off-by: Muhammad Hashmi <mhashmi@berkeley.edu>
Signed-off-by: Muhammad Hashmi <mhashmi@berkeley.edu>
Signed-off-by: Muhammad Hashmi <mhashmi@berkeley.edu>
Signed-off-by: Muhammad Hashmi <mhashmi@berkeley.edu>
| String existingSandboxId = System.getenv("DAYTONA_EXISTING_SANDBOX_ID"); | ||
| if (existingSandboxId != null && !existingSandboxId.isEmpty()) { | ||
| sandbox = daytona.get(existingSandboxId); | ||
| } else { | ||
| CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams(); | ||
| params.setName(sandboxName); | ||
| params.setLanguage("python"); | ||
| params.setLabels(Collections.singletonMap("purpose", "e2e-test")); | ||
| sandbox = daytona.create(params, 60); | ||
| } |
There was a problem hiding this comment.
🟡 Java end-to-end test breaks when reusing an existing sandbox
When an existing sandbox is reused via the new environment-variable branch (E2ETest.java:105-114), the sandbox is fetched instead of created, so its real name never matches the freshly generated sandboxName, and the first ordered test's name check then fails.
Impact: Anyone who points the end-to-end suite at a pre-existing sandbox gets a spurious test failure (and the reused sandbox is also deleted in teardown).
How the name mismatch is introduced
In setUp, sandboxName is always assigned a unique value (E2ETest.java:97). When DAYTONA_EXISTING_SANDBOX_ID is set, setUp takes the daytona.get(existingSandboxId) branch and never applies sandboxName to the sandbox. The ordered test sandboxLifecycleHasIdNameAndOrganizationId asserts assertThat(sandbox.getName()).isEqualTo(sandboxName) (E2ETest.java:169), which cannot hold for a pre-existing sandbox whose name differs from the generated one. Additionally, tearDown calls sandbox.delete() (E2ETest.java:148), which would delete the reused sandbox.
Prompt for agents
In E2ETest.setUp, when the DAYTONA_EXISTING_SANDBOX_ID branch is taken (daytona.get(existingSandboxId)), the sandbox's name will not equal the freshly generated sandboxName, so the Order(1) test sandboxLifecycleHasIdNameAndOrganizationId's assertion assertThat(sandbox.getName()).isEqualTo(sandboxName) will fail. Consider updating sandboxName from the fetched sandbox (e.g. sandboxName = sandbox.getName()) when reusing an existing sandbox, or make the name assertion conditional on whether a sandbox was created vs. reused. Also review tearDown's sandbox.delete() so a reused, pre-existing sandbox is not unintentionally deleted.
Was this helpful? React with 👍 or 👎 to provide feedback.
This updates snapshot-from-sandbox clients to track the Snapshot accepted by the API instead of inferring completion from Sandbox state.
202response asSnapshotDto, addCAPTURING, and regenerate all six API clients.ACTIVE.errorReasonforERRORandBUILD_FAILED.Verification:
Summary by cubic
Snapshot-from-sandbox now returns a
SnapshotDto, and all SDKs poll that snapshot by ID until it becomes ACTIVE. Added a "capturing" state, clearer failure/timeout messages, and kept TypeScript polling on the main API.New Features
SnapshotDtofor POST/sandbox/{id}/snapshot; 409 on name conflicts.SnapshotState"capturing"; SDKs poll the accepted snapshot ID and surface terminal state anderrorReason.Migration
SnapshotDtoinstead of assuming 200/Sandbox.Sandboxmanually, pass aSnapshotsApiinstance alongsideSandboxApi.Written for commit 6d4928c. Summary will update on new commits.