c07ebca867
Delete the smolmachines backend (the whole bot_bottle/backend/smolmachines package and its tests). It had fatal Linux issues (TSI networking under sustained use, exec-channel contention, no SIGWINCH) and is superseded by the Firecracker backend (issue #342). Backend selection now: - default is macos-container on macOS, firecracker on KVM-capable Linux hosts, and docker as the last resort (was smolmachines). - firecracker is selected on a KVM host even when the `firecracker` binary isn't installed, so start routes through its preflight and prints an install pointer (same UX as require_container), instead of silently falling back. Split is_host_capable() (Linux + KVM) out of is_available() (adds the binary check) to drive this. Retarget the cross-backend tests (parity, print-parity, prepare, workspace, freezer, selection) from smolmachines to firecracker rather than dropping the coverage. Remove docker.util.image_id/save, which only smolmachines used. Update README/AGENTS/example bottles and stale comments; historical docs/prds are left as a point-in-time record. BREAKING: BOT_BOTTLE_BACKEND=smolmachines now errors as unknown. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WBMWTEtQdJ4W5UrWuLHCck
62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
"""Unit: `cli.py start --backend=<name>` flag (issue #77).
|
|
|
|
Asserts that the flag wins over the env var, that the env var is
|
|
the fallback, and that the choices are pulled from the backend
|
|
registry (so adding a backend lights up in argparse without code
|
|
edits)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import os
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
|
|
from bot_bottle.backend import known_backend_names
|
|
|
|
|
|
class TestStartBackendFlag(unittest.TestCase):
|
|
"""The flag is wired by `cmd_start`'s argparse and threaded
|
|
through `prepare_with_preflight(backend_name=...)`. Rather than
|
|
drive the whole start flow (which builds containers), we test
|
|
the argparse shape and the resolution function separately."""
|
|
|
|
def _build_parser(self):
|
|
# Mirror the parser definition from `cmd_start` so this
|
|
# test doesn't have to invoke the full command.
|
|
parser = argparse.ArgumentParser(prog="cb start")
|
|
parser.add_argument(
|
|
"--backend",
|
|
choices=known_backend_names(),
|
|
default=None,
|
|
)
|
|
parser.add_argument("name")
|
|
return parser
|
|
|
|
def test_flag_recognized(self):
|
|
args = self._build_parser().parse_args(["--backend=firecracker", "researcher"])
|
|
self.assertEqual("firecracker", args.backend)
|
|
self.assertEqual("researcher", args.name)
|
|
|
|
def test_flag_default_none_means_env_or_default_backend(self):
|
|
args = self._build_parser().parse_args(["researcher"])
|
|
self.assertIsNone(args.backend)
|
|
|
|
def test_invalid_backend_rejected_by_argparse(self):
|
|
parser = self._build_parser()
|
|
with self.assertRaises(SystemExit):
|
|
parser.parse_args(["--backend=garbage", "researcher"])
|
|
|
|
def test_resolution_priority_explicit_over_env(self):
|
|
# Independent assertion that get_bottle_backend (where
|
|
# `--backend` ultimately threads to) prefers the explicit
|
|
# name over BOT_BOTTLE_BACKEND.
|
|
from bot_bottle.backend import get_bottle_backend
|
|
with patch.dict(os.environ, {"BOT_BOTTLE_BACKEND": "firecracker"}):
|
|
self.assertEqual("docker", get_bottle_backend("docker").name)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|