@@ -933,6 +933,65 @@ def orchestrator(ctx: task.OrchestrationContext, orchestrator_input):
933933 assert actions [- 1 ].id == 7
934934
935935
936+ def test_activity_retry_preserves_tags ():
937+ """Activity tags are preserved on every retry-generated schedule action."""
938+
939+ def dummy_activity (ctx , _ ):
940+ raise ValueError ("Kah-BOOOOM!!!" )
941+
942+ tags = {
943+ "durabletask.displayName" : "reserve_inventory" ,
944+ "custom" : "value" ,
945+ }
946+
947+ def orchestrator (ctx : task .OrchestrationContext , orchestrator_input ):
948+ return (yield ctx .call_activity (
949+ dummy_activity ,
950+ retry_policy = task .RetryPolicy (
951+ first_retry_interval = timedelta (seconds = 1 ),
952+ max_number_of_attempts = 3 ,
953+ ),
954+ input = orchestrator_input ,
955+ tags = tags ,
956+ ))
957+
958+ registry = worker ._Registry ()
959+ name = registry .add_orchestrator (orchestrator )
960+ current_timestamp = datetime .utcnow ()
961+ old_events = [
962+ helpers .new_orchestrator_started_event (timestamp = current_timestamp ),
963+ helpers .new_execution_started_event (name , TEST_INSTANCE_ID , encoded_input = None ),
964+ helpers .new_task_scheduled_event (1 , task .get_name (dummy_activity )),
965+ ]
966+
967+ for _ in range (2 ):
968+ failed_events = [
969+ helpers .new_orchestrator_started_event (timestamp = current_timestamp ),
970+ helpers .new_task_failed_event (1 , ValueError ("Kah-BOOOOM!!!" )),
971+ ]
972+ executor = worker ._OrchestrationExecutor (registry , TEST_LOGGER , JsonDataConverter ())
973+ result = executor .execute (TEST_INSTANCE_ID , old_events , failed_events )
974+ timer_action = next (action for action in result .actions if action .HasField ("createTimer" ))
975+
976+ old_events += failed_events
977+ current_timestamp = timer_action .createTimer .fireAt .ToDatetime ()
978+ timer_events = [
979+ helpers .new_orchestrator_started_event (current_timestamp ),
980+ helpers .new_timer_fired_event (timer_action .id , current_timestamp ),
981+ ]
982+ executor = worker ._OrchestrationExecutor (registry , TEST_LOGGER , JsonDataConverter ())
983+ result = executor .execute (TEST_INSTANCE_ID , old_events , timer_events )
984+ retry_actions = [
985+ action .scheduleTask
986+ for action in result .actions
987+ if action .HasField ("scheduleTask" )
988+ ]
989+
990+ assert len (retry_actions ) == 1
991+ assert dict (retry_actions [0 ].tags ) == tags
992+ old_events += timer_events
993+
994+
936995def test_activity_retry_without_max_retry_interval ():
937996 """Tests that retry logic works correctly when max_retry_interval is not set.
938997
0 commit comments