Skip to content

Commit 623feaf

Browse files
committed
fix(e2e): align service account state
1 parent 353c05d commit 623feaf

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎scripts/e2e/lib/doctor-install-switch/scenario.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ create_default_service_state() {
7474
"$account_home/.local/bin/openclaw-wrapper" \
7575
"$account_home/openclaw-wrapper-argv.log"
7676
openclaw_test_state_create "$account_home" empty
77+
export HOME="$account_home"
78+
export USERPROFILE="$account_home"
7779
unset OPENCLAW_HOME OPENCLAW_STATE_DIR OPENCLAW_CONFIG_PATH
7880
}
7981

‎scripts/e2e/lib/upgrade-survivor/run.sh‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ install_baseline() {
690690
}
691691

692692
seed_state() {
693+
local account_home=""
693694
openclaw_e2e_eval_test_state_from_b64 "${OPENCLAW_TEST_STATE_FUNCTION_B64:?missing OPENCLAW_TEST_STATE_FUNCTION_B64}"
694695
if [ "$ROOT_MANAGED_VPS" = "1" ]; then
695696
if [ "$(id -u)" -ne 0 ]; then
@@ -701,6 +702,17 @@ seed_state() {
701702
else
702703
openclaw_test_state_create "$STATE_HOME_ROOT" minimal
703704
fi
705+
if [ "$UPDATE_RESTART_MODE" = "auto-auth" ]; then
706+
account_home="$(getent passwd "$(id -u)" | cut -d: -f6)"
707+
if [ -z "$account_home" ]; then
708+
echo "Could not resolve the current account home" >&2
709+
return 1
710+
fi
711+
export HOME="$account_home"
712+
export USERPROFILE="$account_home"
713+
export OPENCLAW_STATE_DIR="$account_home/.openclaw"
714+
export OPENCLAW_CONFIG_PATH="$OPENCLAW_STATE_DIR/openclaw.json"
715+
fi
704716
export OPENCLAW_UPGRADE_SURVIVOR_BASELINE_VERSION="$baseline_version"
705717
node scripts/e2e/lib/upgrade-survivor/assertions.mjs seed
706718
}

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4390,7 +4390,12 @@ heartbeat_elapsed="\${BASH_REMATCH[1]}"
43904390

43914391
expectTextToIncludeAll(scenario, [
43924392
'command_timeout="${OPENCLAW_DOCKER_DOCTOR_SWITCH_COMMAND_TIMEOUT:-900s}"',
4393-
'openclaw_test_state_create "$account_home" empty\n unset OPENCLAW_HOME OPENCLAW_STATE_DIR OPENCLAW_CONFIG_PATH',
4393+
[
4394+
'openclaw_test_state_create "$account_home" empty',
4395+
' export HOME="$account_home"',
4396+
' export USERPROFILE="$account_home"',
4397+
" unset OPENCLAW_HOME OPENCLAW_STATE_DIR OPENCLAW_CONFIG_PATH",
4398+
].join("\n"),
43944399
"create_default_service_state",
43954400
'openclaw_e2e_maybe_timeout "$command_timeout" bash -c "$install_cmd"',
43964401
'openclaw_e2e_maybe_timeout "$command_timeout" bash -c "$doctor_cmd"',
@@ -4401,9 +4406,28 @@ heartbeat_elapsed="\${BASH_REMATCH[1]}"
44014406
expect(
44024407
scenario.match(/unset OPENCLAW_HOME OPENCLAW_STATE_DIR OPENCLAW_CONFIG_PATH/gu),
44034408
).toHaveLength(1);
4409+
expect(scenario.match(/export USERPROFILE="\$account_home"/gu)).toHaveLength(1);
44044410
expect(scenario).not.toMatch(/^\s*if ! timeout "\$command_timeout"/mu);
44054411
});
44064412

4413+
it("uses the account home for upgrade survivor auto-auth state", () => {
4414+
const runner = readFileSync(UPGRADE_SURVIVOR_RUN_SCRIPT, "utf8");
4415+
4416+
expectTextToIncludeAll(runner, [
4417+
'if [ "$UPDATE_RESTART_MODE" = "auto-auth" ]; then',
4418+
'account_home="$(getent passwd "$(id -u)" | cut -d: -f6)"',
4419+
'if [ -z "$account_home" ]; then',
4420+
'export HOME="$account_home"',
4421+
'export USERPROFILE="$account_home"',
4422+
'export OPENCLAW_STATE_DIR="$account_home/.openclaw"',
4423+
'export OPENCLAW_CONFIG_PATH="$OPENCLAW_STATE_DIR/openclaw.json"',
4424+
]);
4425+
4426+
expect(
4427+
runner.indexOf('export OPENCLAW_CONFIG_PATH="$OPENCLAW_STATE_DIR/openclaw.json"'),
4428+
).toBeLessThan(runner.indexOf("node scripts/e2e/lib/upgrade-survivor/assertions.mjs seed"));
4429+
});
4430+
44074431
it("bounds doctor install switch command log diagnostics", () => {
44084432
const scenario = readFileSync(DOCTOR_SWITCH_SCENARIO_PATH, "utf8");
44094433

0 commit comments

Comments
 (0)