@@ -80,6 +80,11 @@ function collectSqlParams(fragment: unknown): unknown[] {
8080 } )
8181}
8282
83+ /** A swept log as the sweep's update returns it: recent, so it is not marked for the rollup. */
84+ function sweptRun ( id : string ) {
85+ return { id, workspaceId : 'workspace-1' , startedAt : new Date ( ) }
86+ }
87+
8388describe ( 'stale execution cleanup deadline grace' , ( ) => {
8489 beforeEach ( ( ) => {
8590 resetDbChainMock ( )
@@ -324,9 +329,9 @@ describe('stale execution cleanup deadline grace', () => {
324329 } ) )
325330
326331 for ( let batch = 0 ; batch < 10 ; batch ++ ) {
327- const workflowBatch = Array . from ( { length : 100 } , ( _ , index ) => ( {
328- id : `workflow-state-${ batch } -${ index } ` ,
329- } ) )
332+ const workflowBatch = Array . from ( { length : 100 } , ( _ , index ) =>
333+ sweptRun ( `workflow-state-${ batch } -${ index } ` )
334+ )
330335 queueTableRows ( workflowExecutionLogs , workflowBatch )
331336 dbChainMockFns . returning . mockResolvedValueOnce ( workflowBatch )
332337 }
@@ -396,12 +401,10 @@ describe('stale execution cleanup deadline grace', () => {
396401 } )
397402
398403 it ( 'preserves committed workflow cleanup counts when a later batch fails' , async ( ) => {
399- const firstBatch = Array . from ( { length : 100 } , ( _ , index ) => ( {
400- id : `execution-${ index } ` ,
401- } ) )
402- const failedBatch = Array . from ( { length : 37 } , ( _ , index ) => ( {
403- id : `failed-execution-${ index } ` ,
404- } ) )
404+ const firstBatch = Array . from ( { length : 100 } , ( _ , index ) => sweptRun ( `execution-${ index } ` ) )
405+ const failedBatch = Array . from ( { length : 37 } , ( _ , index ) =>
406+ sweptRun ( `failed-execution-${ index } ` )
407+ )
405408 queueTableRows ( workflowExecutionLogs , firstBatch )
406409 queueTableRows ( workflowExecutionLogs , failedBatch )
407410 queueTableRows ( asyncJobs , [ { id : 'async-job-1' } ] )
@@ -426,11 +429,11 @@ describe('stale execution cleanup deadline grace', () => {
426429 } )
427430
428431 it ( 'continues draining when an atomic race updates fewer rows than were selected' , async ( ) => {
429- const firstCandidates = Array . from ( { length : 100 } , ( _ , index ) => ( {
430- id : `execution-${ index } ` ,
431- } ) )
432+ const firstCandidates = Array . from ( { length : 100 } , ( _ , index ) =>
433+ sweptRun ( `execution-${ index } ` )
434+ )
432435 const firstUpdated = firstCandidates . slice ( 0 , 99 )
433- const secondBatch = [ { id : 'execution-100' } ]
436+ const secondBatch = [ sweptRun ( 'execution-100' ) ]
434437 queueTableRows ( workflowExecutionLogs , firstCandidates )
435438 queueTableRows ( workflowExecutionLogs , secondBatch )
436439 dbChainMockFns . returning . mockResolvedValueOnce ( firstUpdated ) . mockResolvedValueOnce ( secondBatch )
0 commit comments