4b6817381b
Benchmark image — build + push to ECR (any adapter) / build + push (push) Waiting to run
CI / quality (ubuntu-latest) (push) Waiting to run
CI / test (tools-runtime) (push) Waiting to run
CI / test (e2e-general) (push) Waiting to run
CI / test (cli-runtime) (push) Waiting to run
CI / test (e2e-provider-and-openclaw) (push) Waiting to run
CI / test (integrations-and-misc) (push) Waiting to run
CI / coverage-report (push) Blocked by required conditions
CI / test-kubernetes (push) Waiting to run
CI / should-run-thorough (push) Waiting to run
CI / test-thorough (cloudwatch-demo) (push) Blocked by required conditions
CI / test-thorough (flink-ecs) (push) Blocked by required conditions
CI / test-thorough (upstream-lambda) (push) Blocked by required conditions
CI / test-thorough (prefect-ecs-fargate) (push) Blocked by required conditions
CodeQL / Analyze (python) (push) Waiting to run
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Blocked by required conditions
Release / publish-release (push) Blocked by required conditions
Release / publish-main-release (push) Blocked by required conditions
Release / prepare (push) Waiting to run
Release / verify (push) Blocked by required conditions
Release / build-python-dist (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Blocked by required conditions
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Waiting to run
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
96 lines
2.4 KiB
Python
96 lines
2.4 KiB
Python
"""Tests for the ``opensre watchdog`` CLI command."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from click.testing import CliRunner
|
|
|
|
from surfaces.cli.__main__ import cli
|
|
from surfaces.cli.commands.watchdog import watchdog_command
|
|
from tools.system.watch_dog.config import WatchdogConfig
|
|
|
|
|
|
def test_watchdog_help_lists_expected_flags() -> None:
|
|
result = CliRunner().invoke(watchdog_command, ["--help"])
|
|
|
|
assert result.exit_code == 0
|
|
for flag in (
|
|
"--pid",
|
|
"--name",
|
|
"--pick-first",
|
|
"--max-cpu",
|
|
"--cpu-window",
|
|
"--max-runtime",
|
|
"--max-rss",
|
|
"--interval",
|
|
"--cooldown",
|
|
"--once",
|
|
"--chat-id",
|
|
"--verbose",
|
|
):
|
|
assert flag in result.output
|
|
|
|
|
|
def test_watchdog_cli_maps_flags_to_config(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
captured: dict[str, WatchdogConfig] = {}
|
|
|
|
def _fake_run(config: WatchdogConfig) -> int:
|
|
captured["config"] = config
|
|
return 0
|
|
|
|
monkeypatch.setattr("surfaces.cli.commands.watchdog.run_watchdog", _fake_run)
|
|
|
|
result = CliRunner().invoke(
|
|
watchdog_command,
|
|
[
|
|
"--pid",
|
|
"123",
|
|
"--max-cpu",
|
|
"90",
|
|
"--cpu-window",
|
|
"30",
|
|
"--max-runtime",
|
|
"30m",
|
|
"--max-rss",
|
|
"4G",
|
|
"--interval",
|
|
"5",
|
|
"--cooldown",
|
|
"5m",
|
|
"--once",
|
|
"--chat-id",
|
|
"chat-1",
|
|
"--verbose",
|
|
],
|
|
)
|
|
|
|
assert result.exit_code == 0
|
|
config = captured["config"]
|
|
assert config.pid == 123
|
|
assert config.max_cpu == 90
|
|
assert config.cpu_window == 30
|
|
assert config.max_runtime == 1800
|
|
assert config.max_rss == 4 * 1024**3
|
|
assert config.interval == 5
|
|
assert config.cooldown == 300
|
|
assert config.once is True
|
|
assert config.chat_id == "chat-1"
|
|
assert config.verbose is True
|
|
|
|
|
|
def test_watchdog_cli_rejects_invalid_selector() -> None:
|
|
result = CliRunner().invoke(
|
|
watchdog_command,
|
|
["--pid", "123", "--name", "python", "--max-cpu", "90"],
|
|
)
|
|
|
|
assert result.exit_code != 0
|
|
assert "Invalid watchdog configuration" in result.output
|
|
|
|
|
|
def test_root_cli_registers_watchdog_command() -> None:
|
|
result = CliRunner().invoke(cli, ["watchdog", "--help"])
|
|
|
|
assert result.exit_code == 0
|
|
assert "--max-runtime" in result.output
|