Skip to content

Commit 740ca0f

Browse files
authored
refactor: share the sealed-service busctl fixture (#132139)
* test(e2e): reuse strict busctl fixture for sealed services * test: isolate tooling fixture setup
1 parent bd9eeae commit 740ca0f

3 files changed

Lines changed: 26 additions & 64 deletions

File tree

‎scripts/e2e/systemd-sealed-service-definition.sh‎

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -32,72 +32,13 @@ install -d -o appuser -g appuser -m 0700 "$state_dir"
3232
install -d -o root -g root -m 0555 "$unit_dir"
3333
install -d -o root -g root -m 0755 "$shim_dir"
3434
install -o root -g root -m 0755 scripts/e2e/lib/doctor-install-switch/shims/systemctl "$shim_dir/systemctl"
35-
install -o root -g root -m 0755 /dev/stdin "$shim_dir/busctl" <<'BUSCTL'
36-
#!/usr/bin/env bash
37-
set -euo pipefail
38-
39-
manager=org.freedesktop.systemd1
40-
object_path=/org/freedesktop/systemd1/unit/openclaw_2dgateway_2eservice
41-
actual=("$@")
42-
expected=(--user --json=short)
43-
44-
reject_invocation() {
45-
printf '%s\n' 'Unsupported sealed systemd busctl invocation.' >&2
46-
exit 1
47-
}
48-
49-
case "${actual[2]:-}" in
50-
call)
51-
expected+=(call "$manager" /org/freedesktop/systemd1 "$manager.Manager" LoadUnit s openclaw-gateway.service)
52-
response=manager
53-
;;
54-
get-property)
55-
case "${actual[5]:-}" in
56-
"$manager.Service")
57-
expected+=(get-property "$manager" "$object_path" "$manager.Service" ExecStart WorkingDirectory Environment EnvironmentFiles UnsetEnvironment)
58-
response=service
59-
;;
60-
"$manager.Unit")
61-
expected+=(get-property "$manager" "$object_path" "$manager.Unit" FragmentPath DropInPaths NeedDaemonReload LoadState)
62-
response=unit
63-
;;
64-
*) reject_invocation ;;
65-
esac
66-
;;
67-
*) reject_invocation ;;
68-
esac
69-
70-
[[ "${#actual[@]}" -eq "${#expected[@]}" ]] || reject_invocation
71-
for index in "${!expected[@]}"; do
72-
[[ "${actual[$index]}" == "${expected[$index]}" ]] || reject_invocation
73-
done
74-
75-
case "$response" in
76-
manager)
77-
printf '%s\n' '{"type":"o","data":["/org/freedesktop/systemd1/unit/openclaw_2dgateway_2eservice"]}'
78-
;;
79-
service)
80-
printf '%s\n' \
81-
'{"type":"a(sasbttttuii)","data":[["/usr/local/bin/node",["/usr/local/bin/node","/app/openclaw.mjs","gateway","--port","18789"],false,0,0,0,0,0,0,0]]}' \
82-
'{"type":"s","data":"/app"}' \
83-
'{"type":"as","data":["OPENCLAW_GATEWAY_PORT=18789"]}' \
84-
'{"type":"a(sb)","data":[["/home/appuser/.openclaw/gateway.systemd.env",false]]}' \
85-
'{"type":"as","data":[]}'
86-
;;
87-
unit)
88-
printf '%s\n' \
89-
'{"type":"s","data":"/home/appuser/.config/systemd/user/openclaw-gateway.service"}' \
90-
'{"type":"as","data":[]}' \
91-
'{"type":"b","data":false}' \
92-
'{"type":"s","data":"loaded"}'
93-
;;
94-
esac
95-
BUSCTL
35+
install -o root -g root -m 0755 scripts/e2e/lib/doctor-install-switch/shims/busctl "$shim_dir/busctl"
36+
install -o root -g root -m 0644 scripts/e2e/lib/doctor-install-switch/shims/systemd-exec-start.mjs "$shim_dir/systemd-exec-start.mjs"
9637
9738
install_sealed_unit() {
9839
install -o root -g "$1" -m "$2" /dev/stdin "$unit_path" <<'UNIT'
9940
[Unit]
100-
Description=OpenClaw Gateway (sealed ownership proof)
41+
Description=OpenClaw Gateway (umbreon-latest sealed ownership proof)
10142
[Service]
10243
ExecStart=/usr/local/bin/node /app/openclaw.mjs gateway --port 18789
10344
WorkingDirectory=/app

‎test/scripts/plugin-sdk-api-diff.test.ts‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,29 @@ async function waitFor(check: () => boolean, timeoutMs: number): Promise<void> {
2424

2525
describe("Plugin SDK API diff CLI", () => {
2626
it("interrupts a running child and removes its registered worktree", async () => {
27-
const repo = git(process.cwd(), ["rev-parse", "--show-toplevel"]).trim();
27+
// Keep revision checkout bounded so startup reaches the child this test cancels.
28+
const repo = tempDirs.make("plugin-sdk-api-diff-repo-");
2829
const runnerTemp = tempDirs.make("plugin-sdk-api-diff-temp-");
2930
const binDir = tempDirs.make("plugin-sdk-api-diff-bin-");
3031
const pnpmMarker = join(binDir, "pnpm-started");
3132

33+
git(repo, ["init", "--quiet", "--initial-branch=main"]);
34+
writeFileSync(join(repo, "README.md"), "fixture\n");
35+
git(repo, ["add", "README.md"]);
36+
git(repo, [
37+
"-c",
38+
"user.name=Test",
39+
"-c",
40+
41+
"-c",
42+
"core.hooksPath=/dev/null",
43+
"commit",
44+
"--no-gpg-sign",
45+
"--quiet",
46+
"-m",
47+
"fixture",
48+
]);
49+
3250
const fakePnpm = join(binDir, "pnpm");
3351
writeFileSync(
3452
fakePnpm,
@@ -54,6 +72,8 @@ describe("Plugin SDK API diff CLI", () => {
5472
PATH: `${binDir}${delimiter}${process.env.PATH ?? ""}`,
5573
PNPM_MARKER: pnpmMarker,
5674
RUNNER_TEMP: runnerTemp,
75+
// The fixture owns Git state; the source CLI still needs its workspace aliases.
76+
TSX_TSCONFIG_PATH: resolve("tsconfig.json"),
5777
},
5878
stdio: ["ignore", "ignore", "pipe"],
5979
},

‎test/scripts/release-telegram-candidate-archive.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ describe("release Telegram candidate archive guard", () => {
448448
});
449449

450450
it("rejects a socket entry", async () => {
451-
const root = tempDirs.make("openclaw-archive-guard-");
451+
// Keep the socket path below macOS's 104-byte sockaddr_un buffer.
452+
const root = tempDirs.make("sock-");
452453
const socketPath = path.join(root, "candidate.sock");
453454
const server = createServer();
454455
await new Promise<void>((resolve, reject) => {

0 commit comments

Comments
 (0)