chore: import upstream snapshot with attribution
CI: cua-driver distro-compat matrix / debian:12 (glibc 2.36) (push) Has been cancelled
CI: SPDX Headers / Check SPDX headers (warn-only) (push) Has been cancelled
CD: Docs MCP Server / build (linux/amd64) (push) Has been cancelled
CD: Docs MCP Server / build (linux/arm64) (push) Has been cancelled
CD: Docs MCP Server / merge (push) Has been cancelled
CI: cua-driver distro-compat matrix / Resolve release version (push) Has been cancelled
CI: cua-driver distro-compat matrix / fedora:41 (glibc 2.40) (push) Has been cancelled
CI: cua-driver distro-compat matrix / rockylinux:9 (glibc 2.34) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:22.04 (glibc 2.35) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:24.04 (glibc 2.39) (push) Has been cancelled
CI: cua-driver distro-compat matrix / Distro compat summary (push) Has been cancelled
CI: Rust Linux unit / Rust Linux unit and compile (push) Has been cancelled
CI: Rust Windows unit / Rust Windows unit and compile (push) Has been cancelled
CI: Nix Linux Rust source / Nix / compositor build (push) Has been cancelled
CI: Nix Linux Rust source / Nix / driver package (push) Has been cancelled
CI: Nix Linux Rust source / Nix / Rust unit tests (push) Has been cancelled
CI: cua-driver distro-compat matrix / debian:12 (glibc 2.36) (push) Has been cancelled
CI: SPDX Headers / Check SPDX headers (warn-only) (push) Has been cancelled
CD: Docs MCP Server / build (linux/amd64) (push) Has been cancelled
CD: Docs MCP Server / build (linux/arm64) (push) Has been cancelled
CD: Docs MCP Server / merge (push) Has been cancelled
CI: cua-driver distro-compat matrix / Resolve release version (push) Has been cancelled
CI: cua-driver distro-compat matrix / fedora:41 (glibc 2.40) (push) Has been cancelled
CI: cua-driver distro-compat matrix / rockylinux:9 (glibc 2.34) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:22.04 (glibc 2.35) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:24.04 (glibc 2.39) (push) Has been cancelled
CI: cua-driver distro-compat matrix / Distro compat summary (push) Has been cancelled
CI: Rust Linux unit / Rust Linux unit and compile (push) Has been cancelled
CI: Rust Windows unit / Rust Windows unit and compile (push) Has been cancelled
CI: Nix Linux Rust source / Nix / compositor build (push) Has been cancelled
CI: Nix Linux Rust source / Nix / driver package (push) Has been cancelled
CI: Nix Linux Rust source / Nix / Rust unit tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
"""Launch a persistent cloud Linux container via the CLI.
|
||||
|
||||
cua sb launch ubuntu:24.04 --json
|
||||
# parse name from JSON output, connect with SDK, run assertions
|
||||
cua sb delete <name>
|
||||
|
||||
Mirrors tests/integration/sandbox_sdk/test_linux_cloud_container.py but exercises the
|
||||
CLI launch path and persistent state tracking instead of Sandbox.ephemeral().
|
||||
Requires CUA_API_KEY environment variable.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
from cua_sandbox import Sandbox
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
def _has_cua_api_key() -> bool:
|
||||
return bool(os.environ.get("CUA_API_KEY"))
|
||||
|
||||
|
||||
def _cua(*args: str) -> subprocess.CompletedProcess:
|
||||
return subprocess.run(["cua", *args], capture_output=True, text=True)
|
||||
|
||||
|
||||
@pytest.mark.skipif(not _has_cua_api_key(), reason="CUA_API_KEY not set")
|
||||
async def test_linux_cloud_container():
|
||||
result = _cua("sb", "launch", "ubuntu:24.04", "--json")
|
||||
assert result.returncode == 0, f"launch failed:\n{result.stderr}"
|
||||
name = json.loads(result.stdout)["name"]
|
||||
|
||||
try:
|
||||
async with Sandbox.connect(name) as sb:
|
||||
out = await sb.shell.run("uname -s")
|
||||
assert out.success
|
||||
assert "Linux" in out.stdout
|
||||
|
||||
screenshot = await sb.screenshot()
|
||||
assert screenshot[:4] == b"\x89PNG"
|
||||
finally:
|
||||
_cua("sb", "delete", name)
|
||||
|
||||
|
||||
async def main():
|
||||
r = _cua("sb", "launch", "ubuntu:24.04", "--json")
|
||||
print(f"launch exit={r.returncode}")
|
||||
name = json.loads(r.stdout)["name"]
|
||||
print(f"name: {name}")
|
||||
|
||||
try:
|
||||
async with Sandbox.connect(name) as sb:
|
||||
out = await sb.shell.run("uname -s")
|
||||
print(f"uname: {out.stdout.strip()}")
|
||||
screenshot = await sb.screenshot()
|
||||
print(f"Screenshot: {len(screenshot)} bytes")
|
||||
with open("/tmp/cli_linux_cloud_container.png", "wb") as f:
|
||||
f.write(screenshot)
|
||||
finally:
|
||||
_cua("sb", "delete", name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user