11import { describe , expect , it } from "vitest" ;
2- import { resolveComputeMigration } from "~/runEngine/concerns/computeMigration.server" ;
2+ import {
3+ allowsAnyCompat ,
4+ resolveComputeMigration ,
5+ } from "~/runEngine/concerns/computeMigration.server" ;
36import {
47 environmentWorkerQueueOverride ,
58 workerQueueForBirth ,
@@ -16,6 +19,7 @@ const assignment = {
1619 splitEnabled : true ,
1720 workerGroups : [ { masterQueue : "us-east-1-next" , workloadType : "MICROVM" as const } ] ,
1821 rootTriggerSource : "api" ,
22+ anyCompatAllowed : true ,
1923} ;
2024
2125describe ( "workerQueueForBirth" , ( ) => {
@@ -242,18 +246,21 @@ describe("per-environment worker queue overrides", () => {
242246 environmentId,
243247 environmentType,
244248 } ) ;
249+ const decision = {
250+ planType : "free" ,
251+ orgId : "org_x" ,
252+ orgFeatureFlags,
253+ flags : { computeMigrationEnabled : migrationEnabled , computeMigrationFreePercentage : 100 } ,
254+ templateKey,
255+ } ;
245256 const migrated = resolveComputeMigration ( {
257+ ...decision ,
246258 baseWorkerQueue : "us-east-1" ,
247259 baseEnableFastPath : false ,
248260 region : "us-east-1" ,
249261 backing,
250- planType : "free" ,
251- orgId : "org_x" ,
252- orgFeatureFlags,
253- flags : { computeMigrationEnabled : migrationEnabled , computeMigrationFreePercentage : 100 } ,
254262 envType : environmentType ,
255263 environmentCompat : environmentOverride . compat ,
256- templateKey,
257264 } ) ;
258265 const workerQueue = workerQueueForBirth ( {
259266 workerQueue : migrated . workerQueue ! ,
@@ -266,6 +273,7 @@ describe("per-environment worker queue overrides", () => {
266273 workerGroups,
267274 rootTriggerSource : "api" ,
268275 templateFallback : migrated . templateFallback ,
276+ anyCompatAllowed : allowsAnyCompat ( decision ) ,
269277 } ) ;
270278 return { workerQueue, enableFastPath : migrated . enableFastPath } ;
271279 }
@@ -341,6 +349,7 @@ describe("per-environment worker queue overrides", () => {
341349 splitEnabled : false ,
342350 workerGroups,
343351 rootTriggerSource : "api" ,
352+ anyCompatAllowed : true ,
344353 } ) ;
345354 expect ( birth ( true ) ) . toBe ( "us-east-1:v2:ondemand:fresh:container:stable" ) ;
346355 expect ( birth ( false ) ) . toBe ( "us-east-1-next" ) ;
@@ -372,10 +381,54 @@ describe("per-environment worker queue overrides", () => {
372381 splitEnabled : false ,
373382 workerGroups : [ { masterQueue : "eu-central-1" , workloadType : "CONTAINER" } ] ,
374383 rootTriggerSource : "api" ,
384+ anyCompatAllowed : true ,
375385 } )
376386 ) . toBe ( "eu-central-1:v2:ondemand:fresh:compute:stable" ) ;
377387 } ) ;
378388
389+ const anyOrg = { [ FEATURE_FLAG . workerQueueCompatibility ] : "any" } ;
390+ const anyStaging = {
391+ [ FEATURE_FLAG . workerQueueEnvironmentOverrides ] : { STAGING : { compat : "any" } } ,
392+ } ;
393+ it . each ( [
394+ { migrationEnabled : false , templateKey : "a" . repeat ( 64 ) , compat : "container" } ,
395+ { migrationEnabled : false , templateKey : null , compat : "container" } ,
396+ { migrationEnabled : true , templateKey : null , compat : "container" } ,
397+ { migrationEnabled : true , templateKey : "a" . repeat ( 64 ) , compat : "any" } ,
398+ ] ) (
399+ "gives the any lane only to a migrated org's keyed deployment (migrated=$migrationEnabled, key=$templateKey)" ,
400+ ( { migrationEnabled, templateKey, compat } ) => {
401+ for ( const orgFeatureFlags of [ anyOrg , anyStaging ] ) {
402+ expect ( trigger ( { orgFeatureFlags, migrationEnabled, templateKey } ) . workerQueue ) . toBe (
403+ `us-east-1:v2:ondemand:fresh:${ compat } :stable`
404+ ) ;
405+ }
406+ }
407+ ) ;
408+
409+ it ( "puts a migrated org's keyless any-compat canary run on the stable container channel" , ( ) => {
410+ const canaryOrg = { [ FEATURE_FLAG . workerQueueChannel ] : "canary" } ;
411+ const canaryStaging = {
412+ [ FEATURE_FLAG . workerQueueEnvironmentOverrides ] : { STAGING : { channel : "canary" } } ,
413+ } ;
414+ const anyCanaryStaging = {
415+ [ FEATURE_FLAG . workerQueueEnvironmentOverrides ] : {
416+ STAGING : { compat : "any" , channel : "canary" } ,
417+ } ,
418+ } ;
419+ for ( const orgFeatureFlags of [
420+ { ...anyOrg , ...canaryOrg } ,
421+ { ...anyStaging , ...canaryOrg } ,
422+ { ...anyOrg , ...canaryStaging } ,
423+ anyCanaryStaging ,
424+ ] ) {
425+ expect ( trigger ( { orgFeatureFlags, migrationEnabled : true , templateKey : null } ) ) . toEqual ( {
426+ workerQueue : "us-east-1:v2:ondemand:fresh:container:stable" ,
427+ enableFastPath : false ,
428+ } ) ;
429+ }
430+ } ) ;
431+
379432 it ( "leaves a channel-only override to the org's migration decision" , ( ) => {
380433 const canaryStaging = {
381434 [ FEATURE_FLAG . workerQueueEnvironmentOverrides ] : { STAGING : { channel : "canary" } } ,
0 commit comments