@@ -2672,6 +2672,56 @@ func (s *standaloneActivityTestSuite) TestStartToCloseTimeout() {
26722672 "expected StartToCloseTimeout but is %s" , describeResp3 .GetOutcome ().GetFailure ().GetTimeoutFailureInfo ().GetTimeoutType ())
26732673}
26742674
2675+ // TestStartToCloseTimeout_WhileCancelRequested verifies that an activity
2676+ // times out due to start-to-close timeout, after a cancellation request has been accepted.
2677+ func (s * standaloneActivityTestSuite ) TestStartToCloseTimeout_WhileCancelRequested () {
2678+ t := s .T ()
2679+ ctx , cancel := context .WithTimeout (t .Context (), 30 * time .Second )
2680+ defer cancel ()
2681+
2682+ activityID := testcore .RandomizeStr (t .Name ())
2683+ taskQueue := testcore .RandomizeStr (t .Name ())
2684+
2685+ startResp , err := s .FrontendClient ().StartActivityExecution (ctx , & workflowservice.StartActivityExecutionRequest {
2686+ Namespace : s .Namespace ().String (),
2687+ ActivityId : activityID ,
2688+ ActivityType : & commonpb.ActivityType {Name : "test-activity" },
2689+ TaskQueue : & taskqueuepb.TaskQueue {Name : taskQueue },
2690+ StartToCloseTimeout : durationpb .New (2 * time .Second ),
2691+ RetryPolicy : & commonpb.RetryPolicy {MaximumAttempts : 1 },
2692+ })
2693+ require .NoError (t , err )
2694+
2695+ // Worker accepts the task — activity is STARTED.
2696+ _ , err = s .FrontendClient ().PollActivityTaskQueue (ctx , & workflowservice.PollActivityTaskQueueRequest {
2697+ Namespace : s .Namespace ().String (),
2698+ TaskQueue : & taskqueuepb.TaskQueue {Name : taskQueue , Kind : enumspb .TASK_QUEUE_KIND_NORMAL },
2699+ })
2700+ require .NoError (t , err )
2701+
2702+ // Request cancellation — activity moves to CANCEL_REQUESTED.
2703+ _ , err = s .FrontendClient ().RequestCancelActivityExecution (ctx , & workflowservice.RequestCancelActivityExecutionRequest {
2704+ Namespace : s .Namespace ().String (),
2705+ ActivityId : activityID ,
2706+ RunId : startResp .RunId ,
2707+ Identity : "canceller" ,
2708+ RequestId : "cancel-req-1" ,
2709+ })
2710+ require .NoError (t , err )
2711+
2712+ // Worker ignores cancellation and doesn't respond.
2713+ // The start-to-close timeout (2s) should still fire.
2714+ pollOutcome , err := s .FrontendClient ().PollActivityExecution (ctx , & workflowservice.PollActivityExecutionRequest {
2715+ Namespace : s .Namespace ().String (),
2716+ ActivityId : activityID ,
2717+ RunId : startResp .RunId ,
2718+ })
2719+ require .NoError (t , err )
2720+ require .Equal (t , enumspb .TIMEOUT_TYPE_START_TO_CLOSE ,
2721+ pollOutcome .GetOutcome ().GetFailure ().GetTimeoutFailureInfo ().GetTimeoutType (),
2722+ "activity in CANCEL_REQUESTED should still time out via START_TO_CLOSE" )
2723+ }
2724+
26752725// TestScheduleToStartTimeout tests that a schedule-to-start timeout is recorded after the activity is
26762726// created but never started. It also verifies that DescribeActivityExecution can be used to long-poll for a TimedOut
26772727// state change caused by execution of a timer task.
0 commit comments