@@ -90,28 +90,38 @@ describe("RunEngine Waitpoints", () => {
9090
9191 //waitForDuration
9292 const date = new Date ( Date . now ( ) + durationMs ) ;
93- const result = await engine . waitForDuration ( {
93+ const { waitpoint } = await engine . createDateTimeWaitpoint ( {
94+ projectId : authenticatedEnvironment . project . id ,
95+ environmentId : authenticatedEnvironment . id ,
96+ completedAfter : date ,
97+ } ) ;
98+ expect ( waitpoint . completedAfter ! . toISOString ( ) ) . toBe ( date . toISOString ( ) ) ;
99+
100+ const result = await engine . blockRunWithWaitpoint ( {
94101 runId : run . id ,
95- snapshotId : attemptResult . snapshot . id ,
96- date,
97- releaseConcurrency : false ,
102+ waitpoints : [ waitpoint . id ] ,
103+ environmentId : authenticatedEnvironment . id ,
104+ projectId : authenticatedEnvironment . project . id ,
105+ organizationId : authenticatedEnvironment . organization . id ,
106+ releaseConcurrency : {
107+ releaseQueue : true ,
108+ } ,
98109 } ) ;
99- expect ( result . waitUntil . toISOString ( ) ) . toBe ( date . toISOString ( ) ) ;
100- expect ( result . snapshot . executionStatus ) . toBe ( "EXECUTING_WITH_WAITPOINTS" ) ;
101- expect ( result . run . status ) . toBe ( "EXECUTING" ) ;
110+ expect ( result . executionStatus ) . toBe ( "EXECUTING_WITH_WAITPOINTS" ) ;
111+ expect ( result . runStatus ) . toBe ( "EXECUTING" ) ;
102112
103113 const executionData = await engine . getRunExecutionData ( { runId : run . id } ) ;
104114 expect ( executionData ?. snapshot . executionStatus ) . toBe ( "EXECUTING_WITH_WAITPOINTS" ) ;
105115
106116 await setTimeout ( 2_000 ) ;
107117
108- const waitpoint = await prisma . waitpoint . findFirst ( {
118+ const waitpoint2 = await prisma . waitpoint . findFirst ( {
109119 where : {
110- id : result . waitpoint . id ,
120+ id : waitpoint . id ,
111121 } ,
112122 } ) ;
113- expect ( waitpoint ?. status ) . toBe ( "COMPLETED" ) ;
114- expect ( waitpoint ?. completedAt ?. getTime ( ) ) . toBeLessThanOrEqual ( date . getTime ( ) + 200 ) ;
123+ expect ( waitpoint2 ?. status ) . toBe ( "COMPLETED" ) ;
124+ expect ( waitpoint2 ?. completedAt ?. getTime ( ) ) . toBeLessThanOrEqual ( date . getTime ( ) + 200 ) ;
115125
116126 const executionDataAfter = await engine . getRunExecutionData ( { runId : run . id } ) ;
117127 expect ( executionDataAfter ?. snapshot . executionStatus ) . toBe ( "EXECUTING" ) ;
@@ -199,11 +209,19 @@ describe("RunEngine Waitpoints", () => {
199209
200210 //waitForDuration
201211 const date = new Date ( Date . now ( ) + 60_000 ) ;
202- const result = await engine . waitForDuration ( {
212+ const { waitpoint } = await engine . createDateTimeWaitpoint ( {
213+ projectId : authenticatedEnvironment . project . id ,
214+ environmentId : authenticatedEnvironment . id ,
215+ completedAfter : date ,
216+ } ) ;
217+ expect ( waitpoint . completedAfter ! . toISOString ( ) ) . toBe ( date . toISOString ( ) ) ;
218+
219+ const result = await engine . blockRunWithWaitpoint ( {
203220 runId : run . id ,
204- snapshotId : attemptResult . snapshot . id ,
205- date,
206- releaseConcurrency : false ,
221+ waitpoints : [ waitpoint . id ] ,
222+ environmentId : authenticatedEnvironment . id ,
223+ projectId : authenticatedEnvironment . project . id ,
224+ organizationId : authenticatedEnvironment . organization . id ,
207225 } ) ;
208226
209227 const executionData = await engine . getRunExecutionData ( { runId : run . id } ) ;
@@ -335,18 +353,19 @@ describe("RunEngine Waitpoints", () => {
335353 expect ( attemptResult . snapshot . executionStatus ) . toBe ( "EXECUTING" ) ;
336354
337355 //create a manual waitpoint
338- const waitpoint = await engine . createManualWaitpoint ( {
356+ const result = await engine . createManualWaitpoint ( {
339357 environmentId : authenticatedEnvironment . id ,
340358 projectId : authenticatedEnvironment . projectId ,
341359 } ) ;
342- expect ( waitpoint . status ) . toBe ( "PENDING" ) ;
360+ expect ( result . waitpoint . status ) . toBe ( "PENDING" ) ;
343361
344362 //block the run
345363 await engine . blockRunWithWaitpoint ( {
346364 runId : run . id ,
347- waitpoints : waitpoint . id ,
365+ waitpoints : result . waitpoint . id ,
348366 environmentId : authenticatedEnvironment . id ,
349367 projectId : authenticatedEnvironment . projectId ,
368+ organizationId : authenticatedEnvironment . organizationId ,
350369 } ) ;
351370
352371 const executionData = await engine . getRunExecutionData ( { runId : run . id } ) ;
@@ -361,7 +380,7 @@ describe("RunEngine Waitpoints", () => {
361380 waitpoint : true ,
362381 } ,
363382 } ) ;
364- expect ( runWaitpointBefore ?. waitpointId ) . toBe ( waitpoint . id ) ;
383+ expect ( runWaitpointBefore ?. waitpointId ) . toBe ( result . waitpoint . id ) ;
365384
366385 let event : EventBusEventArgs < "workerNotification" > [ 0 ] | undefined = undefined ;
367386 engine . eventBus . on ( "workerNotification" , ( result ) => {
@@ -370,7 +389,7 @@ describe("RunEngine Waitpoints", () => {
370389
371390 //complete the waitpoint
372391 await engine . completeWaitpoint ( {
373- id : waitpoint . id ,
392+ id : result . waitpoint . id ,
374393 } ) ;
375394
376395 await setTimeout ( 200 ) ;
@@ -476,17 +495,18 @@ describe("RunEngine Waitpoints", () => {
476495 expect ( attemptResult . snapshot . executionStatus ) . toBe ( "EXECUTING" ) ;
477496
478497 //create a manual waitpoint
479- const waitpoint = await engine . createManualWaitpoint ( {
498+ const result = await engine . createManualWaitpoint ( {
480499 environmentId : authenticatedEnvironment . id ,
481500 projectId : authenticatedEnvironment . projectId ,
482501 } ) ;
483502
484503 //block the run
485504 await engine . blockRunWithWaitpoint ( {
486505 runId : run . id ,
487- waitpoints : waitpoint . id ,
506+ waitpoints : result . waitpoint . id ,
488507 environmentId : authenticatedEnvironment . id ,
489508 projectId : authenticatedEnvironment . projectId ,
509+ organizationId : authenticatedEnvironment . organizationId ,
490510 //fail after 200ms
491511 failAfter : new Date ( Date . now ( ) + 200 ) ,
492512 } ) ;
@@ -600,7 +620,7 @@ describe("RunEngine Waitpoints", () => {
600620 const waitpointCount = 5 ;
601621
602622 //create waitpoints
603- const waitpoints = await Promise . all (
623+ const results = await Promise . all (
604624 Array . from ( { length : waitpointCount } ) . map ( ( ) =>
605625 engine . createManualWaitpoint ( {
606626 environmentId : authenticatedEnvironment . id ,
@@ -611,12 +631,13 @@ describe("RunEngine Waitpoints", () => {
611631
612632 //block the run with them
613633 await Promise . all (
614- waitpoints . map ( ( waitpoint ) =>
634+ results . map ( ( result ) =>
615635 engine . blockRunWithWaitpoint ( {
616636 runId : run . id ,
617- waitpoints : waitpoint . id ,
637+ waitpoints : result . waitpoint . id ,
618638 environmentId : authenticatedEnvironment . id ,
619639 projectId : authenticatedEnvironment . projectId ,
640+ organizationId : authenticatedEnvironment . organizationId ,
620641 } )
621642 )
622643 ) ;
@@ -637,9 +658,9 @@ describe("RunEngine Waitpoints", () => {
637658
638659 //complete the waitpoints
639660 await Promise . all (
640- waitpoints . map ( ( waitpoint ) =>
661+ results . map ( ( result ) =>
641662 engine . completeWaitpoint ( {
642- id : waitpoint . id ,
663+ id : result . waitpoint . id ,
643664 } )
644665 )
645666 ) ;
@@ -746,20 +767,21 @@ describe("RunEngine Waitpoints", () => {
746767
747768 //create a manual waitpoint with timeout
748769 const timeout = new Date ( Date . now ( ) + 1_000 ) ;
749- const waitpoint = await engine . createManualWaitpoint ( {
770+ const result = await engine . createManualWaitpoint ( {
750771 environmentId : authenticatedEnvironment . id ,
751772 projectId : authenticatedEnvironment . projectId ,
752773 timeout,
753774 } ) ;
754- expect ( waitpoint . status ) . toBe ( "PENDING" ) ;
755- expect ( waitpoint . completedAfter ) . toStrictEqual ( timeout ) ;
775+ expect ( result . waitpoint . status ) . toBe ( "PENDING" ) ;
776+ expect ( result . waitpoint . completedAfter ) . toStrictEqual ( timeout ) ;
756777
757778 //block the run
758779 await engine . blockRunWithWaitpoint ( {
759780 runId : run . id ,
760- waitpoints : waitpoint . id ,
781+ waitpoints : result . waitpoint . id ,
761782 environmentId : authenticatedEnvironment . id ,
762783 projectId : authenticatedEnvironment . projectId ,
784+ organizationId : authenticatedEnvironment . organizationId ,
763785 } ) ;
764786
765787 const executionData = await engine . getRunExecutionData ( { runId : run . id } ) ;
@@ -774,7 +796,7 @@ describe("RunEngine Waitpoints", () => {
774796 waitpoint : true ,
775797 } ,
776798 } ) ;
777- expect ( runWaitpointBefore ?. waitpointId ) . toBe ( waitpoint . id ) ;
799+ expect ( runWaitpointBefore ?. waitpointId ) . toBe ( result . waitpoint . id ) ;
778800
779801 let event : EventBusEventArgs < "workerNotification" > [ 0 ] | undefined = undefined ;
780802 engine . eventBus . on ( "workerNotification" , ( result ) => {
@@ -803,7 +825,7 @@ describe("RunEngine Waitpoints", () => {
803825
804826 const waitpoint2 = await prisma . waitpoint . findUnique ( {
805827 where : {
806- id : waitpoint . id ,
828+ id : result . waitpoint . id ,
807829 } ,
808830 } ) ;
809831 assertNonNullable ( waitpoint2 ) ;
@@ -898,21 +920,22 @@ describe("RunEngine Waitpoints", () => {
898920 const idempotencyKey = "a-key" ;
899921
900922 //create a manual waitpoint with timeout
901- const waitpoint = await engine . createManualWaitpoint ( {
923+ const result = await engine . createManualWaitpoint ( {
902924 environmentId : authenticatedEnvironment . id ,
903925 projectId : authenticatedEnvironment . projectId ,
904926 idempotencyKey,
905927 } ) ;
906- expect ( waitpoint . status ) . toBe ( "PENDING" ) ;
907- expect ( waitpoint . idempotencyKey ) . toBe ( idempotencyKey ) ;
908- expect ( waitpoint . userProvidedIdempotencyKey ) . toBe ( true ) ;
928+ expect ( result . waitpoint . status ) . toBe ( "PENDING" ) ;
929+ expect ( result . waitpoint . idempotencyKey ) . toBe ( idempotencyKey ) ;
930+ expect ( result . waitpoint . userProvidedIdempotencyKey ) . toBe ( true ) ;
909931
910932 //block the run
911933 await engine . blockRunWithWaitpoint ( {
912934 runId : run . id ,
913- waitpoints : waitpoint . id ,
935+ waitpoints : result . waitpoint . id ,
914936 environmentId : authenticatedEnvironment . id ,
915937 projectId : authenticatedEnvironment . projectId ,
938+ organizationId : authenticatedEnvironment . organizationId ,
916939 } ) ;
917940
918941 const executionData = await engine . getRunExecutionData ( { runId : run . id } ) ;
@@ -927,7 +950,7 @@ describe("RunEngine Waitpoints", () => {
927950 waitpoint : true ,
928951 } ,
929952 } ) ;
930- expect ( runWaitpointBefore ?. waitpointId ) . toBe ( waitpoint . id ) ;
953+ expect ( runWaitpointBefore ?. waitpointId ) . toBe ( result . waitpoint . id ) ;
931954
932955 let event : EventBusEventArgs < "workerNotification" > [ 0 ] | undefined = undefined ;
933956 engine . eventBus . on ( "workerNotification" , ( result ) => {
@@ -936,7 +959,7 @@ describe("RunEngine Waitpoints", () => {
936959
937960 //complete the waitpoint
938961 await engine . completeWaitpoint ( {
939- id : waitpoint . id ,
962+ id : result . waitpoint . id ,
940963 } ) ;
941964
942965 await setTimeout ( 200 ) ;
@@ -961,7 +984,7 @@ describe("RunEngine Waitpoints", () => {
961984
962985 const waitpoint2 = await prisma . waitpoint . findUnique ( {
963986 where : {
964- id : waitpoint . id ,
987+ id : result . waitpoint . id ,
965988 } ,
966989 } ) ;
967990 assertNonNullable ( waitpoint2 ) ;
@@ -1053,30 +1076,31 @@ describe("RunEngine Waitpoints", () => {
10531076 const idempotencyKey = "a-key" ;
10541077
10551078 //create a manual waitpoint with timeout
1056- const waitpoint = await engine . createManualWaitpoint ( {
1079+ const result = await engine . createManualWaitpoint ( {
10571080 environmentId : authenticatedEnvironment . id ,
10581081 projectId : authenticatedEnvironment . projectId ,
10591082 idempotencyKey,
10601083 idempotencyKeyExpiresAt : new Date ( Date . now ( ) + 200 ) ,
10611084 } ) ;
1062- expect ( waitpoint . status ) . toBe ( "PENDING" ) ;
1063- expect ( waitpoint . idempotencyKey ) . toBe ( idempotencyKey ) ;
1064- expect ( waitpoint . userProvidedIdempotencyKey ) . toBe ( true ) ;
1085+ expect ( result . waitpoint . status ) . toBe ( "PENDING" ) ;
1086+ expect ( result . waitpoint . idempotencyKey ) . toBe ( idempotencyKey ) ;
1087+ expect ( result . waitpoint . userProvidedIdempotencyKey ) . toBe ( true ) ;
10651088
1066- const sameWaitpoint = await engine . createManualWaitpoint ( {
1089+ const sameWaitpointResult = await engine . createManualWaitpoint ( {
10671090 environmentId : authenticatedEnvironment . id ,
10681091 projectId : authenticatedEnvironment . projectId ,
10691092 idempotencyKey,
10701093 idempotencyKeyExpiresAt : new Date ( Date . now ( ) + 200 ) ,
10711094 } ) ;
1072- expect ( sameWaitpoint . id ) . toBe ( waitpoint . id ) ;
1095+ expect ( sameWaitpointResult . waitpoint . id ) . toBe ( result . waitpoint . id ) ;
10731096
10741097 //block the run
10751098 await engine . blockRunWithWaitpoint ( {
10761099 runId : run . id ,
1077- waitpoints : waitpoint . id ,
1100+ waitpoints : result . waitpoint . id ,
10781101 environmentId : authenticatedEnvironment . id ,
10791102 projectId : authenticatedEnvironment . projectId ,
1103+ organizationId : authenticatedEnvironment . organizationId ,
10801104 } ) ;
10811105
10821106 const executionData = await engine . getRunExecutionData ( { runId : run . id } ) ;
@@ -1091,7 +1115,7 @@ describe("RunEngine Waitpoints", () => {
10911115 waitpoint : true ,
10921116 } ,
10931117 } ) ;
1094- expect ( runWaitpointBefore ?. waitpointId ) . toBe ( waitpoint . id ) ;
1118+ expect ( runWaitpointBefore ?. waitpointId ) . toBe ( result . waitpoint . id ) ;
10951119
10961120 let event : EventBusEventArgs < "workerNotification" > [ 0 ] | undefined = undefined ;
10971121 engine . eventBus . on ( "workerNotification" , ( result ) => {
@@ -1100,7 +1124,7 @@ describe("RunEngine Waitpoints", () => {
11001124
11011125 //complete the waitpoint
11021126 await engine . completeWaitpoint ( {
1103- id : waitpoint . id ,
1127+ id : result . waitpoint . id ,
11041128 } ) ;
11051129
11061130 await setTimeout ( 200 ) ;
@@ -1125,7 +1149,7 @@ describe("RunEngine Waitpoints", () => {
11251149
11261150 const waitpoint2 = await prisma . waitpoint . findUnique ( {
11271151 where : {
1128- id : waitpoint . id ,
1152+ id : result . waitpoint . id ,
11291153 } ,
11301154 } ) ;
11311155 assertNonNullable ( waitpoint2 ) ;
0 commit comments