Skip to content

Commit f29e182

Browse files
test(ssh): trim update-wait launcher cases that repeat another case
The marker's startedAt is always a number, so decode it as one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d3faed8 commit f29e182

2 files changed

Lines changed: 16 additions & 23 deletions

File tree

‎apps/server/src/desktopUpdate/DesktopUpdateMarker.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as Option from "effect/Option";
88
import * as Schema from "effect/Schema";
99

1010
const UpdateMarker = Schema.fromJsonString(
11-
Schema.Struct({ startedAt: Schema.optional(Schema.Unknown), expiresAt: Schema.Number }),
11+
Schema.Struct({ startedAt: Schema.Number, expiresAt: Schema.Number }),
1212
);
1313

1414
export class DesktopUpdateMarker extends Context.Service<
@@ -36,7 +36,6 @@ const make = Effect.gen(function* () {
3636
if (Option.isSome(marker)) {
3737
const { startedAt, expiresAt } = marker.value;
3838
if (
39-
typeof startedAt === "number" &&
4039
Number.isFinite(startedAt) &&
4140
Number.isFinite(expiresAt) &&
4241
startedAt <= now &&

‎packages/ssh/src/tunnel.test.ts‎

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,11 +1287,11 @@ describe("SSH launch during desktop update", () => {
12871287
}),
12881288
);
12891289

1290-
it.effect.each([-30_000, 120_000])("bounds a host clock jump to %s", (clockJump) =>
1290+
it.effect("bounds the wait when the host clock jumps back", () =>
12911291
Effect.gen(function* () {
12921292
const result = runLauncher(yield* captureLauncher, {
12931293
marker: { startedAt: 0, expiresAt: 60_000 },
1294-
clockJump,
1294+
clockJump: -30_000,
12951295
});
12961296
assert.deepEqual(result.output, { remotePort: 5999, serverKind: "managed" });
12971297
assert.isBelow(result.events.filter((event) => event.startsWith("runtime ")).length, 62);
@@ -1313,22 +1313,16 @@ describe("SSH launch during desktop update", () => {
13131313
}),
13141314
);
13151315

1316-
it.effect.each([false, true])(
1317-
"reuses a runtime published before the first marker read (archive: %s)",
1318-
(archive) =>
1319-
Effect.gen(function* () {
1320-
const script = archive
1321-
? yield* captureLauncherFor({ archiveVersion: "1.2.3" })
1322-
: yield* captureLauncher;
1323-
const result = runLauncher(script, {
1324-
archive,
1325-
marker: { startedAt: 0, expiresAt: 60_000 },
1326-
publishAfterFirstRuntimeRead: true,
1327-
});
1328-
assert.deepEqual(result.output, { remotePort: 4888, serverKind: "external" });
1329-
assert.equal(result.now, 0);
1330-
assert.isFalse(result.events.some((event) => event.startsWith("start ")));
1331-
}),
1316+
it.effect("reuses a runtime published before the first marker read", () =>
1317+
Effect.gen(function* () {
1318+
const result = runLauncher(yield* captureLauncher, {
1319+
marker: { startedAt: 0, expiresAt: 60_000 },
1320+
publishAfterFirstRuntimeRead: true,
1321+
});
1322+
assert.deepEqual(result.output, { remotePort: 4888, serverKind: "external" });
1323+
assert.equal(result.now, 0);
1324+
assert.isFalse(result.events.some((event) => event.startsWith("start ")));
1325+
}),
13321326
);
13331327

13341328
it.effect("waits across the eight-second installer gap and reuses the replacement server", () =>
@@ -1344,15 +1338,15 @@ describe("SSH launch during desktop update", () => {
13441338
}),
13451339
);
13461340

1347-
it.effect("waits the full marker lifetime despite immediately failing stale-port probes", () =>
1341+
it.effect("keeps waiting while a stale runtime record points at a dead port", () =>
13481342
Effect.gen(function* () {
13491343
const result = runLauncher(yield* captureLauncher, {
13501344
marker: { startedAt: 0, expiresAt: 60_000 },
13511345
initialPort: 3773,
1352-
readyAt: 30_000,
1346+
readyAt: 3_000,
13531347
});
13541348
assert.deepEqual(result.output, { remotePort: 4888, serverKind: "external" });
1355-
assert.equal(result.now, 30_000);
1349+
assert.equal(result.now, 3_000);
13561350
assert.isFalse(result.events.some((event) => event.startsWith("start ")));
13571351
}),
13581352
);

0 commit comments

Comments
 (0)