Docker sandbox real test + cloud merge status endpoint
- DockerExecutor: extra mounts (host.py work/state, repo, codex-home
at same paths), worker --docker-extra-mounts, container user
configurable; Dockerfile copies codex-resources beside the codex
binary and puts bwrap on PATH (previous /usr/local/lib layout
made codex report bubblewrap unavailable inside the container).
- Real Docker task on external host: triple added in ~18s, merged
inside a container, main repo now add+mul2+triple, --rm cleanup.
Honest boundary: this host/kernel forbids unprivileged user
namespaces, so bwrap fails on host and in containers; production
mode here is Docker isolation + inner danger-full-access, not
double sandboxing.
- Cloud merge status: POST /tasks/{id}/merge syncs status only
(merge itself stays with host.py merge); completed -> merged,
maintainer+ (approve_merge), other states and repeat calls 409,
audit merge_task. Tests: cloud 223, host 27, all passing.
This commit is contained in:
1 parent
631580beab
commit
07a8eaaa73
9 files changed
+1082
-37
No files matched your search
@@ -189,12 +189,29 @@ class TestExecutors(unittest.TestCase):
|
||||
self.assertIn("docker not available", str(ctx.exception))
|
||||
# 报错而不是返回 local 结果:绝不静默降级为本地执行
|
||||
|
||||
def test_docker_executor_with_docker_is_placeholder_failure(self):
|
||||
with mock.patch("sandbox.shutil.which", return_value="/usr/bin/docker"):
|
||||
result = DockerExecutor().execute({"id": "t1"})
|
||||
def test_docker_executor_with_docker_runs_container(self):
|
||||
seen = []
|
||||
|
||||
def fake_runner(cmd, timeout=None):
|
||||
seen.append(cmd)
|
||||
return SimpleNamespace(returncode=0, stdout="ok-status")
|
||||
|
||||
with mock.patch("sandbox.shutil.which",
|
||||
return_value="/usr/bin/docker"):
|
||||
executor = DockerExecutor(
|
||||
"/fake/host.py", runner=fake_runner,
|
||||
env={"XCM_API_KEY": "placeholder-not-a-real-key"})
|
||||
result = executor.execute({"id": "t1", "worktree": "/tmp/wt1"})
|
||||
self.assertEqual(result["executor"], "docker")
|
||||
self.assertEqual(result["status"], "failed")
|
||||
self.assertNotEqual(result["executor"], "local")
|
||||
self.assertEqual(result["status"], "completed")
|
||||
self.assertEqual(seen[0][0:2], ["docker", "run"])
|
||||
self.assertIn("--rm", seen[0])
|
||||
self.assertIn("/tmp/wt1:/work", seen[0])
|
||||
self.assertIn("/fake:/app:ro", seen[0])
|
||||
# -e 只传名,值绝不出现在命令列表里。
|
||||
self.assertIn("XCM_API_KEY", seen[0])
|
||||
self.assertNotIn("placeholder-not-a-real-key", seen[0])
|
||||
self.assertNotIn("placeholder-not-a-real-key", " ".join(seen[0]))
|
||||
|
||||
def test_cloud_executor_raises_with_cloud_account(self):
|
||||
with self.assertRaises(RuntimeError) as ctx:
|
||||
|
||||
Reference in new issue
Block a user