Skip to content

Commit ba88b7a

Browse files
committed
fix(e2e): clean plugin lifecycle temp state
1 parent d767e29 commit ba88b7a

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

scripts/e2e/lib/plugin-lifecycle-matrix/sweep.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ package_name="@openclaw/lifecycle-claw"
2020
probe="scripts/e2e/lib/plugin-lifecycle-matrix/probe.mjs"
2121
measure="scripts/e2e/lib/plugin-lifecycle-matrix/measure.mjs"
2222
resource_dir="/tmp/openclaw-plugin-lifecycle-matrix"
23+
pack_root=""
24+
registry_root=""
25+
26+
cleanup() {
27+
openclaw_plugins_cleanup_fixture_servers
28+
rm -rf "$resource_dir"
29+
if [ -n "$pack_root" ]; then
30+
rm -rf "$pack_root"
31+
fi
32+
if [ -n "$registry_root" ]; then
33+
rm -rf "$registry_root"
34+
fi
35+
rm -f \
36+
/tmp/lifecycle-claw-1.0.0.tgz \
37+
/tmp/lifecycle-claw-2.0.0.tgz \
38+
/tmp/plugin-lifecycle-inspect-v1.json
39+
}
40+
trap cleanup EXIT
41+
2342
mkdir -p "$resource_dir"
2443
summary_tsv="$resource_dir/resource-summary.tsv"
2544
printf "phase\tmax_rss_kb\tcpu_seconds\twall_ms\tcpu_core_ratio\tsignal\n" >"$summary_tsv"
@@ -37,6 +56,7 @@ registry_root="$(mktemp -d "/tmp/openclaw-plugin-lifecycle-registry.XXXXXX")"
3756
pack_fixture_plugin "$pack_root/v1" /tmp/lifecycle-claw-1.0.0.tgz "$plugin_id" 1.0.0 lifecycle.v1 "Lifecycle Claw"
3857
pack_fixture_plugin "$pack_root/v2" /tmp/lifecycle-claw-2.0.0.tgz "$plugin_id" 2.0.0 lifecycle.v2 "Lifecycle Claw"
3958
start_npm_fixture_registry "$package_name" 1.0.0 /tmp/lifecycle-claw-1.0.0.tgz "$registry_root" "$package_name" 2.0.0 /tmp/lifecycle-claw-2.0.0.tgz
59+
trap cleanup EXIT
4060

4161
run_measured install-v1 node "$entry" plugins install "npm:$package_name@1.0.0"
4262
node "$probe" assert-version "$plugin_id" 1.0.0

test/scripts/docker-build-helper.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const PLUGIN_UPDATE_CORRUPT_SCENARIO_PATH =
6464
"scripts/e2e/lib/plugin-update/corrupt-update-scenario.sh";
6565
const PLUGIN_UPDATE_PROBE_PATH = "scripts/e2e/lib/plugin-update/probe.mjs";
6666
const PLUGIN_LIFECYCLE_MATRIX_DOCKER_E2E_PATH = "scripts/e2e/plugin-lifecycle-matrix-docker.sh";
67+
const PLUGIN_LIFECYCLE_MATRIX_SWEEP_PATH = "scripts/e2e/lib/plugin-lifecycle-matrix/sweep.sh";
6768
const DOCTOR_SWITCH_DOCKER_E2E_PATH = "scripts/e2e/doctor-install-switch-docker.sh";
6869
const DOCTOR_SWITCH_SCENARIO_PATH = "scripts/e2e/lib/doctor-install-switch/scenario.sh";
6970
const PACKAGE_COMPAT_PATH = "scripts/e2e/lib/package-compat.mjs";
@@ -1077,6 +1078,17 @@ grep -qx -- "OPENCLAW_E2E_COMMAND_TIMEOUT=23s" "$TMPDIR/package-args"
10771078
expect(runner).toContain('docker_e2e_run_with_harness \\\n "${DOCKER_ENV_ARGS[@]}"');
10781079
});
10791080

1081+
it("cleans plugin lifecycle matrix temp roots on exit", () => {
1082+
const sweep = readFileSync(PLUGIN_LIFECYCLE_MATRIX_SWEEP_PATH, "utf8");
1083+
1084+
expect(sweep).toContain("cleanup() {");
1085+
expect(sweep).toContain("openclaw_plugins_cleanup_fixture_servers");
1086+
expect(sweep).toContain('rm -rf "$resource_dir"');
1087+
expect(sweep).toContain('rm -rf "$pack_root"');
1088+
expect(sweep).toContain('rm -rf "$registry_root"');
1089+
expect(sweep.match(/trap cleanup EXIT/g)).toHaveLength(2);
1090+
});
1091+
10801092
it("wraps direct Docker E2E npm installs with the shared timeout helper", () => {
10811093
const multiNode = readFileSync(MULTI_NODE_UPDATE_DOCKER_E2E_PATH, "utf8");
10821094
const updateChannel = readFileSync(UPDATE_CHANNEL_SWITCH_DOCKER_E2E_PATH, "utf8");

0 commit comments

Comments
 (0)