@@ -353,6 +353,48 @@ def orchestrator(context, value):
353353 store .download_async .assert_not_called ()
354354
355355
356+ @pytest .mark .parametrize ("use_async" , [False , True ])
357+ @pytest .mark .parametrize ("missing_blobs" , [False , True ])
358+ async def test_replay_skips_scheduled_inputs (monkeypatch , payload_store_factory , use_async , missing_blobs ):
359+ store = payload_store_factory ()
360+ monkeypatch .setattr (payloads , "_payload_store" , store )
361+ request = pb .OrchestratorRequest (instanceId = TEST_INSTANCE_ID )
362+ request .pastEvents .extend ([
363+ helpers .new_orchestrator_started_event (),
364+ helpers .new_execution_started_event ("activity-replay" , TEST_INSTANCE_ID ),
365+ ])
366+ for task_id in range (1 , 21 ):
367+ token = store .upload (json .dumps ("x" * 300_000 ).encode ())
368+ events = request .pastEvents if task_id < 20 else request .newEvents
369+ events .extend ([
370+ helpers .new_orchestrator_started_event (),
371+ helpers .new_task_scheduled_event (task_id , "echo" , encoded_input = json .dumps (token )),
372+ helpers .new_task_completed_event (task_id , json .dumps ("ok" )),
373+ ])
374+ if missing_blobs :
375+ store ._blobs .clear ()
376+ download = store .download
377+ monkeypatch .setattr (store , "download" , Mock (side_effect = download ))
378+ monkeypatch .setattr (store , "download_async" , AsyncMock (side_effect = download ))
379+
380+ def orchestrator (context , value ):
381+ for index in range (20 ):
382+ result = yield context .call_activity ("echo" , input = "x" * 300_000 )
383+ assert result == "ok"
384+ return "complete"
385+
386+ worker = DurableFunctionsWorker ()
387+ encoded = base64 .b64encode (request .SerializeToString ()).decode ()
388+ result = (await worker .execute_orchestration_request_async (orchestrator , encoded ) if use_async
389+ else worker .execute_orchestration_request (orchestrator , encoded ))
390+ completion = _get_completion_action (_decode_orchestrator_response (result ))
391+ assert completion .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
392+ assert json .loads (completion .result .value ) == "complete"
393+ store .download .assert_not_called ()
394+ store .download_async .assert_not_called ()
395+ assert request .pastEvents [3 ].taskScheduled .HasField ("input" )
396+
397+
356398def _encode_orchestrator_request (name , encoded_input = None , instance_id = TEST_INSTANCE_ID ):
357399 """Build a base64-encoded ``OrchestratorRequest`` for a single new dispatch."""
358400 request = pb .OrchestratorRequest (instanceId = instance_id )
0 commit comments