From a55ec15208792af4c9c07c4a99529d7712a6568c Mon Sep 17 00:00:00 2001 From: MEPalma Date: Fri, 13 Dec 2024 14:45:51 +0100 Subject: [PATCH] remove program copy --- .../state_map/iteration/job.py | 2 +- .../scenarios/scenarios_templates.py | 3 + .../map_state_nested_config_distributed.json5 | 59 +++++++ .../v2/scenarios/test_base_scenarios.py | 22 +++ .../test_base_scenarios.snapshot.json | 150 ++++++++++++++++++ .../test_base_scenarios.validation.json | 3 + 6 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 tests/aws/services/stepfunctions/templates/scenarios/statemachines/map_state_nested_config_distributed.json5 diff --git a/localstack-core/localstack/services/stepfunctions/asl/component/state/state_execution/state_map/iteration/job.py b/localstack-core/localstack/services/stepfunctions/asl/component/state/state_execution/state_map/iteration/job.py index bcab5b247ea4f..1ef24a6e17593 100644 --- a/localstack-core/localstack/services/stepfunctions/asl/component/state/state_execution/state_map/iteration/job.py +++ b/localstack-core/localstack/services/stepfunctions/asl/component/state/state_execution/state_map/iteration/job.py @@ -50,7 +50,7 @@ def __init__(self, job_program: Program, job_inputs: list[Any]): self._jobs_number = len(job_inputs) self._open_jobs = [ - Job(job_index=job_index, job_program=copy.deepcopy(job_program), job_input=job_input) + Job(job_index=job_index, job_program=job_program, job_input=job_input) for job_index, job_input in enumerate(job_inputs) ] self._open_jobs.reverse() diff --git a/tests/aws/services/stepfunctions/templates/scenarios/scenarios_templates.py b/tests/aws/services/stepfunctions/templates/scenarios/scenarios_templates.py index 5d1bdc19755fe..b64f4bf0ed874 100644 --- a/tests/aws/services/stepfunctions/templates/scenarios/scenarios_templates.py +++ b/tests/aws/services/stepfunctions/templates/scenarios/scenarios_templates.py @@ -82,6 +82,9 @@ class ScenariosTemplate(TemplateLoader): MAP_STATE_NESTED: Final[str] = os.path.join( _THIS_FOLDER, "statemachines/map_state_nested.json5" ) + MAP_STATE_NESTED_CONFIG_DISTRIBUTED: Final[str] = os.path.join( + _THIS_FOLDER, "statemachines/map_state_nested_config_distributed.json5" + ) MAP_STATE_NO_PROCESSOR_CONFIG: Final[str] = os.path.join( _THIS_FOLDER, "statemachines/map_state_no_processor_config.json5" ) diff --git a/tests/aws/services/stepfunctions/templates/scenarios/statemachines/map_state_nested_config_distributed.json5 b/tests/aws/services/stepfunctions/templates/scenarios/statemachines/map_state_nested_config_distributed.json5 new file mode 100644 index 0000000000000..1602a74a9e7bc --- /dev/null +++ b/tests/aws/services/stepfunctions/templates/scenarios/statemachines/map_state_nested_config_distributed.json5 @@ -0,0 +1,59 @@ +{ + "StartAt": "SetupState", + "States": { + "SetupState": { + "Type": "Pass", + "Result": { + "values": [ + { + "sub-values": [ + { + "num": 1, + "str": "A" + }, + { + "num": 2, + "str": "B" + } + ] + } + ] + }, + "Next": "MapState", + }, + "MapState": { + "Type": "Map", + "MaxConcurrency": 1, + "ItemsPath": "$.values", + "ItemProcessor": { + "ProcessorConfig": { + "Mode": "DISTRIBUTED", + "ExecutionType": "STANDARD", + }, + "StartAt": "SubMapState", + "States": { + "SubMapState": { + "Type": "Map", + "MaxConcurrency": 1, + "ItemsPath": "$.sub-values", + "ResultPath": "$.result", + "ItemProcessor": { + "ProcessorConfig": { + "Mode": "DISTRIBUTED", + "ExecutionType": "STANDARD", + }, + "StartAt": "SubMapStateSuccess", + "States": { + "SubMapStateSuccess": { + "Type": "Succeed" + } + }, + }, + "End": true, + } + }, + }, + "End": true, + }, + }, +} \ No newline at end of file diff --git a/tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.py b/tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.py index 41a5307915a1d..c5f3a66d4fe93 100644 --- a/tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.py +++ b/tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.py @@ -1353,6 +1353,28 @@ def test_map_state_label( exec_input, ) + @markers.aws.validated + @markers.snapshot.skip_snapshot_verify(paths=["$..events[8].previousEventId"]) + def test_map_state_nested_config_distributed( + self, + aws_client, + create_state_machine_iam_role, + create_state_machine, + sfn_snapshot, + ): + template = ST.load_sfn_template(ST.MAP_STATE_NESTED_CONFIG_DISTRIBUTED) + definition = json.dumps(template) + + exec_input = json.dumps({}) + create_and_record_execution( + aws_client, + create_state_machine_iam_role, + create_state_machine, + sfn_snapshot, + definition, + exec_input, + ) + @markers.aws.validated def test_map_state_result_writer( self, diff --git a/tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.snapshot.json b/tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.snapshot.json index 6562d79cbfe11..f9023e4f1e2dc 100644 --- a/tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.snapshot.json +++ b/tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.snapshot.json @@ -24895,5 +24895,155 @@ } } } + }, + "tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.py::TestBaseScenarios::test_map_state_nested_config_distributed": { + "recorded-date": "13-12-2024, 13:38:16", + "recorded-content": { + "get_execution_history": { + "events": [ + { + "executionStartedEventDetails": { + "input": {}, + "inputDetails": { + "truncated": false + }, + "roleArn": "snf_role_arn" + }, + "id": 1, + "previousEventId": 0, + "timestamp": "timestamp", + "type": "ExecutionStarted" + }, + { + "id": 2, + "previousEventId": 0, + "stateEnteredEventDetails": { + "input": {}, + "inputDetails": { + "truncated": false + }, + "name": "SetupState" + }, + "timestamp": "timestamp", + "type": "PassStateEntered" + }, + { + "id": 3, + "previousEventId": 2, + "stateExitedEventDetails": { + "name": "SetupState", + "output": { + "values": [ + { + "sub-values": [ + { + "num": 1, + "str": "A" + }, + { + "num": 2, + "str": "B" + } + ] + } + ] + }, + "outputDetails": { + "truncated": false + } + }, + "timestamp": "timestamp", + "type": "PassStateExited" + }, + { + "id": 4, + "previousEventId": 3, + "stateEnteredEventDetails": { + "input": { + "values": [ + { + "sub-values": [ + { + "num": 1, + "str": "A" + }, + { + "num": 2, + "str": "B" + } + ] + } + ] + }, + "inputDetails": { + "truncated": false + }, + "name": "MapState" + }, + "timestamp": "timestamp", + "type": "MapStateEntered" + }, + { + "id": 5, + "mapStateStartedEventDetails": { + "length": 1 + }, + "previousEventId": 4, + "timestamp": "timestamp", + "type": "MapStateStarted" + }, + { + "id": 6, + "mapRunStartedEventDetails": { + "mapRunArn": "arn::states::111111111111:mapRun:/:" + }, + "previousEventId": 5, + "timestamp": "timestamp", + "type": "MapRunStarted" + }, + { + "id": 7, + "previousEventId": 6, + "timestamp": "timestamp", + "type": "MapRunSucceeded" + }, + { + "id": 8, + "previousEventId": 7, + "timestamp": "timestamp", + "type": "MapStateSucceeded" + }, + { + "id": 9, + "previousEventId": 6, + "stateExitedEventDetails": { + "name": "MapState", + "output": "[{\"sub-values\":[{\"num\":1,\"str\":\"A\"},{\"num\":2,\"str\":\"B\"}],\"result\":[{\"num\":1,\"str\":\"A\"},{\"num\":2,\"str\":\"B\"}]}]", + "outputDetails": { + "truncated": false + } + }, + "timestamp": "timestamp", + "type": "MapStateExited" + }, + { + "executionSucceededEventDetails": { + "output": "[{\"sub-values\":[{\"num\":1,\"str\":\"A\"},{\"num\":2,\"str\":\"B\"}],\"result\":[{\"num\":1,\"str\":\"A\"},{\"num\":2,\"str\":\"B\"}]}]", + "outputDetails": { + "truncated": false + } + }, + "id": 10, + "previousEventId": 9, + "timestamp": "timestamp", + "type": "ExecutionSucceeded" + } + ], + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } } } diff --git a/tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.validation.json b/tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.validation.json index b52d3a6ab7bcd..3ae7725ca78c9 100644 --- a/tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.validation.json +++ b/tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.validation.json @@ -278,6 +278,9 @@ "tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.py::TestBaseScenarios::test_map_state_nested": { "last_validated_date": "2024-03-29T16:26:02+00:00" }, + "tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.py::TestBaseScenarios::test_map_state_nested_config_distributed": { + "last_validated_date": "2024-12-13T13:38:16+00:00" + }, "tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.py::TestBaseScenarios::test_map_state_no_processor_config": { "last_validated_date": "2023-12-15T21:25:27+00:00" },