From a7cb7f8278cbc8e4ddffe8ca142889eaf47b7dfa Mon Sep 17 00:00:00 2001 From: Yves Bastide Date: Fri, 3 Mar 2017 18:54:19 +0100 Subject: [PATCH 1/3] Executor.signal: workflow_id, run_id in kwargs Cannot use both positional and keyword arguments... Signed-off-by: Yves Bastide --- simpleflow/swf/executor.py | 27 ++++++++++++++++----------- simpleflow/swf/task.py | 14 ++++++++++++-- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/simpleflow/swf/executor.py b/simpleflow/swf/executor.py index e4ca7ed6e..4a5b111c3 100644 --- a/simpleflow/swf/executor.py +++ b/simpleflow/swf/executor.py @@ -758,7 +758,7 @@ def submit(self, func, *args, **kwargs): elif isinstance(func, base_task.WorkflowTask): func = WorkflowTask.from_generic_task(func) elif isinstance(func, base_task.SignalTask): - func = SignalTask.from_generic_task(func, self._workflow_id, self._run_id, None, None) + func = SignalTask.from_generic_task(func, self._workflow_id, self._run_id) elif isinstance(func, base_task.MarkerTask): func = MarkerTask.from_generic_task(func) @@ -971,30 +971,35 @@ def _workflow_id(self): def _run_id(self): return self._execution_context.get('run_id') - def signal(self, name, workflow_id=None, run_id=None, propagate=True, *args, **kwargs): + def signal(self, name, *args, **kwargs): """ Send a signal. :param name: - :param workflow_id: - :param run_id: - :param propagate: :param args: :param kwargs: - :return: + :return: Signal task + :rtype: SignalTask """ + workflow_id = kwargs.pop('workflow_id', None) + run_id = kwargs.pop('run_id', None) + propagate = kwargs.pop('propagate', True) + if not workflow_id: + workflow_id = self._workflow_id + run_id = self._run_id logger.debug('signal: name={name}, workflow_id={workflow_id}, run_id={run_id}, propagate={propagate}'.format( name=name, - workflow_id=workflow_id if workflow_id else self._workflow_id, - run_id=run_id if workflow_id else self._run_id, + workflow_id=workflow_id, + run_id=run_id, propagate=propagate, )) extra_input = {'__propagate': False} if not propagate else None return SignalTask( name, - workflow_id=workflow_id if workflow_id else self._workflow_id, - run_id=run_id if workflow_id else self._run_id, - extra_input=extra_input, + workflow_id, + run_id, + None, + extra_input, *args, **kwargs ) diff --git a/simpleflow/swf/task.py b/simpleflow/swf/task.py index 3389b4ff4..67736d327 100644 --- a/simpleflow/swf/task.py +++ b/simpleflow/swf/task.py @@ -163,10 +163,20 @@ class SignalTask(task.SignalTask, SwfTask): Signal "task" on SWF. """ @classmethod - def from_generic_task(cls, a_task, workflow_id, run_id, control, extra_input): + def from_generic_task(cls, a_task, default_workflow_id, default_run_id): + workflow_id = a_task.kwargs.pop('workflow_id', None) + run_id = a_task.kwargs.pop('run_id', None) + propagate = a_task.kwargs.pop('propagate', True) + if not workflow_id: + workflow_id = default_workflow_id + run_id = default_run_id + + extra_input = {'__propagate': False} if not propagate else None + control = None + return cls(a_task.name, workflow_id, run_id, control, extra_input, *a_task.args, **a_task.kwargs) - def __init__(self, name, workflow_id, run_id, control=None, extra_input=None, *args, **kwargs): + def __init__(self, name, workflow_id, run_id, control, extra_input, *args, **kwargs): super(SignalTask, self).__init__(name, *args, **kwargs) self.workflow_id = workflow_id self.run_id = run_id From 63c8b287fd6db40f4685c9bdf5fe99195d4d860c Mon Sep 17 00:00:00 2001 From: Yves Bastide Date: Fri, 3 Mar 2017 18:55:47 +0100 Subject: [PATCH 2/3] Add signals integration tests Two tests: * one where a signal is sent once (normal case) * one where the signal is sent twice (because it's not waited on). Don't count on this behavior! Signed-off-by: Yves Bastide --- tests/data/__init__.py | 3 + tests/integration/__init__.py | 2 +- .../test_signal_played_once_by_default.yaml | 111 ++++++++++++++++++ .../cassettes/test_signal_played_twice.yaml | 111 ++++++++++++++++++ tests/integration/test_commands.py | 21 +--- tests/integration/test_signals.py | 33 ++++++ tests/integration/workflow.py | 33 +++++- tests/test_simpleflow/swf/test_executor.py | 25 +--- tests/utils.py | 29 ++++- 9 files changed, 321 insertions(+), 47 deletions(-) create mode 100644 tests/integration/cassettes/test_signal_played_once_by_default.yaml create mode 100644 tests/integration/cassettes/test_signal_played_twice.yaml create mode 100644 tests/integration/test_signals.py diff --git a/tests/data/__init__.py b/tests/data/__init__.py index 573836479..3d8a798b9 100644 --- a/tests/data/__init__.py +++ b/tests/data/__init__.py @@ -1,3 +1,6 @@ from .activities import * from .constants import * from .workflows import * + +WORKFLOW = "basic" +TASK_LIST = "example" diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index cec49c270..6463699f6 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -84,7 +84,7 @@ def invoke(self, command, arguments): # type: (str, Union(str, List[str])) -> Result if not hasattr(self, "runner"): self.runner = CliRunner() - if isinstance(arguments, str): + if not isinstance(arguments, (list, tuple)): arguments = arguments.split(" ") print('simpleflow {} {}'.format(command, ' '.join(arguments))) return self.runner.invoke(command, arguments, catch_exceptions=False) diff --git a/tests/integration/cassettes/test_signal_played_once_by_default.yaml b/tests/integration/cassettes/test_signal_played_once_by_default.yaml new file mode 100644 index 000000000..2594b6e94 --- /dev/null +++ b/tests/integration/cassettes/test_signal_played_once_by_default.yaml @@ -0,0 +1,111 @@ +interactions: +- request: + body: !!python/unicode '{"domain": "TestDomain", "workflowType": {"version": "example", + "name": "basic"}}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['81'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] + X-Amz-Date: [20170302T173752Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowType] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"configuration":{"defaultChildPolicy":"TERMINATE","defaultExecutionStartToCloseTimeout":"300","defaultTaskList":{"name":"None"},"defaultTaskStartToCloseTimeout":"300"},"typeInfo":{"creationDate":1.435159034741E9,"status":"REGISTERED","workflowType":{"name":"basic","version":"example"}}}'} + headers: + content-length: ['288'] + content-type: [application/json] + x-amzn-requestid: [f652dd7a-ff6e-11e6-9d27-49ea4ba39529] + status: {code: 200, message: OK} +- request: + body: !!python/unicode '{"domain": "TestDomain", "taskList": {"name": "test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"}, + "childPolicy": "TERMINATE", "input": "{\"args\":[true]}", "workflowType": {"version": + "example", "name": "basic"}, "workflowId": "test-simpleflow-workflow"}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['264'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] + X-Amz-Date: [20170302T173752Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.StartWorkflowExecution] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"runId":"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY="}'} + headers: + content-length: ['58'] + content-type: [application/json] + x-amzn-requestid: [f68b7a50-ff6e-11e6-9667-25907cf9f9e8] + status: {code: 200, message: OK} +- request: + body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", + "runId": "224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY="}}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['140'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] + X-Amz-Date: [20170302T173755Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowExecution] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"executionConfiguration":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"},"taskStartToCloseTimeout":"300"},"executionInfo":{"cancelRequested":false,"execution":{"runId":"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=","workflowId":"test-simpleflow-workflow"},"executionStatus":"OPEN","startTimestamp":1.488476272965E9,"workflowType":{"name":"basic","version":"example"}},"openCounts":{"openActivityTasks":0,"openChildWorkflowExecutions":0,"openDecisionTasks":1,"openLambdaFunctions":0,"openTimers":0}}'} + headers: + content-length: ['597'] + content-type: [application/json] + x-amzn-requestid: [f8159c05-ff6e-11e6-bfdf-110dd4d1b4a7] + status: {code: 200, message: OK} +- request: + body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", + "runId": "224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY="}}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['140'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] + X-Amz-Date: [20170302T173757Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowExecution] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"executionConfiguration":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"},"taskStartToCloseTimeout":"300"},"executionInfo":{"cancelRequested":false,"closeStatus":"COMPLETED","closeTimestamp":1.488476277319E9,"execution":{"runId":"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=","workflowId":"test-simpleflow-workflow"},"executionStatus":"CLOSED","startTimestamp":1.488476272965E9,"workflowType":{"name":"basic","version":"example"}},"openCounts":{"openActivityTasks":0,"openChildWorkflowExecutions":0,"openDecisionTasks":0,"openLambdaFunctions":0,"openTimers":0}}'} + headers: + content-length: ['659'] + content-type: [application/json] + x-amzn-requestid: [f98531dc-ff6e-11e6-b6f2-332d5d7bf4ec] + status: {code: 200, message: OK} +- request: + body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", + "runId": "224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY="}}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['140'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] + X-Amz-Date: [20170302T173858Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.GetWorkflowExecutionHistory] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"events":[{"eventId":1,"eventTimestamp":1.488476272965E9,"eventType":"WorkflowExecutionStarted","workflowExecutionStartedEventAttributes":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","input":"{\"args\":[true]}","parentInitiatedEventId":0,"taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"},"taskStartToCloseTimeout":"300","workflowType":{"name":"basic","version":"example"}}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"}},"eventId":2,"eventTimestamp":1.488476272965E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27872,\"user\":\"zeb\"}","scheduledEventId":2},"eventId":3,"eventTimestamp":1.488476273148E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":2,"startedEventId":3},"eventId":4,"eventTimestamp":1.488476273557E9,"eventType":"DecisionTaskCompleted"},{"eventId":5,"eventTimestamp":1.488476273557E9,"eventType":"SignalExternalWorkflowExecutionInitiated","signalExternalWorkflowExecutionInitiatedEventAttributes":{"decisionTaskCompletedEventId":4,"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[1],\"__run_id\":\"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=\",\"kwargs\":{}}","runId":"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=","signalName":"signal","workflowId":"test-simpleflow-workflow"}},{"eventId":6,"eventTimestamp":1.488476273596E9,"eventType":"WorkflowExecutionSignaled","workflowExecutionSignaledEventAttributes":{"externalInitiatedEventId":5,"externalWorkflowExecution":{"runId":"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=","workflowId":"test-simpleflow-workflow"},"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[1],\"__run_id\":\"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=\",\"kwargs\":{}}","signalName":"signal"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"}},"eventId":7,"eventTimestamp":1.488476273596E9,"eventType":"DecisionTaskScheduled"},{"eventId":8,"eventTimestamp":1.488476273609E9,"eventType":"ExternalWorkflowExecutionSignaled","externalWorkflowExecutionSignaledEventAttributes":{"initiatedEventId":5,"workflowExecution":{"runId":"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=","workflowId":"test-simpleflow-workflow"}}},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27872,\"user\":\"zeb\"}","scheduledEventId":7},"eventId":9,"eventTimestamp":1.48847627396E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":7,"startedEventId":9},"eventId":10,"eventTimestamp":1.48847627438E9,"eventType":"DecisionTaskCompleted"},{"eventId":11,"eventTimestamp":1.48847627438E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":10,"markerName":"marker + 1"}},{"eventId":12,"eventTimestamp":1.48847627438E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":10,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":13,"eventTimestamp":1.488476274394E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":12,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"}},"eventId":14,"eventTimestamp":1.488476274394E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27872,\"user\":\"zeb\"}","scheduledEventId":14},"eventId":15,"eventTimestamp":1.488476274827E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":14,"startedEventId":15},"eventId":16,"eventTimestamp":1.488476275268E9,"eventType":"DecisionTaskCompleted"},{"eventId":17,"eventTimestamp":1.488476275268E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":16,"markerName":"marker + 2"}},{"eventId":18,"eventTimestamp":1.488476275268E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":16,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":19,"eventTimestamp":1.48847627528E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":18,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"}},"eventId":20,"eventTimestamp":1.48847627528E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27872,\"user\":\"zeb\"}","scheduledEventId":20},"eventId":21,"eventTimestamp":1.488476275744E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":20,"startedEventId":21},"eventId":22,"eventTimestamp":1.488476276481E9,"eventType":"DecisionTaskCompleted"},{"eventId":23,"eventTimestamp":1.488476276481E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":22,"markerName":"marker + 3"}},{"eventId":24,"eventTimestamp":1.488476276481E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":22,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":25,"eventTimestamp":1.488476276497E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":24,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"}},"eventId":26,"eventTimestamp":1.488476276497E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27872,\"user\":\"zeb\"}","scheduledEventId":26},"eventId":27,"eventTimestamp":1.488476276902E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":26,"startedEventId":27},"eventId":28,"eventTimestamp":1.488476277319E9,"eventType":"DecisionTaskCompleted"},{"eventId":29,"eventTimestamp":1.488476277319E9,"eventType":"WorkflowExecutionCompleted","workflowExecutionCompletedEventAttributes":{"decisionTaskCompletedEventId":28,"result":"null"}}]}'} + headers: + content-length: ['6565'] + content-type: [application/json] + x-amzn-requestid: [1dc10359-ff6f-11e6-863d-5733ea0eb9aa] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/integration/cassettes/test_signal_played_twice.yaml b/tests/integration/cassettes/test_signal_played_twice.yaml new file mode 100644 index 000000000..c8c737ab0 --- /dev/null +++ b/tests/integration/cassettes/test_signal_played_twice.yaml @@ -0,0 +1,111 @@ +interactions: +- request: + body: !!python/unicode '{"domain": "TestDomain", "workflowType": {"version": "example", + "name": "basic"}}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['81'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] + X-Amz-Date: [20170302T173858Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowType] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"configuration":{"defaultChildPolicy":"TERMINATE","defaultExecutionStartToCloseTimeout":"300","defaultTaskList":{"name":"None"},"defaultTaskStartToCloseTimeout":"300"},"typeInfo":{"creationDate":1.435159034741E9,"status":"REGISTERED","workflowType":{"name":"basic","version":"example"}}}'} + headers: + content-length: ['288'] + content-type: [application/json] + x-amzn-requestid: [1e15da10-ff6f-11e6-8e40-97845affe6f0] + status: {code: 200, message: OK} +- request: + body: !!python/unicode '{"domain": "TestDomain", "taskList": {"name": "test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"}, + "childPolicy": "TERMINATE", "input": "{\"args\":[false]}", "workflowType": {"version": + "example", "name": "basic"}, "workflowId": "test-simpleflow-workflow"}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['265'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] + X-Amz-Date: [20170302T173859Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.StartWorkflowExecution] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk="}'} + headers: + content-length: ['58'] + content-type: [application/json] + x-amzn-requestid: [1e537f5c-ff6f-11e6-82a1-8536ef9790ab] + status: {code: 200, message: OK} +- request: + body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", + "runId": "22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk="}}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['140'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] + X-Amz-Date: [20170302T173901Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowExecution] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"executionConfiguration":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"},"taskStartToCloseTimeout":"300"},"executionInfo":{"cancelRequested":false,"execution":{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","workflowId":"test-simpleflow-workflow"},"executionStatus":"OPEN","startTimestamp":1.488476339688E9,"workflowType":{"name":"basic","version":"example"}},"openCounts":{"openActivityTasks":0,"openChildWorkflowExecutions":0,"openDecisionTasks":1,"openLambdaFunctions":0,"openTimers":0}}'} + headers: + content-length: ['597'] + content-type: [application/json] + x-amzn-requestid: [1fc62205-ff6f-11e6-980b-cd693c7fefbe] + status: {code: 200, message: OK} +- request: + body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", + "runId": "22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk="}}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['140'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] + X-Amz-Date: [20170302T173904Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowExecution] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"executionConfiguration":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"},"taskStartToCloseTimeout":"300"},"executionInfo":{"cancelRequested":false,"closeStatus":"COMPLETED","closeTimestamp":1.488476342708E9,"execution":{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","workflowId":"test-simpleflow-workflow"},"executionStatus":"CLOSED","startTimestamp":1.488476339688E9,"workflowType":{"name":"basic","version":"example"}},"openCounts":{"openActivityTasks":0,"openChildWorkflowExecutions":0,"openDecisionTasks":0,"openLambdaFunctions":0,"openTimers":0}}'} + headers: + content-length: ['659'] + content-type: [application/json] + x-amzn-requestid: [21356962-ff6f-11e6-a413-4ff367a4d482] + status: {code: 200, message: OK} +- request: + body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", + "runId": "22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk="}}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['140'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] + X-Amz-Date: [20170302T174003Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.GetWorkflowExecutionHistory] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"events":[{"eventId":1,"eventTimestamp":1.488476339688E9,"eventType":"WorkflowExecutionStarted","workflowExecutionStartedEventAttributes":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","input":"{\"args\":[false]}","parentInitiatedEventId":0,"taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"},"taskStartToCloseTimeout":"300","workflowType":{"name":"basic","version":"example"}}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"}},"eventId":2,"eventTimestamp":1.488476339688E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27931,\"user\":\"zeb\"}","scheduledEventId":2},"eventId":3,"eventTimestamp":1.488476339758E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":2,"startedEventId":3},"eventId":4,"eventTimestamp":1.488476340233E9,"eventType":"DecisionTaskCompleted"},{"eventId":5,"eventTimestamp":1.488476340233E9,"eventType":"SignalExternalWorkflowExecutionInitiated","signalExternalWorkflowExecutionInitiatedEventAttributes":{"decisionTaskCompletedEventId":4,"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[1],\"__run_id\":\"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=\",\"kwargs\":{}}","runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","signalName":"signal","workflowId":"test-simpleflow-workflow"}},{"eventId":6,"eventTimestamp":1.488476340233E9,"eventType":"SignalExternalWorkflowExecutionInitiated","signalExternalWorkflowExecutionInitiatedEventAttributes":{"decisionTaskCompletedEventId":4,"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[2],\"__run_id\":\"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=\",\"kwargs\":{}}","runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","signalName":"signal","workflowId":"test-simpleflow-workflow"}},{"eventId":7,"eventTimestamp":1.488476340233E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":4,"markerName":"marker + 1"}},{"eventId":8,"eventTimestamp":1.488476340233E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":4,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":9,"eventTimestamp":1.488476340253E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":8,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"}},"eventId":10,"eventTimestamp":1.488476340253E9,"eventType":"DecisionTaskScheduled"},{"eventId":11,"eventTimestamp":1.488476340307E9,"eventType":"WorkflowExecutionSignaled","workflowExecutionSignaledEventAttributes":{"externalInitiatedEventId":6,"externalWorkflowExecution":{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","workflowId":"test-simpleflow-workflow"},"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[2],\"__run_id\":\"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=\",\"kwargs\":{}}","signalName":"signal"}},{"eventId":12,"eventTimestamp":1.488476340316E9,"eventType":"WorkflowExecutionSignaled","workflowExecutionSignaledEventAttributes":{"externalInitiatedEventId":5,"externalWorkflowExecution":{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","workflowId":"test-simpleflow-workflow"},"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[1],\"__run_id\":\"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=\",\"kwargs\":{}}","signalName":"signal"}},{"eventId":13,"eventTimestamp":1.488476340329E9,"eventType":"ExternalWorkflowExecutionSignaled","externalWorkflowExecutionSignaledEventAttributes":{"initiatedEventId":6,"workflowExecution":{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","workflowId":"test-simpleflow-workflow"}}},{"eventId":14,"eventTimestamp":1.488476340337E9,"eventType":"ExternalWorkflowExecutionSignaled","externalWorkflowExecutionSignaledEventAttributes":{"initiatedEventId":5,"workflowExecution":{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","workflowId":"test-simpleflow-workflow"}}},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27931,\"user\":\"zeb\"}","scheduledEventId":10},"eventId":15,"eventTimestamp":1.488476340629E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":10,"startedEventId":15},"eventId":16,"eventTimestamp":1.488476341024E9,"eventType":"DecisionTaskCompleted"},{"eventId":17,"eventTimestamp":1.488476341024E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":16,"markerName":"marker + 2"}},{"eventId":18,"eventTimestamp":1.488476341024E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":16,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":19,"eventTimestamp":1.488476341036E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":18,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"}},"eventId":20,"eventTimestamp":1.488476341036E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27931,\"user\":\"zeb\"}","scheduledEventId":20},"eventId":21,"eventTimestamp":1.488476341435E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":20,"startedEventId":21},"eventId":22,"eventTimestamp":1.488476341886E9,"eventType":"DecisionTaskCompleted"},{"eventId":23,"eventTimestamp":1.488476341886E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":22,"markerName":"marker + 3"}},{"eventId":24,"eventTimestamp":1.488476341886E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":22,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":25,"eventTimestamp":1.488476341908E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":24,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"}},"eventId":26,"eventTimestamp":1.488476341908E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27931,\"user\":\"zeb\"}","scheduledEventId":26},"eventId":27,"eventTimestamp":1.488476342303E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":26,"startedEventId":27},"eventId":28,"eventTimestamp":1.488476342708E9,"eventType":"DecisionTaskCompleted"},{"eventId":29,"eventTimestamp":1.488476342708E9,"eventType":"WorkflowExecutionCompleted","workflowExecutionCompletedEventAttributes":{"decisionTaskCompletedEventId":28,"result":"null"}}]}'} + headers: + content-length: ['7161'] + content-type: [application/json] + x-amzn-requestid: [4467e1ce-ff6f-11e6-87a6-0fd8451cf51d] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/integration/test_commands.py b/tests/integration/test_commands.py index a05c74c45..31b908167 100644 --- a/tests/integration/test_commands.py +++ b/tests/integration/test_commands.py @@ -5,14 +5,11 @@ from sure import expect import simpleflow.command + from . import vcr, VCRIntegrationTest class TestSimpleflowCommand(VCRIntegrationTest): - def invoke(self, command, arguments): - if not hasattr(self, "runner"): - self.runner = CliRunner() - return self.runner.invoke(command, arguments.split(" ")) def cleanup_sleep_workflow(self): # ideally this should be in a tearDown() or setUp() call, but those @@ -80,7 +77,7 @@ def test_simpleflow_activity_rerun(self): # run a very short workflow result = self.invoke( simpleflow.command.cli, - "standalone --workflow-id %s --input {\"args\":[0]} --nb-workers 1 " \ + "standalone --workflow-id %s --input {\"args\":[0]} --nb-workers 1 " "--nb-deciders 1 tests.integration.workflow.SleepWorkflow" % self.workflow_id ) expect(result.exit_code).to.equal(0) @@ -103,18 +100,7 @@ def test_simpleflow_activity_rerun(self): @flaky(max_runs=2) @vcr.use_cassette def test_simpleflow_idempotent(self): - result = self.invoke( - simpleflow.command.cli, - "standalone --workflow-id %s --input {}" - " --nb-deciders 2 --nb-workers 2" - " tests.integration.workflow.ATestDefinitionWithIdempotentTask" % self.workflow_id - ) - expect(result.exit_code).to.equal(0) - lines = result.output.split("\n") - start_line = [line for line in lines if line.startswith(self.workflow_id)][0] - _, run_id = start_line.split(" ", 1) - - events = self.get_events(run_id) + events = self.run_standalone("tests.integration.workflow.ATestDefinitionWithIdempotentTask") activities = [ e['activityTaskScheduledEventAttributes']['activityId'] @@ -134,7 +120,6 @@ def test_simpleflow_idempotent(self): expect(failures).should_not.contain('ACTIVITY_ID_ALREADY_IN_USE') # TODO: simpleflow decider.start -# TODO: simpleflow standalone # TODO: simpleflow task.info # TODO: simpleflow worker.start # TODO: simpleflow workflow.filter diff --git a/tests/integration/test_signals.py b/tests/integration/test_signals.py new file mode 100644 index 000000000..7ab21f8a5 --- /dev/null +++ b/tests/integration/test_signals.py @@ -0,0 +1,33 @@ +import unittest + +from flaky import flaky +from sure import expect + +import simpleflow.command +from tests.integration import VCRIntegrationTest, vcr + + +class TestSignals(VCRIntegrationTest): + @flaky(max_runs=2) + @vcr.use_cassette + def test_signal_played_once_by_default(self): + events = self.run_standalone('tests.integration.workflow.ASignalingTestParentWorkflow', True) + signals_initiated = filter( + lambda e: e["eventType"] == "SignalExternalWorkflowExecutionInitiated", + events + ) + expect(len(list(signals_initiated))).to.equal(1) + + @flaky(max_runs=2) + @vcr.use_cassette + def test_signal_played_twice(self): + events = self.run_standalone('tests.integration.workflow.ASignalingTestParentWorkflow', False) + signals_initiated = filter( + lambda e: e["eventType"] == "SignalExternalWorkflowExecutionInitiated", + events + ) + expect(len(list(signals_initiated))).to.equal(2) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/integration/workflow.py b/tests/integration/workflow.py index 66bbad2cf..0fe42daa7 100644 --- a/tests/integration/workflow.py +++ b/tests/integration/workflow.py @@ -50,8 +50,34 @@ def run(self): assert results[0].result != results[-1].result +@activity.with_attributes(task_list='quickstart', version='example', idempotent=True) +def get_uuid(unused=None): + return str(uuid.uuid4()) + + +class ASignalingTestParentWorkflow(Workflow): + name = 'basic' + version = 'example' + task_list = 'example' + decision_tasks_timeout = '300' + execution_timeout = '3600' + + def run(self, wait_after_first): + # Signaled twice since there's no barrier + sig = self.submit(self.signal('signal', 1)) + if wait_after_first: + futures.wait(sig) + sig = self.submit(self.signal('signal', 2)) + futures.wait(self.submit(self.record_marker('marker 1'))) + sig_again = self.submit(self.signal('signal', 3)) + futures.wait(self.submit(self.record_marker('marker 2'))) + sig_ter = self.submit(self.signal('signal', 8, foo='bar')) + futures.wait(self.submit(self.record_marker('marker 3'))) + futures.wait(sig, sig_again, sig_ter) + + class MarkerWorkflow(Workflow): - name = 'example' + name = 'basic' version = 'example' task_list = 'example' decision_tasks_timeout = '300' @@ -72,8 +98,3 @@ def run(self, use_chain): self.submit(m2) self.submit(m3) futures.wait(future) - - -@activity.with_attributes(task_list='quickstart', version='example', idempotent=True) -def get_uuid(unused=None): - return str(uuid.uuid4()) diff --git a/tests/test_simpleflow/swf/test_executor.py b/tests/test_simpleflow/swf/test_executor.py index f47abe3ee..1118dab8e 100644 --- a/tests/test_simpleflow/swf/test_executor.py +++ b/tests/test_simpleflow/swf/test_executor.py @@ -1,7 +1,3 @@ -import unittest - -import boto -from moto import mock_swf from sure import expect from simpleflow import activity, futures @@ -10,8 +6,10 @@ from tests.data import ( BaseTestWorkflow, DOMAIN, + TASK_LIST, increment, ) +from tests.utils import SimpleflowTestCase @activity.with_attributes(task_priority=32) @@ -40,25 +38,10 @@ def run(self): futures.wait(a, b, c, d, e) -@mock_swf -class TestSimpleflowSwfExecutor(unittest.TestCase): - def setUp(self): - self.conn = boto.connect_swf() - self.conn.register_domain("TestDomain", "50") - self.conn.register_workflow_type( - "TestDomain", "test-workflow", "v1.2", - task_list="test-task-list", default_child_policy="TERMINATE", - default_execution_start_to_close_timeout="6", - default_task_start_to_close_timeout="3", - ) - self.conn.start_workflow_execution("TestDomain", "wfe-1234", - "test-workflow", "v1.2") - - def tearDown(self): - pass +class TestSimpleflowSwfExecutor(SimpleflowTestCase): def test_submit_resolves_priority(self): - response = Decider(DOMAIN, "test-task-list").poll() + response = Decider(DOMAIN, TASK_LIST).poll() executor = Executor(DOMAIN, ExampleWorkflow) decisions, _ = executor.replay(response) diff --git a/tests/utils.py b/tests/utils.py index d62f91232..881351486 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,11 +1,16 @@ import os -import platform import re import signal import unittest +import boto +from moto import mock_swf from psutil import Process, NoSuchProcess +from tests.data import WORKFLOW, DEFAULT_VERSION, TASK_LIST + +DOMAIN = "TestDomain" + class IntegrationTestCase(unittest.TestCase): def tearDown(self): @@ -30,3 +35,25 @@ def assertProcess(self, regex, count=1): count, regex, len(matching), children ) ) + + +@mock_swf +class SimpleflowTestCase(unittest.TestCase): + def setUp(self): + self.conn = boto.connect_swf() + self.conn.register_domain(DOMAIN, "365") + self.conn.register_workflow_type( + DOMAIN, + WORKFLOW, + DEFAULT_VERSION, + task_list=TASK_LIST, + default_child_policy="TERMINATE", + default_execution_start_to_close_timeout="6", + default_task_start_to_close_timeout="3", + ) + self.conn.start_workflow_execution( + DOMAIN, + "wfe-1234", + WORKFLOW, + DEFAULT_VERSION + ) From 53b8f78ab971bf4b8c75392fb753a322bb2fc8f1 Mon Sep 17 00:00:00 2001 From: Yves Bastide Date: Mon, 6 Mar 2017 13:51:09 +0100 Subject: [PATCH 3/3] Mark signals as idempotent This should prevent them from being resent during a specific replay. We'll have to check if this is what causes signals duplication in our workflows... Signed-off-by: Yves Bastide --- simpleflow/swf/task.py | 6 +- .../test_signal_played_once_by_default.yaml | 73 ++++-------- .../cassettes/test_signal_played_twice.yaml | 111 ------------------ ...al_played_twice_ignored_as_idempotent.yaml | 90 ++++++++++++++ tests/integration/test_signals.py | 6 +- tests/integration/workflow.py | 6 +- 6 files changed, 129 insertions(+), 163 deletions(-) delete mode 100644 tests/integration/cassettes/test_signal_played_twice.yaml create mode 100644 tests/integration/cassettes/test_signal_played_twice_ignored_as_idempotent.yaml diff --git a/simpleflow/swf/task.py b/simpleflow/swf/task.py index 67736d327..c638a9ee8 100644 --- a/simpleflow/swf/task.py +++ b/simpleflow/swf/task.py @@ -189,7 +189,11 @@ def id(self): @property def idempotent(self): - return None + """ + Don't resend send a signal multiple times during a replay. + :return: + """ + return True def __repr__(self): return '{}(name={}, workflow_id={}, run_id={}, control={}, args={}, kwargs={})'.format( diff --git a/tests/integration/cassettes/test_signal_played_once_by_default.yaml b/tests/integration/cassettes/test_signal_played_once_by_default.yaml index 2594b6e94..97657c308 100644 --- a/tests/integration/cassettes/test_signal_played_once_by_default.yaml +++ b/tests/integration/cassettes/test_signal_played_once_by_default.yaml @@ -8,8 +8,8 @@ interactions: Content-Length: ['81'] Content-Type: [application/json; charset=UTF-8] Host: [swf.us-east-1.amazonaws.com] - User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] - X-Amz-Date: [20170302T173752Z] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-40-generic] + X-Amz-Date: [20170306T121652Z] X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowType] method: POST uri: https://swf.us-east-1.amazonaws.com/ @@ -18,94 +18,73 @@ interactions: headers: content-length: ['288'] content-type: [application/json] - x-amzn-requestid: [f652dd7a-ff6e-11e6-9d27-49ea4ba39529] + x-amzn-requestid: [c804b211-0266-11e7-808f-3ffe28c7f98c] status: {code: 200, message: OK} - request: - body: !!python/unicode '{"domain": "TestDomain", "taskList": {"name": "test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"}, - "childPolicy": "TERMINATE", "input": "{\"args\":[true]}", "workflowType": {"version": - "example", "name": "basic"}, "workflowId": "test-simpleflow-workflow"}' + body: !!python/unicode '{"domain": "TestDomain", "taskList": {"name": "test-simpleflow-workflow-7497278950d942e18332319f435bf5f9"}, + "childPolicy": "TERMINATE", "input": "{\"args\":[true],\"kwargs\":{}}", "workflowType": + {"version": "example", "name": "basic"}, "workflowId": "test-simpleflow-workflow"}' headers: Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] Content-Encoding: [amz-1.0] - Content-Length: ['264'] + Content-Length: ['278'] Content-Type: [application/json; charset=UTF-8] Host: [swf.us-east-1.amazonaws.com] - User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] - X-Amz-Date: [20170302T173752Z] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-40-generic] + X-Amz-Date: [20170306T121652Z] X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.StartWorkflowExecution] method: POST uri: https://swf.us-east-1.amazonaws.com/ response: - body: {string: !!python/unicode '{"runId":"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY="}'} + body: {string: !!python/unicode '{"runId":"22YyGhSHsF499shptrnhtzopwx7GVVy9Zyban1ZYyvX9w="}'} headers: content-length: ['58'] content-type: [application/json] - x-amzn-requestid: [f68b7a50-ff6e-11e6-9667-25907cf9f9e8] + x-amzn-requestid: [c844a0f1-0266-11e7-8721-c3a4922e7b51] status: {code: 200, message: OK} - request: body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", - "runId": "224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY="}}' + "runId": "22YyGhSHsF499shptrnhtzopwx7GVVy9Zyban1ZYyvX9w="}}' headers: Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] Content-Encoding: [amz-1.0] Content-Length: ['140'] Content-Type: [application/json; charset=UTF-8] Host: [swf.us-east-1.amazonaws.com] - User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] - X-Amz-Date: [20170302T173755Z] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-40-generic] + X-Amz-Date: [20170306T121654Z] X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowExecution] method: POST uri: https://swf.us-east-1.amazonaws.com/ response: - body: {string: !!python/unicode '{"executionConfiguration":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"},"taskStartToCloseTimeout":"300"},"executionInfo":{"cancelRequested":false,"execution":{"runId":"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=","workflowId":"test-simpleflow-workflow"},"executionStatus":"OPEN","startTimestamp":1.488476272965E9,"workflowType":{"name":"basic","version":"example"}},"openCounts":{"openActivityTasks":0,"openChildWorkflowExecutions":0,"openDecisionTasks":1,"openLambdaFunctions":0,"openTimers":0}}'} + body: {string: !!python/unicode '{"executionConfiguration":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-7497278950d942e18332319f435bf5f9"},"taskStartToCloseTimeout":"300"},"executionInfo":{"cancelRequested":false,"closeStatus":"COMPLETED","closeTimestamp":1.488802615241E9,"execution":{"runId":"22YyGhSHsF499shptrnhtzopwx7GVVy9Zyban1ZYyvX9w=","workflowId":"test-simpleflow-workflow"},"executionStatus":"CLOSED","startTimestamp":1.48880261282E9,"workflowType":{"name":"basic","version":"example"}},"openCounts":{"openActivityTasks":0,"openChildWorkflowExecutions":0,"openDecisionTasks":0,"openLambdaFunctions":0,"openTimers":0}}'} headers: - content-length: ['597'] + content-length: ['658'] content-type: [application/json] - x-amzn-requestid: [f8159c05-ff6e-11e6-bfdf-110dd4d1b4a7] + x-amzn-requestid: [c9b98de6-0266-11e7-9e70-1f9247b7ce8b] status: {code: 200, message: OK} - request: body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", - "runId": "224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY="}}' + "runId": "22YyGhSHsF499shptrnhtzopwx7GVVy9Zyban1ZYyvX9w="}}' headers: Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] Content-Encoding: [amz-1.0] Content-Length: ['140'] Content-Type: [application/json; charset=UTF-8] Host: [swf.us-east-1.amazonaws.com] - User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] - X-Amz-Date: [20170302T173757Z] - X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowExecution] - method: POST - uri: https://swf.us-east-1.amazonaws.com/ - response: - body: {string: !!python/unicode '{"executionConfiguration":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"},"taskStartToCloseTimeout":"300"},"executionInfo":{"cancelRequested":false,"closeStatus":"COMPLETED","closeTimestamp":1.488476277319E9,"execution":{"runId":"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=","workflowId":"test-simpleflow-workflow"},"executionStatus":"CLOSED","startTimestamp":1.488476272965E9,"workflowType":{"name":"basic","version":"example"}},"openCounts":{"openActivityTasks":0,"openChildWorkflowExecutions":0,"openDecisionTasks":0,"openLambdaFunctions":0,"openTimers":0}}'} - headers: - content-length: ['659'] - content-type: [application/json] - x-amzn-requestid: [f98531dc-ff6e-11e6-b6f2-332d5d7bf4ec] - status: {code: 200, message: OK} -- request: - body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", - "runId": "224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY="}}' - headers: - Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] - Content-Encoding: [amz-1.0] - Content-Length: ['140'] - Content-Type: [application/json; charset=UTF-8] - Host: [swf.us-east-1.amazonaws.com] - User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] - X-Amz-Date: [20170302T173858Z] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-40-generic] + X-Amz-Date: [20170306T121755Z] X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.GetWorkflowExecutionHistory] method: POST uri: https://swf.us-east-1.amazonaws.com/ response: - body: {string: !!python/unicode '{"events":[{"eventId":1,"eventTimestamp":1.488476272965E9,"eventType":"WorkflowExecutionStarted","workflowExecutionStartedEventAttributes":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","input":"{\"args\":[true]}","parentInitiatedEventId":0,"taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"},"taskStartToCloseTimeout":"300","workflowType":{"name":"basic","version":"example"}}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"}},"eventId":2,"eventTimestamp":1.488476272965E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27872,\"user\":\"zeb\"}","scheduledEventId":2},"eventId":3,"eventTimestamp":1.488476273148E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":2,"startedEventId":3},"eventId":4,"eventTimestamp":1.488476273557E9,"eventType":"DecisionTaskCompleted"},{"eventId":5,"eventTimestamp":1.488476273557E9,"eventType":"SignalExternalWorkflowExecutionInitiated","signalExternalWorkflowExecutionInitiatedEventAttributes":{"decisionTaskCompletedEventId":4,"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[1],\"__run_id\":\"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=\",\"kwargs\":{}}","runId":"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=","signalName":"signal","workflowId":"test-simpleflow-workflow"}},{"eventId":6,"eventTimestamp":1.488476273596E9,"eventType":"WorkflowExecutionSignaled","workflowExecutionSignaledEventAttributes":{"externalInitiatedEventId":5,"externalWorkflowExecution":{"runId":"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=","workflowId":"test-simpleflow-workflow"},"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[1],\"__run_id\":\"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=\",\"kwargs\":{}}","signalName":"signal"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"}},"eventId":7,"eventTimestamp":1.488476273596E9,"eventType":"DecisionTaskScheduled"},{"eventId":8,"eventTimestamp":1.488476273609E9,"eventType":"ExternalWorkflowExecutionSignaled","externalWorkflowExecutionSignaledEventAttributes":{"initiatedEventId":5,"workflowExecution":{"runId":"224a/ZEx3C3w1hCdInDr+/B60z7rCRWhvnJ9ONAJJcjBY=","workflowId":"test-simpleflow-workflow"}}},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27872,\"user\":\"zeb\"}","scheduledEventId":7},"eventId":9,"eventTimestamp":1.48847627396E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":7,"startedEventId":9},"eventId":10,"eventTimestamp":1.48847627438E9,"eventType":"DecisionTaskCompleted"},{"eventId":11,"eventTimestamp":1.48847627438E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":10,"markerName":"marker - 1"}},{"eventId":12,"eventTimestamp":1.48847627438E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":10,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":13,"eventTimestamp":1.488476274394E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":12,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"}},"eventId":14,"eventTimestamp":1.488476274394E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27872,\"user\":\"zeb\"}","scheduledEventId":14},"eventId":15,"eventTimestamp":1.488476274827E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":14,"startedEventId":15},"eventId":16,"eventTimestamp":1.488476275268E9,"eventType":"DecisionTaskCompleted"},{"eventId":17,"eventTimestamp":1.488476275268E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":16,"markerName":"marker - 2"}},{"eventId":18,"eventTimestamp":1.488476275268E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":16,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":19,"eventTimestamp":1.48847627528E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":18,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"}},"eventId":20,"eventTimestamp":1.48847627528E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27872,\"user\":\"zeb\"}","scheduledEventId":20},"eventId":21,"eventTimestamp":1.488476275744E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":20,"startedEventId":21},"eventId":22,"eventTimestamp":1.488476276481E9,"eventType":"DecisionTaskCompleted"},{"eventId":23,"eventTimestamp":1.488476276481E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":22,"markerName":"marker - 3"}},{"eventId":24,"eventTimestamp":1.488476276481E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":22,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":25,"eventTimestamp":1.488476276497E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":24,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-2b572127fdbb49e5885d74a53374a6cd"}},"eventId":26,"eventTimestamp":1.488476276497E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27872,\"user\":\"zeb\"}","scheduledEventId":26},"eventId":27,"eventTimestamp":1.488476276902E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":26,"startedEventId":27},"eventId":28,"eventTimestamp":1.488476277319E9,"eventType":"DecisionTaskCompleted"},{"eventId":29,"eventTimestamp":1.488476277319E9,"eventType":"WorkflowExecutionCompleted","workflowExecutionCompletedEventAttributes":{"decisionTaskCompletedEventId":28,"result":"null"}}]}'} + body: {string: !!python/unicode '{"events":[{"eventId":1,"eventTimestamp":1.48880261282E9,"eventType":"WorkflowExecutionStarted","workflowExecutionStartedEventAttributes":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","input":"{\"args\":[true],\"kwargs\":{}}","parentInitiatedEventId":0,"taskList":{"name":"test-simpleflow-workflow-7497278950d942e18332319f435bf5f9"},"taskStartToCloseTimeout":"300","workflowType":{"name":"basic","version":"example"}}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-7497278950d942e18332319f435bf5f9"}},"eventId":2,"eventTimestamp":1.48880261282E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":446,\"user\":\"zeb\"}","scheduledEventId":2},"eventId":3,"eventTimestamp":1.488802612881E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":2,"startedEventId":3},"eventId":4,"eventTimestamp":1.488802613312E9,"eventType":"DecisionTaskCompleted"},{"eventId":5,"eventTimestamp":1.488802613312E9,"eventType":"SignalExternalWorkflowExecutionInitiated","signalExternalWorkflowExecutionInitiatedEventAttributes":{"decisionTaskCompletedEventId":4,"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[1],\"__run_id\":\"22YyGhSHsF499shptrnhtzopwx7GVVy9Zyban1ZYyvX9w=\",\"kwargs\":{}}","runId":"22YyGhSHsF499shptrnhtzopwx7GVVy9Zyban1ZYyvX9w=","signalName":"signal","workflowId":"test-simpleflow-workflow"}},{"eventId":6,"eventTimestamp":1.488802613351E9,"eventType":"WorkflowExecutionSignaled","workflowExecutionSignaledEventAttributes":{"externalInitiatedEventId":5,"externalWorkflowExecution":{"runId":"22YyGhSHsF499shptrnhtzopwx7GVVy9Zyban1ZYyvX9w=","workflowId":"test-simpleflow-workflow"},"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[1],\"__run_id\":\"22YyGhSHsF499shptrnhtzopwx7GVVy9Zyban1ZYyvX9w=\",\"kwargs\":{}}","signalName":"signal"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-7497278950d942e18332319f435bf5f9"}},"eventId":7,"eventTimestamp":1.488802613351E9,"eventType":"DecisionTaskScheduled"},{"eventId":8,"eventTimestamp":1.488802613369E9,"eventType":"ExternalWorkflowExecutionSignaled","externalWorkflowExecutionSignaledEventAttributes":{"initiatedEventId":5,"workflowExecution":{"runId":"22YyGhSHsF499shptrnhtzopwx7GVVy9Zyban1ZYyvX9w=","workflowId":"test-simpleflow-workflow"}}},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":445,\"user\":\"zeb\"}","scheduledEventId":7},"eventId":9,"eventTimestamp":1.488802613394E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":7,"startedEventId":9},"eventId":10,"eventTimestamp":1.488802613804E9,"eventType":"DecisionTaskCompleted"},{"eventId":11,"eventTimestamp":1.488802613804E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":10,"markerName":"marker + 1"}},{"eventId":12,"eventTimestamp":1.488802613804E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":10,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":13,"eventTimestamp":1.488802613819E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":12,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-7497278950d942e18332319f435bf5f9"}},"eventId":14,"eventTimestamp":1.488802613819E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":446,\"user\":\"zeb\"}","scheduledEventId":14},"eventId":15,"eventTimestamp":1.488802613852E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":14,"startedEventId":15},"eventId":16,"eventTimestamp":1.488802614279E9,"eventType":"DecisionTaskCompleted"},{"eventId":17,"eventTimestamp":1.488802614279E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":16,"markerName":"marker + 2"}},{"eventId":18,"eventTimestamp":1.488802614279E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":16,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":19,"eventTimestamp":1.488802614301E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":18,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-7497278950d942e18332319f435bf5f9"}},"eventId":20,"eventTimestamp":1.488802614301E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":445,\"user\":\"zeb\"}","scheduledEventId":20},"eventId":21,"eventTimestamp":1.488802614346E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":20,"startedEventId":21},"eventId":22,"eventTimestamp":1.488802614753E9,"eventType":"DecisionTaskCompleted"},{"eventId":23,"eventTimestamp":1.488802614753E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":22,"markerName":"marker + 3"}},{"eventId":24,"eventTimestamp":1.488802614753E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":22,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":25,"eventTimestamp":1.48880261477E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":24,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-7497278950d942e18332319f435bf5f9"}},"eventId":26,"eventTimestamp":1.48880261477E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":446,\"user\":\"zeb\"}","scheduledEventId":26},"eventId":27,"eventTimestamp":1.488802614808E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":26,"startedEventId":27},"eventId":28,"eventTimestamp":1.488802615241E9,"eventType":"DecisionTaskCompleted"},{"eventId":29,"eventTimestamp":1.488802615241E9,"eventType":"WorkflowExecutionCompleted","workflowExecutionCompletedEventAttributes":{"decisionTaskCompletedEventId":28,"result":"null"}}]}'} headers: - content-length: ['6565'] + content-length: ['6571'] content-type: [application/json] - x-amzn-requestid: [1dc10359-ff6f-11e6-863d-5733ea0eb9aa] + x-amzn-requestid: [ee02cc7b-0266-11e7-98db-9384dad28582] status: {code: 200, message: OK} version: 1 diff --git a/tests/integration/cassettes/test_signal_played_twice.yaml b/tests/integration/cassettes/test_signal_played_twice.yaml deleted file mode 100644 index c8c737ab0..000000000 --- a/tests/integration/cassettes/test_signal_played_twice.yaml +++ /dev/null @@ -1,111 +0,0 @@ -interactions: -- request: - body: !!python/unicode '{"domain": "TestDomain", "workflowType": {"version": "example", - "name": "basic"}}' - headers: - Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] - Content-Encoding: [amz-1.0] - Content-Length: ['81'] - Content-Type: [application/json; charset=UTF-8] - Host: [swf.us-east-1.amazonaws.com] - User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] - X-Amz-Date: [20170302T173858Z] - X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowType] - method: POST - uri: https://swf.us-east-1.amazonaws.com/ - response: - body: {string: !!python/unicode '{"configuration":{"defaultChildPolicy":"TERMINATE","defaultExecutionStartToCloseTimeout":"300","defaultTaskList":{"name":"None"},"defaultTaskStartToCloseTimeout":"300"},"typeInfo":{"creationDate":1.435159034741E9,"status":"REGISTERED","workflowType":{"name":"basic","version":"example"}}}'} - headers: - content-length: ['288'] - content-type: [application/json] - x-amzn-requestid: [1e15da10-ff6f-11e6-8e40-97845affe6f0] - status: {code: 200, message: OK} -- request: - body: !!python/unicode '{"domain": "TestDomain", "taskList": {"name": "test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"}, - "childPolicy": "TERMINATE", "input": "{\"args\":[false]}", "workflowType": {"version": - "example", "name": "basic"}, "workflowId": "test-simpleflow-workflow"}' - headers: - Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] - Content-Encoding: [amz-1.0] - Content-Length: ['265'] - Content-Type: [application/json; charset=UTF-8] - Host: [swf.us-east-1.amazonaws.com] - User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] - X-Amz-Date: [20170302T173859Z] - X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.StartWorkflowExecution] - method: POST - uri: https://swf.us-east-1.amazonaws.com/ - response: - body: {string: !!python/unicode '{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk="}'} - headers: - content-length: ['58'] - content-type: [application/json] - x-amzn-requestid: [1e537f5c-ff6f-11e6-82a1-8536ef9790ab] - status: {code: 200, message: OK} -- request: - body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", - "runId": "22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk="}}' - headers: - Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] - Content-Encoding: [amz-1.0] - Content-Length: ['140'] - Content-Type: [application/json; charset=UTF-8] - Host: [swf.us-east-1.amazonaws.com] - User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] - X-Amz-Date: [20170302T173901Z] - X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowExecution] - method: POST - uri: https://swf.us-east-1.amazonaws.com/ - response: - body: {string: !!python/unicode '{"executionConfiguration":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"},"taskStartToCloseTimeout":"300"},"executionInfo":{"cancelRequested":false,"execution":{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","workflowId":"test-simpleflow-workflow"},"executionStatus":"OPEN","startTimestamp":1.488476339688E9,"workflowType":{"name":"basic","version":"example"}},"openCounts":{"openActivityTasks":0,"openChildWorkflowExecutions":0,"openDecisionTasks":1,"openLambdaFunctions":0,"openTimers":0}}'} - headers: - content-length: ['597'] - content-type: [application/json] - x-amzn-requestid: [1fc62205-ff6f-11e6-980b-cd693c7fefbe] - status: {code: 200, message: OK} -- request: - body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", - "runId": "22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk="}}' - headers: - Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] - Content-Encoding: [amz-1.0] - Content-Length: ['140'] - Content-Type: [application/json; charset=UTF-8] - Host: [swf.us-east-1.amazonaws.com] - User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] - X-Amz-Date: [20170302T173904Z] - X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowExecution] - method: POST - uri: https://swf.us-east-1.amazonaws.com/ - response: - body: {string: !!python/unicode '{"executionConfiguration":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"},"taskStartToCloseTimeout":"300"},"executionInfo":{"cancelRequested":false,"closeStatus":"COMPLETED","closeTimestamp":1.488476342708E9,"execution":{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","workflowId":"test-simpleflow-workflow"},"executionStatus":"CLOSED","startTimestamp":1.488476339688E9,"workflowType":{"name":"basic","version":"example"}},"openCounts":{"openActivityTasks":0,"openChildWorkflowExecutions":0,"openDecisionTasks":0,"openLambdaFunctions":0,"openTimers":0}}'} - headers: - content-length: ['659'] - content-type: [application/json] - x-amzn-requestid: [21356962-ff6f-11e6-a413-4ff367a4d482] - status: {code: 200, message: OK} -- request: - body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", - "runId": "22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk="}}' - headers: - Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] - Content-Encoding: [amz-1.0] - Content-Length: ['140'] - Content-Type: [application/json; charset=UTF-8] - Host: [swf.us-east-1.amazonaws.com] - User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-38-generic] - X-Amz-Date: [20170302T174003Z] - X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.GetWorkflowExecutionHistory] - method: POST - uri: https://swf.us-east-1.amazonaws.com/ - response: - body: {string: !!python/unicode '{"events":[{"eventId":1,"eventTimestamp":1.488476339688E9,"eventType":"WorkflowExecutionStarted","workflowExecutionStartedEventAttributes":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","input":"{\"args\":[false]}","parentInitiatedEventId":0,"taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"},"taskStartToCloseTimeout":"300","workflowType":{"name":"basic","version":"example"}}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"}},"eventId":2,"eventTimestamp":1.488476339688E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27931,\"user\":\"zeb\"}","scheduledEventId":2},"eventId":3,"eventTimestamp":1.488476339758E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":2,"startedEventId":3},"eventId":4,"eventTimestamp":1.488476340233E9,"eventType":"DecisionTaskCompleted"},{"eventId":5,"eventTimestamp":1.488476340233E9,"eventType":"SignalExternalWorkflowExecutionInitiated","signalExternalWorkflowExecutionInitiatedEventAttributes":{"decisionTaskCompletedEventId":4,"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[1],\"__run_id\":\"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=\",\"kwargs\":{}}","runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","signalName":"signal","workflowId":"test-simpleflow-workflow"}},{"eventId":6,"eventTimestamp":1.488476340233E9,"eventType":"SignalExternalWorkflowExecutionInitiated","signalExternalWorkflowExecutionInitiatedEventAttributes":{"decisionTaskCompletedEventId":4,"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[2],\"__run_id\":\"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=\",\"kwargs\":{}}","runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","signalName":"signal","workflowId":"test-simpleflow-workflow"}},{"eventId":7,"eventTimestamp":1.488476340233E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":4,"markerName":"marker - 1"}},{"eventId":8,"eventTimestamp":1.488476340233E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":4,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":9,"eventTimestamp":1.488476340253E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":8,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"}},"eventId":10,"eventTimestamp":1.488476340253E9,"eventType":"DecisionTaskScheduled"},{"eventId":11,"eventTimestamp":1.488476340307E9,"eventType":"WorkflowExecutionSignaled","workflowExecutionSignaledEventAttributes":{"externalInitiatedEventId":6,"externalWorkflowExecution":{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","workflowId":"test-simpleflow-workflow"},"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[2],\"__run_id\":\"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=\",\"kwargs\":{}}","signalName":"signal"}},{"eventId":12,"eventTimestamp":1.488476340316E9,"eventType":"WorkflowExecutionSignaled","workflowExecutionSignaledEventAttributes":{"externalInitiatedEventId":5,"externalWorkflowExecution":{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","workflowId":"test-simpleflow-workflow"},"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[1],\"__run_id\":\"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=\",\"kwargs\":{}}","signalName":"signal"}},{"eventId":13,"eventTimestamp":1.488476340329E9,"eventType":"ExternalWorkflowExecutionSignaled","externalWorkflowExecutionSignaledEventAttributes":{"initiatedEventId":6,"workflowExecution":{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","workflowId":"test-simpleflow-workflow"}}},{"eventId":14,"eventTimestamp":1.488476340337E9,"eventType":"ExternalWorkflowExecutionSignaled","externalWorkflowExecutionSignaledEventAttributes":{"initiatedEventId":5,"workflowExecution":{"runId":"22zCvwbdKALrdtW7maAJ5RlqtzPHlzSKrF2GtnEt2ZcPk=","workflowId":"test-simpleflow-workflow"}}},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27931,\"user\":\"zeb\"}","scheduledEventId":10},"eventId":15,"eventTimestamp":1.488476340629E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":10,"startedEventId":15},"eventId":16,"eventTimestamp":1.488476341024E9,"eventType":"DecisionTaskCompleted"},{"eventId":17,"eventTimestamp":1.488476341024E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":16,"markerName":"marker - 2"}},{"eventId":18,"eventTimestamp":1.488476341024E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":16,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":19,"eventTimestamp":1.488476341036E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":18,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"}},"eventId":20,"eventTimestamp":1.488476341036E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27931,\"user\":\"zeb\"}","scheduledEventId":20},"eventId":21,"eventTimestamp":1.488476341435E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":20,"startedEventId":21},"eventId":22,"eventTimestamp":1.488476341886E9,"eventType":"DecisionTaskCompleted"},{"eventId":23,"eventTimestamp":1.488476341886E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":22,"markerName":"marker - 3"}},{"eventId":24,"eventTimestamp":1.488476341886E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":22,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":25,"eventTimestamp":1.488476341908E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":24,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-03ff0cc6fd7040d2a446ad23270ddacb"}},"eventId":26,"eventTimestamp":1.488476341908E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":27931,\"user\":\"zeb\"}","scheduledEventId":26},"eventId":27,"eventTimestamp":1.488476342303E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":26,"startedEventId":27},"eventId":28,"eventTimestamp":1.488476342708E9,"eventType":"DecisionTaskCompleted"},{"eventId":29,"eventTimestamp":1.488476342708E9,"eventType":"WorkflowExecutionCompleted","workflowExecutionCompletedEventAttributes":{"decisionTaskCompletedEventId":28,"result":"null"}}]}'} - headers: - content-length: ['7161'] - content-type: [application/json] - x-amzn-requestid: [4467e1ce-ff6f-11e6-87a6-0fd8451cf51d] - status: {code: 200, message: OK} -version: 1 diff --git a/tests/integration/cassettes/test_signal_played_twice_ignored_as_idempotent.yaml b/tests/integration/cassettes/test_signal_played_twice_ignored_as_idempotent.yaml new file mode 100644 index 000000000..01c5ba710 --- /dev/null +++ b/tests/integration/cassettes/test_signal_played_twice_ignored_as_idempotent.yaml @@ -0,0 +1,90 @@ +interactions: +- request: + body: !!python/unicode '{"domain": "TestDomain", "workflowType": {"version": "example", + "name": "basic"}}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['81'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-40-generic] + X-Amz-Date: [20170306T124726Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowType] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"configuration":{"defaultChildPolicy":"TERMINATE","defaultExecutionStartToCloseTimeout":"300","defaultTaskList":{"name":"None"},"defaultTaskStartToCloseTimeout":"300"},"typeInfo":{"creationDate":1.435159034741E9,"status":"REGISTERED","workflowType":{"name":"basic","version":"example"}}}'} + headers: + content-length: ['288'] + content-type: [application/json] + x-amzn-requestid: [0da6f095-026b-11e7-950a-0d9d27046e47] + status: {code: 200, message: OK} +- request: + body: !!python/unicode '{"domain": "TestDomain", "taskList": {"name": "test-simpleflow-workflow-b18eee2c341c4644b892875a3bc7c66c"}, + "childPolicy": "TERMINATE", "input": "{\"args\":[false],\"kwargs\":{}}", "workflowType": + {"version": "example", "name": "basic"}, "workflowId": "test-simpleflow-workflow"}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['279'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-40-generic] + X-Amz-Date: [20170306T124727Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.StartWorkflowExecution] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"runId":"22HQmw9J1ARZ8MEJ9C3AMQjSv2tNau2DmpOxUwPHS3d7k="}'} + headers: + content-length: ['58'] + content-type: [application/json] + x-amzn-requestid: [0de0507c-026b-11e7-bb43-e9379e4b337b] + status: {code: 200, message: OK} +- request: + body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", + "runId": "22HQmw9J1ARZ8MEJ9C3AMQjSv2tNau2DmpOxUwPHS3d7k="}}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['140'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-40-generic] + X-Amz-Date: [20170306T124729Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.DescribeWorkflowExecution] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"executionConfiguration":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-b18eee2c341c4644b892875a3bc7c66c"},"taskStartToCloseTimeout":"300"},"executionInfo":{"cancelRequested":false,"closeStatus":"COMPLETED","closeTimestamp":1.488804449563E9,"execution":{"runId":"22HQmw9J1ARZ8MEJ9C3AMQjSv2tNau2DmpOxUwPHS3d7k=","workflowId":"test-simpleflow-workflow"},"executionStatus":"CLOSED","startTimestamp":1.48880444759E9,"workflowType":{"name":"basic","version":"example"}},"openCounts":{"openActivityTasks":0,"openChildWorkflowExecutions":0,"openDecisionTasks":0,"openLambdaFunctions":0,"openTimers":0}}'} + headers: + content-length: ['658'] + content-type: [application/json] + x-amzn-requestid: [0f511e85-026b-11e7-a854-3df266125500] + status: {code: 200, message: OK} +- request: + body: !!python/unicode '{"domain": "TestDomain", "execution": {"workflowId": "test-simpleflow-workflow", + "runId": "22HQmw9J1ARZ8MEJ9C3AMQjSv2tNau2DmpOxUwPHS3d7k="}}' + headers: + Authorization: ['AWS4-HMAC-SHA256 Credential=1234AB/20160823/us-east-1/swf/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=foobar'] + Content-Encoding: [amz-1.0] + Content-Length: ['140'] + Content-Type: [application/json; charset=UTF-8] + Host: [swf.us-east-1.amazonaws.com] + User-Agent: [Boto/2.46.1 Python/2.7.12+ Linux/4.8.0-40-generic] + X-Amz-Date: [20170306T124830Z] + X-Amz-Target: [com.amazonaws.swf.service.model.SimpleWorkflowService.GetWorkflowExecutionHistory] + method: POST + uri: https://swf.us-east-1.amazonaws.com/ + response: + body: {string: !!python/unicode '{"events":[{"eventId":1,"eventTimestamp":1.48880444759E9,"eventType":"WorkflowExecutionStarted","workflowExecutionStartedEventAttributes":{"childPolicy":"TERMINATE","executionStartToCloseTimeout":"300","input":"{\"args\":[false],\"kwargs\":{}}","parentInitiatedEventId":0,"taskList":{"name":"test-simpleflow-workflow-b18eee2c341c4644b892875a3bc7c66c"},"taskStartToCloseTimeout":"300","workflowType":{"name":"basic","version":"example"}}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-b18eee2c341c4644b892875a3bc7c66c"}},"eventId":2,"eventTimestamp":1.48880444759E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":4636,\"user\":\"zeb\"}","scheduledEventId":2},"eventId":3,"eventTimestamp":1.488804447657E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":2,"startedEventId":3},"eventId":4,"eventTimestamp":1.488804448128E9,"eventType":"DecisionTaskCompleted"},{"eventId":5,"eventTimestamp":1.488804448128E9,"eventType":"SignalExternalWorkflowExecutionInitiated","signalExternalWorkflowExecutionInitiatedEventAttributes":{"decisionTaskCompletedEventId":4,"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[1],\"__run_id\":\"22HQmw9J1ARZ8MEJ9C3AMQjSv2tNau2DmpOxUwPHS3d7k=\",\"kwargs\":{}}","runId":"22HQmw9J1ARZ8MEJ9C3AMQjSv2tNau2DmpOxUwPHS3d7k=","signalName":"signal","workflowId":"test-simpleflow-workflow"}},{"eventId":6,"eventTimestamp":1.488804448128E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":4,"markerName":"marker + 1"}},{"eventId":7,"eventTimestamp":1.488804448128E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":4,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":8,"eventTimestamp":1.488804448146E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":7,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-b18eee2c341c4644b892875a3bc7c66c"}},"eventId":9,"eventTimestamp":1.488804448146E9,"eventType":"DecisionTaskScheduled"},{"eventId":10,"eventTimestamp":1.488804448177E9,"eventType":"WorkflowExecutionSignaled","workflowExecutionSignaledEventAttributes":{"externalInitiatedEventId":5,"externalWorkflowExecution":{"runId":"22HQmw9J1ARZ8MEJ9C3AMQjSv2tNau2DmpOxUwPHS3d7k=","workflowId":"test-simpleflow-workflow"},"input":"{\"__workflow_id\":\"test-simpleflow-workflow\",\"args\":[1],\"__run_id\":\"22HQmw9J1ARZ8MEJ9C3AMQjSv2tNau2DmpOxUwPHS3d7k=\",\"kwargs\":{}}","signalName":"signal"}},{"eventId":11,"eventTimestamp":1.488804448188E9,"eventType":"ExternalWorkflowExecutionSignaled","externalWorkflowExecutionSignaledEventAttributes":{"initiatedEventId":5,"workflowExecution":{"runId":"22HQmw9J1ARZ8MEJ9C3AMQjSv2tNau2DmpOxUwPHS3d7k=","workflowId":"test-simpleflow-workflow"}}},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":4634,\"user\":\"zeb\"}","scheduledEventId":9},"eventId":12,"eventTimestamp":1.488804448195E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":9,"startedEventId":12},"eventId":13,"eventTimestamp":1.488804448591E9,"eventType":"DecisionTaskCompleted"},{"eventId":14,"eventTimestamp":1.488804448591E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":13,"markerName":"marker + 2"}},{"eventId":15,"eventTimestamp":1.488804448591E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":13,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":16,"eventTimestamp":1.488804448605E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":15,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-b18eee2c341c4644b892875a3bc7c66c"}},"eventId":17,"eventTimestamp":1.488804448605E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":4636,\"user\":\"zeb\"}","scheduledEventId":17},"eventId":18,"eventTimestamp":1.488804448637E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":17,"startedEventId":18},"eventId":19,"eventTimestamp":1.488804449033E9,"eventType":"DecisionTaskCompleted"},{"eventId":20,"eventTimestamp":1.488804449033E9,"eventType":"MarkerRecorded","markerRecordedEventAttributes":{"decisionTaskCompletedEventId":19,"markerName":"marker + 3"}},{"eventId":21,"eventTimestamp":1.488804449033E9,"eventType":"TimerStarted","timerStartedEventAttributes":{"decisionTaskCompletedEventId":19,"startToFireTimeout":"0","timerId":"_simpleflow_wake_up_timer"}},{"eventId":22,"eventTimestamp":1.488804449046E9,"eventType":"TimerFired","timerFiredEventAttributes":{"startedEventId":21,"timerId":"_simpleflow_wake_up_timer"}},{"decisionTaskScheduledEventAttributes":{"startToCloseTimeout":"300","taskList":{"name":"test-simpleflow-workflow-b18eee2c341c4644b892875a3bc7c66c"}},"eventId":23,"eventTimestamp":1.488804449046E9,"eventType":"DecisionTaskScheduled"},{"decisionTaskStartedEventAttributes":{"identity":"{\"hostname\":\"zeb-Precision-T3610\",\"pid\":4634,\"user\":\"zeb\"}","scheduledEventId":23},"eventId":24,"eventTimestamp":1.488804449153E9,"eventType":"DecisionTaskStarted"},{"decisionTaskCompletedEventAttributes":{"scheduledEventId":23,"startedEventId":24},"eventId":25,"eventTimestamp":1.488804449563E9,"eventType":"DecisionTaskCompleted"},{"eventId":26,"eventTimestamp":1.488804449563E9,"eventType":"WorkflowExecutionCompleted","workflowExecutionCompletedEventAttributes":{"decisionTaskCompletedEventId":25,"result":"null"}}]}'} + headers: + content-length: ['5949'] + content-type: [application/json] + x-amzn-requestid: [33b2eea4-026b-11e7-8ba1-b1b5bd2f3fd9] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/integration/test_signals.py b/tests/integration/test_signals.py index 7ab21f8a5..3b16bb60f 100644 --- a/tests/integration/test_signals.py +++ b/tests/integration/test_signals.py @@ -16,17 +16,19 @@ def test_signal_played_once_by_default(self): lambda e: e["eventType"] == "SignalExternalWorkflowExecutionInitiated", events ) + print(signals_initiated) expect(len(list(signals_initiated))).to.equal(1) @flaky(max_runs=2) @vcr.use_cassette - def test_signal_played_twice(self): + def test_signal_played_twice_ignored_as_idempotent(self): events = self.run_standalone('tests.integration.workflow.ASignalingTestParentWorkflow', False) signals_initiated = filter( lambda e: e["eventType"] == "SignalExternalWorkflowExecutionInitiated", events ) - expect(len(list(signals_initiated))).to.equal(2) + print(signals_initiated) + expect(len(list(signals_initiated))).to.equal(1) if __name__ == '__main__': diff --git a/tests/integration/workflow.py b/tests/integration/workflow.py index 0fe42daa7..40f555cfb 100644 --- a/tests/integration/workflow.py +++ b/tests/integration/workflow.py @@ -63,11 +63,13 @@ class ASignalingTestParentWorkflow(Workflow): execution_timeout = '3600' def run(self, wait_after_first): - # Signaled twice since there's no barrier sig = self.submit(self.signal('signal', 1)) if wait_after_first: futures.wait(sig) - sig = self.submit(self.signal('signal', 2)) + else: + # Will be signaled once anyway since signals are marked as idempotent + pass + sig = self.submit(self.signal('signal', 1)) futures.wait(self.submit(self.record_marker('marker 1'))) sig_again = self.submit(self.signal('signal', 3)) futures.wait(self.submit(self.record_marker('marker 2')))