Skip to content

Commit dcf21ac

Browse files
committed
fix(e2e): isolate release scenario mock state
1 parent e128efa commit dcf21ac

5 files changed

Lines changed: 69 additions & 6 deletions

File tree

scripts/e2e/lib/release-typed-onboarding/scenario.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export OPENAI_API_KEY="sk-openclaw-release-typed-onboarding"
1919
PORT="18789"
2020
MOCK_PORT="44190"
2121
SUCCESS_MARKER="OPENCLAW_E2E_OK_TYPED_ONBOARDING"
22-
MOCK_REQUEST_LOG="/tmp/openclaw-release-typed-onboarding-openai.jsonl"
22+
scenario_tmp="$(mktemp -d "${TMPDIR:-/tmp}/openclaw-release-typed-onboarding.XXXXXX")"
23+
MOCK_REQUEST_LOG="$scenario_tmp/openai-requests.jsonl"
2324
export SUCCESS_MARKER MOCK_REQUEST_LOG
2425

2526
mock_pid=""
@@ -32,6 +33,7 @@ cleanup() {
3233
if [ -n "${input_fifo_dir:-}" ]; then
3334
rm -rf "$input_fifo_dir"
3435
fi
36+
rm -rf "$scenario_tmp"
3537
}
3638
trap cleanup EXIT
3739

scripts/e2e/lib/release-upgrade-user-journey/scenario.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ PORT="18789"
2121
MOCK_PORT="44210"
2222
CLICKCLACK_PORT="44211"
2323
SUCCESS_MARKER="OPENCLAW_E2E_OK_RELEASE_UPGRADE"
24-
MOCK_REQUEST_LOG="/tmp/openclaw-release-upgrade-user-journey-openai.jsonl"
25-
CLICKCLACK_STATE="/tmp/openclaw-release-upgrade-user-journey-clickclack.json"
24+
scenario_tmp="$(mktemp -d "${TMPDIR:-/tmp}/openclaw-release-upgrade-user-journey.XXXXXX")"
25+
MOCK_REQUEST_LOG="$scenario_tmp/openai-requests.jsonl"
26+
CLICKCLACK_STATE="$scenario_tmp/clickclack.json"
2627
BASELINE_SPEC="${OPENCLAW_RELEASE_UPGRADE_BASELINE_SPEC:-openclaw@latest}"
2728
export SUCCESS_MARKER MOCK_REQUEST_LOG CLICKCLACK_STATE
2829

@@ -38,6 +39,7 @@ cleanup() {
3839
openclaw_e2e_terminate_gateways "${gateway_pid:-}"
3940
openclaw_e2e_stop_process "${clickclack_pid:-}"
4041
openclaw_e2e_stop_process "${mock_pid:-}"
42+
rm -rf "$scenario_tmp"
4143
}
4244
trap cleanup EXIT
4345

scripts/e2e/lib/release-user-journey/scenario.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ PORT="18789"
2222
MOCK_PORT="44180"
2323
CLICKCLACK_PORT="44181"
2424
SUCCESS_MARKER="OPENCLAW_E2E_OK_RELEASE_USER_JOURNEY"
25-
MOCK_REQUEST_LOG="/tmp/openclaw-release-user-journey-openai.jsonl"
26-
CLICKCLACK_STATE="/tmp/openclaw-release-user-journey-clickclack.json"
25+
scenario_tmp="$(mktemp -d "${TMPDIR:-/tmp}/openclaw-release-user-journey.XXXXXX")"
26+
MOCK_REQUEST_LOG="$scenario_tmp/openai-requests.jsonl"
27+
CLICKCLACK_STATE="$scenario_tmp/clickclack.json"
2728
export SUCCESS_MARKER MOCK_REQUEST_LOG CLICKCLACK_STATE
2829

2930
mock_pid=""
@@ -34,6 +35,7 @@ cleanup() {
3435
openclaw_e2e_terminate_gateways "${gateway_pid:-}"
3536
openclaw_e2e_stop_process "${clickclack_pid:-}"
3637
openclaw_e2e_stop_process "${mock_pid:-}"
38+
rm -rf "$scenario_tmp"
3739
}
3840
trap cleanup EXIT
3941

scripts/e2e/npm-onboard-channel-agent-docker.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ CHANNEL="${OPENCLAW_NPM_ONBOARD_CHANNEL:?missing OPENCLAW_NPM_ONBOARD_CHANNEL}"
7272
PORT="18789"
7373
MOCK_PORT="44080"
7474
SUCCESS_MARKER="OPENCLAW_AGENT_E2E_OK_ASSISTANT"
75-
MOCK_REQUEST_LOG="/tmp/openclaw-mock-openai-requests.jsonl"
75+
scenario_tmp="$(mktemp -d "${TMPDIR:-/tmp}/openclaw-npm-onboard-channel-agent.XXXXXX")"
76+
MOCK_REQUEST_LOG="$scenario_tmp/mock-openai-requests.jsonl"
7677
export SUCCESS_MARKER MOCK_REQUEST_LOG
7778
mock_pid=""
7879
@@ -104,6 +105,7 @@ esac
104105
105106
cleanup() {
106107
openclaw_e2e_stop_process "${mock_pid:-}"
108+
rm -rf "$scenario_tmp"
107109
}
108110
trap cleanup EXIT
109111

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,61 @@ grep -qx -- "OPENCLAW_E2E_COMMAND_TIMEOUT=23s" "$TMPDIR/package-args"
12021202
);
12031203
});
12041204

1205+
it("keeps append-only mock E2E state under per-run scratch roots", () => {
1206+
const scripts = [
1207+
{
1208+
path: "scripts/e2e/lib/release-typed-onboarding/scenario.sh",
1209+
scratch:
1210+
'scenario_tmp="$(mktemp -d "${TMPDIR:-/tmp}/openclaw-release-typed-onboarding.XXXXXX")"',
1211+
requestLog: 'MOCK_REQUEST_LOG="$scenario_tmp/openai-requests.jsonl"',
1212+
removed: ["/tmp/openclaw-release-typed-onboarding-openai.jsonl"],
1213+
},
1214+
{
1215+
path: "scripts/e2e/lib/release-user-journey/scenario.sh",
1216+
scratch:
1217+
'scenario_tmp="$(mktemp -d "${TMPDIR:-/tmp}/openclaw-release-user-journey.XXXXXX")"',
1218+
requestLog: 'MOCK_REQUEST_LOG="$scenario_tmp/openai-requests.jsonl"',
1219+
extraState: 'CLICKCLACK_STATE="$scenario_tmp/clickclack.json"',
1220+
removed: [
1221+
"/tmp/openclaw-release-user-journey-openai.jsonl",
1222+
"/tmp/openclaw-release-user-journey-clickclack.json",
1223+
],
1224+
},
1225+
{
1226+
path: RELEASE_UPGRADE_USER_JOURNEY_SCENARIO_PATH,
1227+
scratch:
1228+
'scenario_tmp="$(mktemp -d "${TMPDIR:-/tmp}/openclaw-release-upgrade-user-journey.XXXXXX")"',
1229+
requestLog: 'MOCK_REQUEST_LOG="$scenario_tmp/openai-requests.jsonl"',
1230+
extraState: 'CLICKCLACK_STATE="$scenario_tmp/clickclack.json"',
1231+
removed: [
1232+
"/tmp/openclaw-release-upgrade-user-journey-openai.jsonl",
1233+
"/tmp/openclaw-release-upgrade-user-journey-clickclack.json",
1234+
],
1235+
},
1236+
{
1237+
path: NPM_ONBOARD_CHANNEL_AGENT_DOCKER_E2E_PATH,
1238+
scratch:
1239+
'scenario_tmp="$(mktemp -d "${TMPDIR:-/tmp}/openclaw-npm-onboard-channel-agent.XXXXXX")"',
1240+
requestLog: 'MOCK_REQUEST_LOG="$scenario_tmp/mock-openai-requests.jsonl"',
1241+
removed: ["/tmp/openclaw-mock-openai-requests.jsonl"],
1242+
},
1243+
];
1244+
1245+
for (const { path, scratch, requestLog, extraState, removed } of scripts) {
1246+
const script = readFileSync(path, "utf8");
1247+
1248+
expect(script, path).toContain(scratch);
1249+
expect(script, path).toContain(requestLog);
1250+
expect(script, path).toContain('rm -rf "$scenario_tmp"');
1251+
if (extraState) {
1252+
expect(script, path).toContain(extraState);
1253+
}
1254+
for (const stalePath of removed) {
1255+
expect(script, path).not.toContain(stalePath);
1256+
}
1257+
}
1258+
});
1259+
12051260
it("kills timed Docker scenario runners after the grace period", () => {
12061261
const multiNode = readFileSync(MULTI_NODE_UPDATE_DOCKER_E2E_PATH, "utf8");
12071262
const upgradeSurvivor = readFileSync(UPGRADE_SURVIVOR_DOCKER_E2E_PATH, "utf8");

0 commit comments

Comments
 (0)