@@ -3250,8 +3250,11 @@ describe("scripts/lib/ci-node-test-plan.mts", () => {
32503250 expect ( groups . flatMap ( ( group ) => group . includePatterns ?? [ ] ) . toSorted ( ) ) . toEqual (
32513251 targets . toSorted ( ) ,
32523252 ) ;
3253- expect ( plan . filter ( ( job ) => job . planConcurrency === 2 ) ) . toHaveLength ( 1 ) ;
3253+ // Selection retains full-plan concurrency. Unrelated inventory may move these
3254+ // groups into serial Gateway templates; fixed-inventory coverage below proves
3255+ // parallel capacity is retained when the canonical templates permit it.
32543256 for ( const job of plan ) {
3257+ expect ( [ 1 , 2 ] ) . toContain ( job . planConcurrency ) ;
32553258 expect ( job . runner ) . toBe (
32563259 job . planConcurrency === 2
32573260 ? "blacksmith-32vcpu-ubuntu-2404"
@@ -3486,71 +3489,105 @@ describe("scripts/lib/ci-node-test-plan.mts", () => {
34863489 }
34873490 } ) ;
34883491
3489- it ( "retains the ordered wall budget when repacking selected files" , async ( ) => {
3490- const config = "test/vitest/vitest.infra.config.ts" ;
3491- const entries = [
3492- [ "src/infra/env.test.ts" , "core-runtime-infra-env-auth" , 170 ] ,
3493- [ "src/infra/os-summary.test.ts" , "core-runtime-infra-misc-os" , 170 ] ,
3494- [ "src/infra/ports-probe.test.ts" , "core-runtime-infra-system-runtime" , 160 ] ,
3495- [ "src/infra/provider-usage.test.ts" , "core-runtime-infra-provider-push" , 160 ] ,
3496- [ "src/infra/channel-runtime-context.test.ts" , "core-runtime-infra-channel-plugin" , 150 ] ,
3497- [ "src/infra/diagnostic-trace-context.test.ts" , "core-runtime-infra-diagnostics-state" , 150 ] ,
3498- ] as const ;
3499- const files = entries . map ( ( [ file ] ) => file ) ;
3500- const targets = files . slice ( 0 , 3 ) ;
3501- vi . resetModules ( ) ;
3502- vi . doMock ( "../vitest/vitest.test-shards.mjs" , async ( importOriginal ) => ( {
3503- ...( await importOriginal < typeof import ( "../vitest/vitest.test-shards.mjs" ) > ( ) ) ,
3504- fullSuiteVitestShards : [ { name : "core-runtime" , config, projects : [ config ] } ] ,
3505- } ) ) ;
3506- vi . doMock ( "../vitest/vitest.database-worker-core-paths.mjs" , async ( importOriginal ) => ( {
3507- ...( await importOriginal < typeof import ( "../vitest/vitest.database-worker-core-paths.mjs" ) > ( ) ) ,
3508- databaseWorkerCoreTestFiles : [ ] ,
3509- isDatabaseWorkerCoreTestFile : ( ) => false ,
3510- } ) ) ;
3511- vi . doMock ( "../../scripts/lib/list-test-files.mts" , async ( importOriginal ) => ( {
3512- ...( await importOriginal < typeof import ( "../../scripts/lib/list-test-files.mts" ) > ( ) ) ,
3513- listTrackedTestFiles : ( root : string ) => ( root === "src/infra" ? files : [ ] ) ,
3514- } ) ) ;
3515- vi . doMock ( "../../scripts/lib/ci-test-timings.mts" , ( ) => ( {
3516- ...testTimings ,
3517- readCompactGroupTimings : ( ) =>
3518- Object . fromEntries ( entries . map ( ( [ , owner , seconds ] ) => [ owner , seconds ] ) ) ,
3519- readRuntimePlacementTimings : ( ) => [ ] ,
3520- } ) ) ;
3521- vi . doMock ( "../../scripts/lib/vitest-build-prerequisites.mts" , async ( importOriginal ) => ( {
3522- ...( await importOriginal <
3523- typeof import ( "../../scripts/lib/vitest-build-prerequisites.mts" )
3524- > ( ) ) ,
3525- resolveVitestPretestBuildMode : ( ) => undefined ,
3526- } ) ) ;
3527- try {
3528- const { createSelectedNodeTestShardBundles : createSelected } =
3529- await import ( "../../scripts/lib/ci-node-test-plan.mts" ) ;
3530- const selected = expectDefined (
3531- createSelected ( targets , { runnerBackend : "blacksmith" } ) ,
3532- "selected infra plan" ,
3533- ) ;
3534- // The selected 170/170/160 envelopes fit the aggregate limit but need 330 seconds together.
3535- expect ( selected ) . toHaveLength ( 2 ) ;
3536- expect ( selected . every ( ( job ) => job . planConcurrency === 2 ) ) . toBe ( true ) ;
3537- expect ( selected . every ( ( job ) => job . predictedTestSeconds ! <= 300 ) ) . toBe ( true ) ;
3538- expect ( selected . map ( ( job ) => job . predictedTestSeconds ! ) . toSorted ( ( a , b ) => a - b ) ) . toEqual ( [
3539- 160 , 170 ,
3540- ] ) ;
3541- expect ( selected . reduce ( ( sum , job ) => sum + job . predictedSeconds ! , 0 ) ) . toBe ( 500 ) ;
3542- expect (
3543- selected . flatMap ( ( job ) => job . groups . flatMap ( ( group ) => group . includePatterns ! ) ) . toSorted ( ) ,
3544- ) . toEqual ( targets . toSorted ( ) ) ;
3545- } finally {
3546- vi . doUnmock ( "../../scripts/lib/vitest-build-prerequisites.mts" ) ;
3547- vi . doUnmock ( "../../scripts/lib/ci-test-timings.mts" ) ;
3548- vi . doUnmock ( "../../scripts/lib/list-test-files.mts" ) ;
3549- vi . doUnmock ( "../vitest/vitest.database-worker-core-paths.mjs" ) ;
3550- vi . doUnmock ( "../vitest/vitest.test-shards.mjs" ) ;
3492+ it . each ( [ "blacksmith" , "hybrid" ] ) (
3493+ "retains parallel capacity and ordered wall budgets for selected %s files" ,
3494+ async ( runnerBackend ) => {
3495+ const config = "test/vitest/vitest.infra.config.ts" ;
3496+ const entries = [
3497+ [ "src/infra/env.test.ts" , "core-runtime-infra-env-auth" , 170 ] ,
3498+ [ "src/infra/os-summary.test.ts" , "core-runtime-infra-misc-os" , 170 ] ,
3499+ [ "src/infra/ports-probe.test.ts" , "core-runtime-infra-system-runtime" , 160 ] ,
3500+ [ "src/infra/provider-usage.test.ts" , "core-runtime-infra-provider-push" , 160 ] ,
3501+ [ "src/infra/channel-runtime-context.test.ts" , "core-runtime-infra-channel-plugin" , 150 ] ,
3502+ [ "src/infra/diagnostic-trace-context.test.ts" , "core-runtime-infra-diagnostics-state" , 150 ] ,
3503+ ] as const ;
3504+ const files = entries . map ( ( [ file ] ) => file ) ;
3505+ const targets = files . slice ( 0 , 3 ) ;
35513506 vi . resetModules ( ) ;
3552- }
3553- } ) ;
3507+ vi . doMock ( "../vitest/vitest.test-shards.mjs" , async ( importOriginal ) => ( {
3508+ ...( await importOriginal < typeof import ( "../vitest/vitest.test-shards.mjs" ) > ( ) ) ,
3509+ fullSuiteVitestShards : [ { name : "core-runtime" , config, projects : [ config ] } ] ,
3510+ } ) ) ;
3511+ vi . doMock ( "../vitest/vitest.database-worker-core-paths.mjs" , async ( importOriginal ) => ( {
3512+ ...( await importOriginal <
3513+ typeof import ( "../vitest/vitest.database-worker-core-paths.mjs" )
3514+ > ( ) ) ,
3515+ databaseWorkerCoreTestFiles : [ ] ,
3516+ isDatabaseWorkerCoreTestFile : ( ) => false ,
3517+ } ) ) ;
3518+ vi . doMock ( "../../scripts/lib/list-test-files.mts" , async ( importOriginal ) => ( {
3519+ ...( await importOriginal < typeof import ( "../../scripts/lib/list-test-files.mts" ) > ( ) ) ,
3520+ listTrackedTestFiles : ( root : string ) => ( root === "src/infra" ? files : [ ] ) ,
3521+ } ) ) ;
3522+ vi . doMock ( "../../scripts/lib/ci-test-timings.mts" , ( ) => ( {
3523+ ...testTimings ,
3524+ readCompactGroupTimings : ( ) =>
3525+ Object . fromEntries ( entries . map ( ( [ , owner , seconds ] ) => [ owner , seconds ] ) ) ,
3526+ readRuntimePlacementTimings : ( ) => [ ] ,
3527+ } ) ) ;
3528+ vi . doMock ( "../../scripts/lib/vitest-build-prerequisites.mts" , async ( importOriginal ) => ( {
3529+ ...( await importOriginal <
3530+ typeof import ( "../../scripts/lib/vitest-build-prerequisites.mts" )
3531+ > ( ) ) ,
3532+ resolveVitestPretestBuildMode : ( ) => undefined ,
3533+ } ) ) ;
3534+ try {
3535+ const {
3536+ createSelectedNodeTestShardBundles : createSelected ,
3537+ createNodeTestShardBundles : createBundles ,
3538+ } = await import ( "../../scripts/lib/ci-node-test-plan.mts" ) ;
3539+ const full = createBundles ( {
3540+ runnerBackend,
3541+ includeReleaseOnlyPluginShards : false ,
3542+ includeProofTests : false ,
3543+ changedPaths : targets ,
3544+ compactMode : "pull-request" ,
3545+ } ) ;
3546+ const selected = expectDefined (
3547+ createSelected ( targets , { runnerBackend } ) ,
3548+ "selected infra plan" ,
3549+ ) ;
3550+ // The selected 170/170/160 envelopes fit the aggregate limit but need 330 seconds together.
3551+ expect ( selected ) . toHaveLength ( 2 ) ;
3552+ expect ( selected . every ( ( job ) => job . planConcurrency === 2 ) ) . toBe ( true ) ;
3553+ for ( const job of selected ) {
3554+ expect ( job . runner ) . toBe ( "blacksmith-32vcpu-ubuntu-2404" ) ;
3555+ for ( const group of job . groups ) {
3556+ const original = expectDefined (
3557+ full . find ( ( owner ) =>
3558+ owner . groups . some ( ( entry ) => entry . shard_name === group . shard_name ) ,
3559+ ) ,
3560+ "canonical template" ,
3561+ ) ;
3562+ const owner = expectDefined (
3563+ original . groups . find ( ( entry ) => entry . shard_name === group . shard_name ) ,
3564+ "canonical group" ,
3565+ ) ;
3566+ expect ( job . planConcurrency ) . toBe ( original . planConcurrency ) ;
3567+ expect ( group . env ) . toEqual ( owner . env ) ;
3568+ expect ( group . fallbackMaxWorkers ) . toBe ( owner . fallbackMaxWorkers ) ;
3569+ }
3570+ }
3571+ expect ( selected . every ( ( job ) => job . predictedTestSeconds ! <= 300 ) ) . toBe ( true ) ;
3572+ expect ( selected . map ( ( job ) => job . predictedTestSeconds ! ) . toSorted ( ( a , b ) => a - b ) ) . toEqual ( [
3573+ 160 , 170 ,
3574+ ] ) ;
3575+ expect ( selected . reduce ( ( sum , job ) => sum + job . predictedSeconds ! , 0 ) ) . toBe ( 500 ) ;
3576+ expect (
3577+ selected
3578+ . flatMap ( ( job ) => job . groups . flatMap ( ( group ) => group . includePatterns ! ) )
3579+ . toSorted ( ) ,
3580+ ) . toEqual ( targets . toSorted ( ) ) ;
3581+ } finally {
3582+ vi . doUnmock ( "../../scripts/lib/vitest-build-prerequisites.mts" ) ;
3583+ vi . doUnmock ( "../../scripts/lib/ci-test-timings.mts" ) ;
3584+ vi . doUnmock ( "../../scripts/lib/list-test-files.mts" ) ;
3585+ vi . doUnmock ( "../vitest/vitest.database-worker-core-paths.mjs" ) ;
3586+ vi . doUnmock ( "../vitest/vitest.test-shards.mjs" ) ;
3587+ vi . resetModules ( ) ;
3588+ }
3589+ } ,
3590+ ) ;
35543591
35553592 async function createToolingFixturePlan ( params : {
35563593 files : string [ ] ;
0 commit comments