Skip to content

Commit ef07fd0

Browse files
committed
Honor benchmark suite defaults
Pass suite-level load and duration defaults into the unsafe public inbox destination check. Public inbox runs allowed with --allow-unsafe-target now follow the same documented explicit-default contract as the top-level target gate. #744 #784 Assisted-by: Codex:gpt-5.5
1 parent e51c5dd commit ef07fd0

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

packages/cli/src/bench/action.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,52 @@ scenarios:
390390
}
391391
});
392392

393+
test("runBench - unsafe public inbox destination honors suite defaults", async () => {
394+
const target = await spawnBenchmarkTarget();
395+
try {
396+
const file = await writeSuite(`version: 1
397+
target: ${target.url.href}
398+
defaults:
399+
duration: 1ms
400+
load: { rate: 1/s }
401+
scenarios:
402+
- name: inbox-shared
403+
type: inbox
404+
recipient: "${new URL("/users/alice", target.url).href}"
405+
inbox: "https://prod.example/inbox"
406+
`);
407+
let code = -1;
408+
let message = "";
409+
await runBench(
410+
command({
411+
scenario: file,
412+
target: target.url.href,
413+
allowUnsafeTarget: true,
414+
advertiseHost: "127.0.0.1",
415+
}),
416+
{
417+
exit: (c) => {
418+
code = c;
419+
},
420+
writeOutput: () => Promise.resolve(),
421+
log: (m) => {
422+
message = m;
423+
},
424+
fetch: (input) => {
425+
const url = new URL(input instanceof Request ? input.url : input);
426+
if (url.hostname === "prod.example") {
427+
return Promise.resolve(new Response("accepted", { status: 202 }));
428+
}
429+
return fetch(input);
430+
},
431+
},
432+
);
433+
assert.strictEqual(code, 0, message);
434+
} finally {
435+
await target.close();
436+
}
437+
});
438+
393439
test("runBench - malformed expect assertion exits 2 before any load", async () => {
394440
// The expect typo must be caught in preflight, so the run exits 2 (a config
395441
// error) without ever probing the target or sending load.

packages/cli/src/bench/action.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export default async function runBench(
181181
targetBenchmarkMode: probe.benchmarkMode,
182182
allowUnsafe: command.allowUnsafeTarget,
183183
explicitCliTarget: command.target != null,
184+
suite: validated,
184185
});
185186
};
186187

@@ -447,6 +448,7 @@ interface PublicDestinationOverrideContext {
447448
readonly targetBenchmarkMode: boolean;
448449
readonly allowUnsafe: boolean;
449450
readonly explicitCliTarget: boolean;
451+
readonly suite: Suite;
450452
}
451453

452454
function assertPublicDestinationOverrideAllowed(
@@ -467,7 +469,7 @@ function assertPublicDestinationOverrideAllowed(
467469
benchmarkMode: false,
468470
allowUnsafe: true,
469471
explicitCliTarget: context.explicitCliTarget,
470-
scenarios: [unsafeOverrideScenario(scenario)],
472+
scenarios: [unsafeOverrideScenario(scenario, context.suite)],
471473
});
472474
}
473475

0 commit comments

Comments
 (0)