@norskvideo/ctl-test-harness 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/container-net.js +4 -2
- package/launch.d.ts +10 -0
- package/launch.js +39 -0
- package/package.json +1 -1
package/container-net.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Reach launched product instances by their norsk-net service DNS instead of a
|
|
2
|
-
// host-published port.
|
|
3
|
-
//
|
|
2
|
+
// host-published port. Dissolves the cross-product host-port collision the
|
|
3
|
+
// release gate trips on. Consumed by the playout, funke, and commentary
|
|
4
|
+
// integration harnesses (studioApiBase / mediaHttpBase / srtEgressUrl /
|
|
5
|
+
// studioBaseFrom); commentary's WHIP path already reaches media directly.
|
|
4
6
|
//
|
|
5
7
|
// WHY host ports collide: in the docker-outside-of-docker CI runner the test
|
|
6
8
|
// process is itself a container and studio/media run as HOST-sibling containers,
|
package/launch.d.ts
CHANGED
|
@@ -12,3 +12,13 @@ export declare function withContainerUser<T>(opts: T & {
|
|
|
12
12
|
}): T & {
|
|
13
13
|
containerUser?: string;
|
|
14
14
|
};
|
|
15
|
+
/** True when the resolved norsk-ctl CLI understands `--no-publish`. Memoised. */
|
|
16
|
+
export declare function ctlSupportsNoPublish(): Promise<boolean>;
|
|
17
|
+
/** In `direct` reach mode, ask the daemon to bind no host ports (`noPublish`) so
|
|
18
|
+
* concurrent instances on a shared runner can't collide on the product's
|
|
19
|
+
* host-port bands — but only when the resolved ctl supports the flag (see
|
|
20
|
+
* {@link ctlSupportsNoPublish}). `publish` mode and an explicit `noPublish` pass
|
|
21
|
+
* through untouched. Async because the capability probe is. */
|
|
22
|
+
export declare function withNoPublish<T extends {
|
|
23
|
+
noPublish?: boolean;
|
|
24
|
+
}>(opts: T): Promise<T>;
|
package/launch.js
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
// This is the prevention half; @norskvideo/ctl-test-harness/daemon's
|
|
10
10
|
// cleanupDaemon is the tolerance half (root-nuke on teardown). Pairing the two
|
|
11
11
|
// is the harness's whole "launch clean, tear down clean" story.
|
|
12
|
+
import { cliCommand } from "./cli-command.js";
|
|
13
|
+
import { netReachMode } from "./container-net.js";
|
|
12
14
|
/** The `uid:gid` the current process runs as, for docker `--container-user`, or
|
|
13
15
|
* undefined where POSIX uids don't exist (e.g. Windows, or Docker Desktop's VM
|
|
14
16
|
* which maps bind-mount ownership itself and needs no explicit spec). */
|
|
@@ -30,3 +32,40 @@ export function withContainerUser(opts) {
|
|
|
30
32
|
const user = runnerContainerUser();
|
|
31
33
|
return user === undefined ? opts : { ...opts, containerUser: user };
|
|
32
34
|
}
|
|
35
|
+
// The CLI is `.strict()`, so passing `--no-publish` to a norsk-ctl that predates
|
|
36
|
+
// the flag aborts the launch with "Unknown argument". A newer product must still
|
|
37
|
+
// launch on an older ctl (the contract's whole additive rule), so we probe the
|
|
38
|
+
// resolved binary once and only emit the flag when it advertises it. On an old
|
|
39
|
+
// ctl this silently no-ops (publish as today); when `latest` catches up the same
|
|
40
|
+
// harness starts binding no host ports — no cross-repo release ordering to get
|
|
41
|
+
// right. Cached: one `--help` spawn per process.
|
|
42
|
+
let noPublishSupport;
|
|
43
|
+
async function probeNoPublishSupport() {
|
|
44
|
+
try {
|
|
45
|
+
const proc = Bun.spawn([...cliCommand, "instance", "launch-template", "--help"], {
|
|
46
|
+
stdout: "pipe",
|
|
47
|
+
stderr: "pipe",
|
|
48
|
+
});
|
|
49
|
+
const [out, errText] = await Promise.all([new Response(proc.stdout).text(), new Response(proc.stderr).text()]);
|
|
50
|
+
await proc.exited;
|
|
51
|
+
return `${out}${errText}`.includes("--no-publish");
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** True when the resolved norsk-ctl CLI understands `--no-publish`. Memoised. */
|
|
58
|
+
export function ctlSupportsNoPublish() {
|
|
59
|
+
noPublishSupport ??= probeNoPublishSupport();
|
|
60
|
+
return noPublishSupport;
|
|
61
|
+
}
|
|
62
|
+
/** In `direct` reach mode, ask the daemon to bind no host ports (`noPublish`) so
|
|
63
|
+
* concurrent instances on a shared runner can't collide on the product's
|
|
64
|
+
* host-port bands — but only when the resolved ctl supports the flag (see
|
|
65
|
+
* {@link ctlSupportsNoPublish}). `publish` mode and an explicit `noPublish` pass
|
|
66
|
+
* through untouched. Async because the capability probe is. */
|
|
67
|
+
export async function withNoPublish(opts) {
|
|
68
|
+
if (opts.noPublish !== undefined || netReachMode() !== "direct")
|
|
69
|
+
return opts;
|
|
70
|
+
return (await ctlSupportsNoPublish()) ? { ...opts, noPublish: true } : opts;
|
|
71
|
+
}
|