@smoothbricks/nx-plugin 0.4.29 → 0.4.31
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 +104 -25
- package/dist/bin/smoo-nx-test-clocks.d.ts +3 -0
- package/dist/bin/smoo-nx-test-clocks.d.ts.map +1 -0
- package/dist/bin/smoo-nx-test-clocks.js +28 -0
- package/dist/bounded-test-policy.d.ts +1 -8
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +2 -8
- package/dist/cargo-closure-input.d.ts +11 -0
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +16 -6
- package/dist/ensure-built-receipt.d.ts +8 -2
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +45 -13
- package/dist/ensure-built-witness.d.ts +40 -4
- package/dist/ensure-built-witness.d.ts.map +1 -1
- package/dist/ensure-built-witness.js +68 -15
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +11 -3
- package/dist/executors/bounded-exec/cpu-pool.d.ts +7 -3
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +9 -4
- package/dist/executors/bounded-exec/cpu-tokens.d.ts +22 -5
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-tokens.js +189 -18
- package/dist/executors/bounded-exec/executor.d.ts +1 -1
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +38 -14
- package/dist/executors/bounded-exec/no-space.d.ts +8 -0
- package/dist/executors/bounded-exec/no-space.d.ts.map +1 -0
- package/dist/executors/bounded-exec/no-space.js +31 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +3 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +15 -4
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts +10 -0
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -0
- package/dist/executors/bounded-exec/run-cpu-pool.js +63 -0
- package/dist/executors/bounded-exec/verdict.d.ts +34 -4
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +54 -3
- package/dist/graph-input-contract.d.ts +4 -0
- package/dist/graph-input-contract.d.ts.map +1 -1
- package/dist/graph-input-contract.js +17 -4
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -3
- package/dist/owned-installation.d.ts +14 -0
- package/dist/owned-installation.d.ts.map +1 -0
- package/dist/owned-installation.js +324 -0
- package/dist/producer-receipts.d.ts.map +1 -1
- package/dist/producer-receipts.js +15 -10
- package/dist/test-backstop.d.ts +9 -0
- package/dist/test-backstop.d.ts.map +1 -0
- package/dist/test-backstop.js +10 -0
- package/dist/test-clock-policy.d.ts +30 -0
- package/dist/test-clock-policy.d.ts.map +1 -0
- package/dist/test-clock-policy.js +686 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +8 -1
- package/managed/raw/tooling/direnv/developer-links.ts +1 -8
- package/managed/raw/tooling/direnv/setup-environment.ts +13 -1
- package/package.json +15 -4
- package/src/__tests__/cargo-closure-fixture.ts +113 -0
- package/src/__tests__/counted-cargo.ts +8 -25
- package/src/__tests__/directory-change.ts +27 -0
- package/src/__tests__/owned-installation.ts +4 -164
- package/src/__tests__/past-tick.ts +12 -0
- package/src/bin/smoo-nx-test-clocks.ts +29 -0
- package/src/bounded-test-policy.ts +2 -8
- package/src/cargo-closure-input.property.test.ts +50 -0
- package/src/cargo-closure-input.test.ts +15 -112
- package/src/cargo-closure-input.ts +23 -6
- package/src/cargo-closure-key.test.ts +240 -0
- package/src/cargo-resolve-cache.test.ts +29 -7
- package/src/ensure-built-receipt.ts +56 -13
- package/src/ensure-built-witness.test.ts +113 -4
- package/src/ensure-built-witness.ts +75 -16
- package/src/ensure-built.test.ts +74 -2
- package/src/ensure-built.ts +13 -2
- package/src/executors/bounded-exec/cpu-pool.test.ts +18 -0
- package/src/executors/bounded-exec/cpu-pool.ts +10 -4
- package/src/executors/bounded-exec/cpu-tokens.test.ts +205 -0
- package/src/executors/bounded-exec/cpu-tokens.ts +229 -22
- package/src/executors/bounded-exec/disk-lease.test.ts +47 -13
- package/src/executors/bounded-exec/executor-host.test.ts +23 -11
- package/src/executors/bounded-exec/executor.test.ts +189 -63
- package/src/executors/bounded-exec/executor.ts +39 -13
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +14 -8
- package/src/executors/bounded-exec/no-space.ts +40 -0
- package/src/executors/bounded-exec/ram-temp-host.test.ts +9 -8
- package/src/executors/bounded-exec/ram-temp.test.ts +32 -18
- package/src/executors/bounded-exec/ram-temp.ts +17 -4
- package/src/executors/bounded-exec/run-cpu-pool.test.ts +76 -0
- package/src/executors/bounded-exec/run-cpu-pool.ts +75 -0
- package/src/executors/bounded-exec/verdict.test.ts +125 -25
- package/src/executors/bounded-exec/verdict.ts +78 -3
- package/src/graph-input-contract.test.ts +8 -0
- package/src/graph-input-contract.ts +26 -4
- package/src/index.test.ts +12 -2
- package/src/index.ts +13 -3
- package/src/nextest-extraction.test.ts +114 -4
- package/src/nx-daemon-claim.test.ts +5 -3
- package/src/nx-daemon-idle-policy.test.ts +22 -18
- package/src/nx-daemon-validity.test.ts +5 -13
- package/src/owned-installation.ts +174 -0
- package/src/producer-receipts.ts +15 -10
- package/src/test-backstop.ts +11 -0
- package/src/test-clock-policy.test.ts +338 -0
- package/src/test-clock-policy.ts +708 -0
- package/src/testing.ts +8 -1
- package/test-timings.json +4 -0
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it } from 'bun:test';
|
|
1
|
+
import { afterEach, describe, expect, it, jest } from 'bun:test';
|
|
2
2
|
import { rmSync } from 'node:fs';
|
|
3
3
|
import { mkdtemp, readFile } from 'node:fs/promises';
|
|
4
4
|
import { createServer, type Server, type Socket } from 'node:net';
|
|
5
5
|
import { tmpdir } from 'node:os';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
|
+
import { BOUNDED_TEST_IDLE_TIMEOUT_MS } from '../../bounded-test-policy.js';
|
|
7
8
|
import { ownedSocketDirectory } from '../../testing.js';
|
|
8
9
|
import { diskClassOf, takeDiskLease, unixMicros, waitRecord } from './disk-lease.js';
|
|
10
|
+
import { holdLease, type LeaseBounds } from './gateway-lease.js';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
+
* The leg's backstop for each lease bound these cases are not about. The stand-ins answer at once, refuse at once, or
|
|
14
|
+
* are absent, so no such bound decides a verdict; a case that did wait on one would hang, and the leg's idle timeout
|
|
15
|
+
* ends the run (packages/nx-plugin/README.md, "Bounded Test Targets"). `grantMs: null` waits for as long as the gateway
|
|
16
|
+
* keeps the request queued.
|
|
13
17
|
*/
|
|
14
|
-
const
|
|
18
|
+
const BACKSTOP: LeaseBounds = {
|
|
19
|
+
ackMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
20
|
+
afterCloseMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
21
|
+
grantMs: null,
|
|
22
|
+
};
|
|
15
23
|
|
|
16
24
|
const servers: Server[] = [];
|
|
17
25
|
const directories: string[] = [];
|
|
18
26
|
|
|
19
27
|
afterEach(() => {
|
|
28
|
+
jest.useRealTimers();
|
|
20
29
|
for (const server of servers.splice(0)) {
|
|
21
30
|
server.close();
|
|
22
31
|
}
|
|
@@ -78,7 +87,7 @@ describe('cowshed disk-lifecycle lease client', () => {
|
|
|
78
87
|
// after the peer closes until the server ends it, so 'close' is not that signal on Linux.
|
|
79
88
|
client.on('end', () => close());
|
|
80
89
|
});
|
|
81
|
-
const lease = await takeDiskLease(socket, 'storage', '/usr/bin/hdiutil detach /dev/disk9',
|
|
90
|
+
const lease = await takeDiskLease(socket, 'storage', '/usr/bin/hdiutil detach /dev/disk9', BACKSTOP, 'shared');
|
|
82
91
|
expect(await request).toBe(
|
|
83
92
|
'{"op":"disk-lease","class":"storage","command":"/usr/bin/hdiutil detach /dev/disk9"}\n',
|
|
84
93
|
);
|
|
@@ -90,14 +99,22 @@ describe('cowshed disk-lifecycle lease client', () => {
|
|
|
90
99
|
});
|
|
91
100
|
|
|
92
101
|
it('recognizes a gateway that predates leases by its answer to the half-close', async () => {
|
|
102
|
+
// The ack bound is the subject: this gateway answers nothing until it reads EOF, so only the expiry of the ack bound
|
|
103
|
+
// half-closes the request. The bound is armed on connect, right after the request is written, and the read below
|
|
104
|
+
// happens before the advance, so the advance expires an armed ack bound and no other bound is due.
|
|
105
|
+
jest.useFakeTimers();
|
|
106
|
+
const { promise: requested, resolve: sawRequest } = Promise.withResolvers<void>();
|
|
93
107
|
const socket = await gateway((client) => {
|
|
94
|
-
client.
|
|
108
|
+
client.once('data', () => sawRequest());
|
|
95
109
|
client.on('end', () =>
|
|
96
110
|
client.end('{"ok":false,"code":"invalid-request","error":"unknown gateway control operation"}\n'),
|
|
97
111
|
);
|
|
98
112
|
});
|
|
99
|
-
const
|
|
100
|
-
|
|
113
|
+
const ackMs = 200;
|
|
114
|
+
const lease = takeDiskLease(socket, 'namespace', '/sbin/umount /x', { ...BACKSTOP, ackMs }, 'shared');
|
|
115
|
+
await requested;
|
|
116
|
+
jest.advanceTimersByTime(ackMs);
|
|
117
|
+
expect(await lease).toEqual({
|
|
101
118
|
granted: false,
|
|
102
119
|
cause: 'predates',
|
|
103
120
|
reason:
|
|
@@ -113,7 +130,7 @@ describe('cowshed disk-lifecycle lease client', () => {
|
|
|
113
130
|
client.write('{"ok":true,"lease":"queued"}\n{"ok":true,"lease":"granted"}\n');
|
|
114
131
|
});
|
|
115
132
|
});
|
|
116
|
-
const lease = await takeDiskLease(socket, 'storage', '/usr/bin/hdiutil detach /dev/disk9',
|
|
133
|
+
const lease = await takeDiskLease(socket, 'storage', '/usr/bin/hdiutil detach /dev/disk9', BACKSTOP, 'alone');
|
|
117
134
|
expect(await request).toBe(
|
|
118
135
|
'{"op":"disk-lease","class":"storage","share":"alone","command":"/usr/bin/hdiutil detach /dev/disk9"}\n',
|
|
119
136
|
);
|
|
@@ -131,21 +148,38 @@ describe('cowshed disk-lifecycle lease client', () => {
|
|
|
131
148
|
),
|
|
132
149
|
);
|
|
133
150
|
});
|
|
134
|
-
const lease = await takeDiskLease(socket, 'storage', 'x',
|
|
151
|
+
const lease = await takeDiskLease(socket, 'storage', 'x', BACKSTOP, 'alone');
|
|
135
152
|
expect(lease.granted === false && lease.cause).toBe('predates-field');
|
|
136
153
|
});
|
|
137
154
|
|
|
138
155
|
it('runs unleased, said as absent, when no gateway listens', async () => {
|
|
139
|
-
const lease = await takeDiskLease(await socketPath('none.sock'), 'storage', 'x',
|
|
156
|
+
const lease = await takeDiskLease(await socketPath('none.sock'), 'storage', 'x', BACKSTOP, 'shared');
|
|
140
157
|
expect(lease.granted === false && lease.cause).toBe('absent');
|
|
141
158
|
});
|
|
142
159
|
|
|
143
160
|
it('runs unleased when the grant never comes', async () => {
|
|
161
|
+
// The grant bound is the subject, so this case advances a clock it owns. `holdLease` arms the grant bound when the
|
|
162
|
+
// gateway's `queued` is read, and `sawQueued` runs in that same read, so the advance below expires an armed grant
|
|
163
|
+
// bound and nothing else is due: the grant never comes, so only that expiry ends the wait.
|
|
164
|
+
jest.useFakeTimers();
|
|
165
|
+
const { promise: queued, resolve: sawQueued } = Promise.withResolvers<void>();
|
|
144
166
|
const socket = await gateway((client) => {
|
|
145
167
|
client.once('data', () => client.write('{"ok":true,"lease":"queued"}\n'));
|
|
146
168
|
});
|
|
147
|
-
const lease =
|
|
148
|
-
|
|
169
|
+
const lease = holdLease(
|
|
170
|
+
socket,
|
|
171
|
+
{ op: 'disk-lease', class: 'storage', command: 'x' },
|
|
172
|
+
'disk leases',
|
|
173
|
+
{ ...BACKSTOP, grantMs: 500 },
|
|
174
|
+
() => sawQueued(),
|
|
175
|
+
);
|
|
176
|
+
await queued;
|
|
177
|
+
jest.advanceTimersByTime(500);
|
|
178
|
+
expect(await lease).toEqual({
|
|
179
|
+
granted: false,
|
|
180
|
+
cause: 'other',
|
|
181
|
+
reason: 'the gateway granted nothing within 500 ms',
|
|
182
|
+
});
|
|
149
183
|
});
|
|
150
184
|
|
|
151
185
|
it('appends a start and an end line per wait, numbered per record and stamped in microseconds', async () => {
|
|
@@ -5,6 +5,7 @@ import { createServer, type Socket } from 'node:net';
|
|
|
5
5
|
import { tmpdir } from 'node:os';
|
|
6
6
|
import { basename, dirname, join } from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from '../../bounded-test-policy.js';
|
|
8
9
|
import { CPU_POOL_ENV, type CpuPool, createCpuPool } from './cpu-pool.js';
|
|
9
10
|
import { CPU_TOKENS_ENV } from './cpu-tokens.js';
|
|
10
11
|
import type { BoundedExecOptions } from './schema.js';
|
|
@@ -37,8 +38,11 @@ const ACTIVE_RESOURCES = 'cowshed-test active-resources ';
|
|
|
37
38
|
const CHURN_NAMES = ['churna', 'churnb'] as const;
|
|
38
39
|
/** Written into a case's root to stop its churn workers; each checks it between runs, never mid-run. */
|
|
39
40
|
const CHURN_STOP = 'churn.stop';
|
|
40
|
-
/**
|
|
41
|
-
|
|
41
|
+
/**
|
|
42
|
+
* One churn run: `true` on one token, so each lease is a real acquire, run and release. Its `timeoutMs` is the leg
|
|
43
|
+
* backstop: a run ends on its own exit, and only a hung run reaches the bound (`specs/cowshed/08_testing.md:511-514`).
|
|
44
|
+
*/
|
|
45
|
+
const CHURN_OPTIONS: BoundedExecOptions = { command: 'true', timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS, parallelism: 1 };
|
|
42
46
|
/** A churn worker's stdout: a `begin` line before each run it starts, a `ran` line after each run that succeeded. */
|
|
43
47
|
const CHURN_BEGIN = /^cowshed-test churn [a-z]+ begin [0-9]+$/gm;
|
|
44
48
|
const CHURN_RAN = /^cowshed-test churn [a-z]+ ran [0-9]+$/gm;
|
|
@@ -128,7 +132,7 @@ describe('@smoothbricks/nx-plugin:bounded-exec host proofs', () => {
|
|
|
128
132
|
const leafScript = await writeRunner(
|
|
129
133
|
root,
|
|
130
134
|
'leaf',
|
|
131
|
-
{ command: `node -e "console.log('leaf')"`, timeoutMs:
|
|
135
|
+
{ command: `node -e "console.log('leaf')"`, timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS, parallelism: 1 },
|
|
132
136
|
leafDirectory,
|
|
133
137
|
);
|
|
134
138
|
const nestedDirectory = join(root, 'nested');
|
|
@@ -138,7 +142,7 @@ describe('@smoothbricks/nx-plugin:bounded-exec host proofs', () => {
|
|
|
138
142
|
const run = await startRunner(
|
|
139
143
|
root,
|
|
140
144
|
'nested',
|
|
141
|
-
{ command: nestedCommand, cwd: PACKAGE_ROOT, timeoutMs:
|
|
145
|
+
{ command: nestedCommand, cwd: PACKAGE_ROOT, timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS, parallelism: 2 },
|
|
142
146
|
nestedDirectory,
|
|
143
147
|
childEnv(pool.environment),
|
|
144
148
|
);
|
|
@@ -175,7 +179,7 @@ describe('@smoothbricks/nx-plugin:bounded-exec host proofs', () => {
|
|
|
175
179
|
`const options = ${JSON.stringify({
|
|
176
180
|
command: `node -e "console.log('lease')"`,
|
|
177
181
|
cwd: PACKAGE_ROOT,
|
|
178
|
-
timeoutMs:
|
|
182
|
+
timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
179
183
|
parallelism: 1,
|
|
180
184
|
})};`,
|
|
181
185
|
`const context = ${JSON.stringify({ root })};`,
|
|
@@ -209,7 +213,11 @@ describe('@smoothbricks/nx-plugin:bounded-exec host proofs', () => {
|
|
|
209
213
|
startRunner(
|
|
210
214
|
root,
|
|
211
215
|
name,
|
|
212
|
-
{
|
|
216
|
+
{
|
|
217
|
+
command: siblingCommand(barrier.port, name),
|
|
218
|
+
timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
219
|
+
parallelism: 1,
|
|
220
|
+
},
|
|
213
221
|
join(root, name),
|
|
214
222
|
childEnv(pool.environment),
|
|
215
223
|
),
|
|
@@ -266,7 +274,7 @@ describe('@smoothbricks/nx-plugin:bounded-exec host proofs', () => {
|
|
|
266
274
|
await withPool(1, async (outer) => {
|
|
267
275
|
const options: BoundedExecOptions = {
|
|
268
276
|
command: `node -e "console.log('actual-tokens=' + process.env.${CPU_TOKENS_ENV})"`,
|
|
269
|
-
timeoutMs:
|
|
277
|
+
timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
270
278
|
parallelism: 1,
|
|
271
279
|
};
|
|
272
280
|
const directory = join(root, 'stale');
|
|
@@ -329,8 +337,8 @@ describe('@smoothbricks/nx-plugin:bounded-exec host proofs', () => {
|
|
|
329
337
|
'outlives',
|
|
330
338
|
{
|
|
331
339
|
command: `sh -c 'echo started; read -r line < "$0"; echo finished' '${go}'`,
|
|
332
|
-
timeoutMs:
|
|
333
|
-
killAfterMs:
|
|
340
|
+
timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
341
|
+
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
334
342
|
parallelism: 1,
|
|
335
343
|
},
|
|
336
344
|
join(root, 'outlives'),
|
|
@@ -356,7 +364,7 @@ describe('@smoothbricks/nx-plugin:bounded-exec host proofs', () => {
|
|
|
356
364
|
const unremovable = await startRunner(
|
|
357
365
|
root,
|
|
358
366
|
'unremovable',
|
|
359
|
-
{ command: UNREMOVABLE_COMMAND, timeoutMs:
|
|
367
|
+
{ command: UNREMOVABLE_COMMAND, timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS, parallelism: 1 },
|
|
360
368
|
join(root, 'unremovable'),
|
|
361
369
|
childEnv(pool.environment),
|
|
362
370
|
);
|
|
@@ -371,7 +379,11 @@ describe('@smoothbricks/nx-plugin:bounded-exec host proofs', () => {
|
|
|
371
379
|
const next = await startRunner(
|
|
372
380
|
root,
|
|
373
381
|
'next',
|
|
374
|
-
{
|
|
382
|
+
{
|
|
383
|
+
command: `node -e "console.log(process.env.${CPU_TOKENS_ENV})"`,
|
|
384
|
+
timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
385
|
+
parallelism: 1,
|
|
386
|
+
},
|
|
375
387
|
join(root, 'next'),
|
|
376
388
|
childEnv(pool.environment),
|
|
377
389
|
);
|