File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
393439test ( "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.
Original file line number Diff line number Diff 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
452454function 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
You can’t perform that action at this time.
0 commit comments