Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions apps/rush-cli-client/src/test/GraphGenerationWire.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,12 @@ describe('generation-aware graph reference client', () => {
return;
}
try {
if (
request.argv[2] === 'status' &&
(mode === 'remaining-budget' || mode === 'expired-preflight')
) {
if (request.argv[2] === 'status' && mode === 'remaining-budget') {
await delayAsync(200);
} else if (request.argv[2] === 'status' && mode === 'expired-preflight') {
// Answer only once the client's admission deadline has passed, however long it took to
// send this preflight.
await delayAsync(request.admission!.waitTimeoutMs! + 100);
}
await connection.sendFrameAsync({
kind: DaemonFrameType.event,
Expand Down Expand Up @@ -367,7 +368,7 @@ describe('generation-aware graph reference client', () => {
mode === 'no-wait'
? ['--no-wait']
: mode === 'expired-preflight'
? ['--wait-timeout', '0.1']
? ['--wait-timeout', '2']
: ['timeout', 'remaining-budget', 'explicit'].includes(mode)
? ['--wait-timeout', '0.5']
: [];
Expand Down Expand Up @@ -426,7 +427,7 @@ describe('generation-aware graph reference client', () => {
: mode === 'default' || mode === 'cancel-preflight'
? 30000
: mode === 'expired-preflight'
? 100
? 2000
: 500;
expect(requests[0].admission!.waitTimeoutMs).toBeGreaterThan(0);
expect(requests[0].admission!.waitTimeoutMs).toBeLessThanOrEqual(maximum);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"type": "none",
"packageName": "@rushstack/rush-cli-client"
}
],
"packageName": "@rushstack/rush-cli-client",
"email": "3408176+TheLarkInn@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"type": "none",
"packageName": "@rushstack/rush-client-core"
}
],
"packageName": "@rushstack/rush-client-core",
"email": "3408176+TheLarkInn@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"type": "none",
"packageName": "@rushstack/rush-daemon"
}
],
"packageName": "@rushstack/rush-daemon",
"email": "3408176+TheLarkInn@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,33 @@ describe('detached daemon startup while the startup helper runs', () => {
// and exits.
const { timeline, restore } = recordStartupTimeline();
try {
// A slow machine can take seconds to start the helper and daemon, so leave room for later attempts.
await expect(
connectOrStartDaemonAsync({
...options,
startupTimeoutMs: 3000,
startupTimeoutMs: 8000,
startCommand: { ...options.startCommand!, args: [...options.startCommand!.args, 'other'] }
})
).rejects.toThrow('Daemon startup timed out awaiting hello/ping readiness.');
const timedOutAt: number = performance.now();
const { attempts, helperClosedAt } = timeline;
expect(helperClosedAt).toBeDefined();
const afterExit: number[] = attempts.filter((attempt) => attempt >= helperClosedAt!);
// Only the first attempt after the exit comes early. Each later one waits a whole step, so fewer
// than 10 fit in the rest of the deadline.
// At most two attempts after the exit come early: one that checked the helper just before it exited,
// and the next. Each later one waits a whole step of at least 50, 100, 200, 400, then 500 ms, and the
// deadline may cut only the last step short.
let maximumAttempts: number = 3;
for (let step: number = 50, elapsed: number = step; elapsed <= timedOutAt - helperClosedAt!; ) {
maximumAttempts++;
step = Math.min(500, step * 2);
elapsed += step;
}
expect(afterExit.length).toBeGreaterThan(1);
expect(afterExit.length).toBeLessThan(10);
expect(afterExit.length).toBeLessThanOrEqual(maximumAttempts);
} finally {
restore();
}
}, 15000);
}, 30000);

it('stops at once when aborted while it waits for its startup helper', async () => {
// The daemon waits before it listens, so this client sleeps between refused connection attempts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ describe('version-selected daemon launcher', () => {
}

it('attests the actual bundled engine and protocol without changing the caller environment', async () => {
// Attestation loads the engine in a fresh Node.js process, which can take seconds on a busy machine.
const originalRushLibPath: string | undefined = process.env._RUSH_LIB_PATH;
const selected = await selectDaemonLauncherAsync(context, { allowInstall: false });
expect(selected.rushVersion).toBe(Rush.version);
Expand All @@ -99,7 +100,7 @@ describe('version-selected daemon launcher', () => {
);
expect(selected.startCommand.command).toBe(process.execPath);
expect(process.env._RUSH_LIB_PATH).toBe(originalRushLibPath);
});
}, 15000);

it("starts the daemon without the starting client's request-scoped variables", () => {
const command = getSelectedDaemonStartCommand(path.join(repoRoot, 'package.json'), {
Expand Down Expand Up @@ -174,7 +175,7 @@ describe('version-selected daemon launcher', () => {
);
expect(selected.rushVersion).toBe(Rush.version);
expect(fs.readFileSync(path.join(repoRoot, 'rush.json'), 'utf8')).toBe(rushJson);
});
}, 15000);

it.each([false, true])(
'starts the attested engine through its real default APIs (preview: %s)',
Expand Down