@harperfast/integration-testing 0.6.1 → 0.6.3
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/README.md
CHANGED
|
@@ -50,6 +50,34 @@ npx harper-integration-test-setup-loopback
|
|
|
50
50
|
|
|
51
51
|
This script requires `sudo` and respects the `HARPER_INTEGRATION_TEST_LOOPBACK_POOL_COUNT` environment variable (defaults to 32).
|
|
52
52
|
|
|
53
|
+
On macOS the aliases are configured with a host (`/32`) netmask. This matters: with the default class-A (`/8`) netmask every `127.0.0.x` alias claims the whole `127.0.0.0/8` network, and at large pool counts the resulting set of overlapping-subnet interface addresses drives `mDNSResponder`'s address-conflict defense into a CPU-pinning storm of mDNS announcements on port 5353. If you previously ran an older version of this script, re-run it to convert the existing aliases to `/32`.
|
|
54
|
+
|
|
55
|
+
### Persisting across reboots (macOS)
|
|
56
|
+
|
|
57
|
+
`ifconfig` aliases live only in the running kernel — macOS does not persist manually added `lo0` aliases, so they vanish on every reboot and the pool has to be reconfigured. For a dev machine that reboots regularly, install a `launchd` daemon that runs the setup script at boot. `scripts/io.harperdb.loopback-setup.plist` is provided for this; the script is root-aware, so it needs no `sudo` when launchd runs it as root.
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
# 1. Copy the setup script to a stable, root-owned path (the plist points here)
|
|
61
|
+
sudo mkdir -p /usr/local/sbin
|
|
62
|
+
sudo install -m 755 -o root -g wheel \
|
|
63
|
+
"$(npm root)/@harperfast/integration-testing/scripts/setup-loopback.sh" \
|
|
64
|
+
/usr/local/sbin/harper-loopback-setup.sh
|
|
65
|
+
|
|
66
|
+
# 2. Install the daemon (must be root:wheel and mode 644 or launchd rejects it)
|
|
67
|
+
sudo install -m 644 -o root -g wheel \
|
|
68
|
+
"$(npm root)/@harperfast/integration-testing/scripts/io.harperdb.loopback-setup.plist" \
|
|
69
|
+
/Library/LaunchDaemons/io.harperdb.loopback-setup.plist
|
|
70
|
+
|
|
71
|
+
# 3. Load and run it now (also runs at every boot via RunAtLoad)
|
|
72
|
+
sudo launchctl bootstrap system /Library/LaunchDaemons/io.harperdb.loopback-setup.plist
|
|
73
|
+
|
|
74
|
+
# 4. Verify
|
|
75
|
+
cat /var/log/harper-loopback-setup.log # ✓ Configured ... line
|
|
76
|
+
ifconfig lo0 | grep '127.0.0' | tail -3 # aliases present
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Edit the `HARPER_INTEGRATION_TEST_LOOPBACK_POOL_COUNT` value in the installed plist to change the pool size (it defaults to 32, matching the script). To remove the daemon: `sudo launchctl bootout system/io.harperdb.loopback-setup` and delete the plist. If you edit the installed plist, `bootout` then `bootstrap` again to reload it.
|
|
80
|
+
|
|
53
81
|
## API
|
|
54
82
|
|
|
55
83
|
The lifecycle and utility APIs below are framework-agnostic. They manage Harper child processes and a cross-process loopback address pool. Use them in the setup/teardown hooks of whichever test framework you prefer.
|
|
@@ -41,6 +41,25 @@ const CONFLICT_PROBE_PORT = (() => {
|
|
|
41
41
|
// can't turn into a `server.listen(NaN)` crash during allocation.
|
|
42
42
|
return Number.isNaN(parsed) || parsed < 0 || parsed > 65535 ? 9925 : parsed;
|
|
43
43
|
})();
|
|
44
|
+
// Second conflict-canary port: Harper's HTTP listener (`HTTP_PORT` in harperLifecycle.ts).
|
|
45
|
+
// The operations port above is bound by the MAIN thread without SO_REUSEPORT, so it catches
|
|
46
|
+
// a fully-alive (or recently-signalled) node. But the most common contamination shape after
|
|
47
|
+
// a kill/teardown is different: the main thread has already exited (freeing the operations
|
|
48
|
+
// port) while the HTTP WORKER threads still linger holding the address with SO_REUSEPORT.
|
|
49
|
+
// The operations-port probe alone reports such an address as free and hands it out, producing
|
|
50
|
+
// a silent SO_REUSEPORT co-bind on the HTTP port. A plain (non-reusePort) bind still fails
|
|
51
|
+
// with EADDRINUSE against a lingering SO_REUSEPORT socket (Linux disallows mixing reusePort
|
|
52
|
+
// and non-reusePort binders on the same address:port), so probing the HTTP port here closes
|
|
53
|
+
// that blind spot. (This detection is Linux-effective — macOS/BSD SO_REUSEPORT semantics differ
|
|
54
|
+
// and may not surface EADDRINUSE here, but macOS also doesn't exhibit the silent co-bind in the
|
|
55
|
+
// first place, and CI runs on Linux.) Override via HARPER_INTEGRATION_TEST_HTTP_CONFLICT_PROBE_PORT
|
|
56
|
+
// if HTTP_PORT ever changes. (Hardcoded rather than imported from harperLifecycle to avoid a circular import.)
|
|
57
|
+
const HTTP_CONFLICT_PROBE_PORT = (() => {
|
|
58
|
+
const parsed = parseInt(process.env.HARPER_INTEGRATION_TEST_HTTP_CONFLICT_PROBE_PORT || '', 10);
|
|
59
|
+
return Number.isNaN(parsed) || parsed < 0 || parsed > 65535 ? 9926 : parsed;
|
|
60
|
+
})();
|
|
61
|
+
// The set of ports the conflict canary probes, de-duplicated in case the two overrides collide.
|
|
62
|
+
const CONFLICT_PROBE_PORTS = [...new Set([CONFLICT_PROBE_PORT, HTTP_CONFLICT_PROBE_PORT])];
|
|
44
63
|
// Custom error classes
|
|
45
64
|
class LoopbackAddressValidationError extends Error {
|
|
46
65
|
constructor(address, cause) {
|
|
@@ -206,18 +225,15 @@ function validateLoopbackAddress(loopbackAddress) {
|
|
|
206
225
|
});
|
|
207
226
|
}
|
|
208
227
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* owns the address's operations port, this bind fails with EADDRINUSE.
|
|
228
|
+
* Probes a single port on `loopbackAddress` with an exclusive (non-SO_REUSEPORT) bind.
|
|
229
|
+
* Node's `net` server does not set SO_REUSEPORT, so if a stale/overlapping Harper node still
|
|
230
|
+
* holds this port — even via a SO_REUSEPORT worker socket — the bind fails with EADDRINUSE.
|
|
213
231
|
*
|
|
214
|
-
* Returns `true` if the
|
|
232
|
+
* Returns `true` if the port appears in use (EADDRINUSE), `false` if it is free.
|
|
215
233
|
* Re-throws any other bind error (e.g. EADDRNOTAVAIL) — that's a real configuration
|
|
216
234
|
* problem the caller should surface, not a transient conflict to skip.
|
|
217
|
-
*
|
|
218
|
-
* @param loopbackAddress The loopback IP address to probe (e.g., "127.0.0.2")
|
|
219
235
|
*/
|
|
220
|
-
function
|
|
236
|
+
function isPortInUseOnAddress(port, loopbackAddress) {
|
|
221
237
|
return new Promise((resolve, reject) => {
|
|
222
238
|
const server = createServer();
|
|
223
239
|
const onError = (error) => {
|
|
@@ -230,8 +246,8 @@ function isLoopbackAddressInUse(loopbackAddress) {
|
|
|
230
246
|
reject(enhancedError);
|
|
231
247
|
};
|
|
232
248
|
server.once('error', onError);
|
|
233
|
-
server.listen(
|
|
234
|
-
// Bind succeeded — the
|
|
249
|
+
server.listen(port, loopbackAddress, () => {
|
|
250
|
+
// Bind succeeded — the port is free. Drop the error listener so a stray
|
|
235
251
|
// post-bind socket error during close() can't flip the resolved verdict.
|
|
236
252
|
server.off('error', onError);
|
|
237
253
|
server.close(() => {
|
|
@@ -240,6 +256,29 @@ function isLoopbackAddressInUse(loopbackAddress) {
|
|
|
240
256
|
});
|
|
241
257
|
});
|
|
242
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Conflict canary: detects whether a Harper node is already bound to `loopbackAddress` by
|
|
261
|
+
* probing each of Harper's canary ports (see `CONFLICT_PROBE_PORTS`). Two ports are checked
|
|
262
|
+
* because a lingering node can hold the address in two distinct states:
|
|
263
|
+
* - the operations port (main-thread, non-reusePort) — a fully-alive or recently-signalled node;
|
|
264
|
+
* - the HTTP port (worker-thread, SO_REUSEPORT) — a node whose main thread already exited but
|
|
265
|
+
* whose HTTP workers still linger, the common post-kill/post-teardown shape.
|
|
266
|
+
* A plain bind fails with EADDRINUSE against either, so probing both catches both shapes and
|
|
267
|
+
* prevents an SO_REUSEPORT co-bind that would split connections between two nodes.
|
|
268
|
+
*
|
|
269
|
+
* Returns the first in-use port number, or `null` if the address is free.
|
|
270
|
+
* Re-throws any non-EADDRINUSE bind error (a real configuration problem).
|
|
271
|
+
*
|
|
272
|
+
* @param loopbackAddress The loopback IP address to probe (e.g., "127.0.0.2")
|
|
273
|
+
*/
|
|
274
|
+
async function findConflictingPort(loopbackAddress) {
|
|
275
|
+
for (const port of CONFLICT_PROBE_PORTS) {
|
|
276
|
+
if (await isPortInUseOnAddress(port, loopbackAddress)) {
|
|
277
|
+
return port;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
243
282
|
/**
|
|
244
283
|
* This method attempts to validate all loopback addresses in the pool by trying to
|
|
245
284
|
* bind to each one. It returns an object containing arrays of successfully bound
|
|
@@ -339,25 +378,27 @@ export async function getNextAvailableLoopbackAddress() {
|
|
|
339
378
|
}
|
|
340
379
|
// Conflict canary: a stale or still-running Harper node from an overlapping
|
|
341
380
|
// suite may already hold this address (e.g. the pool slot was freed while its
|
|
342
|
-
// node lingered
|
|
343
|
-
//
|
|
344
|
-
//
|
|
345
|
-
//
|
|
346
|
-
|
|
381
|
+
// node lingered — including the common shape where the main thread exited but the
|
|
382
|
+
// HTTP workers still hold the address). SO_REUSEPORT on Harper's shared HTTP/
|
|
383
|
+
// replication ports would otherwise let our node silently co-bind it, splitting
|
|
384
|
+
// connections between two nodes and corrupting both suites. Detect that here by
|
|
385
|
+
// probing both the exclusive operations port and the worker-held HTTP port, and
|
|
386
|
+
// skip the poisoned address.
|
|
387
|
+
let conflictingPort;
|
|
347
388
|
try {
|
|
348
|
-
|
|
389
|
+
conflictingPort = await findConflictingPort(loopbackAddress);
|
|
349
390
|
}
|
|
350
391
|
catch (error) {
|
|
351
392
|
throw new LoopbackAddressValidationError(loopbackAddress, error);
|
|
352
393
|
}
|
|
353
|
-
if (
|
|
394
|
+
if (conflictingPort === null) {
|
|
354
395
|
return loopbackAddress;
|
|
355
396
|
}
|
|
356
397
|
// Release the slot back to the pool (so it isn't leaked under our PID) and remember
|
|
357
398
|
// not to re-try it this attempt; loop to claim the next available one.
|
|
358
399
|
await releaseLoopbackAddress(loopbackAddress);
|
|
359
400
|
triedIndices.add(assignedIndex);
|
|
360
|
-
console.warn(`[loopback-pool] ${loopbackAddress} is still in use by another Harper node (
|
|
401
|
+
console.warn(`[loopback-pool] ${loopbackAddress} is still in use by another Harper node (port ${conflictingPort} bound); skipping to avoid an SO_REUSEPORT co-bind.`);
|
|
361
402
|
continue;
|
|
362
403
|
}
|
|
363
404
|
// No available addresses; clear the per-attempt skip set so poisoned addresses can be
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loopbackAddressPool.js","sourceRoot":"","sources":["../src/loopbackAddressPool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,0BAA0B;AAC1B,uFAAuF;AACvF,mEAAmE;AACnE,oEAAoE;AACpE,MAAM,0BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC,2CAA2C;IACzF,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,2CAA2C,EAAE,EAAE,CAAC;IACvE,CAAC,CAAC,CAAC,CAAC;AACL,IAAI,0BAA0B,GAAG,CAAC,IAAI,0BAA0B,GAAG,GAAG,EAAE,CAAC;IACxE,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;AAC1F,CAAC;AACD,MAAM,0BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC,2CAA2C;IACzF,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,2CAA2C,EAAE,EAAE,CAAC;IACvE,CAAC,CAAC,EAAE,CAAC;AACN,MAAM,wBAAwB,GAAG,GAAG,GAAG,0BAA0B,CAAC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BACrC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;YACxB,CAAC;QACF,CAAC;QAED,0CAA0C;QAC1C,MAAM,aAAa,CAAC,YAAY,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harperfast/integration-testing",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Integration testing utilities for Harper-based projects. Provides Harper instance lifecycle management, loopback address pooling, and a test runner script.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>Label</key>
|
|
6
|
+
<string>io.harperdb.loopback-setup</string>
|
|
7
|
+
|
|
8
|
+
<key>ProgramArguments</key>
|
|
9
|
+
<array>
|
|
10
|
+
<string>/bin/bash</string>
|
|
11
|
+
<string>/usr/local/sbin/harper-loopback-setup.sh</string>
|
|
12
|
+
</array>
|
|
13
|
+
|
|
14
|
+
<!-- One-shot at boot. Not a long-running service, so no KeepAlive. -->
|
|
15
|
+
<key>RunAtLoad</key>
|
|
16
|
+
<true/>
|
|
17
|
+
|
|
18
|
+
<!-- Pool size. Omit to use the script default (32); raise to 254 for the full pool. -->
|
|
19
|
+
<key>EnvironmentVariables</key>
|
|
20
|
+
<dict>
|
|
21
|
+
<key>HARPER_INTEGRATION_TEST_LOOPBACK_POOL_COUNT</key>
|
|
22
|
+
<string>32</string>
|
|
23
|
+
</dict>
|
|
24
|
+
|
|
25
|
+
<key>StandardOutPath</key>
|
|
26
|
+
<string>/var/log/harper-loopback-setup.log</string>
|
|
27
|
+
<key>StandardErrorPath</key>
|
|
28
|
+
<string>/var/log/harper-loopback-setup.log</string>
|
|
29
|
+
</dict>
|
|
30
|
+
</plist>
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
sudo -v
|
|
3
|
+
# Run ifconfig via sudo when invoked interactively, or directly when already root
|
|
4
|
+
# (e.g. from the launchd daemon at boot, where there is no tty for `sudo -v`).
|
|
5
|
+
if [ "$(id -u)" -eq 0 ]; then
|
|
6
|
+
SUDO=""
|
|
7
|
+
else
|
|
8
|
+
SUDO="sudo"
|
|
9
|
+
# Prompt for password upfront
|
|
10
|
+
sudo -v
|
|
11
|
+
fi
|
|
5
12
|
|
|
6
13
|
# The pool starts at 127.0.0.2 by default (127.0.0.1 is left for other services on localhost).
|
|
7
14
|
# Override via the HARPER_INTEGRATION_TEST_LOOPBACK_POOL_START environment variable.
|
|
@@ -35,7 +42,20 @@ fi
|
|
|
35
42
|
|
|
36
43
|
END=$((START + COUNT - 1))
|
|
37
44
|
for i in $(seq $START $END); do
|
|
38
|
-
|
|
45
|
+
# Use a host (/32) netmask, not the implicit class-A /8. Without an explicit netmask,
|
|
46
|
+
# macOS gives each 127.0.0.x alias a 255.0.0.0 mask, so every alias claims to own the
|
|
47
|
+
# entire 127.0.0.0/8 network. With a large COUNT that means dozens/hundreds of interface
|
|
48
|
+
# addresses all asserting the same subnet, which drives mDNSResponder's address-conflict
|
|
49
|
+
# defense (PacketRRConflict) into an O(n^2) storm — pinning a CPU core and flooding
|
|
50
|
+
# 5353 with loopback announcements. A /32 host route removes the subnet overlap: each
|
|
51
|
+
# alias is an isolated host, so there is no conflict cascade even at the full 254-address
|
|
52
|
+
# pool. (Measured: 254 aliases /8 => ~65% CPU; 254 aliases /32 => ~0% CPU.)
|
|
53
|
+
#
|
|
54
|
+
# Remove any pre-existing alias first so re-running this converts a machine previously
|
|
55
|
+
# configured with the old /8 aliases; ifconfig alias on an existing address does not
|
|
56
|
+
# reliably reset its netmask. The `-alias` is a harmless no-op if the address is absent.
|
|
57
|
+
$SUDO ifconfig lo0 -alias 127.0.0.$i 2>/dev/null
|
|
58
|
+
$SUDO ifconfig lo0 alias 127.0.0.$i netmask 255.255.255.255 up
|
|
39
59
|
done
|
|
40
60
|
|
|
41
61
|
echo "✓ Configured $COUNT loopback addresses (127.0.0.$START-127.0.0.$END)"
|