From 911f075f7eb20103541024e377af8ead8d05b495 Mon Sep 17 00:00:00 2001 From: David Justo Date: Mon, 16 Aug 2021 11:21:14 -0700 Subject: [PATCH 1/3] inc sequence number in fire-and-forget APIs --- azure/durable_functions/models/DurableOrchestrationContext.py | 1 + 1 file changed, 1 insertion(+) diff --git a/azure/durable_functions/models/DurableOrchestrationContext.py b/azure/durable_functions/models/DurableOrchestrationContext.py index dde2d018..c4979ddf 100644 --- a/azure/durable_functions/models/DurableOrchestrationContext.py +++ b/azure/durable_functions/models/DurableOrchestrationContext.py @@ -473,6 +473,7 @@ def _record_fire_and_forget_action(self, action: Action): else: new_action = [action] self._add_to_actions(new_action) + self._sequence_number += 1 def signal_entity(self, entityId: EntityId, operationName: str, operationInput: Optional[Any] = None): From 7e5d41fc2a34f84a2e4b8c3fc8eb9d58fd7d8a5c Mon Sep 17 00:00:00 2001 From: David Justo Date: Mon, 16 Aug 2021 11:27:55 -0700 Subject: [PATCH 2/3] add test --- tests/orchestrator/test_entity.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/orchestrator/test_entity.py b/tests/orchestrator/test_entity.py index 872066cc..164b2860 100644 --- a/tests/orchestrator/test_entity.py +++ b/tests/orchestrator/test_entity.py @@ -196,6 +196,23 @@ def test_signal_entity_sent(): #assert_valid_schema(result) assert_orchestration_state_equals(expected, result) +def test_signal_entity_sent_and_response_received(): + entityId = df.EntityId("Counter", "myCounter") + context_builder = ContextBuilder('test_simple_function') + add_call_entity_completed_events(context_builder, "add", df.EntityId.get_scheduler_id(entityId), 3, 0) + + + result = get_orchestration_state_result( + context_builder, generator_function_signal_entity) + + expected_state = base_expected_state() + add_signal_entity_action(expected_state, entityId, "add", 3) + add_call_entity_action(expected_state, entityId, "get", None) + expected = expected_state.to_json() + + #assert_valid_schema(result) + assert_orchestration_state_equals(expected, result) + def test_call_entity_raised(): entityId = df.EntityId("Counter", "myCounter") From 21f340443c471ca28d694831224c31aef04cf17d Mon Sep 17 00:00:00 2001 From: David Justo Date: Mon, 16 Aug 2021 12:40:52 -0700 Subject: [PATCH 3/3] fix entity test, serialize strings correctly in continueASNew --- .../durable_functions/models/actions/ContinueAsNewAction.py | 4 +++- tests/orchestrator/test_entity.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/azure/durable_functions/models/actions/ContinueAsNewAction.py b/azure/durable_functions/models/actions/ContinueAsNewAction.py index 76e49f6e..7af0508b 100644 --- a/azure/durable_functions/models/actions/ContinueAsNewAction.py +++ b/azure/durable_functions/models/actions/ContinueAsNewAction.py @@ -3,6 +3,8 @@ from .Action import Action from .ActionType import ActionType from ..utils.json_utils import add_attrib +from json import dumps +from azure.functions._durable_functions import _serialize_custom_object class ContinueAsNewAction(Action): @@ -13,7 +15,7 @@ class ContinueAsNewAction(Action): """ def __init__(self, input_=None): - self.input_ = input_ + self.input_ = dumps(input_, default=_serialize_custom_object) @property def action_type(self) -> int: diff --git a/tests/orchestrator/test_entity.py b/tests/orchestrator/test_entity.py index 164b2860..e4b07ae7 100644 --- a/tests/orchestrator/test_entity.py +++ b/tests/orchestrator/test_entity.py @@ -199,15 +199,16 @@ def test_signal_entity_sent(): def test_signal_entity_sent_and_response_received(): entityId = df.EntityId("Counter", "myCounter") context_builder = ContextBuilder('test_simple_function') - add_call_entity_completed_events(context_builder, "add", df.EntityId.get_scheduler_id(entityId), 3, 0) + add_call_entity_completed_events(context_builder, "get", df.EntityId.get_scheduler_id(entityId), 3, 1) result = get_orchestration_state_result( context_builder, generator_function_signal_entity) - expected_state = base_expected_state() + expected_state = base_expected_state([3]) add_signal_entity_action(expected_state, entityId, "add", 3) add_call_entity_action(expected_state, entityId, "get", None) + expected_state._is_done = True expected = expected_state.to_json() #assert_valid_schema(result)