Repository navigation
test: count and remove only the containers of sandboxes this test's process made - #585
Merged
andrewpark-scaleai merged 2 commits intoNov 10, 2026
Conversation
…rocess made multi_env_computers_test compared every container on the machine before and after a failed redeploy, so another pytest worker's sandboxes coming and going failed it when the slow tier ran two tests at a time (PR #582). tst/util/local_sandboxes.record notes the LocalSandboxes a process makes and containers() names theirs; the test and local_stack_at, which #584 taught the same, both use it. Co-Authored-By: Claude <[email protected]>
…tainers fails Co-Authored-By: Claude <[email protected]>
earakely-scale
approved these changes
Nov 10, 2026
andrewpark-scaleai
deleted the
andrew-park/ci-multi-env-computers-own-containers
branch
November 10, 2026 19:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The goal is a slow tier that can run two tests at a time on each runner. On #582's rerun with
-n 2, one shard failedmulti_env_computers_test.py::test_two_computers_keep_serving_through_restarts_and_a_failed_redeploy_and_close_ends_them:The test compared every container on the machine before and after a failed redeploy, so the other worker's sandboxes coming and going failed it.
What changes
tst/util/local_sandboxes.pyprovides two helpers:recorded_sandbox_ids(monkeypatch)lists theLocalSandboxids a process makes.container_names_carrying(ids)names their containers. Every local sandbox container carries its sandbox's id:agent-<id>,relay-<id>, and the gateway stack'sagent-env-<id>-…. It runsdocker pswithcheck=True, so a Docker failure raises rather than reading as "no containers".multi_env_computers_test.pycounts only the containers of the sandboxes its test made, through amadefixture. So "nothing left up" is asserted as== set().local_stack_at, which test: have the local stack remove only the sandboxes its own process made #584 scoped the same way, now uses the same helper.Verification
LocalSandboxrecord it, module fixtures make no sandboxes, and the narrowed check is at least as strict as before for every container this test makes.ruff checkpasses.Mutation check
The new checks must still catch a leak, so I ran the two changed tests against a mutant whose
LocalSandbox.terminate()returns at once. This was a local run of main + #580 + this PR, on Python 3.12, with a local registry and the computer image mirror, as the slow tier runs.test_a_computer_that_fails_mid_deploy_fails_the_deploy_and_leaves_nothing_upfails at_containers_made(made) == set()and listsagent-env-local-2044d505-…-pgweb-1and others.test_two_computers_keep_serving_through_restarts_and_a_failed_redeploy_and_close_ends_themfails atafter_failure == deployed_before, which lists the failed redeploy'sagent-env-local-d64414bc-…andagent-local-…containers.

Confidence Score: 5/5
The PR appears safe to merge; the latest change fixes the reported cleanup problem.Summary
The PR limits container checks and cleanup to sandboxes created by the current test process.
Reviews (8) · Last reviewed commit: "test: still reset the stores and remove ..." · Reviewed by Greptile