test(resilience): cover broken plugin startup and onboarding

This commit is contained in:
Vincent Koc
2026-04-14 19:19:55 +01:00
parent 58a9905976
commit 95cdaf957b
3 changed files with 224 additions and 0 deletions

View File

@@ -624,6 +624,73 @@ run_ref_onboard() {
--json
}
inject_bad_plugin_fixture() {
guest_exec bash -lc "$(cat <<'EOF'
set -euo pipefail
plugin_dir=/root/.openclaw/test-bad-plugin
mkdir -p "$plugin_dir"
cat >"$plugin_dir/package.json" <<'JSON'
{
"name": "@openclaw/test-bad-plugin",
"version": "1.0.0",
"openclaw": {
"extensions": ["./index.cjs"],
"setupEntry": "./setup-entry.cjs"
}
}
JSON
cat >"$plugin_dir/openclaw.plugin.json" <<'JSON'
{
"id": "test-bad-plugin",
"configSchema": {
"type": "object",
"additionalProperties": false,
"properties": {}
},
"channels": ["test-bad-plugin"]
}
JSON
cat >"$plugin_dir/index.cjs" <<'JS'
module.exports = { id: "test-bad-plugin", register() {} };
JS
cat >"$plugin_dir/setup-entry.cjs" <<'JS'
module.exports = {
kind: "bundled-channel-setup-entry",
loadSetupPlugin() {
throw new Error("boom: bad plugin smoke fixture");
},
};
JS
python3 - <<'PY'
import json
from pathlib import Path
config_path = Path("/root/.openclaw/openclaw.json")
config = {}
if config_path.exists():
config = json.loads(config_path.read_text())
plugins = config.setdefault("plugins", {})
load = plugins.setdefault("load", {})
paths = load.setdefault("paths", [])
plugin_dir = "/root/.openclaw/test-bad-plugin"
if plugin_dir not in paths:
paths.append(plugin_dir)
allow = plugins.get("allow")
if isinstance(allow, list) and "test-bad-plugin" not in allow:
allow.append("test-bad-plugin")
config_path.write_text(json.dumps(config, indent=2) + "\n")
PY
EOF
)"
}
verify_bad_plugin_diagnostic() {
guest_exec grep -F "failed to load setup entry" /tmp/openclaw-parallels-linux-gateway.log
}
start_gateway_background() {
local cmd api_key_value_q
api_key_value_q="$(shell_quote "$API_KEY_VALUE")"
@@ -786,8 +853,10 @@ run_fresh_main_lane() {
phase_run "fresh.install-main" "$TIMEOUT_INSTALL_S" install_main_tgz "$host_ip" "openclaw-main-fresh.tgz"
FRESH_MAIN_VERSION="$(extract_last_version "$(phase_log_path fresh.install-main)")"
phase_run "fresh.verify-main-version" "$TIMEOUT_VERIFY_S" verify_target_version
phase_run "fresh.inject-bad-plugin" "$TIMEOUT_VERIFY_S" inject_bad_plugin_fixture
phase_run "fresh.onboard-ref" "$TIMEOUT_ONBOARD_S" run_ref_onboard
phase_run "fresh.gateway-start" "$TIMEOUT_GATEWAY_S" start_gateway_background
phase_run "fresh.bad-plugin-diagnostic" "$TIMEOUT_VERIFY_S" verify_bad_plugin_diagnostic
phase_run "fresh.gateway-status" "$TIMEOUT_VERIFY_S" show_gateway_status_compat
FRESH_GATEWAY_STATUS="pass"
phase_run "fresh.first-local-agent-turn" "$TIMEOUT_AGENT_S" verify_local_turn
@@ -805,8 +874,10 @@ run_upgrade_lane() {
phase_run "upgrade.install-main" "$TIMEOUT_INSTALL_S" install_main_tgz "$host_ip" "openclaw-main-upgrade.tgz"
UPGRADE_MAIN_VERSION="$(extract_last_version "$(phase_log_path upgrade.install-main)")"
phase_run "upgrade.verify-main-version" "$TIMEOUT_VERIFY_S" verify_target_version
phase_run "upgrade.inject-bad-plugin" "$TIMEOUT_VERIFY_S" inject_bad_plugin_fixture
phase_run "upgrade.onboard-ref" "$TIMEOUT_ONBOARD_S" run_ref_onboard
phase_run "upgrade.gateway-start" "$TIMEOUT_GATEWAY_S" start_gateway_background
phase_run "upgrade.bad-plugin-diagnostic" "$TIMEOUT_VERIFY_S" verify_bad_plugin_diagnostic
phase_run "upgrade.gateway-status" "$TIMEOUT_VERIFY_S" show_gateway_status_compat
UPGRADE_GATEWAY_STATUS="pass"
phase_run "upgrade.first-local-agent-turn" "$TIMEOUT_AGENT_S" verify_local_turn