Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions tests/config/config-ownership-concurrent-record.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ describe("serialized ownership manifest (#8093)", () => {
expect(existsSync(join(dir, CONFIG_OWNERSHIP_LOCK))).toBe(false);
}), 60_000);

test("an interrupted uninstall refuses registrations, cached paths included, and a rerun finishes it",
{ skip: process.platform === "win32" || process.getuid?.() === 0 },
test.skipIf(process.platform === "win32" || process.getuid?.() === 0)("an interrupted uninstall refuses registrations, cached paths included, and a rerun finishes it",
withHome(async dir => {
// This process records (and caches) paths, as a long-running proxy would.
expect(recordOwnedConfigPath(dir, join(dir, "seed"))).toBe(true);
Expand Down Expand Up @@ -189,7 +188,28 @@ describe("serialized ownership manifest (#8093)", () => {
});

describe("callers that create files after registering them (#8093)", () => {
test("service log rotation goes ahead unrecorded once the ownership lock keeps failing", { skip: process.platform === "win32" },
test("service log rotation goes ahead unrecorded while the ownership lock is busy", withHome(async dir => {
expect(recordOwnedConfigPath(dir, join(dir, "seed"))).toBe(true);
const { startServiceLogging, SERVICE_LOG_MAX_BYTES } = await import("../../src/service/logging");
const path = join(dir, "service.log");
writeFileSync(path, "x".repeat(SERVICE_LOG_MAX_BYTES + 1));
expect(manifest(dir).paths).not.toContain("service.log.1");
const release = holdLock(dir);
let stop: (() => void) | undefined;
try {
expect(() => recordOwnedConfigPath(dir, path + ".1")).toThrow(ConfigOwnershipLockError);
stop = startServiceLogging(path, { OCX_SERVICE: "1" }, 10);
expect(existsSync(path + ".1")).toBe(false);
const deadline = Date.now() + 3_000;
while (!existsSync(path + ".1") && Date.now() < deadline) await Bun.sleep(10);
expect(existsSync(path + ".1")).toBe(true);
expect(manifest(dir).paths).not.toContain("service.log.1");
} finally {
try { stop?.(); } finally { release(); }
}
}));

test.skipIf(process.platform === "win32")("service log rotation goes ahead unrecorded once the ownership lock keeps failing",
Comment thread
luvs01 marked this conversation as resolved.
Resolved
withHome(async dir => {
expect(recordOwnedConfigPath(dir, join(dir, "seed"))).toBe(true);
// A second link to the lock file is refused on every attempt: a lock fault that persists.
Expand Down Expand Up @@ -274,8 +294,7 @@ describe("manifest limits and uninstall leftovers (#8093)", () => {
});

describe("upgraded homes near the manifest byte limit (#8093)", () => {
test("an interrupted uninstall of a near-limit manifest still resumes after the tombstone",
{ skip: process.platform === "win32" || process.getuid?.() === 0 },
test.skipIf(process.platform === "win32" || process.getuid?.() === 0)("an interrupted uninstall of a near-limit manifest still resumes after the tombstone",
withHome(dir => {
expect(recordOwnedConfigPath(dir, join(dir, "seed"))).toBe(true);
// An older version could fill the manifest up to the limit with no tombstone reserve.
Expand Down Expand Up @@ -498,7 +517,7 @@ describe("paths recorded after the uninstall snapshot (#8093)", () => {
expect(existsSync(join(dir, "fresh-between"))).toBe(false);
}), 60_000);

test("a finishing uninstall leaves a lock file another installation created in place", { skip: process.platform === "win32" },
test.skipIf(process.platform === "win32")("a finishing uninstall leaves a lock file another installation created in place",
withHome(async dir => {
const { setUninstallStepHookForTests } = await import("../../src/lib/config-ownership");
expect(recordOwnedConfigPath(dir, join(dir, "seed"))).toBe(true);
Expand Down Expand Up @@ -682,7 +701,7 @@ describe("ownership edge cases from review (#8093)", () => {
expect(removeOwnedConfigState(dir)).toEqual({ status: "removed", residualPaths: [] });
}));

test("a finishing uninstall unlinks its lock file before releasing it", { skip: process.platform === "win32" }, withHome(dir => {
test.skipIf(process.platform === "win32")("a finishing uninstall unlinks its lock file before releasing it", withHome(dir => {
expect(recordOwnedConfigPath(dir, join(dir, "seed"))).toBe(true);
// A process that takes the old file after release must see the path change and retry, so the
// path is gone while this run still holds the lock.
Expand Down Expand Up @@ -756,7 +775,7 @@ describe("ownership edge cases from review (#8093)", () => {
expect(existsSync(join(dir, "config-mutation.sqlite"))).toBe(true);
}));

test("a listed symlink whose target is gone is removed", { skip: process.platform === "win32" }, withHome(dir => {
test.skipIf(process.platform === "win32")("a listed symlink whose target is gone is removed", withHome(dir => {
expect(recordOwnedConfigPath(dir, join(dir, "linked"))).toBe(true);
symlinkSync(join(dirname(dir), "missing-target"), join(dir, "linked"));
expect(removeOwnedConfigState(dir)).toEqual({ status: "removed", residualPaths: [] });
Expand Down
Loading