@norskvideo/ctl-test-harness 0.1.127 → 0.1.129
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 +0 -1
- package/daemon.js +0 -8
- package/free-port.d.ts +1 -1
- package/free-port.js +16 -3
- package/package.json +2 -2
package/daemon.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ export declare function runCli(storeDir: string, ...args: string[]): Promise<{
|
|
|
20
20
|
stderr: string;
|
|
21
21
|
exitCode: number;
|
|
22
22
|
}>;
|
|
23
|
-
export declare function isPortFree(port: number): Promise<boolean>;
|
|
24
23
|
/** `-sTCP:LISTEN` is load-bearing: without it lsof also reports every process
|
|
25
24
|
* holding a client socket to the port, including this test runner's own
|
|
26
25
|
* keep-alive connection to a previous daemon there. */
|
package/daemon.js
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import { spawn, spawnSync } from "node:child_process";
|
|
11
11
|
import { createHash } from "node:crypto";
|
|
12
12
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
13
|
-
import { createServer } from "node:net";
|
|
14
13
|
import { join } from "node:path";
|
|
15
14
|
import { cliCommand } from "./cli-command.js";
|
|
16
15
|
import { currentInstanceNetworks } from "./container-net.js";
|
|
@@ -106,13 +105,6 @@ export async function runCliWith(command, storeDir, ...args) {
|
|
|
106
105
|
export async function runCli(storeDir, ...args) {
|
|
107
106
|
return runCliWith(cliCommand, storeDir, ...args);
|
|
108
107
|
}
|
|
109
|
-
export function isPortFree(port) {
|
|
110
|
-
return new Promise((resolve) => {
|
|
111
|
-
const srv = createServer();
|
|
112
|
-
srv.once("error", () => resolve(false));
|
|
113
|
-
srv.listen(port, () => srv.close(() => resolve(true)));
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
108
|
/** `-sTCP:LISTEN` is load-bearing: without it lsof also reports every process
|
|
117
109
|
* holding a client socket to the port, including this test runner's own
|
|
118
110
|
* keep-alive connection to a previous daemon there. */
|
package/free-port.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export declare const FREE_PORT_RANGE: {
|
|
|
2
2
|
readonly min: 32000;
|
|
3
3
|
readonly max: 32767;
|
|
4
4
|
};
|
|
5
|
-
/** Is `port`
|
|
5
|
+
/** Is `port` free on this host right now, for both TCP and UDP? Advisory, as
|
|
6
6
|
* ctl's own probe is: docker's bind at container start is the real test. Both
|
|
7
7
|
* protocols because the caller does not know which one the template publishes. */
|
|
8
8
|
export declare function hostPortFree(port: number): Promise<boolean>;
|
package/free-port.js
CHANGED
|
@@ -30,14 +30,27 @@ function udpFree(port) {
|
|
|
30
30
|
sock.bind(port, "0.0.0.0", () => sock.close(() => resolve(true)));
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function tcpBindable(port, host) {
|
|
34
34
|
return new Promise((resolve) => {
|
|
35
35
|
const srv = createServer();
|
|
36
36
|
srv.once("error", () => resolve(false));
|
|
37
|
-
|
|
37
|
+
const done = () => srv.close(() => resolve(true));
|
|
38
|
+
if (host === undefined)
|
|
39
|
+
srv.listen(port, done);
|
|
40
|
+
else
|
|
41
|
+
srv.listen(port, host, done);
|
|
38
42
|
});
|
|
39
43
|
}
|
|
40
|
-
|
|
44
|
+
// macOS lets a bind on one wildcard share a port another process holds on
|
|
45
|
+
// 127.0.0.1 or on the other wildcard, so no single bind proves the port free.
|
|
46
|
+
async function tcpFree(port) {
|
|
47
|
+
for (const host of ["127.0.0.1", "0.0.0.0", undefined]) {
|
|
48
|
+
if (!(await tcpBindable(port, host)))
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/** Is `port` free on this host right now, for both TCP and UDP? Advisory, as
|
|
41
54
|
* ctl's own probe is: docker's bind at container start is the real test. Both
|
|
42
55
|
* protocols because the caller does not know which one the template publishes. */
|
|
43
56
|
export async function hostPortFree(port) {
|
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.129",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"ctl-contention": "./contention/cli.js"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@norskvideo/ctl-product-template-schema": "^0.1.
|
|
104
|
+
"@norskvideo/ctl-product-template-schema": "^0.1.77",
|
|
105
105
|
"@norskvideo/ctl-sdk": "^0.1.0",
|
|
106
106
|
"yaml": "^2.8.0",
|
|
107
107
|
"zod": "4.6.7"
|