test(macos): cover rootless image launch wiring
test / stage-firecracker-inputs (pull_request) Successful in 4s
test / integration-docker (pull_request) Successful in 13s
tracker-policy-pr / check-pr (pull_request) Successful in 11s
test / unit (pull_request) Successful in 35s
lint / lint (push) Successful in 2m33s
test / build-infra (pull_request) Successful in 3m24s
test / integration-firecracker (pull_request) Successful in 1m35s
test / coverage (pull_request) Successful in 1m35s
test / publish-infra (pull_request) Has been skipped
test / stage-firecracker-inputs (pull_request) Successful in 4s
test / integration-docker (pull_request) Successful in 13s
tracker-policy-pr / check-pr (pull_request) Successful in 11s
test / unit (pull_request) Successful in 35s
lint / lint (push) Successful in 2m33s
test / build-infra (pull_request) Successful in 3m24s
test / integration-firecracker (pull_request) Successful in 1m35s
test / coverage (pull_request) Successful in 1m35s
test / publish-infra (pull_request) Has been skipped
This commit is contained in:
@@ -3,11 +3,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from typing import cast
|
||||
from unittest.mock import patch
|
||||
|
||||
from bot_bottle.backend.macos_container import rootless_docker
|
||||
from bot_bottle.backend.macos_container import launch as launch_mod
|
||||
from bot_bottle.backend.macos_container.bottle_plan import MacosContainerBottlePlan
|
||||
|
||||
|
||||
class _Bottle:
|
||||
@@ -24,6 +28,20 @@ def _result(returncode: int, *, stdout: str = "", stderr: str = "") -> SimpleNam
|
||||
return SimpleNamespace(returncode=returncode, stdout=stdout, stderr=stderr)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class _AgentProvision:
|
||||
image: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class _Plan:
|
||||
slug: str
|
||||
image: str
|
||||
dockerfile_path: str
|
||||
docker_access: bool
|
||||
agent_provision: _AgentProvision
|
||||
|
||||
|
||||
class TestRootlessDockerStart(unittest.TestCase):
|
||||
def test_bootstraps_then_waits_for_guest_local_daemon(self) -> None:
|
||||
bottle = _Bottle([_result(0), _result(1), _result(0)])
|
||||
@@ -72,6 +90,30 @@ class TestRootlessDockerImage(unittest.TestCase):
|
||||
self.assertEqual("agent:base-rootless-docker", image)
|
||||
self.assertEqual("agent:base-rootless-docker", calls[0][0])
|
||||
|
||||
def test_launch_builds_base_then_rootless_variant(self) -> None:
|
||||
plan = cast(MacosContainerBottlePlan, cast(object, _Plan(
|
||||
slug="dev-abc",
|
||||
image="agent:base",
|
||||
dockerfile_path="/repo/Dockerfile",
|
||||
docker_access=True,
|
||||
agent_provision=_AgentProvision(image="agent:base"),
|
||||
)))
|
||||
with patch.object(launch_mod, "read_committed_image", return_value=None), \
|
||||
patch.object(launch_mod.container_mod, "build_image") as build, \
|
||||
patch.object(
|
||||
launch_mod.rootless_docker,
|
||||
"build_image",
|
||||
return_value="agent:base-rootless-docker",
|
||||
) as build_rootless:
|
||||
result = launch_mod._build_images(plan) # pylint: disable=protected-access
|
||||
|
||||
build.assert_called_once_with(
|
||||
"agent:base", launch_mod._REPO_DIR, # pylint: disable=protected-access
|
||||
dockerfile="/repo/Dockerfile",
|
||||
)
|
||||
build_rootless.assert_called_once_with("agent:base", build)
|
||||
self.assertEqual("agent:base-rootless-docker", result.agent_provision.image)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user