@@ -434,6 +434,52 @@ func (s *workflowSuite) TestCatchupWindow() {
434434 s .True (workflow .IsContinueAsNewError (s .env .GetWorkflowError ()))
435435}
436436
437+ func (s * workflowSuite ) TestCatchupWindowWhilePaused () {
438+ // written using low-level mocks so we can set initial state
439+
440+ s .env .RegisterDelayedCallback (func () {
441+ // should not count any "misses" since we were paused
442+ s .Equal (int64 (0 ), s .describe ().Info .MissedCatchupWindow )
443+ // unpause just to make the test end cleanly
444+ s .env .SignalWorkflow (SignalNamePatch , & schedpb.SchedulePatch {Unpause : "go ahead" })
445+ }, 3 * time .Minute )
446+ s .expectStart (func (req * schedspb.StartWorkflowRequest ) (* schedspb.StartWorkflowResponse , error ) {
447+ s .True (time .Date (2022 , 6 , 1 , 0 , 17 , 0 , 0 , time .UTC ).Equal (s .now ()))
448+ s .Equal ("myid-2022-06-01T00:17:00Z" , req .Request .WorkflowId )
449+ return nil , nil
450+ })
451+
452+ currentTweakablePolicies .IterationsBeforeContinueAsNew = 3
453+ s .env .SetStartTime (baseStartTime )
454+ s .env .ExecuteWorkflow (SchedulerWorkflow , & schedspb.StartScheduleArgs {
455+ Schedule : & schedpb.Schedule {
456+ Spec : & schedpb.ScheduleSpec {
457+ Calendar : []* schedpb.CalendarSpec {{
458+ Minute : "17" ,
459+ Hour : "*" ,
460+ }},
461+ },
462+ Action : s .defaultAction ("myid" ),
463+ Policies : & schedpb.SchedulePolicies {
464+ CatchupWindow : timestamp .DurationPtr (1 * time .Hour ),
465+ },
466+ State : & schedpb.ScheduleState {
467+ Paused : true ,
468+ },
469+ },
470+ State : & schedspb.InternalState {
471+ Namespace : "myns" ,
472+ NamespaceId : "mynsid" ,
473+ ScheduleId : "myschedule" ,
474+ ConflictToken : InitialConflictToken ,
475+ // workflow "woke up" after 6 hours
476+ LastProcessedTime : timestamp .TimePtr (time .Date (2022 , 5 , 31 , 18 , 0 , 0 , 0 , time .UTC )),
477+ },
478+ })
479+ s .True (s .env .IsWorkflowCompleted ())
480+ s .True (workflow .IsContinueAsNewError (s .env .GetWorkflowError ()), s .env .GetWorkflowError ())
481+ }
482+
437483func (s * workflowSuite ) TestOverlapSkip () {
438484 s .runAcrossContinue (
439485 []workflowRun {
0 commit comments