8000 [SFN] Add support for Task Timeouts by MEPalma · Pull Request #8376 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

[SFN] Add support for Task Timeouts #8376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix cycle on send success
  • Loading branch information
MEPalma committed Jun 22, 2023
commit de9a3200fef1f488b9fdd770d008fa38027276a3
3 changes: 2 additions & 1 deletion tests/integration/stepfunctions/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ def _create_state_machine(sqs_queue_url):
state_machine_arn = creation_resp["stateMachineArn"]

aws_client.stepfunctions.start_execution(
stateMachineArn=state_machine_arn, input=json.dumps({"QueueUrl": sqs_queue_url})
stateMachineArn=state_machine_arn,
input=json.dumps({"QueueUrl": sqs_queue_url, "Iterator": {"Count": 300}}),
)

return _create_state_machine
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
{
"Comment": "sqs_success_on_task_token",
"StartAt": "WaitAndRestart",
"StartAt": "Iterate",
"States": {
"WaitAndRestart": {
"Iterate": {
"Type": "Pass",
"Parameters": {
"Count.$": "States.MathAdd($.Iterator.Count, -1)"
},
"ResultPath": "$.Iterator",
"Next": "IterateStep"
},
"IterateStep": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.Iterator.Count",
"NumericLessThanEquals": 0,
"Next": "NoMoreCycles"
}
],
"Default": "WaitAndReceive",
},
"WaitAndReceive": {
"Type": "Wait",
"Seconds": 1,
"Next": "Receive"
Expand All @@ -25,7 +44,7 @@
"Next": "SendSuccesses"
}
],
"Default": "WaitAndRestart"
"Default": "Iterate"
},
"SendSuccesses": {
"Type": "Map",
Expand All @@ -39,24 +58,27 @@
"ParseBody": {
"Type": "Pass",
"Parameters": {
"body.$": "States.StringToJson($.Body)"
"Body.$": "States.StringToJson($.Body)"
},
"Next": "Send"
},
"Send": {
"Type": "Task",
"Resource": "arn:aws:states:::aws-sdk:sfn:sendTaskSuccess",
"Parameters": {
"Output.$": "States.JsonToString($.body.Message)",
"TaskToken.$": "$.body.TaskToken"
"Output.$": "States.JsonToString($.Body.Message)",
"TaskToken.$": "$.Body.TaskToken"
},
"End": true
}
},
},
"ResultPath": null,
"OutputPath": "$.QueueUrl",
"Next": "WaitAndRestart"
"Next": "Iterate"
},
"NoMoreCycles": {
"Type": "Pass",
"End": true
}
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)
class TestCallback:
@pytest.mark.skip_snapshot_verify(paths=["$..MD5OfMessageBody"])
def test_sqs_wait_for_task_tok(
def test_sqs_wait_for_task_token(
self,
aws_client,
create_iam_role_for_sfn,
Expand Down
E30A
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tests/integration/stepfunctions/v2/callback/test_callback.py::TestCallback::test_sqs_wait_for_task_tok": {
"recorded-date": "22-06-2023, 13:05:16",
"tests/integration/stepfunctions/v2/callback/test_callback.py::TestCallback::test_sqs_wait_for_task_token": {
"recorded-date": "22-06-2023, 18:19:29",
"recorded-content": {
"get_execution_history": {
"events": [
Expand Down Expand Up @@ -69,7 +69,7 @@
"previousEventId": 4,
"taskSubmittedEventDetails": {
"output": {
"MD5OfMessageBody": "476a20e5904cb4822a4cd978ced5e607",
"MD5OfMessageBody": "a445f4b8c855092007f589f7060598df",
"MessageId": "<uuid:1>",
"SdkHttpMetadata": {
"AllHttpHeaders": {
Expand Down Expand Up @@ -152,145 +152,8 @@
}
}
},
"tests/integration/stepfunctions/v2/callback/test_callback.py::TestCallback::test_sqs_wait_for_task_tok_timeout": {
"recorded-date": "26-05-2023, 16:56:20",
"recorded-content": {
"get_execution_history": {
"events": [
{
"executionStartedEventDetails": {
"input": {
"QueueUrl": "https://sqs.<region>.amazonaws.com/111111111111/<sqs_queue_name>",
"Message": "test_message_txt"
},
"inputDetails": {
"truncated": false
},
"roleArn": "arn:aws:iam::111111111111:role/<resource:1>"
},
"id": 1,
"previousEventId": 0,
"timestamp": "timestamp",
"type": "ExecutionStarted"
},
{
"id": 2,
"previousEventId": 0,
"stateEnteredEventDetails": {
"input": {
"QueueUrl": "https://sqs.<region>.amazonaws.com/111111111111/<sqs_queue_name>",
"Message": "test_message_txt"
},
"inputDetails": {
"truncated": false
},
"name": "SendMessageWithWaitAndTimeout"
},
"timestamp": "timestamp",
"type": "TaskStateEntered"
},
{
"id": 3,
"previousEventId": 2,
"taskScheduledEventDetails": {
"parameters": {
"MessageBody": {
"Message": "test_message_txt",
"TaskToken": "<<task_token>:1>"
},
"QueueUrl": "https://sqs.<region>.amazonaws.com/111111111111/<sqs_queue_name>"
},
"region": "<region>",
"resource": "sendMessage.waitForTaskToken",
"resourceType": "sqs",
"timeoutInSeconds": 1
},
"timestamp": "timestamp",
"type": "TaskScheduled"
},
{
"id": 4,
"previousEventId": 3,
"taskStartedEventDetails": {
"resource": "sendMessage.waitForTaskToken",
"resourceType": "sqs"
},
"timestamp": "timestamp",
"type": "TaskStarted"
},
{
"id": 5,
"previousEventId": 4,
"taskSubmittedEventDetails": {
"output": {
"MD5OfMessageBody": "183da57f008a0a0a7fc9c0d01781ec6c",
"MessageId": "<uuid:1>",
"SdkHttpMetadata": {
"AllHttpHeaders": {
"x-amzn-RequestId": [
"<uuid:2>"
],
"Content-Length": [
"378"
],
"Date": [
"Fri, 26 May 2023 14:56:18 GMT"
],
"Content-Type": [
"text/xml"
]
},
"HttpHeaders": {
"Content-Length": "378",
"Content-Type": "text/xml",
"Date": "Fri, 26 May 2023 14:56:18 GMT",
"x-amzn-RequestId": "<uuid:2>"
},
"HttpStatusCode": 200
},
"SdkResponseMetadata": {
"RequestId": "<uuid:2>"
}
},
"outputDetails": {
"truncated": false
},
"resource": "sendMessage.waitForTaskToken",
"resourceType": "sqs"
},
"timestamp": "timestamp",
"type": "TaskSubmitted"
},
{
"id": 6,
"previousEventId": 5,
"taskTimedOutEventDetails": {
"error": "States.Timeout",
"resource": "sendMessage.waitForTaskToken",
"resourceType": "sqs"
},
"timestamp": "timestamp",
"type": "TaskTimedOut"
},
{
"executionFailedEventDetails": {
"error": "States.Timeout"
},
"id": 7,
"previousEventId": 6,
"timestamp": "timestamp",
"type": "ExecutionFailed"
}
],
"ResponseMetadata": {
"HTTPHeaders": {},
"HTTPStatusCode": 200
}
}
}
},
"tests/integration/stepfunctions/v2/callback/test_callback.py::TestCallback::test_sqs_wait_for_task_token_timeout": {
"recorded-date": "22-06-2023, 14:42:04",
"recorded-date": "22-06-2023, 18:19:51",
"recorded-content": {
"get_execution_history": {
"events": [
Expand Down Expand Up @@ -360,7 +223,7 @@
"previousEventId": 4,
"taskSubmittedEventDetails": {
"output": {
"MD5OfMessageBody": "823533eb403070c450a065ce6b7bedf6",
"MD5OfMessageBody": "e0fa4294b7e41cf70658b6b898f216b2",
"MessageId": "<uuid:1>",
"SdkHttpMetadata": {
"AllHttpHeaders": {
Expand Down
0