@@ -37,6 +37,8 @@ import { workerQueueForBirth } from "~/runEngine/concerns/workerQueueAssignment.
3737import { DefaultQueueManager } from "~/runEngine/concerns/queues.server" ;
3838import type { RunEngine } from "~/v3/runEngine.server" ;
3939import { RedisTaskMetadataCache } from "~/services/taskMetadataCache.server" ;
40+ import { FEATURE_FLAG } from "~/v3/featureFlags" ;
41+ import { makeSetFlag } from "~/v3/featureFlags.server" ;
4042import { ChangeCurrentDeploymentService } from "~/v3/services/changeCurrentDeployment.server" ;
4143import { TemplatePrebuildService } from "~/v3/services/templatePrebuild.server" ;
4244import {
@@ -463,7 +465,7 @@ describe("a mixed-runtime group as its region's compute backing", () => {
463465 // One CONTAINER group carries both runtimes; the old MICROVM group is hidden unless asked.
464466 async function setupRegion (
465467 prisma : PrismaClient ,
466- options : { migrated : boolean ; visibleMicrovm ?: boolean }
468+ options : { migrated : boolean ; visibleMicrovm ?: boolean ; globalDefault ?: boolean }
467469 ) {
468470 const environment = await setupAuthenticatedEnvironment ( prisma , "PRODUCTION" ) ;
469471 const group = ( masterQueue : string , workloadType : "CONTAINER" | "MICROVM" , hidden : boolean ) =>
@@ -480,10 +482,17 @@ describe("a mixed-runtime group as its region's compute backing", () => {
480482 } ) ;
481483 const mixed = await group ( "cme-mixed" , "CONTAINER" , false ) ;
482484 await group ( "us-east-1-mvm" , "MICROVM" , ! options . visibleMicrovm ) ;
485+ // With globalDefault, the project has no default group and falls back to the global one.
483486 await prisma . project . update ( {
484487 where : { id : environment . project . id } ,
485- data : { defaultWorkerGroupId : mixed . id } ,
488+ data : { defaultWorkerGroupId : options . globalDefault ? null : mixed . id } ,
486489 } ) ;
490+ if ( options . globalDefault ) {
491+ await makeSetFlag ( prisma ) ( {
492+ key : FEATURE_FLAG . defaultWorkerInstanceGroupId ,
493+ value : mixed . id ,
494+ } ) ;
495+ }
487496 await prisma . organization . update ( {
488497 where : { id : environment . organization . id } ,
489498 data : { featureFlags : { computeMigrationEnabled : options . migrated } } ,
@@ -575,6 +584,23 @@ describe("a mixed-runtime group as its region's compute backing", () => {
575584 }
576585 ) ;
577586
587+ containerTest (
588+ "a migrated org without a project default group is eligible through the global default" ,
589+ async ( { prisma, redisOptions } ) => {
590+ db . client = prisma ;
591+ const { environment, mixed } = await setupRegion ( prisma , {
592+ migrated : true ,
593+ globalDefault : true ,
594+ } ) ;
595+
596+ expect ( await prebuildMode ( prisma , environment . project . id , [ mixed . id ] ) ) . toEqual ( {
597+ mode : "shadow" ,
598+ reason : "migrated" ,
599+ } ) ;
600+ expect ( await birthQueue ( prisma , redisOptions , environment , [ mixed . id ] , KEY ) ) . toBe ( COMPUTE ) ;
601+ }
602+ ) ;
603+
578604 containerTest (
579605 "a migrated org's keyless run on a listed group stays on containers" ,
580606 async ( { prisma, redisOptions } ) => {
0 commit comments