8000 [SFN] Support for SFN and Sync, reworked exception handling, fixes, tests by MEPalma · Pull Request #8623 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

[SFN] Support for SFN and Sync, reworked exception handling, fixes, tests #8623

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 43 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3b0c2e9
base
MEPalma May 8, 2023
2f392e7
fixes
MEPalma May 10, 2023
4d63d30
update snap test
MEPalma May 10, 2023
21f10ee
reworked parameters, improved double dep of lambda state tasks, tests
MEPalma May 11, 2023
0b750d2
minor conflicts
MEPalma May 16, 2023
0cd04f9
Merge branch 'MEP-sfn-callbacks' into MEP-sfn-lambda-fix-params
MEPalma May 16, 2023
d2f539b
Merge branch 'master' into MEP-sfn-lambda-fix-params
MEPalma May 24, 2023
a24ee43
timeouts support
MEPalma May 26, 2023
f07015a
Merge branch 'master' into MEP-sfn-lambda-fix-params
MEPalma May 27, 2023
eb5f0ea
task failure support and tests
MEPalma May 29, 2023
1382972
heartbeat base support
MEPalma May 29, 2023
4c75562
provider
MEPalma May 29, 2023
4f83e57
heartbeat tests, fixes
MEPalma Jun 2, 2023
406f3c0
Merge branch 'master' into MEP-sfn-timeout
8000 MEPalma Jun 21, 2023
ae5ee1e
minor
MEPalma Jun 21, 2023
d0a65b1
pr items
MEPalma Jun 22, 2023
2682ffa
minor cleanup
MEPalma Jun 22, 2023
95ee8e0
Merge branch 'master' into MEP-sfn-timeout
MEPalma Jun 22, 2023
07107db
conflicts, minors
MEPalma Jun 22, 2023
de9a320
fix cycle on send success
MEPalma Jun 22, 2023
1ceb08a
fix fail sender machine
MEPalma Jun 23, 2023
387016f
Merge branch 'master' into MEP-sfn-timeout
MEPalma Jun 23, 2023
51a9f84
Merge branch 'MEP-sfn-timeout' into MEP-sfn-taskfailure
MEPalma Jun 23, 2023
157993c
conflicts
MEPalma Jun 25, 2023
03ba9ce
conflicts, iterator in heartbeat_success machine
MEPalma Jun 25, 2023
497186c
conflicts
MEPalma Jun 26, 2023
d55ace6
update heartbeat snapshot tests
MEPalma Jun 26, 2023
44a83eb
base sfn support working
MEPalma Jun 28, 2023
2e3bb6e
input stringification
MEPalma Jun 28, 2023
e77df2b
sync happy path
MEPalma Jul 3, 2023
a73fe68
[]
MEPalma Jul 4, 2023
a90ecb8
timeout error types
MEPalma Jul 4, 2023
840a8a4
Merge branch 'master' into MEP-snf-heartbeat
MEPalma Jul 5, 2023
ad247a5
Merge branch 'MEP-snf-heartbeat' into MEP-sfn-sync-and-sfn
MEPalma Jul 5, 2023
525fae0
reworked exceptinos handling, fixes, tests
MEPalma Jul 5, 2023
7b85932
Merge branch 'master' into MEP-snf-heartbeat
MEPalma Jul 6, 2023
581f46f
cleanup
MEPalma Jul 6, 2023
b8d2526
Merge branch 'MEP-snf-heartbeat' into MEP-sfn-sync-and-sfn
MEPalma Jul 6, 2023
fc69033
Merge branch 'master' into MEP-sfn-sync-and-sfn
MEPalma Jul 6, 2023
0942505
Merge branch 'master' into MEP-sfn-sync-and-sfn
MEPalma Jul 7, 2023
9edad2d
connect_to in sqs
MEPalma Jul 13, 2023
562c236
Merge branch 'master' into MEP-sfn-sync-and-sfn
MEPalma Jul 13, 2023
e4985ee
Merge branch 'master' into MEP-sfn-sync-and-sfn
MEPalma Jul 14, 2023
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
[]
  • Loading branch information
MEPalma committed Jul 4, 2023
commit a73fe6870cc0d8a3f44aadb11a90d42ed6132bb4
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
from typing import Optional

from localstack.aws.api.stepfunctions import HistoryEventType
from localstack.aws.api.stepfunctions import HistoryEventType, TaskFailedEventDetails
from localstack.services.stepfunctions.asl.component.common.cause_decl import CauseDecl
from localstack.services.stepfunctions.asl.component.common.error_decl import ErrorDecl
from localstack.services.stepfunctions.asl.component.common.error_name.custom_error_name import (
CustomErrorName,
)
from localstack.services.stepfunctions.asl.component.common.error_name.failure_event import (
FailureEvent,
)
from localstack.services.stepfunctions.asl.component.state.state import CommonStateField
from localstack.services.stepfunctions.asl.component.state.state_props import StateProps
from localstack.services.stepfunctions.asl.eval.environment import Environment
from localstack.services.stepfunctions.asl.eval.event.event_detail import EventDetails


class StateFail(CommonStateField):
Expand All @@ -23,5 +30,13 @@ def from_state_props(self, state_props: StateProps) -> None:
self.error = state_props.get(ErrorDecl)

def _eval_state(self, env: Environment) -> None:
# TODO.
env.set_error(self)
failure_event = FailureEvent(
error_name=CustomErrorName(self.error.error),
event_type=HistoryEventType.TaskFailed,
event_details=EventDetails(
taskFailedEventDetails=TaskFailedEventDetails(
error=self.error.error, cause=self.cause.cause
)
),
)
env.stack.append(failure_event)
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class BaseTemplate(TemplateLoader):
BASE_PASS_RESULT: Final[str] = os.path.join(_THIS_FOLDER, "statemachines/pass_result.json5")
BASE_TASK_SEQ_2: Final[str] = os.path.join(_THIS_FOLDER, "statemachines/task_seq_2.json5")
BASE_WAIT_1_MIN: Final[str] = os.path.join(_THIS_FOLDER, "statemachines/wait_1_min.json5")
BASE_RAISE_FAILURE: Final[str] = os.path.join(_THIS_FOLDER, "statemachines/raise_failure.json5")
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Comment": "BASE_RAISE_FAILURE",
"StartAt": "FailState",
"States": {
"FailState": {
"Type": "Fail",
"Error": "SomeFailure",
"Cause": "This state machines raises a 'SomeFailure' failure."
},
},
}
46 changes: 46 additions & 0 deletions tests/integration/stepfunctions/v2/callback/test_callback.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,49 @@ def test_start_execution_sync(
definition,
exec_input,
)

def test_start_execution_sync_delegate_failure(
self,
aws_client,
create_iam_role_for_sfn,
create_state_machine,
sfn_snapshot,
):
sfn_snapshot.add_transformer(
JsonpathTransformer(
jsonpath="$..output.StartDate",
replacement="start-date",
replace_reference=False,
)
)
sfn_snapshot.add_transformer(
JsonpathTransformer(
jsonpath="$..cause.StartDate",
replacement="stop-date",
replace_reference=False,
)
)

template_target = BT.load_sfn_template(BT.BASE_RAISE_FAILURE)
definition_target = json.dumps(template_target)
state_machine_arn_target = create(
create_iam_role_for_sfn,
create_state_machine,
sfn_snapshot,
definition_target,
)

template = CT.load_sfn_template(CT.SFN_START_EXECUTION_SYNC)
definition = json.dumps(template)

exec_input = json.dumps(
{"StateMachineArn": state_machine_arn_target, "Input": None, "Name": "TestStartTarget"}
)
create_and_record_execution(
aws_client.stepfunctions,
create_iam_role_for_sfn,
create_state_machine,
sfn_snapshot,
definition,
exec_input,
)
Original file line number Diff line number Diff line change
Expand Up @@ -779,5 +779,171 @@
}
}
}
},
"tests/integration/stepfunctions/v2/callback/test_callback.py::TestCallback::test_start_execution_sync_delegate_failure": {
"recorded-date": "03-07-2023, 11:11:56",
"recorded-content": {
"get_execution_history": {
"events": [
{
"executionStartedEventDetails": {
"input": {
"StateMachineArn": "arn:aws:states:<region>:111111111111:stateMachine:<ArnPart_0idx>",
"Input": null,
"Name": "TestStartTarget"
},
"inputDetails": {
"truncated": false
},
"roleArn": "snf_role_arn"
},
"id": 1,
"previousEventId": 0,
"timestamp": "timestamp",
"type": "ExecutionStarted"
},
{
"id": 2,
"previousEventId": 0,
"stateEnteredEventDetails": {
"input": {
"StateMachineArn": "arn:aws:states:<region>:111111111111:stateMachine:<ArnPart_0idx>",
"Input": null,
"Name": "TestStartTarget"
},
"inputDetails": {
"truncated": false
},
"name": "StartExecution"
},
"timestamp": "timestamp",
"type": "TaskStateEntered"
},
{
"id": 3,
"previousEventId": 2,
"taskScheduledEventDetails": {
"parameters": {
"Input": null,
"StateMachineArn": "arn:aws:states:<region>:111111111111:stateMachine:<ArnPart_0idx>",
"Name": "TestStartTarget"
},
"region": "<region>",
"resource": "startExecution.sync",
"resourceType": "states"
},
"timestamp": "timestamp",
"type": "TaskScheduled"
},
{
"id": 4,
"previousEventId": 3,
"taskStartedEventDetails": {
"resource": "startExecution.sync",
"resourceType": "states"
},
"timestamp": "timestamp",
"type": "TaskStarted"
},
{
"id": 5,
"previousEventId": 4,
"taskSubmittedEventDetails": {
"output": {
"ExecutionArn": "arn:aws:states:<region>:111111111111:execution:<ArnPart_0idx>:TestStartTarget",
"SdkHttpMetadata": {
"AllHttpHeaders": {
"x-amzn-RequestId": [
"<uuid:1>"
],
"connection": [
"keep-alive"
],
"Content-Length": [
"161"
],
"Date": "date",
"Content-Type": [
"application/x-amz-json-1.0"
]
},
"HttpHeaders": {
"connection": "keep-alive",
"Content-Length": "161",
"Content-Type": "application/x-amz-json-1.0",
"Date": "date",
"x-amzn-RequestId": "<uuid:1>"
},
"HttpStatusCode": 200
},
"SdkResponseMetadata": {
"RequestId": "<uuid:1>"
},
"StartDate": "start-date"
},
"outputDetails": {
"truncated": false
},
"resource": "startExecution.sync",
"resourceType": "states"
},
"timestamp": "timestamp",
"type": "TaskSubmitted"
},
{
"id": 6,
"previousEventId": 5,
"taskFailedEventDetails": {
"cause": {
"Cause": "This state machines raises a 'SomeFailure' failure.",
"Error": "SomeFailure",
"ExecutionArn": "arn:aws:states:<region>:111111111111:execution:<ArnPart_0idx>:TestStartTarget",
"Input": "{}",
"InputDetails": {
"Included": true
},
"Name": "TestStartTarget",
"StartDate": "stop-date",
"StateMachineArn": "arn:aws:states:<region>:111111111111:stateMachine:<ArnPart_0idx>",
"Status": "FAILED",
"StopDate": 1688375513430
},
"error": "States.TaskFailed",
"resource": "startExecution.sync",
"resourceType": "states"
},
"timestamp": "timestamp",
"type": "TaskFailed"
},
{
"executionFailedEventDetails": {
"cause": {
"Cause": "This state machines raises a 'SomeFailure' failure.",
"Error": "SomeFailure",
"ExecutionArn": "arn:aws:states:<region>:111111111111:execution:<ArnPart_0idx>:TestStartTarget",
"Input": "{}",
"InputDetails": {
"Included": true
},
"Name": "TestStartTarget",
"StartDate": "stop-date",
"StateMachineArn": "arn:aws:states:<region>:111111111111:stateMachine:<ArnPart_0idx>",
"Status": "FAILED",
"StopDate": 1688375513430
},
"error": "States.TaskFailed"
},
"id": 7,
"previousEventId": 6,
"timestamp": "timestamp",
"type": "ExecutionFailed"
}
],
"ResponseMetadata": {
"HTTPHeaders": {},
"HTTPStatusCode": 200
}
}
}
}
}
0