From 403190572bc93d0f4e4c3febf2877ab4b658d7dc Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 1 Jun 2026 23:19:35 +0200 Subject: [PATCH] fix(e2e): isolate release media memory artifacts --- .../e2e/lib/release-media-memory/scenario.sh | 101 ++++++++++-------- .../release-media-memory-scenario.test.ts | 11 +- 2 files changed, 64 insertions(+), 48 deletions(-) diff --git a/scripts/e2e/lib/release-media-memory/scenario.sh b/scripts/e2e/lib/release-media-memory/scenario.sh index 2de9cfe3ca6..aa292495b77 100755 --- a/scripts/e2e/lib/release-media-memory/scenario.sh +++ b/scripts/e2e/lib/release-media-memory/scenario.sh @@ -21,12 +21,31 @@ PORT="18789" MOCK_PORT="44200" SUCCESS_MARKER="OPENCLAW_E2E_OK_MEDIA_MEMORY" MEMORY_MARKER="release-media-memory-saffron-$(date +%s)" -MOCK_REQUEST_LOG="/tmp/openclaw-release-media-memory-openai.jsonl" +media_root="$(mktemp -d /tmp/openclaw-release-media-memory.XXXXXX)" +INSTALL_LOG="$media_root/install.log" +ONBOARD_LOG="$media_root/onboard.log" +ENV_LOG="$media_root/env.log" +CONFIG_JSON="$media_root/config.json" +PACKAGE_FILES_LOG="$media_root/package-files.log" +PLUGINS_JSON="$media_root/plugins.json" +PLUGINS_STDERR_LOG="$media_root/plugins.stderr.log" +MOCK_OPENAI_LOG="$media_root/openai.log" +MOCK_REQUEST_LOG="$media_root/openai-requests.jsonl" +DESCRIBE_JSON="$media_root/describe.json" +DESCRIBE_STDERR_LOG="$media_root/describe.stderr.log" +GENERATE_JSON="$media_root/generate.json" +GENERATE_STDERR_LOG="$media_root/generate.stderr.log" +INDEX_LOG="$media_root/index.log" +SEARCH_BEFORE_JSON="$media_root/search-before.json" +SEARCH_BEFORE_STDERR_LOG="$media_root/search-before.stderr.log" +SEARCH_AFTER_JSON="$media_root/search-after.json" +SEARCH_AFTER_STDERR_LOG="$media_root/search-after.stderr.log" +GATEWAY_1_LOG="$media_root/gateway-1.log" +GATEWAY_2_LOG="$media_root/gateway-2.log" export SUCCESS_MARKER MOCK_REQUEST_LOG mock_pid="" gateway_pid="" -media_root="" cleanup() { openclaw_e2e_terminate_gateways "${gateway_pid:-}" openclaw_e2e_stop_process "${mock_pid:-}" @@ -40,26 +59,26 @@ dump_debug_logs() { local status="$1" echo "release media memory failed with exit code $status" >&2 openclaw_e2e_dump_logs \ - /tmp/openclaw-release-media-memory-install.log \ - /tmp/openclaw-release-media-memory-onboard.log \ - /tmp/openclaw-release-media-memory-env.log \ - /tmp/openclaw-release-media-memory-config.json \ - /tmp/openclaw-release-media-memory-package-files.log \ - /tmp/openclaw-release-media-memory-plugins.json \ - /tmp/openclaw-release-media-memory-plugins.stderr.log \ - /tmp/openclaw-release-media-memory-openai.log \ + "$INSTALL_LOG" \ + "$ONBOARD_LOG" \ + "$ENV_LOG" \ + "$CONFIG_JSON" \ + "$PACKAGE_FILES_LOG" \ + "$PLUGINS_JSON" \ + "$PLUGINS_STDERR_LOG" \ + "$MOCK_OPENAI_LOG" \ "$MOCK_REQUEST_LOG" \ - /tmp/openclaw-release-media-memory-describe.json \ - /tmp/openclaw-release-media-memory-describe.stderr.log \ - /tmp/openclaw-release-media-memory-generate.json \ - /tmp/openclaw-release-media-memory-generate.stderr.log \ - /tmp/openclaw-release-media-memory-index.log \ - /tmp/openclaw-release-media-memory-search-before.json \ - /tmp/openclaw-release-media-memory-search-before.stderr.log \ - /tmp/openclaw-release-media-memory-search-after.json \ - /tmp/openclaw-release-media-memory-search-after.stderr.log \ - /tmp/openclaw-release-media-memory-gateway-1.log \ - /tmp/openclaw-release-media-memory-gateway-2.log + "$DESCRIBE_JSON" \ + "$DESCRIBE_STDERR_LOG" \ + "$GENERATE_JSON" \ + "$GENERATE_STDERR_LOG" \ + "$INDEX_LOG" \ + "$SEARCH_BEFORE_JSON" \ + "$SEARCH_BEFORE_STDERR_LOG" \ + "$SEARCH_AFTER_JSON" \ + "$SEARCH_AFTER_STDERR_LOG" \ + "$GATEWAY_1_LOG" \ + "$GATEWAY_2_LOG" } trap 'status=$?; dump_debug_logs "$status"; exit "$status"' ERR @@ -74,7 +93,7 @@ stop_gateway() { gateway_pid="" } -openclaw_e2e_install_package /tmp/openclaw-release-media-memory-install.log +openclaw_e2e_install_package "$INSTALL_LOG" command -v openclaw >/dev/null package_root="$(openclaw_e2e_package_root)" entry="$(openclaw_e2e_package_entrypoint "$package_root")" @@ -86,14 +105,14 @@ entry="$(openclaw_e2e_package_entrypoint "$package_root")" printf 'OPENCLAW_HOME=%s\n' "$OPENCLAW_HOME" printf 'OPENCLAW_STATE_DIR=%s\n' "$OPENCLAW_STATE_DIR" printf 'OPENCLAW_CONFIG_PATH=%s\n' "$OPENCLAW_CONFIG_PATH" -} >/tmp/openclaw-release-media-memory-env.log +} >"$ENV_LOG" openclaw_e2e_enable_openclaw_cli_timeout ( cd "$package_root/dist/extensions/memory-core" find . -type f | sed 's#^\./##' | sort -) >/tmp/openclaw-release-media-memory-package-files.log +) >"$PACKAGE_FILES_LOG" -mock_pid="$(openclaw_e2e_start_mock_openai "$MOCK_PORT" /tmp/openclaw-release-media-memory-openai.log)" +mock_pid="$(openclaw_e2e_start_mock_openai "$MOCK_PORT" "$MOCK_OPENAI_LOG")" openclaw_e2e_wait_mock_openai "$MOCK_PORT" openclaw onboard \ @@ -108,30 +127,28 @@ openclaw onboard \ --skip-ui \ --skip-channels \ --skip-skills \ - --skip-health >/tmp/openclaw-release-media-memory-onboard.log 2>&1 -cp "$OPENCLAW_CONFIG_PATH" /tmp/openclaw-release-media-memory-config.json -openclaw plugins list --json >/tmp/openclaw-release-media-memory-plugins.json \ - 2>/tmp/openclaw-release-media-memory-plugins.stderr.log -node scripts/e2e/lib/release-scenarios/assertions.mjs assert-file-contains /tmp/openclaw-release-media-memory-plugins.json memory-core + --skip-health >"$ONBOARD_LOG" 2>&1 +cp "$OPENCLAW_CONFIG_PATH" "$CONFIG_JSON" +openclaw plugins list --json >"$PLUGINS_JSON" 2>"$PLUGINS_STDERR_LOG" +node scripts/e2e/lib/release-scenarios/assertions.mjs assert-file-contains "$PLUGINS_JSON" memory-core node scripts/e2e/lib/release-scenarios/assertions.mjs configure-mock-openai "$MOCK_PORT" mkdir -p "$OPENCLAW_STATE_DIR/workspace/memory" -media_root="$(mktemp -d /tmp/openclaw-release-media-memory.XXXXXX)" printf '%s' 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+yf7kAAAAASUVORK5CYII=' | base64 -d >"$media_root/input.png" openclaw infer image describe \ --file "$media_root/input.png" \ --model openai/gpt-5.5 \ --prompt "Describe this image and return marker $SUCCESS_MARKER" \ - --json >/tmp/openclaw-release-media-memory-describe.json 2>/tmp/openclaw-release-media-memory-describe.stderr.log -node scripts/e2e/lib/release-scenarios/assertions.mjs assert-image-describe /tmp/openclaw-release-media-memory-describe.json "$MOCK_REQUEST_LOG" + --json >"$DESCRIBE_JSON" 2>"$DESCRIBE_STDERR_LOG" +node scripts/e2e/lib/release-scenarios/assertions.mjs assert-image-describe "$DESCRIBE_JSON" "$MOCK_REQUEST_LOG" openclaw infer image generate \ --model openai/gpt-image-1 \ --prompt "Generate a tiny test image for $SUCCESS_MARKER" \ --output "$media_root/generated.png" \ - --json >/tmp/openclaw-release-media-memory-generate.json 2>/tmp/openclaw-release-media-memory-generate.stderr.log -node scripts/e2e/lib/release-scenarios/assertions.mjs assert-image-generate /tmp/openclaw-release-media-memory-generate.json "$MOCK_REQUEST_LOG" + --json >"$GENERATE_JSON" 2>"$GENERATE_STDERR_LOG" +node scripts/e2e/lib/release-scenarios/assertions.mjs assert-image-generate "$GENERATE_JSON" "$MOCK_REQUEST_LOG" cat >"$OPENCLAW_STATE_DIR/workspace/MEMORY.md" <"$OPENCLAW_STATE_DIR/workspace/MEMORY.md" </tmp/openclaw-release-media-memory-index.log 2>&1 -openclaw memory search "$MEMORY_MARKER" --json >/tmp/openclaw-release-media-memory-search-before.json 2>/tmp/openclaw-release-media-memory-search-before.stderr.log -node scripts/e2e/lib/release-scenarios/assertions.mjs assert-memory-search /tmp/openclaw-release-media-memory-search-before.json "$MEMORY_MARKER" +openclaw memory index --force >"$INDEX_LOG" 2>&1 +openclaw memory search "$MEMORY_MARKER" --json >"$SEARCH_BEFORE_JSON" 2>"$SEARCH_BEFORE_STDERR_LOG" +node scripts/e2e/lib/release-scenarios/assertions.mjs assert-memory-search "$SEARCH_BEFORE_JSON" "$MEMORY_MARKER" -start_gateway /tmp/openclaw-release-media-memory-gateway-1.log +start_gateway "$GATEWAY_1_LOG" stop_gateway -start_gateway /tmp/openclaw-release-media-memory-gateway-2.log -openclaw memory search "$MEMORY_MARKER" --json >/tmp/openclaw-release-media-memory-search-after.json 2>/tmp/openclaw-release-media-memory-search-after.stderr.log -node scripts/e2e/lib/release-scenarios/assertions.mjs assert-memory-search /tmp/openclaw-release-media-memory-search-after.json "$MEMORY_MARKER" +start_gateway "$GATEWAY_2_LOG" +openclaw memory search "$MEMORY_MARKER" --json >"$SEARCH_AFTER_JSON" 2>"$SEARCH_AFTER_STDERR_LOG" +node scripts/e2e/lib/release-scenarios/assertions.mjs assert-memory-search "$SEARCH_AFTER_JSON" "$MEMORY_MARKER" stop_gateway echo "Release media memory scenario passed." diff --git a/test/scripts/release-media-memory-scenario.test.ts b/test/scripts/release-media-memory-scenario.test.ts index afbbc09bc84..ea8da9031a0 100644 --- a/test/scripts/release-media-memory-scenario.test.ts +++ b/test/scripts/release-media-memory-scenario.test.ts @@ -6,12 +6,8 @@ const SCENARIO = "scripts/e2e/lib/release-media-memory/scenario.sh"; describe("release media memory scenario", () => { it("fails when packaged plugin listing is broken or omits memory-core", () => { const script = readFileSync(SCENARIO, "utf8"); - const listIndex = script.indexOf( - "openclaw plugins list --json >/tmp/openclaw-release-media-memory-plugins.json", - ); - const assertIndex = script.indexOf( - "assert-file-contains /tmp/openclaw-release-media-memory-plugins.json memory-core", - ); + const listIndex = script.indexOf('openclaw plugins list --json >"$PLUGINS_JSON"'); + const assertIndex = script.indexOf('assert-file-contains "$PLUGINS_JSON" memory-core'); expect(listIndex).toBeGreaterThanOrEqual(0); expect(assertIndex).toBeGreaterThan(listIndex); @@ -29,8 +25,11 @@ describe("release media memory scenario", () => { expect(script).toContain('media_root="$(mktemp -d /tmp/openclaw-release-media-memory.XXXXXX)"'); expect(script).toContain('rm -rf "$media_root"'); + expect(script).toContain('MOCK_REQUEST_LOG="$media_root/openai-requests.jsonl"'); + expect(script).toContain('PLUGINS_JSON="$media_root/plugins.json"'); expect(script).toContain('--file "$media_root/input.png"'); expect(script).toContain('--output "$media_root/generated.png"'); + expect(script).not.toContain("/tmp/openclaw-release-media-memory-plugins.json"); expect(script).not.toContain( 'mkdir -p "$OPENCLAW_STATE_DIR/workspace/memory" /tmp/openclaw-release-media-memory', );