@norskvideo/ctl-test-harness 0.1.66 → 0.1.67

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/daemon.d.ts CHANGED
@@ -56,6 +56,20 @@ export interface StartDaemonOptions {
56
56
  * A suite that writes its own config.yaml (to pick a networkMode, a proxy
57
57
  * port) still gets the working directory added, unless it states one. */
58
58
  export declare function seedDaemonConfig(storeDir: string): void;
59
+ /** The environment a test daemon is spawned with.
60
+ *
61
+ * The daemon's singleton containers default to box-global names, and on a
62
+ * docker-outside-of-docker runner the "box" is a host daemon shared by every
63
+ * runner on it: concurrent jobs replaced and removed each other's `norsk-proxy`
64
+ * (and each daemon start `rm -f`s the cpu-monitor sidecar by name). Naming them
65
+ * after the daemon's port, which is already unique per live daemon on a box,
66
+ * keeps each job to its own. A ctl that predates an override ignores it. */
67
+ export declare function daemonSpawnEnv(o: {
68
+ storeDir: string;
69
+ port: number;
70
+ inherited: Record<string, string | undefined>;
71
+ overrides?: Record<string, string>;
72
+ }): Record<string, string | undefined>;
59
73
  export declare function startDaemon(storeDir: string, options?: StartDaemonOptions): {
60
74
  daemon: DaemonProcess;
61
75
  ready: Promise<void>;
package/daemon.js CHANGED
@@ -145,6 +145,29 @@ export function seedDaemonConfig(storeDir) {
145
145
  const separator = existing === "" || existing.endsWith("\n") ? "" : "\n";
146
146
  writeFileSync(configPath, `${existing}${separator}${workdirLine}`);
147
147
  }
148
+ /** The environment a test daemon is spawned with.
149
+ *
150
+ * The daemon's singleton containers default to box-global names, and on a
151
+ * docker-outside-of-docker runner the "box" is a host daemon shared by every
152
+ * runner on it: concurrent jobs replaced and removed each other's `norsk-proxy`
153
+ * (and each daemon start `rm -f`s the cpu-monitor sidecar by name). Naming them
154
+ * after the daemon's port, which is already unique per live daemon on a box,
155
+ * keeps each job to its own. A ctl that predates an override ignores it. */
156
+ export function daemonSpawnEnv(o) {
157
+ // A spawned daemon must boot GUARDED: exercising the real ingress secret is
158
+ // the point of the tiers that spawn one. The unit tier's marker would
159
+ // otherwise be inherited straight through this env spread and quietly open
160
+ // it (RFC 0003 D10b).
161
+ const { NORSK_CTL_UNGUARDED_TEST_DAEMON: _unguarded, ...inherited } = o.inherited;
162
+ return {
163
+ NORSK_CTL_PROXY_CONTAINER: `norsk-proxy-${o.port}`,
164
+ NORSK_CTL_CPU_MONITOR_CONTAINER: `norsk-ctl-cpu-monitor-${o.port}`,
165
+ ...inherited,
166
+ NORSK_CTL_STORE_DIR: o.storeDir,
167
+ NORSK_CTL_PORT: String(o.port),
168
+ ...o.overrides,
169
+ };
170
+ }
148
171
  export function startDaemon(storeDir, options) {
149
172
  const port = options?.port ?? 8333;
150
173
  // Before the spawn, so anything reaching for this daemon's ingress secret can
@@ -154,15 +177,15 @@ export function startDaemon(storeDir, options) {
154
177
  if (options?.seedConfig !== false)
155
178
  seedDaemonConfig(storeDir);
156
179
  const [cmd, ...cmdArgs] = cliCommand;
157
- // A spawned daemon must boot GUARDED: exercising the real ingress secret is
158
- // the point of the tiers that spawn one. The unit tier's marker would
159
- // otherwise be inherited straight through this env spread and quietly open
160
- // it (RFC 0003 D10b).
161
- const { NORSK_CTL_UNGUARDED_TEST_DAEMON: _unguarded, ...inheritedEnv } = process.env;
162
180
  const proc = spawn(cmd, [...cmdArgs, "serve"], {
163
181
  stdio: "inherit",
164
182
  detached: options?.detached === true,
165
- env: { ...inheritedEnv, NORSK_CTL_STORE_DIR: storeDir, NORSK_CTL_PORT: String(port), ...options?.env },
183
+ env: daemonSpawnEnv({
184
+ storeDir,
185
+ port,
186
+ inherited: process.env,
187
+ ...(options?.env ? { overrides: options.env } : {}),
188
+ }),
166
189
  });
167
190
  const spawnFailed = new Promise((_, reject) => {
168
191
  proc.once("error", (e) => reject(new Error(cliUnavailableMessage(cliCommand, e.message))));
package/demo/run.d.ts CHANGED
@@ -246,8 +246,8 @@ export declare function demoUrlHost(opts: {
246
246
  *
247
247
  * The daemon is a process in this very process' container, so `localhost`
248
248
  * reaches it. Its proxy is NOT: every `nginx proxy starting on port N` is
249
- * followed by `docker: Container norsk-proxy Created/Started`, for a private
250
- * daemon exactly as for a reused one. On a docker-outside-of-docker runner
249
+ * followed by `docker: Container norsk-proxy[-<port>] Created/Started`, for a
250
+ * private daemon exactly as for a reused one. On a docker-outside-of-docker runner
251
251
  * that container is created by the HOST's daemon and publishes there
252
252
  * (`0.0.0.0:22263->22263/tcp`, HostIp "" — measured on test2, 2026-10-01), so
253
253
  * from inside this container `localhost:<proxyPort>` reaches nothing at all.
package/demo/run.js CHANGED
@@ -348,8 +348,8 @@ export function demoUrlHost(opts) {
348
348
  *
349
349
  * The daemon is a process in this very process' container, so `localhost`
350
350
  * reaches it. Its proxy is NOT: every `nginx proxy starting on port N` is
351
- * followed by `docker: Container norsk-proxy Created/Started`, for a private
352
- * daemon exactly as for a reused one. On a docker-outside-of-docker runner
351
+ * followed by `docker: Container norsk-proxy[-<port>] Created/Started`, for a
352
+ * private daemon exactly as for a reused one. On a docker-outside-of-docker runner
353
353
  * that container is created by the HOST's daemon and publishes there
354
354
  * (`0.0.0.0:22263->22263/tcp`, HostIp "" — measured on test2, 2026-10-01), so
355
355
  * from inside this container `localhost:<proxyPort>` reaches nothing at all.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@norskvideo/ctl-test-harness",
3
- "version": "0.1.66",
3
+ "version": "0.1.67",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {