

























@@ -4,20 +4,20 @@
44# Sourced by scripts/e2e/bundled-channel-runtime-deps-docker.sh.
5566run_load_failure_scenario() {
7-local run_log
87local state_script_b64
9- run_log="$(docker_e2e_run_log bundled-channel-load-failure)"
108 state_script_b64="$(docker_e2e_test_state_shell_b64 bundled-channel-load-failure empty)"
1191210echo "Running bundled channel load-failure isolation Docker E2E..."
13-if ! timeout "$DOCKER_RUN_TIMEOUT" docker run --rm \
11+run_logged_print bundled-channel-load-failure timeout "$DOCKER_RUN_TIMEOUT" docker run --rm \
1412 -e COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \
1513 -e "OPENCLAW_TEST_STATE_SCRIPT_B64=$state_script_b64" \
1614"${DOCKER_E2E_PACKAGE_ARGS[@]}" \
17- -i "$IMAGE_NAME" bash -s >"$run_log" 2>&1 <<'EOF'
15+"${DOCKER_E2E_HARNESS_ARGS[@]}" \
16+ -i "$IMAGE_NAME" bash -s <<'EOF'
1817set -euo pipefail
191820-eval "$(printf "%s" "${OPENCLAW_TEST_STATE_SCRIPT_B64:?missing OPENCLAW_TEST_STATE_SCRIPT_B64}" | base64 -d)"
19+source scripts/lib/openclaw-e2e-instance.sh
20+openclaw_e2e_eval_test_state_from_b64 "${OPENCLAW_TEST_STATE_SCRIPT_B64:?missing OPENCLAW_TEST_STATE_SCRIPT_B64}"
2121export NPM_CONFIG_PREFIX="$HOME/.npm-global"
2222export PATH="$NPM_CONFIG_PREFIX/bin:$PATH"
2323export OPENCLAW_NO_ONBOARD=1
@@ -106,16 +106,28 @@ if (!bundledPath) {
106106 throw new Error("missing packaged bundled channel loader artifact");
107107}
108108const bundled = await import(pathToFileURL(bundledPath));
109-const oneArgExports = Object.entries(bundled).filter(
110- ([, value]) => typeof value === "function" && value.length === 1,
109+const loaderNames = [
110+ "getBundledChannelPlugin",
111+ "getBundledChannelSetupPlugin",
112+ "getBundledChannelSecrets",
113+ "getBundledChannelSetupSecrets",
114+];
115+const exportedLoaders = new Map(
116+ Object.values(bundled)
117+ .filter((value) => typeof value === "function")
118+ .map((fn) => [fn.name, fn]),
111119);
112-if (oneArgExports.length === 0) {
113- throw new Error(`missing one-argument bundled loader exports; exports=${Object.keys(bundled).join(",")}`);
114-}
120+const loaders = loaderNames.map((name) => {
121+ const fn = exportedLoaders.get(name);
122+ if (typeof fn !== "function") {
123+ throw new Error(`missing packaged bundled loader export ${name}; exports=${Object.keys(bundled).join(",")}`);
124+ }
125+ return [name, fn];
126+});
115127116128const id = "load-failure-alpha";
117-for (let i = 0; i < 2; i += 1) {
118- for (const [name, fn] of oneArgExports) {
129+function exerciseLoaders() {
130+ for (const [name, fn] of loaders) {
119131 try {
120132 fn(id);
121133 } catch (error) {
@@ -127,36 +139,35 @@ for (let i = 0; i < 2; i += 1) {
127139 }
128140}
129141130-const counts = {
131- plugin: globalThis.__loadFailurePlugin,
132- setup: globalThis.__loadFailureSetup,
133- secrets: globalThis.__loadFailureSecrets,
134- setupSecrets: globalThis.__loadFailureSetupSecrets,
135-};
136-for (const [key, value] of Object.entries({
137- plugin: counts.plugin,
138- setup: counts.setup,
139- setupSecrets: counts.setupSecrets,
140-})) {
141- if (value !== 1) {
142- throw new Error(`expected ${key} failure to be cached after one load, got ${value}`);
142+function loadCounts() {
143+ return {
144+ plugin: globalThis.__loadFailurePlugin,
145+ setup: globalThis.__loadFailureSetup,
146+ secrets: globalThis.__loadFailureSecrets,
147+ setupSecrets: globalThis.__loadFailureSetupSecrets,
148+ };
149+}
150+151+exerciseLoaders();
152+const firstCounts = loadCounts();
153+exerciseLoaders();
154+const secondCounts = loadCounts();
155+for (const key of ["plugin", "setup", "setupSecrets"]) {
156+ const first = firstCounts[key];
157+ if (!Number.isInteger(first) || first < 1) {
158+ throw new Error(`expected ${key} failure to be exercised at least once, got ${first}`);
159+ }
160+ if (secondCounts[key] !== first) {
161+ throw new Error(`expected ${key} failure to be cached after first pass, got ${first} then ${secondCounts[key]}`);
143162 }
144163}
145-if (counts.secrets !== undefined && counts.secrets !== 1) {
146- throw new Error(`expected secrets failure to be cached after one load when exercised, got ${counts.secrets}`);
164+if (firstCounts.secrets !== undefined && secondCounts.secrets !== firstCounts.secrets) {
165+ throw new Error(`expected secrets failure to be cached after first pass, got ${firstCounts.secrets} then ${secondCounts.secrets}`);
147166}
148167console.log("synthetic bundled channel load failures were isolated and cached");
149168NODE
150169)
151170152171echo "bundled channel load-failure isolation Docker E2E passed"
153172EOF
154-then
155- docker_e2e_print_log "$run_log"
156- rm -f "$run_log"
157-exit 1
158-fi
159-160- docker_e2e_print_log "$run_log"
161- rm -f "$run_log"
162173}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。