Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

test(install): make abort recovery harness static

Abdurrahman Fakhrulcc54ff090e8c
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 6abd34c4..82a1ceba 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -46,6 +46,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Tests**
+- `install` make abort recovery harness static
- `gateway` treat zombie children as stopped
- `gateway` isolate lifecycle fixtures
- `cli` lock offline update dispatch
diff --git a/scripts/install-runtime-abort-recovery.test.ts b/scripts/install-runtime-abort-recovery.test.ts
index 578ec583..9a008bb2 100644
--- a/scripts/install-runtime-abort-recovery.test.ts
+++ b/scripts/install-runtime-abort-recovery.test.ts
@@ -1,53 +1,29 @@
import { spawnSync } from "node:child_process";
-import fs from "node:fs";
-import os from "node:os";
import path from "node:path";
-import { afterEach, describe, expect, it } from "vitest";
+import { describe, expect, it } from "vitest";
-const HELPER = path.join(process.cwd(), "scripts/lib/install-runtime-lifecycle.sh");
-const roots: string[] = [];
+const FIXTURE = path.join(process.cwd(), "scripts/test-fixtures/install-runtime-abort-recovery.sh");
-function runCleanup(mutationStarted: boolean) {
- const root = fs.mkdtempSync(path.join(os.tmpdir(), "mso-install-abort-"));
- roots.push(root);
- const capture = path.join(root, "capture");
- const script = `
-set -euo pipefail
-DIR=/tmp; PORT=4005; DO_SERVICE=1; SERVICE=mso.service
-die(){ echo "die:$*" >&2; exit 1; }
-sudo_do(){ printf 'sudo %s\n' "$*" >> ${JSON.stringify(capture)}; }
-systemd_ready(){ return 0; }
-. ${JSON.stringify(HELPER)}
-runtime_exclusion_release(){ echo release-runtime >> ${JSON.stringify(capture)}; }
-update_gateway_restore_all(){ echo restore-fallbacks >> ${JSON.stringify(capture)}; }
-update_lock_release(){ echo release-update >> ${JSON.stringify(capture)}; }
-INSTALL_RUNTIME_LIFECYCLE=1
-INSTALL_RUNTIME_SERVICE_STOPPED=1
-${mutationStarted ? "install_runtime_lifecycle_mark_mutation_started" : ""}
-install_runtime_lifecycle_cleanup
-`;
- const out = spawnSync("bash", ["-c", script], { encoding: "utf8" });
- return { out, calls: fs.existsSync(capture) ? fs.readFileSync(capture, "utf8") : "" };
+function runCleanup(mode: "pre" | "post") {
+ return spawnSync("bash", [FIXTURE, mode], { encoding: "utf8" });
}
-afterEach(() => { for (const root of roots.splice(0)) fs.rmSync(root, { recursive: true, force: true }); });
-
describe("installer abort recovery", () => {
it("restores the known-good service and fallbacks when aborting before mutation", () => {
- const { out, calls } = runCleanup(false);
+ const out = runCleanup("pre");
expect(out.status).toBe(0);
- expect(calls).toContain("release-runtime");
- expect(calls).toContain("sudo systemctl start mso.service");
- expect(calls).toContain("restore-fallbacks");
- expect(calls).toContain("release-update");
+ expect(out.stdout).toContain("release-runtime");
+ expect(out.stdout).toContain("sudo systemctl start mso.service");
+ expect(out.stdout).toContain("restore-fallbacks");
+ expect(out.stdout).toContain("release-update");
});
it("does not restart any runtime after installer mutation has started", () => {
- const { out, calls } = runCleanup(true);
+ const out = runCleanup("post");
expect(out.status).toBe(0);
- expect(calls).toContain("release-runtime");
- expect(calls).toContain("release-update");
- expect(calls).not.toContain("systemctl start mso.service");
- expect(calls).not.toContain("restore-fallbacks");
+ expect(out.stdout).toContain("release-runtime");
+ expect(out.stdout).toContain("release-update");
+ expect(out.stdout).not.toContain("systemctl start mso.service");
+ expect(out.stdout).not.toContain("restore-fallbacks");
});
});
diff --git a/scripts/test-fixtures/install-runtime-abort-recovery.sh b/scripts/test-fixtures/install-runtime-abort-recovery.sh
new file mode 100644
index 00000000..c9a5f802
--- /dev/null
+++ b/scripts/test-fixtures/install-runtime-abort-recovery.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
+MODE="${1:-}"
+case "$MODE" in pre|post) ;; *) exit 2 ;; esac
+
+DIR=/tmp
+PORT=4005
+DO_SERVICE=1
+SERVICE=mso.service
+die() { printf 'die:%s\n' "$*" >&2; exit 1; }
+sudo_do() { printf 'sudo %s\n' "$*"; }
+systemd_ready() { return 0; }
+
+# shellcheck source=scripts/lib/install-runtime-lifecycle.sh
+. "$ROOT/scripts/lib/install-runtime-lifecycle.sh"
+runtime_exclusion_release() { printf 'release-runtime\n'; }
+update_gateway_restore_all() { printf 'restore-fallbacks\n'; }
+update_lock_release() { printf 'release-update\n'; }
+
+INSTALL_RUNTIME_LIFECYCLE=1
+INSTALL_RUNTIME_SERVICE_STOPPED=1
+[ "$MODE" = pre ] || install_runtime_lifecycle_mark_mutation_started
+install_runtime_lifecycle_cleanup