11from tests .test_utils .ContextBuilder import ContextBuilder
2+ from tests .test_utils .testClasses import SerializableClass
23from azure .durable_functions .models .RetryOptions import RetryOptions
34from azure .durable_functions .models .OrchestratorState import OrchestratorState
45from azure .durable_functions .models .DurableOrchestrationContext import DurableOrchestrationContext
@@ -42,6 +43,38 @@ def generator_function(context: DurableOrchestrationContext):
4243
4344 return outputs
4445
46+
47+ def generator_function_with_serialization (context : DurableOrchestrationContext ):
48+ """Orchestrator function for testing retry'ing with serializable input arguments.
49+
50+ Parameters
51+ ----------
52+ context: DurableOrchestrationContext
53+ Durable orchestration context, exposes the Durable API
54+
55+ Returns
56+ -------
57+ List[str]:
58+ Output of activities, a list of hello'd cities
59+ """
60+
61+ outputs = []
62+
63+ retry_options = RETRY_OPTIONS
64+ task1 = yield context .call_activity_with_retry (
65+ "Hello" , retry_options , SerializableClass ("Tokyo" ))
66+ task2 = yield context .call_activity_with_retry (
67+ "Hello" , retry_options , SerializableClass ("Seatlle" ))
68+ task3 = yield context .call_activity_with_retry (
69+ "Hello" , retry_options , SerializableClass ("London" ))
70+
71+ outputs .append (task1 )
72+ outputs .append (task2 )
73+ outputs .append (task3 )
74+
75+ return outputs
76+
77+
4578def get_context_with_retries_and_corrupted_completion () -> ContextBuilder :
4679 """Get a ContextBuilder whose history contains a late completion event
4780 for an event that already failed.
@@ -267,4 +300,18 @@ def test_retries_can_fail():
267300 error_msg = f"{ REASONS } \n { DETAILS } "
268301
269302 expected_error_str = f"{ error_msg } { error_label } "
270- assert str .startswith (error_str , expected_error_str )
303+ assert str .startswith (error_str , expected_error_str )
304+
305+ def test_retries_with_serializable_input ():
306+ """Tests that retried tasks work with serialized input classes."""
307+ context = get_context_with_retries ()
308+
309+ result_1 = get_orchestration_state_result (
310+ context , generator_function )
311+
312+ result_2 = get_orchestration_state_result (
313+ context , generator_function_with_serialization )
314+
315+ assert "output" in result_1
316+ assert "output" in result_2
317+ assert result_1 ["output" ] == result_2 ["output" ]
0 commit comments