Merge remote-tracking branch 'origin/master' into gitea/feature/end
Resolved conflicts taking origin/master (v0.5.55) as canonical, with local features re-applied: - runtime log level (LOG_LEVEL env + dashboard Settings → Logging, applied immediately and persisted across restarts) - free/noAuth provider enable/disable toggle via providerStrategies.enabled - parallel model testing (Test All Models / Test Selected Keys)
This commit is contained in:
39
tests/unit/tunnel-pid-ownership.test.js
Normal file
39
tests/unit/tunnel-pid-ownership.test.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
describe("cloudflared PID ownership", () => {
|
||||
let dataDir;
|
||||
|
||||
beforeEach(() => {
|
||||
dataDir = fs.mkdtempSync(path.join(os.tmpdir(), "9router-tunnel-pid-"));
|
||||
process.env.DATA_DIR = dataDir;
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete process.env.DATA_DIR;
|
||||
fs.rmSync(dataDir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("does not let an old child clear its successor PID", async () => {
|
||||
const { clearPid, loadPid, savePid } = await import("../../src/lib/tunnel/cloudflare/pid.js");
|
||||
|
||||
savePid(100);
|
||||
savePid(200);
|
||||
clearPid(100);
|
||||
|
||||
expect(loadPid()).toBe(200);
|
||||
|
||||
clearPid(200);
|
||||
expect(loadPid()).toBeNull();
|
||||
});
|
||||
|
||||
it("releases PID and process ownership for the exiting child only", () => {
|
||||
const source = fs.readFileSync(new URL("../../src/lib/tunnel/cloudflare/cloudflared.js", import.meta.url), "utf8");
|
||||
|
||||
expect(source.match(/clearPid\(child\.pid\)/g)).toHaveLength(2);
|
||||
expect(source.match(/cloudflaredProcess === child/g)).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user