pyro-mcp/tests/test_runtime_boot_check.py
Thales Maciel 287f6d100f Add stopped-workspace disk export and inspection
Finish the 3.1.0 secondary disk-tools milestone so stable workspaces can be
stopped, inspected offline, exported as raw ext4 images, and started again
without changing the primary workspace-first interaction model.

Add workspace stop/start plus workspace disk export/list/read across the CLI,
SDK, and MCP, backed by a new offline debugfs inspection helper and guest-only
validation. Scrub runtime-only guest state before disk inspection/export, and
fix the real guest reliability gaps by flushing the filesystem on stop and
removing stale Firecracker socket files before restart.

Update the docs, examples, changelog, and roadmap to mark 3.1.0 done, and
cover the new lifecycle/disk paths with API, CLI, manager, contract, and
package-surface tests.

Validation: uv lock; UV_CACHE_DIR=.uv-cache make check; UV_CACHE_DIR=.uv-cache
make dist-check; real guest-backed smoke for create, shell/service activity,
stop, workspace disk list/read/export, start, exec, and delete.
2026-03-12 20:57:16 -03:00

52 lines
1.7 KiB
Python

from __future__ import annotations
import pytest
from pyro_mcp.runtime_boot_check import _classify_result, run_boot_check
def test_classify_result_reports_kernel_panic() -> None:
reason = _classify_result(
firecracker_log="Successfully started microvm",
serial_log="Kernel panic - not syncing: VFS: Unable to mount root fs",
vm_alive=False,
)
assert reason == "guest kernel panic during boot"
def test_classify_result_reports_success_when_vm_stays_alive() -> None:
reason = _classify_result(
firecracker_log="Successfully started microvm",
serial_log="boot log",
vm_alive=True,
)
assert reason is None
def test_classify_result_reports_logger_failure_and_early_exit() -> None:
logger_reason = _classify_result(
firecracker_log="Successfully started microvm",
serial_log="Could not initialize logger",
vm_alive=False,
)
early_exit_reason = _classify_result(
firecracker_log="partial log",
serial_log="boot log",
vm_alive=False,
)
assert logger_reason == "firecracker logger initialization failed"
assert early_exit_reason == "firecracker did not fully start the microVM"
def test_classify_result_reports_boot_window_exit_after_start() -> None:
reason = _classify_result(
firecracker_log="Successfully started microvm",
serial_log="boot log",
vm_alive=False,
)
assert reason == "microVM exited before boot validation window elapsed"
def test_run_boot_check_requires_positive_wait_seconds() -> None:
with pytest.raises(ValueError, match="wait_seconds must be positive"):
run_boot_check(wait_seconds=0)