@norskvideo/ctl-test-harness 0.1.20 → 0.1.21
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/compose-advancing.d.ts +26 -0
- package/compose-advancing.js +61 -0
- package/container-logs.d.ts +48 -0
- package/container-logs.js +101 -0
- package/demo/cli.d.ts +6 -2
- package/demo/cli.js +37 -11
- package/demo/gates.d.ts +22 -0
- package/demo/gates.js +56 -0
- package/demo/index.d.ts +4 -3
- package/demo/index.js +2 -1
- package/demo/run.d.ts +37 -3
- package/demo/run.js +348 -70
- package/demo/spec.d.ts +36 -4
- package/demo/spec.js +17 -0
- package/package.json +9 -1
package/demo/spec.d.ts
CHANGED
|
@@ -30,14 +30,26 @@ export interface DemoSource {
|
|
|
30
30
|
ingest: DemoIngest;
|
|
31
31
|
streamId?: string;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
/** How the product is registered: `dev` runs `dev.command` from source and
|
|
34
|
+
* adds it by URL; `image` adds the built `image` (the customer path). */
|
|
35
|
+
export type DemoMode = "dev" | "image";
|
|
36
|
+
/** Whose daemon: a `private` one on a throwaway store (the default; what
|
|
37
|
+
* `check` always uses), or `reuse` the developer's listening daemon and its
|
|
38
|
+
* real store — where `product add` refuses an existing name and stored
|
|
39
|
+
* templates are immutable, so the driver deletes/removes/re-adds first. */
|
|
40
|
+
export type DemoDaemonPolicy = "private" | "reuse";
|
|
41
|
+
/** What `beforeLaunch` sees: the template is stored, nothing is launched. */
|
|
42
|
+
export interface DemoLaunchContext {
|
|
34
43
|
action: "up" | "check";
|
|
44
|
+
mode: DemoMode;
|
|
45
|
+
daemon: DemoDaemonPolicy;
|
|
35
46
|
product: string;
|
|
36
47
|
instanceId: string;
|
|
37
48
|
daemonPort: number;
|
|
38
49
|
storeDir: string;
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
templateName: string;
|
|
51
|
+
/** The stored template's directory (`compose.yml`, `workflow.yml`, ...). */
|
|
52
|
+
templateDir: string;
|
|
41
53
|
cli(argv: string[], opts?: {
|
|
42
54
|
output?: "json" | "yaml";
|
|
43
55
|
}): Promise<{
|
|
@@ -45,9 +57,13 @@ export interface DemoContext {
|
|
|
45
57
|
stderr: string;
|
|
46
58
|
exitCode: number;
|
|
47
59
|
}>;
|
|
48
|
-
fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
49
60
|
log(line: string): void;
|
|
50
61
|
}
|
|
62
|
+
export interface DemoContext extends DemoLaunchContext {
|
|
63
|
+
/** Resolve a spec URL against this run's ports. */
|
|
64
|
+
url(ref: DemoUrl): string;
|
|
65
|
+
fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
66
|
+
}
|
|
51
67
|
export type DemoReady = {
|
|
52
68
|
http: DemoUrl;
|
|
53
69
|
status?: number;
|
|
@@ -75,9 +91,21 @@ export type DemoTemplate = {
|
|
|
75
91
|
input: string | Record<string, unknown>;
|
|
76
92
|
};
|
|
77
93
|
};
|
|
94
|
+
/** A sidecar container the demo needs beside the instance (funke's ad-push
|
|
95
|
+
* capture origin): `docker run -d --name <name> --network norsk-net <args>
|
|
96
|
+
* <image> <command>`, started before the launch, removed at teardown. */
|
|
97
|
+
export interface DemoExtra {
|
|
98
|
+
name: string;
|
|
99
|
+
image: string;
|
|
100
|
+
/** Extra `docker run` flags (`-p`, `-v`, `--entrypoint`, ...). */
|
|
101
|
+
args?: string[];
|
|
102
|
+
command?: string[];
|
|
103
|
+
}
|
|
78
104
|
export interface DemoSpec {
|
|
79
105
|
/** Manifest name, e.g. "norsk-playout". The registration must report it. */
|
|
80
106
|
product: string;
|
|
107
|
+
/** The default `--mode`; `dev` when omitted. */
|
|
108
|
+
mode?: DemoMode;
|
|
81
109
|
/** Started with PORT=<driver-chosen> in the environment; the driver polls
|
|
82
110
|
* `readyPath` (default `/manifest.json`, what `product add` fetches). */
|
|
83
111
|
dev: {
|
|
@@ -99,6 +127,10 @@ export interface DemoSpec {
|
|
|
99
127
|
path: string;
|
|
100
128
|
hint: string;
|
|
101
129
|
}>;
|
|
130
|
+
extras?: DemoExtra[];
|
|
131
|
+
/** Runs once the template is stored and pin-checked, before the launch —
|
|
132
|
+
* the place for a product-only patch to the stored template. */
|
|
133
|
+
beforeLaunch?: (ctx: DemoLaunchContext) => Promise<void>;
|
|
102
134
|
sources?: DemoSource[];
|
|
103
135
|
/** Gates polled in order once the instance runs and the sources pump — so a
|
|
104
136
|
* gate may demand what only a source produces (composing, analysing). */
|
package/demo/spec.js
CHANGED
|
@@ -41,6 +41,7 @@ const relativePath = z
|
|
|
41
41
|
export const DemoSpecSchema = z
|
|
42
42
|
.strictObject({
|
|
43
43
|
product: z.string().min(1),
|
|
44
|
+
mode: z.enum(["dev", "image"]).optional(),
|
|
44
45
|
dev: z.strictObject({
|
|
45
46
|
command: z.array(z.string().min(1)).min(1),
|
|
46
47
|
readyPath: z.string().startsWith("/").optional(),
|
|
@@ -65,6 +66,15 @@ export const DemoSpecSchema = z
|
|
|
65
66
|
})
|
|
66
67
|
.optional(),
|
|
67
68
|
prerequisites: z.array(z.strictObject({ path: z.string().min(1), hint: z.string().min(1) })).optional(),
|
|
69
|
+
extras: z
|
|
70
|
+
.array(z.strictObject({
|
|
71
|
+
name: z.string().min(1),
|
|
72
|
+
image: z.string().min(1),
|
|
73
|
+
args: z.array(z.string()).optional(),
|
|
74
|
+
command: z.array(z.string().min(1)).optional(),
|
|
75
|
+
}))
|
|
76
|
+
.optional(),
|
|
77
|
+
beforeLaunch: fn().optional(),
|
|
68
78
|
sources: z
|
|
69
79
|
.array(z.strictObject({
|
|
70
80
|
name: z.string().min(1),
|
|
@@ -106,6 +116,13 @@ export const DemoSpecSchema = z
|
|
|
106
116
|
}
|
|
107
117
|
seen.add(s.name);
|
|
108
118
|
});
|
|
119
|
+
const extras = new Set();
|
|
120
|
+
(spec.extras ?? []).forEach((e, i) => {
|
|
121
|
+
if (extras.has(e.name)) {
|
|
122
|
+
ctx.addIssue({ code: "custom", path: ["extras", i, "name"], message: `duplicate extra name '${e.name}'` });
|
|
123
|
+
}
|
|
124
|
+
extras.add(e.name);
|
|
125
|
+
});
|
|
109
126
|
});
|
|
110
127
|
/** Format zod's issue list as one line per problem, path first. A union's
|
|
111
128
|
* failure would otherwise arrive as every branch's complaint; the rule the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@norskvideo/ctl-test-harness",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -46,6 +46,14 @@
|
|
|
46
46
|
"./demo": {
|
|
47
47
|
"types": "./demo/index.d.ts",
|
|
48
48
|
"default": "./demo/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./container-logs": {
|
|
51
|
+
"types": "./container-logs.d.ts",
|
|
52
|
+
"default": "./container-logs.js"
|
|
53
|
+
},
|
|
54
|
+
"./compose-advancing": {
|
|
55
|
+
"types": "./compose-advancing.d.ts",
|
|
56
|
+
"default": "./compose-advancing.js"
|
|
49
57
|
}
|
|
50
58
|
},
|
|
51
59
|
"main": "./index.js",
|