@norskvideo/ctl-test-harness 0.1.134 → 0.1.135

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/demo/run.d.ts CHANGED
@@ -58,6 +58,9 @@ export interface DemoDeps {
58
58
  /** Does the resolved ctl run its daemon and proxy on system-assigned ports?
59
59
  * Optional so an existing custom-deps consumer keeps working; absent = no. */
60
60
  supportsEphemeralPorts?(): Promise<boolean>;
61
+ /** Is this process itself in a container (see proxyUrlHost)? Optional so an
62
+ * existing custom-deps consumer keeps working; absent = runningInContainer(). */
63
+ inContainer?(): boolean;
61
64
  /** A host port free for TCP and UDP that is not in `taken` (free-port.ts).
62
65
  * Optional so an existing custom-deps consumer keeps working; absent = probe. */
63
66
  freePort?(taken: ReadonlySet<number>): Promise<number>;
package/demo/run.js CHANGED
@@ -501,7 +501,10 @@ export class DemoSession {
501
501
  const host = demoUrlHost({ publicHost: opts.publicHost, daemon: opts.daemon });
502
502
  this.host = host;
503
503
  // The proxy is a container even when the daemon is ours; see proxyUrlHost.
504
- const proxyHost = proxyUrlHost({ publicHost: opts.publicHost, inContainer: runningInContainer() });
504
+ const proxyHost = proxyUrlHost({
505
+ publicHost: opts.publicHost,
506
+ inContainer: deps.inContainer?.() ?? runningInContainer(),
507
+ });
505
508
  this.proxyHost = proxyHost;
506
509
  this.band = demoPorts(slug);
507
510
  this.ephemeralPorts = opts.ephemeralPorts === true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@norskvideo/ctl-test-harness",
3
- "version": "0.1.134",
3
+ "version": "0.1.135",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
package/smoke.d.ts CHANGED
@@ -162,6 +162,10 @@ export interface SmokeDeps {
162
162
  * Optional so an existing custom-deps consumer keeps working; absent = no,
163
163
  * and the band decides both, as before. */
164
164
  supportsEphemeralPorts?(): Promise<boolean>;
165
+ /** The CI runner's name (GitHub's RUNNER_NAME), which keys the port band.
166
+ * Optional so an existing custom-deps consumer keeps working; absent = the
167
+ * slug's band, as before. */
168
+ runnerName?(): string | undefined;
165
169
  cli(storeDir: string, argv: string[]): Promise<CliResult>;
166
170
  startSources(opts: {
167
171
  daemonPort: number;
@@ -216,12 +220,16 @@ export interface SmokeDeps {
216
220
  }
217
221
  /** Per-slug port band, above the product integration harnesses' own bands:
218
222
  * daemon, dev backend, published Studio port and an instance base, twenty
219
- * apart per slug. */
223
+ * apart per slug. On a CI runner (`runner` given) the band is the runner's,
224
+ * not the slug's: jobs that share a docker host are always on different
225
+ * runners, so whatever the band still decides (ports ctl and freePort do not
226
+ * assign) cannot meet between them. smoke.test.ts asserts the jankings
227
+ * runners' bands are distinct per host. */
220
228
  export interface SmokePorts extends BaseHarnessPorts {
221
229
  /** The daemon's oauth2 proxy; banded so co-located runs never meet on :9443. */
222
230
  proxyPort: number;
223
231
  }
224
- export declare function smokePorts(slug: string, overrides?: Partial<SmokePorts>): SmokePorts;
232
+ export declare function smokePorts(slug: string, overrides?: Partial<SmokePorts>, runner?: string): SmokePorts;
225
233
  export declare const defaultSmokeDeps: SmokeDeps;
226
234
  /** A manifest's `ui.sidebarEntries` are what ctl's product page renders as
227
235
  * links, under /products/<name>/<route>. Nothing else checks that the product
package/smoke.js CHANGED
@@ -48,8 +48,9 @@ const MOQ_PORT_PARAM = "MOQ_PORT";
48
48
  /** ctl's allocated host port: a `*_PORT` param defaulting to `auto`, which it
49
49
  * resolves to the first free port from a PREFERRED value every run shares. */
50
50
  const isAllocatedPortParam = (name, dflt) => dflt === "auto" && /_PORT$/.test(name);
51
- export function smokePorts(slug, overrides = {}) {
52
- const daemonPort = SMOKE_PORT_BASE + hashSlot(`smoke:${slug}`, SMOKE_BANDS) * SMOKE_BAND_WIDTH;
51
+ export function smokePorts(slug, overrides = {}, runner) {
52
+ const key = runner ? `smoke:${runner}` : `smoke:${slug}`;
53
+ const daemonPort = SMOKE_PORT_BASE + hashSlot(key, SMOKE_BANDS) * SMOKE_BAND_WIDTH;
53
54
  return {
54
55
  daemonPort,
55
56
  backendPort: daemonPort + 1,
@@ -65,6 +66,7 @@ export const defaultSmokeDeps = {
65
66
  writeFile: (path, contents) => writeFileSync(path, contents),
66
67
  startDaemon,
67
68
  supportsEphemeralPorts: ctlSupportsEphemeralPorts,
69
+ runnerName: () => process.env.RUNNER_NAME || undefined,
68
70
  freePort: (taken) => freeHostPort({ taken }),
69
71
  cli: (storeDir, argv) => runCli(storeDir, ...argv),
70
72
  startSources: startSrtSources,
@@ -217,7 +219,10 @@ export function sdkClientIdentityFromEnv(env = process.env) {
217
219
  return { certB64, keyB64 };
218
220
  }
219
221
  export async function runProductSmoke(slug, spec, deps = defaultSmokeDeps) {
220
- const ports = smokePorts(slug, spec.ports);
222
+ const runner = deps.runnerName?.();
223
+ const ports = smokePorts(slug, spec.ports, runner);
224
+ if (runner)
225
+ deps.log(`${slug}: port band from runner ${runner} (daemon base :${ports.daemonPort})`);
221
226
  const storeDir = deps.storeDir(slug);
222
227
  const instanceId = `smoke-${slug}`;
223
228
  const timeouts = {