@@ -45,19 +45,35 @@ describe('Fireworks deployment routing', () => {
4545 } )
4646
4747 it ( 'isDeploymentCoolingDown returns false initially' , ( ) => {
48- expect ( isDeploymentCoolingDown ( ) ) . toBe ( false )
48+ expect ( isDeploymentCoolingDown ( DEPLOYMENT_MODEL_ID ) ) . toBe ( false )
4949 } )
5050
5151 it ( 'isDeploymentCoolingDown returns true after markDeploymentScalingUp' , ( ) => {
52- markDeploymentScalingUp ( )
53- expect ( isDeploymentCoolingDown ( ) ) . toBe ( true )
52+ markDeploymentScalingUp ( DEPLOYMENT_MODEL_ID )
53+ expect ( isDeploymentCoolingDown ( DEPLOYMENT_MODEL_ID ) ) . toBe ( true )
5454 } )
5555
5656 it ( 'isDeploymentCoolingDown returns false after resetDeploymentCooldown' , ( ) => {
57- markDeploymentScalingUp ( )
58- expect ( isDeploymentCoolingDown ( ) ) . toBe ( true )
57+ markDeploymentScalingUp ( DEPLOYMENT_MODEL_ID )
58+ expect ( isDeploymentCoolingDown ( DEPLOYMENT_MODEL_ID ) ) . toBe ( true )
5959 resetDeploymentCooldown ( )
60- expect ( isDeploymentCoolingDown ( ) ) . toBe ( false )
60+ expect ( isDeploymentCoolingDown ( DEPLOYMENT_MODEL_ID ) ) . toBe ( false )
61+ } )
62+
63+ it ( 'cooldown on one deployment does not affect other deployments' , ( ) => {
64+ const otherDeployment = 'accounts/james-65d217/deployments/other123'
65+ markDeploymentScalingUp ( DEPLOYMENT_MODEL_ID )
66+ expect ( isDeploymentCoolingDown ( DEPLOYMENT_MODEL_ID ) ) . toBe ( true )
67+ expect ( isDeploymentCoolingDown ( otherDeployment ) ) . toBe ( false )
68+ } )
69+
70+ it ( 'resetDeploymentCooldown with an id only clears that deployment' , ( ) => {
71+ const otherDeployment = 'accounts/james-65d217/deployments/other123'
72+ markDeploymentScalingUp ( DEPLOYMENT_MODEL_ID )
73+ markDeploymentScalingUp ( otherDeployment )
74+ resetDeploymentCooldown ( DEPLOYMENT_MODEL_ID )
75+ expect ( isDeploymentCoolingDown ( DEPLOYMENT_MODEL_ID ) ) . toBe ( false )
76+ expect ( isDeploymentCoolingDown ( otherDeployment ) ) . toBe ( true )
6177 } )
6278
6379 it ( 'DEPLOYMENT_COOLDOWN_MS is 2 minutes' , ( ) => {
@@ -195,8 +211,8 @@ describe('Fireworks deployment routing', () => {
195211 expect ( fetchCalls ) . toHaveLength ( 2 )
196212 expect ( fetchCalls [ 0 ] ) . toBe ( DEPLOYMENT_MODEL_ID )
197213 expect ( fetchCalls [ 1 ] ) . toBe ( STANDARD_MODEL_ID )
198- // Verify cooldown was activated
199- expect ( isDeploymentCoolingDown ( ) ) . toBe ( true )
214+ // Verify cooldown was activated for this specific deployment
215+ expect ( isDeploymentCoolingDown ( DEPLOYMENT_MODEL_ID ) ) . toBe ( true )
200216 } finally {
201217 spy . restore ( )
202218 }
@@ -243,7 +259,7 @@ describe('Fireworks deployment routing', () => {
243259 expect ( fetchCalls [ 0 ] ) . toBe ( DEPLOYMENT_MODEL_ID )
244260 expect ( fetchCalls [ 1 ] ) . toBe ( STANDARD_MODEL_ID )
245261 // Non-scaling 503 should NOT activate the cooldown
246- expect ( isDeploymentCoolingDown ( ) ) . toBe ( false )
262+ expect ( isDeploymentCoolingDown ( DEPLOYMENT_MODEL_ID ) ) . toBe ( false )
247263 } finally {
248264 spy . restore ( )
249265 }
@@ -283,15 +299,15 @@ describe('Fireworks deployment routing', () => {
283299 expect ( fetchCalls ) . toHaveLength ( 2 )
284300 expect ( fetchCalls [ 0 ] ) . toBe ( DEPLOYMENT_MODEL_ID )
285301 expect ( fetchCalls [ 1 ] ) . toBe ( STANDARD_MODEL_ID )
286- expect ( isDeploymentCoolingDown ( ) ) . toBe ( false )
302+ expect ( isDeploymentCoolingDown ( DEPLOYMENT_MODEL_ID ) ) . toBe ( false )
287303 } finally {
288304 spy . restore ( )
289305 }
290306 } )
291307
292308 it ( 'skips deployment during cooldown and goes straight to standard API' , async ( ) => {
293309 const spy = spyDeploymentHours ( true )
294- markDeploymentScalingUp ( )
310+ markDeploymentScalingUp ( DEPLOYMENT_MODEL_ID )
295311
296312 const fetchCalls : string [ ] = [ ]
297313 const mockFetch = mock ( async ( _url : string | URL | Request , init ?: RequestInit ) => {
0 commit comments