test(e2e): harden plugin smoke cleanup · openclaw/openclaw@1a86255
vincentkoc
·
2026-05-22
·
via Recent Commits to openclaw:main
File tree
bundled-plugin-install-uninstall
| Original file line number | Diff line number | Diff line change |
|---|
@@ -259,16 +259,27 @@ async function assertHttpOk(port, pathName) {
|
259 | 259 | } |
260 | 260 | |
261 | 261 | async function assertReadyzProbe(options) { |
262 | | -const res = await fetch(`http://127.0.0.1:${options.port}/readyz`); |
263 | | -if (res.ok) { |
264 | | -return; |
265 | | -} |
266 | | -if (!options.allowDegradedReadyz) { |
267 | | -throw new Error(`/readyz returned HTTP ${res.status}`); |
| 262 | +const started = Date.now(); |
| 263 | +let lastError; |
| 264 | +while (Date.now() - started < RPC_READY_TIMEOUT_MS) { |
| 265 | +try { |
| 266 | +const res = await fetch(`http://127.0.0.1:${options.port}/readyz`); |
| 267 | +if (res.ok) { |
| 268 | +return; |
| 269 | +} |
| 270 | +if (options.allowDegradedReadyz) { |
| 271 | +console.log( |
| 272 | +`Runtime readyz smoke degraded for ${options.pluginId}: /readyz returned HTTP ${res.status}`, |
| 273 | +); |
| 274 | +return; |
| 275 | +} |
| 276 | +lastError = new Error(`/readyz returned HTTP ${res.status}`); |
| 277 | +} catch (error) { |
| 278 | +lastError = error; |
| 279 | +} |
| 280 | +await delay(500); |
268 | 281 | } |
269 | | -console.log( |
270 | | -`Runtime readyz smoke degraded for ${options.pluginId}: /readyz returned HTTP ${res.status}`, |
271 | | -); |
| 282 | +throw lastError ?? new Error("/readyz did not return HTTP 200"); |
272 | 283 | } |
273 | 284 | |
274 | 285 | async function rpcCall(method, params, options) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -20,7 +20,7 @@ run_plugins_clawhub_scenario() {
|
20 | 20 | for _ in $(seq 1 100); do |
21 | 21 | if [[ -s "$server_port_file" ]]; then |
22 | 22 | export OPENCLAW_CLAWHUB_URL="http://127.0.0.1:$(cat "$server_port_file")" |
23 | | -trap 'if [[ -f "'"$server_pid_file"'" ]]; then kill "$(cat "'"$server_pid_file"'")" 2>/dev/null || true; fi' EXIT |
| 23 | +openclaw_plugins_register_fixture_pid_file "$server_pid_file" |
24 | 24 | return 0 |
25 | 25 | fi |
26 | 26 | if ! kill -0 "$server_pid" 2>/dev/null; then |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +OPENCLAW_PLUGINS_FIXTURE_PID_FILES=() |
| 2 | + |
| 3 | +openclaw_plugins_cleanup_fixture_servers() { |
| 4 | +local pid_file |
| 5 | +local pid |
| 6 | +for pid_file in "${OPENCLAW_PLUGINS_FIXTURE_PID_FILES[@]:-}"; do |
| 7 | + [[ -f "$pid_file" ]] || continue |
| 8 | + pid="$(cat "$pid_file" 2>/dev/null || true)" |
| 9 | +if [[ "$pid" =~ ^[0-9]+$ ]]; then |
| 10 | +kill "$pid" 2>/dev/null || true |
| 11 | +fi |
| 12 | + rm -f "$pid_file" |
| 13 | +done |
| 14 | +} |
| 15 | + |
| 16 | +openclaw_plugins_register_fixture_pid_file() { |
| 17 | +local pid_file="$1" |
| 18 | + OPENCLAW_PLUGINS_FIXTURE_PID_FILES+=("$pid_file") |
| 19 | +trap openclaw_plugins_cleanup_fixture_servers EXIT |
| 20 | +} |
| 21 | + |
1 | 22 | record_fixture_plugin_trust() { |
2 | 23 | local plugin_id="$1" |
3 | 24 | local plugin_root="$2" |
@@ -125,7 +146,7 @@ start_npm_fixture_registry() {
|
125 | 146 | for _ in $(seq 1 100); do |
126 | 147 | if [[ -s "$server_port_file" ]]; then |
127 | 148 | export NPM_CONFIG_REGISTRY="http://127.0.0.1:$(cat "$server_port_file")" |
128 | | -trap 'if [[ -f "'"$server_pid_file"'" ]]; then kill "$(cat "'"$server_pid_file"'")" 2>/dev/null || true; fi' EXIT |
| 149 | +openclaw_plugins_register_fixture_pid_file "$server_pid_file" |
129 | 150 | return 0 |
130 | 151 | fi |
131 | 152 | if ! kill -0 "$server_pid" 2>/dev/null; then |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。