@@ -268,62 +268,6 @@ def parent_orchestrator(ctx: task.OrchestrationContext, input: str):
268268 assert child_call_count == 2
269269
270270
271- def test_rewind_does_not_rerun_successful_activities ():
272- """Successful activities must not be re-executed during rewind.
273-
274- The orchestration calls two activities in sequence. The first
275- succeeds and the second fails. After rewind, only the failed
276- activity is retried; the successful activity's result is replayed
277- from history and its body is never called again.
278- """
279- success_call_count = 0
280- fail_call_count = 0
281-
282- def success_activity (_ : task .ActivityContext , input : str ) -> str :
283- nonlocal success_call_count
284- success_call_count += 1
285- return f"ok:{ input } "
286-
287- def fail_activity (_ : task .ActivityContext , input : str ) -> str :
288- nonlocal fail_call_count
289- fail_call_count += 1
290- if fail_call_count == 1 :
291- raise RuntimeError ("Temporary failure" )
292- return f"recovered:{ input } "
293-
294- def orchestrator (ctx : task .OrchestrationContext , input : str ):
295- r1 = yield ctx .call_activity (success_activity , input = input )
296- r2 = yield ctx .call_activity (fail_activity , input = input )
297- return [r1 , r2 ]
298-
299- with DurableTaskSchedulerWorker (host_address = endpoint , secure_channel = True ,
300- taskhub = taskhub_name , token_credential = None ) as w :
301- w .add_orchestrator (orchestrator )
302- w .add_activity (success_activity )
303- w .add_activity (fail_activity )
304- w .start ()
305-
306- c = DurableTaskSchedulerClient (host_address = endpoint , secure_channel = True ,
307- taskhub = taskhub_name , token_credential = None )
308- instance_id = c .schedule_new_orchestration (orchestrator , input = "v" )
309- state = c .wait_for_orchestration_completion (instance_id , timeout = 30 )
310-
311- assert state is not None
312- assert state .runtime_status == client .OrchestrationStatus .FAILED
313-
314- # Rewind – only the failed activity should be retried.
315- c .rewind_orchestration (instance_id , reason = "retry" )
316- state = c .wait_for_orchestration_completion (instance_id , timeout = 30 )
317-
318- assert state is not None
319- assert state .runtime_status == client .OrchestrationStatus .COMPLETED
320- assert state .serialized_output == json .dumps (["ok:v" , "recovered:v" ])
321- # The successful activity must have been called exactly once.
322- assert success_call_count == 1
323- # The failing activity was called twice (once failed, once succeeded).
324- assert fail_call_count == 2
325-
326-
327271def test_rewind_without_reason ():
328272 """Rewind should work when no reason is provided."""
329273 call_count = 0
0 commit comments