Skip to content

Commit 1f35ad1

Browse files
committed
fix(test): reject malformed parallels smoke limits
1 parent 3d4d30f commit 1f35ad1

3 files changed

Lines changed: 63 additions & 11 deletions

File tree

scripts/e2e/parallels/linux-smoke.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
parseBoolEnv,
1111
parseMode,
1212
parseProvider,
13+
readPositiveIntEnv,
1314
modelProviderConfigBatchJson,
1415
posixProviderOnlyPluginIsolationScript,
1516
repoRoot,
@@ -234,6 +235,10 @@ function stripLeadingPackageManagerSeparator(argv: string[]): string[] {
234235
class LinuxSmoke extends SmokeRunController<LinuxOptions> {
235236
private auth: ProviderAuth;
236237
private disableBonjour = parseBoolEnv(process.env.OPENCLAW_PARALLELS_LINUX_DISABLE_BONJOUR);
238+
private agentTimeoutSeconds = readPositiveIntEnv(
239+
"OPENCLAW_PARALLELS_LINUX_AGENT_TIMEOUT_S",
240+
1500,
241+
);
237242
private artifact: PackageArtifact | null = null;
238243
private latestVersion = "";
239244
private snapshot!: SnapshotInfo;
@@ -322,7 +327,7 @@ class LinuxSmoke extends SmokeRunController<LinuxOptions> {
322327
this.status.freshGateway = "pass";
323328
await this.phase(
324329
"fresh.first-local-agent-turn",
325-
Number(process.env.OPENCLAW_PARALLELS_LINUX_AGENT_TIMEOUT_S || 1500),
330+
this.agentTimeoutSeconds,
326331
() => this.verifyLocalTurn(),
327332
);
328333
this.status.freshAgent = "pass";
@@ -354,7 +359,7 @@ class LinuxSmoke extends SmokeRunController<LinuxOptions> {
354359
this.status.upgradeGateway = "pass";
355360
await this.phase(
356361
"upgrade.first-local-agent-turn",
357-
Number(process.env.OPENCLAW_PARALLELS_LINUX_AGENT_TIMEOUT_S || 1500),
362+
this.agentTimeoutSeconds,
358363
() => this.verifyLocalTurn(),
359364
);
360365
this.status.upgradeAgent = "pass";

scripts/e2e/parallels/windows-smoke.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
makeTempDir,
99
parseMode,
1010
parseProvider,
11+
readPositiveIntEnv,
1112
resolveLatestVersion,
1213
resolveParallelsModelTimeoutSeconds,
1314
resolveWindowsProviderAuth,
@@ -226,6 +227,16 @@ function stripLeadingPackageManagerSeparator(argv: string[]): string[] {
226227

227228
class WindowsSmoke extends SmokeRunController<WindowsOptions> {
228229
private auth: ProviderAuth;
230+
private agentTimeoutSeconds = readPositiveIntEnv(
231+
"OPENCLAW_PARALLELS_WINDOWS_AGENT_TIMEOUT_S",
232+
2700,
233+
);
234+
private updateTimeoutSeconds = readPositiveIntEnv(
235+
"OPENCLAW_PARALLELS_WINDOWS_UPDATE_TIMEOUT_S",
236+
1200,
237+
);
238+
private gatewayRecoveryAfterMs =
239+
readPositiveIntEnv("OPENCLAW_PARALLELS_WINDOWS_GATEWAY_RECOVERY_AFTER_S", 180) * 1000;
229240
private artifact: PackageArtifact | null = null;
230241
private minGitZipPath = "";
231242
private latestVersion = "";
@@ -348,7 +359,7 @@ class WindowsSmoke extends SmokeRunController<WindowsOptions> {
348359
this.status.freshGateway = "pass";
349360
await this.phase(
350361
"fresh.first-agent-turn",
351-
Number(process.env.OPENCLAW_PARALLELS_WINDOWS_AGENT_TIMEOUT_S || 2700),
362+
this.agentTimeoutSeconds,
352363
() => this.verifyTurn(),
353364
);
354365
this.status.freshAgent = "pass";
@@ -394,7 +405,7 @@ class WindowsSmoke extends SmokeRunController<WindowsOptions> {
394405
await this.phase("upgrade.gateway-stop-before-update", 420, () => this.gatewayAction("stop"));
395406
await this.phase(
396407
"upgrade.update-dev",
397-
Number(process.env.OPENCLAW_PARALLELS_WINDOWS_UPDATE_TIMEOUT_S || 1200),
408+
this.updateTimeoutSeconds,
398409
() => this.runDevChannelUpdate(),
399410
);
400411
this.status.upgradeVersion = await this.extractLastVersion("upgrade.update-dev");
@@ -406,7 +417,7 @@ class WindowsSmoke extends SmokeRunController<WindowsOptions> {
406417
this.status.upgradeGateway = "pass";
407418
await this.phase(
408419
"upgrade.first-agent-turn",
409-
Number(process.env.OPENCLAW_PARALLELS_WINDOWS_AGENT_TIMEOUT_S || 2700),
420+
this.agentTimeoutSeconds,
410421
() => this.verifyTurn(),
411422
);
412423
this.status.upgradeAgent = "pass";
@@ -645,7 +656,7 @@ Invoke-WithScopedEnv @{ OPENCLAW_ALLOW_OLDER_BINARY_DESTRUCTIVE_ACTIONS = '1'; O
645656
if ($script:OpenClawUpdateExit -ne 0) { throw "openclaw update failed with exit code $script:OpenClawUpdateExit" }
646657
Invoke-OpenClaw --version
647658
Invoke-OpenClaw update status --json`,
648-
{ timeoutMs: Number(process.env.OPENCLAW_PARALLELS_WINDOWS_UPDATE_TIMEOUT_S || 1200) * 1000 },
659+
{ timeoutMs: this.updateTimeoutSeconds * 1000 },
649660
);
650661
}
651662

@@ -676,8 +687,6 @@ if ($LASTEXITCODE -ne 0) { throw "gateway ${action} failed with exit code $LASTE
676687
const deadline = Date.now() + 420_000;
677688
let attempt = 1;
678689
let recoveryTried = false;
679-
const recoveryAfter =
680-
Number(process.env.OPENCLAW_PARALLELS_WINDOWS_GATEWAY_RECOVERY_AFTER_S || 180) * 1000;
681690
const start = Date.now();
682691
while (Date.now() < deadline) {
683692
const probe = this.guestPowerShell(
@@ -687,7 +696,7 @@ if ($LASTEXITCODE -ne 0) { throw "gateway ${action} failed with exit code $LASTE
687696
if (/"ok"\s*:\s*true/.test(probe)) {
688697
return;
689698
}
690-
if (!recoveryTried && Date.now() - start >= recoveryAfter) {
699+
if (!recoveryTried && Date.now() - start >= this.gatewayRecoveryAfterMs) {
691700
warn(
692701
`gateway-reachable recovery: gateway start after ${Math.floor((Date.now() - start) / 1000)}s`,
693702
);
@@ -759,7 +768,7 @@ for ($attempt = 1; $attempt -le 2; $attempt++) {
759768
}
760769
}
761770
if (-not $agentOk) { throw 'openclaw agent finished without OK response' }`,
762-
Number(process.env.OPENCLAW_PARALLELS_WINDOWS_AGENT_TIMEOUT_S || 2700) * 1000,
771+
this.agentTimeoutSeconds * 1000,
763772
);
764773
}
765774

test/scripts/parallels-smoke-model.test.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ describe("Parallels smoke model selection", () => {
171171
let missingProviderKeyResult: ReturnType<typeof spawnNodeEvalSync>;
172172
let invalidModelTimeoutResult: ReturnType<typeof spawnNodeEvalSync>;
173173
let invalidHostPortResult: ReturnType<typeof spawnNodeEvalSync>;
174+
let invalidLinuxAgentTimeoutResult: ReturnType<typeof spawnNodeEvalSync>;
175+
let invalidWindowsAgentTimeoutResult: ReturnType<typeof spawnNodeEvalSync>;
176+
let invalidWindowsUpdateTimeoutResult: ReturnType<typeof spawnNodeEvalSync>;
174177

175178
beforeAll(() => {
176179
invalidProviderResult = spawnNodeEvalSync(
@@ -192,6 +195,18 @@ describe("Parallels smoke model selection", () => {
192195
`process.argv = ["node", "${TS_PATHS.macos}", "--host-port", "18425x"]; await import("./${TS_PATHS.macos}");`,
193196
{ env: process.env, imports: ["tsx"] },
194197
);
198+
invalidLinuxAgentTimeoutResult = spawnNodeEvalSync(
199+
`process.env.OPENCLAW_PARALLELS_LINUX_AGENT_TIMEOUT_S = "1e3"; process.argv = ["node", "${TS_PATHS.linux}"]; await import("./${TS_PATHS.linux}");`,
200+
{ env: process.env, imports: ["tsx"] },
201+
);
202+
invalidWindowsAgentTimeoutResult = spawnNodeEvalSync(
203+
`process.env.OPENCLAW_PARALLELS_WINDOWS_AGENT_TIMEOUT_S = "2700s"; process.argv = ["node", "${TS_PATHS.windows}"]; await import("./${TS_PATHS.windows}");`,
204+
{ env: process.env, imports: ["tsx"] },
205+
);
206+
invalidWindowsUpdateTimeoutResult = spawnNodeEvalSync(
207+
`process.env.OPENCLAW_PARALLELS_WINDOWS_UPDATE_TIMEOUT_S = "12.5"; process.argv = ["node", "${TS_PATHS.windows}"]; await import("./${TS_PATHS.windows}");`,
208+
{ env: process.env, imports: ["tsx"] },
209+
);
195210
});
196211

197212
it("keeps the public shell entrypoints as thin TypeScript launchers", () => {
@@ -1067,7 +1082,9 @@ setInterval(() => {}, 1000);
10671082

10681083
expect(script).toContain('guestPowerShellBackground(\n "agent-turn"');
10691084
expect(script).toContain("OPENCLAW_PARALLELS_WINDOWS_AGENT_TIMEOUT_S");
1070-
expect(script).toContain("OPENCLAW_PARALLELS_WINDOWS_AGENT_TIMEOUT_S || 2700");
1085+
expect(script).toContain(
1086+
'readPositiveIntEnv(\n "OPENCLAW_PARALLELS_WINDOWS_AGENT_TIMEOUT_S"',
1087+
);
10711088
expect(script).toContain("windowsAgentTurnConfigPatchScript(this.auth.modelId)");
10721089
expect(script).toContain("--model");
10731090
expect(script).toContain('resolveParallelsModelTimeoutSeconds("windows")');
@@ -1118,9 +1135,30 @@ setInterval(() => {}, 1000);
11181135
expect(invalidHostPortResult.status).toBe(1);
11191136
expect(invalidHostPortResult.stderr).toContain("invalid --host-port: 18425x");
11201137

1138+
expect(invalidLinuxAgentTimeoutResult.status).toBe(1);
1139+
expect(invalidLinuxAgentTimeoutResult.stderr).toContain(
1140+
"invalid OPENCLAW_PARALLELS_LINUX_AGENT_TIMEOUT_S: 1e3",
1141+
);
1142+
1143+
expect(invalidWindowsAgentTimeoutResult.status).toBe(1);
1144+
expect(invalidWindowsAgentTimeoutResult.stderr).toContain(
1145+
"invalid OPENCLAW_PARALLELS_WINDOWS_AGENT_TIMEOUT_S: 2700s",
1146+
);
1147+
1148+
expect(invalidWindowsUpdateTimeoutResult.status).toBe(1);
1149+
expect(invalidWindowsUpdateTimeoutResult.stderr).toContain(
1150+
"invalid OPENCLAW_PARALLELS_WINDOWS_UPDATE_TIMEOUT_S: 12.5",
1151+
);
1152+
11211153
expect(readFileSync(TS_PATHS.macos, "utf8")).toContain(
11221154
'this.updateDevTimeoutSeconds = readPositiveIntEnv(\n "OPENCLAW_PARALLELS_MACOS_UPDATE_DEV_TIMEOUT_S"',
11231155
);
1156+
expect(readFileSync(TS_PATHS.linux, "utf8")).toContain(
1157+
'readPositiveIntEnv(\n "OPENCLAW_PARALLELS_LINUX_AGENT_TIMEOUT_S"',
1158+
);
1159+
expect(readFileSync(TS_PATHS.windows, "utf8")).toContain(
1160+
'readPositiveIntEnv(\n "OPENCLAW_PARALLELS_WINDOWS_UPDATE_TIMEOUT_S"',
1161+
);
11241162
expect(readFileSync(TS_PATHS.packageArtifact, "utf8")).toContain(
11251163
'readPositiveIntEnv("OPENCLAW_PARALLELS_PACKAGE_LOCK_TIMEOUT_MS", 30 * 60_000)',
11261164
);

0 commit comments

Comments
 (0)