localstack-core 4.10.1.dev42__py3-none-any.whl → 4.12.1.dev18__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of localstack-core might be problematic. Click here for more details.
- localstack/aws/api/apigateway/__init__.py +42 -0
- localstack/aws/api/cloudformation/__init__.py +161 -0
- localstack/aws/api/ec2/__init__.py +1178 -12
- localstack/aws/api/iam/__init__.py +228 -0
- localstack/aws/api/kms/__init__.py +1 -0
- localstack/aws/api/lambda_/__init__.py +1034 -66
- localstack/aws/api/logs/__init__.py +500 -0
- localstack/aws/api/opensearch/__init__.py +100 -0
- localstack/aws/api/redshift/__init__.py +69 -0
- localstack/aws/api/resourcegroupstaggingapi/__init__.py +36 -0
- localstack/aws/api/route53/__init__.py +45 -0
- localstack/aws/api/route53resolver/__init__.py +1 -0
- localstack/aws/api/s3/__init__.py +64 -0
- localstack/aws/api/s3control/__init__.py +19 -0
- localstack/aws/api/secretsmanager/__init__.py +37 -23
- localstack/aws/api/stepfunctions/__init__.py +52 -10
- localstack/aws/api/sts/__init__.py +52 -0
- localstack/aws/connect.py +35 -15
- localstack/aws/handlers/logging.py +8 -4
- localstack/aws/handlers/service.py +11 -2
- localstack/aws/protocol/serializer.py +1 -1
- localstack/config.py +8 -0
- localstack/constants.py +3 -0
- localstack/deprecations.py +0 -6
- localstack/dev/kubernetes/__main__.py +39 -14
- localstack/runtime/analytics.py +11 -0
- localstack/services/acm/provider.py +17 -1
- localstack/services/apigateway/legacy/provider.py +28 -15
- localstack/services/cloudformation/engine/template_preparer.py +6 -2
- localstack/services/cloudformation/engine/v2/change_set_model.py +9 -0
- localstack/services/cloudformation/engine/v2/change_set_model_preproc.py +15 -1
- localstack/services/cloudformation/engine/v2/change_set_resource_support_checker.py +114 -0
- localstack/services/cloudformation/provider.py +26 -1
- localstack/services/cloudformation/provider_utils.py +20 -0
- localstack/services/cloudformation/resource_provider.py +5 -4
- localstack/services/cloudformation/scaffolding/__main__.py +94 -22
- localstack/services/cloudformation/v2/provider.py +41 -0
- localstack/services/cloudwatch/provider.py +10 -3
- localstack/services/cloudwatch/provider_v2.py +6 -3
- localstack/services/configservice/provider.py +5 -1
- localstack/services/dynamodb/provider.py +1 -0
- localstack/services/dynamodb/v2/provider.py +1 -0
- localstack/services/dynamodbstreams/provider.py +6 -0
- localstack/services/dynamodbstreams/v2/provider.py +6 -0
- localstack/services/ec2/provider.py +6 -0
- localstack/services/es/provider.py +6 -0
- localstack/services/events/provider.py +4 -0
- localstack/services/events/v1/provider.py +9 -0
- localstack/services/firehose/provider.py +5 -0
- localstack/services/iam/provider.py +4 -0
- localstack/services/kinesis/packages.py +1 -1
- localstack/services/kms/models.py +16 -22
- localstack/services/kms/provider.py +4 -0
- localstack/services/lambda_/analytics.py +11 -2
- localstack/services/lambda_/api_utils.py +37 -20
- localstack/services/lambda_/event_source_mapping/pollers/stream_poller.py +1 -1
- localstack/services/lambda_/invocation/assignment.py +4 -1
- localstack/services/lambda_/invocation/event_manager.py +15 -11
- localstack/services/lambda_/invocation/execution_environment.py +21 -2
- localstack/services/lambda_/invocation/lambda_models.py +31 -2
- localstack/services/lambda_/invocation/lambda_service.py +62 -3
- localstack/services/lambda_/invocation/models.py +9 -1
- localstack/services/lambda_/invocation/version_manager.py +18 -3
- localstack/services/lambda_/provider.py +307 -106
- localstack/services/lambda_/resource_providers/aws_lambda_function.py +33 -1
- localstack/services/lambda_/runtimes.py +3 -1
- localstack/services/logs/provider.py +9 -0
- localstack/services/opensearch/packages.py +34 -20
- localstack/services/opensearch/provider.py +53 -3
- localstack/services/resource_groups/provider.py +5 -1
- localstack/services/resourcegroupstaggingapi/provider.py +6 -1
- localstack/services/route53/provider.py +7 -0
- localstack/services/route53resolver/provider.py +5 -0
- localstack/services/s3/constants.py +5 -0
- localstack/services/s3/exceptions.py +9 -0
- localstack/services/s3/models.py +9 -1
- localstack/services/s3/provider.py +51 -43
- localstack/services/s3/utils.py +81 -15
- localstack/services/s3control/provider.py +107 -2
- localstack/services/s3control/validation.py +50 -0
- localstack/services/scheduler/provider.py +4 -2
- localstack/services/secretsmanager/provider.py +4 -0
- localstack/services/ses/provider.py +4 -0
- localstack/services/sns/constants.py +16 -1
- localstack/services/sns/provider.py +5 -0
- localstack/services/sns/publisher.py +15 -6
- localstack/services/sns/v2/models.py +9 -0
- localstack/services/sns/v2/provider.py +750 -19
- localstack/services/sns/v2/utils.py +12 -0
- localstack/services/sqs/constants.py +6 -0
- localstack/services/sqs/provider.py +9 -1
- localstack/services/sqs/resource_providers/aws_sqs_queue.py +61 -46
- localstack/services/ssm/provider.py +6 -0
- localstack/services/stepfunctions/asl/component/common/path/result_path.py +1 -1
- localstack/services/stepfunctions/asl/component/state/state_execution/execute_state.py +0 -1
- localstack/services/stepfunctions/asl/component/state/state_execution/state_map/state_map.py +0 -1
- localstack/services/stepfunctions/asl/component/state/state_execution/state_task/lambda_eval_utils.py +8 -8
- localstack/services/stepfunctions/asl/component/state/state_execution/state_task/{mock_eval_utils.py → local_mock_eval_utils.py} +13 -9
- localstack/services/stepfunctions/asl/component/state/state_execution/state_task/service/state_task_service.py +6 -6
- localstack/services/stepfunctions/asl/component/state/state_execution/state_task/service/state_task_service_callback.py +1 -1
- localstack/services/stepfunctions/asl/component/state/state_fail/state_fail.py +4 -0
- localstack/services/stepfunctions/asl/component/test_state/state/base_mock.py +118 -0
- localstack/services/stepfunctions/asl/component/test_state/state/common.py +82 -0
- localstack/services/stepfunctions/asl/component/test_state/state/execution.py +139 -0
- localstack/services/stepfunctions/asl/component/test_state/state/map.py +77 -0
- localstack/services/stepfunctions/asl/component/test_state/state/task.py +44 -0
- localstack/services/stepfunctions/asl/eval/environment.py +30 -22
- localstack/services/stepfunctions/asl/eval/states.py +1 -1
- localstack/services/stepfunctions/asl/eval/test_state/environment.py +49 -9
- localstack/services/stepfunctions/asl/eval/test_state/program_state.py +22 -0
- localstack/services/stepfunctions/asl/jsonata/jsonata.py +5 -1
- localstack/services/stepfunctions/asl/parse/preprocessor.py +67 -24
- localstack/services/stepfunctions/asl/parse/test_state/asl_parser.py +5 -4
- localstack/services/stepfunctions/asl/parse/test_state/preprocessor.py +222 -31
- localstack/services/stepfunctions/asl/static_analyser/test_state/test_state_analyser.py +256 -22
- localstack/services/stepfunctions/backend/execution.py +10 -11
- localstack/services/stepfunctions/backend/execution_worker.py +5 -5
- localstack/services/stepfunctions/backend/test_state/execution.py +36 -0
- localstack/services/stepfunctions/backend/test_state/execution_worker.py +33 -1
- localstack/services/stepfunctions/backend/test_state/test_state_mock.py +127 -0
- localstack/services/stepfunctions/local_mocking/__init__.py +9 -0
- localstack/services/stepfunctions/{mocking → local_mocking}/mock_config.py +24 -17
- localstack/services/stepfunctions/provider.py +83 -25
- localstack/services/stepfunctions/test_state/mock_config.py +47 -0
- localstack/services/sts/provider.py +7 -0
- localstack/services/support/provider.py +5 -1
- localstack/services/swf/provider.py +5 -1
- localstack/services/transcribe/provider.py +7 -0
- localstack/testing/aws/lambda_utils.py +1 -1
- localstack/testing/aws/util.py +2 -1
- localstack/testing/config.py +1 -0
- localstack/testing/pytest/fixtures.py +28 -0
- localstack/testing/snapshots/transformer_utility.py +5 -0
- localstack/utils/analytics/publisher.py +37 -155
- localstack/utils/analytics/service_request_aggregator.py +6 -4
- localstack/utils/aws/arns.py +7 -0
- localstack/utils/aws/client_types.py +2 -4
- localstack/utils/batching.py +258 -0
- localstack/utils/bootstrap.py +2 -2
- localstack/utils/catalog/catalog.py +3 -2
- localstack/utils/collections.py +23 -11
- localstack/utils/container_utils/container_client.py +22 -13
- localstack/utils/container_utils/docker_cmd_client.py +6 -6
- localstack/version.py +2 -2
- {localstack_core-4.10.1.dev42.dist-info → localstack_core-4.12.1.dev18.dist-info}/METADATA +7 -7
- {localstack_core-4.10.1.dev42.dist-info → localstack_core-4.12.1.dev18.dist-info}/RECORD +155 -146
- localstack_core-4.12.1.dev18.dist-info/plux.json +1 -0
- localstack/services/stepfunctions/mocking/__init__.py +0 -0
- localstack/utils/batch_policy.py +0 -124
- localstack_core-4.10.1.dev42.dist-info/plux.json +0 -1
- /localstack/services/stepfunctions/{mocking → local_mocking}/mock_config_file.py +0 -0
- {localstack_core-4.10.1.dev42.data → localstack_core-4.12.1.dev18.data}/scripts/localstack +0 -0
- {localstack_core-4.10.1.dev42.data → localstack_core-4.12.1.dev18.data}/scripts/localstack-supervisor +0 -0
- {localstack_core-4.10.1.dev42.data → localstack_core-4.12.1.dev18.data}/scripts/localstack.bat +0 -0
- {localstack_core-4.10.1.dev42.dist-info → localstack_core-4.12.1.dev18.dist-info}/WHEEL +0 -0
- {localstack_core-4.10.1.dev42.dist-info → localstack_core-4.12.1.dev18.dist-info}/entry_points.txt +0 -0
- {localstack_core-4.10.1.dev42.dist-info → localstack_core-4.12.1.dev18.dist-info}/licenses/LICENSE.txt +0 -0
- {localstack_core-4.10.1.dev42.dist-info → localstack_core-4.12.1.dev18.dist-info}/top_level.txt +0 -0
|
@@ -7,13 +7,17 @@ from antlr4.tree.Tree import ParseTree, TerminalNodeImpl
|
|
|
7
7
|
|
|
8
8
|
from localstack.services.stepfunctions.asl.antlr.runtime.ASLLexer import ASLLexer
|
|
9
9
|
from localstack.services.stepfunctions.asl.antlr.runtime.ASLParser import ASLParser
|
|
10
|
-
from localstack.services.stepfunctions.asl.antlr.runtime.ASLParserVisitor import
|
|
10
|
+
from localstack.services.stepfunctions.asl.antlr.runtime.ASLParserVisitor import (
|
|
11
|
+
ASLParserVisitor,
|
|
12
|
+
)
|
|
11
13
|
from localstack.services.stepfunctions.asl.antlt4utils.antlr4utils import (
|
|
12
14
|
from_string_literal,
|
|
13
15
|
is_production,
|
|
14
16
|
is_terminal,
|
|
15
17
|
)
|
|
16
|
-
from localstack.services.stepfunctions.asl.component.common.assign.assign_decl import
|
|
18
|
+
from localstack.services.stepfunctions.asl.component.common.assign.assign_decl import (
|
|
19
|
+
AssignDecl,
|
|
20
|
+
)
|
|
17
21
|
from localstack.services.stepfunctions.asl.component.common.assign.assign_decl_binding import (
|
|
18
22
|
AssignDeclBinding,
|
|
19
23
|
)
|
|
@@ -36,9 +40,15 @@ from localstack.services.stepfunctions.asl.component.common.assign.assign_templa
|
|
|
36
40
|
AssignTemplateValueTerminalLit,
|
|
37
41
|
AssignTemplateValueTerminalStringJSONata,
|
|
38
42
|
)
|
|
39
|
-
from localstack.services.stepfunctions.asl.component.common.catch.catch_decl import
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
from localstack.services.stepfunctions.asl.component.common.catch.catch_decl import (
|
|
44
|
+
CatchDecl,
|
|
45
|
+
)
|
|
46
|
+
from localstack.services.stepfunctions.asl.component.common.catch.catcher_decl import (
|
|
47
|
+
CatcherDecl,
|
|
48
|
+
)
|
|
49
|
+
from localstack.services.stepfunctions.asl.component.common.catch.catcher_props import (
|
|
50
|
+
CatcherProps,
|
|
51
|
+
)
|
|
42
52
|
from localstack.services.stepfunctions.asl.component.common.comment import Comment
|
|
43
53
|
from localstack.services.stepfunctions.asl.component.common.error_name.custom_error_name import (
|
|
44
54
|
CustomErrorName,
|
|
@@ -46,7 +56,9 @@ from localstack.services.stepfunctions.asl.component.common.error_name.custom_er
|
|
|
46
56
|
from localstack.services.stepfunctions.asl.component.common.error_name.error_equals_decl import (
|
|
47
57
|
ErrorEqualsDecl,
|
|
48
58
|
)
|
|
49
|
-
from localstack.services.stepfunctions.asl.component.common.error_name.error_name import
|
|
59
|
+
from localstack.services.stepfunctions.asl.component.common.error_name.error_name import (
|
|
60
|
+
ErrorName,
|
|
61
|
+
)
|
|
50
62
|
from localstack.services.stepfunctions.asl.component.common.error_name.states_error_name import (
|
|
51
63
|
StatesErrorName,
|
|
52
64
|
)
|
|
@@ -79,10 +91,18 @@ from localstack.services.stepfunctions.asl.component.common.parargs import (
|
|
|
79
91
|
Parameters,
|
|
80
92
|
Parargs,
|
|
81
93
|
)
|
|
82
|
-
from localstack.services.stepfunctions.asl.component.common.path.input_path import
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
from localstack.services.stepfunctions.asl.component.common.path.
|
|
94
|
+
from localstack.services.stepfunctions.asl.component.common.path.input_path import (
|
|
95
|
+
InputPath,
|
|
96
|
+
)
|
|
97
|
+
from localstack.services.stepfunctions.asl.component.common.path.items_path import (
|
|
98
|
+
ItemsPath,
|
|
99
|
+
)
|
|
100
|
+
from localstack.services.stepfunctions.asl.component.common.path.output_path import (
|
|
101
|
+
OutputPath,
|
|
102
|
+
)
|
|
103
|
+
from localstack.services.stepfunctions.asl.component.common.path.result_path import (
|
|
104
|
+
ResultPath,
|
|
105
|
+
)
|
|
86
106
|
from localstack.services.stepfunctions.asl.component.common.payload.payloadvalue.payload_value import (
|
|
87
107
|
PayloadValue,
|
|
88
108
|
)
|
|
@@ -116,7 +136,9 @@ from localstack.services.stepfunctions.asl.component.common.query_language impor
|
|
|
116
136
|
QueryLanguage,
|
|
117
137
|
QueryLanguageMode,
|
|
118
138
|
)
|
|
119
|
-
from localstack.services.stepfunctions.asl.component.common.result_selector import
|
|
139
|
+
from localstack.services.stepfunctions.asl.component.common.result_selector import (
|
|
140
|
+
ResultSelector,
|
|
141
|
+
)
|
|
120
142
|
from localstack.services.stepfunctions.asl.component.common.retry.backoff_rate_decl import (
|
|
121
143
|
BackoffRateDecl,
|
|
122
144
|
)
|
|
@@ -133,9 +155,15 @@ from localstack.services.stepfunctions.asl.component.common.retry.max_attempts_d
|
|
|
133
155
|
from localstack.services.stepfunctions.asl.component.common.retry.max_delay_seconds_decl import (
|
|
134
156
|
MaxDelaySecondsDecl,
|
|
135
157
|
)
|
|
136
|
-
from localstack.services.stepfunctions.asl.component.common.retry.retrier_decl import
|
|
137
|
-
|
|
138
|
-
|
|
158
|
+
from localstack.services.stepfunctions.asl.component.common.retry.retrier_decl import (
|
|
159
|
+
RetrierDecl,
|
|
160
|
+
)
|
|
161
|
+
from localstack.services.stepfunctions.asl.component.common.retry.retrier_props import (
|
|
162
|
+
RetrierProps,
|
|
163
|
+
)
|
|
164
|
+
from localstack.services.stepfunctions.asl.component.common.retry.retry_decl import (
|
|
165
|
+
RetryDecl,
|
|
166
|
+
)
|
|
139
167
|
from localstack.services.stepfunctions.asl.component.common.string.string_expression import (
|
|
140
168
|
StringContextPath,
|
|
141
169
|
StringExpression,
|
|
@@ -291,15 +319,23 @@ from localstack.services.stepfunctions.asl.component.state.state_fail.error_decl
|
|
|
291
319
|
Error,
|
|
292
320
|
ErrorPath,
|
|
293
321
|
)
|
|
294
|
-
from localstack.services.stepfunctions.asl.component.state.state_fail.state_fail import
|
|
295
|
-
|
|
296
|
-
|
|
322
|
+
from localstack.services.stepfunctions.asl.component.state.state_fail.state_fail import (
|
|
323
|
+
StateFail,
|
|
324
|
+
)
|
|
325
|
+
from localstack.services.stepfunctions.asl.component.state.state_pass.result import (
|
|
326
|
+
Result,
|
|
327
|
+
)
|
|
328
|
+
from localstack.services.stepfunctions.asl.component.state.state_pass.state_pass import (
|
|
329
|
+
StatePass,
|
|
330
|
+
)
|
|
297
331
|
from localstack.services.stepfunctions.asl.component.state.state_props import StateProps
|
|
298
332
|
from localstack.services.stepfunctions.asl.component.state.state_succeed.state_succeed import (
|
|
299
333
|
StateSucceed,
|
|
300
334
|
)
|
|
301
335
|
from localstack.services.stepfunctions.asl.component.state.state_type import StateType
|
|
302
|
-
from localstack.services.stepfunctions.asl.component.state.state_wait.state_wait import
|
|
336
|
+
from localstack.services.stepfunctions.asl.component.state.state_wait.state_wait import (
|
|
337
|
+
StateWait,
|
|
338
|
+
)
|
|
303
339
|
from localstack.services.stepfunctions.asl.component.state.state_wait.wait_function.seconds import (
|
|
304
340
|
Seconds,
|
|
305
341
|
SecondsJSONata,
|
|
@@ -311,18 +347,24 @@ from localstack.services.stepfunctions.asl.component.state.state_wait.wait_funct
|
|
|
311
347
|
Timestamp,
|
|
312
348
|
TimestampPath,
|
|
313
349
|
)
|
|
314
|
-
from localstack.services.stepfunctions.asl.parse.intrinsic.intrinsic_parser import
|
|
350
|
+
from localstack.services.stepfunctions.asl.parse.intrinsic.intrinsic_parser import (
|
|
351
|
+
IntrinsicParser,
|
|
352
|
+
)
|
|
315
353
|
from localstack.services.stepfunctions.asl.parse.typed_props import TypedProps
|
|
316
354
|
|
|
317
355
|
LOG = logging.getLogger(__name__)
|
|
318
356
|
|
|
319
357
|
|
|
320
358
|
class Preprocessor(ASLParserVisitor):
|
|
321
|
-
|
|
359
|
+
def __init__(self):
|
|
360
|
+
self._query_language_per_scope: list[QueryLanguage] = []
|
|
322
361
|
|
|
323
362
|
def _get_current_query_language(self) -> QueryLanguage:
|
|
324
363
|
return self._query_language_per_scope[-1]
|
|
325
364
|
|
|
365
|
+
def _get_top_level_query_language(self) -> QueryLanguage:
|
|
366
|
+
return self._query_language_per_scope[0]
|
|
367
|
+
|
|
326
368
|
def _open_query_language_scope(self, parse_tree: ParseTree) -> None:
|
|
327
369
|
production = is_production(parse_tree)
|
|
328
370
|
if production is None:
|
|
@@ -347,11 +389,11 @@ class Preprocessor(ASLParserVisitor):
|
|
|
347
389
|
query_language = QueryLanguage()
|
|
348
390
|
# Otherwise, check for logical conflicts and add the latest or inherited value to as the next scope.
|
|
349
391
|
else:
|
|
350
|
-
|
|
392
|
+
top_query_language = self._get_top_level_query_language()
|
|
351
393
|
if query_language is None:
|
|
352
|
-
query_language =
|
|
394
|
+
query_language = top_query_language
|
|
353
395
|
if (
|
|
354
|
-
|
|
396
|
+
top_query_language.query_language_mode == QueryLanguageMode.JSONata
|
|
355
397
|
and query_language.query_language_mode == QueryLanguageMode.JSONPath
|
|
356
398
|
):
|
|
357
399
|
raise ValueError(
|
|
@@ -1507,5 +1549,6 @@ class Preprocessor(ASLParserVisitor):
|
|
|
1507
1549
|
intrinsic_function_derivation = ctx.STRINGINTRINSICFUNC().getText()[1:-1]
|
|
1508
1550
|
function, _ = IntrinsicParser.parse(intrinsic_function_derivation)
|
|
1509
1551
|
return StringIntrinsicFunction(
|
|
1510
|
-
intrinsic_function_derivation=intrinsic_function_derivation,
|
|
1552
|
+
intrinsic_function_derivation=intrinsic_function_derivation,
|
|
1553
|
+
function=function,
|
|
1511
1554
|
)
|
|
@@ -15,7 +15,9 @@ from localstack.services.stepfunctions.asl.parse.test_state.preprocessor import
|
|
|
15
15
|
|
|
16
16
|
class TestStateAmazonStateLanguageParser(AmazonStateLanguageParser):
|
|
17
17
|
@staticmethod
|
|
18
|
-
def parse(
|
|
18
|
+
def parse(
|
|
19
|
+
definition: str, state_name: str | None = None
|
|
20
|
+
) -> tuple[EvalComponent, ParserRuleContext]:
|
|
19
21
|
# Attempt to build the AST and look out for syntax errors.
|
|
20
22
|
syntax_error_listener = SyntaxErrorListener()
|
|
21
23
|
|
|
@@ -25,15 +27,14 @@ class TestStateAmazonStateLanguageParser(AmazonStateLanguageParser):
|
|
|
25
27
|
parser = ASLParser(stream)
|
|
26
28
|
parser.removeErrorListeners()
|
|
27
29
|
parser.addErrorListener(syntax_error_listener)
|
|
28
|
-
# Unlike the main Program parser, TestState parsing occurs at a state declaration level.
|
|
29
|
-
tree = parser.state_decl_body()
|
|
30
30
|
|
|
31
|
+
tree = parser.state_machine() if state_name else parser.state_decl_body()
|
|
31
32
|
errors = syntax_error_listener.errors
|
|
32
33
|
if errors:
|
|
33
34
|
raise ASLParserException(errors=errors)
|
|
34
35
|
|
|
35
36
|
# Attempt to preprocess the AST into evaluation components.
|
|
36
37
|
preprocessor = TestStatePreprocessor()
|
|
37
|
-
test_state_program = preprocessor.
|
|
38
|
+
test_state_program = preprocessor.to_test_state_program(tree, state_name)
|
|
38
39
|
|
|
39
40
|
return test_state_program, tree
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import enum
|
|
2
2
|
from typing import Final
|
|
3
3
|
|
|
4
|
+
from antlr4.tree.Tree import ParseTree
|
|
5
|
+
|
|
4
6
|
from localstack.services.stepfunctions.asl.antlr.runtime.ASLParser import ASLParser
|
|
5
|
-
from localstack.services.stepfunctions.asl.
|
|
7
|
+
from localstack.services.stepfunctions.asl.antlt4utils.antlr4utils import (
|
|
8
|
+
is_production,
|
|
9
|
+
)
|
|
10
|
+
from localstack.services.stepfunctions.asl.component.common.parargs import (
|
|
11
|
+
ArgumentsJSONataTemplateValueObject,
|
|
12
|
+
ArgumentsStringJSONata,
|
|
13
|
+
Parameters,
|
|
14
|
+
)
|
|
6
15
|
from localstack.services.stepfunctions.asl.component.common.path.input_path import InputPath
|
|
16
|
+
from localstack.services.stepfunctions.asl.component.common.path.items_path import ItemsPath
|
|
7
17
|
from localstack.services.stepfunctions.asl.component.common.path.result_path import ResultPath
|
|
8
18
|
from localstack.services.stepfunctions.asl.component.common.query_language import QueryLanguage
|
|
9
19
|
from localstack.services.stepfunctions.asl.component.common.result_selector import ResultSelector
|
|
@@ -11,13 +21,43 @@ from localstack.services.stepfunctions.asl.component.state.state import CommonSt
|
|
|
11
21
|
from localstack.services.stepfunctions.asl.component.state.state_choice.state_choice import (
|
|
12
22
|
StateChoice,
|
|
13
23
|
)
|
|
14
|
-
from localstack.services.stepfunctions.asl.component.state.state_execution.
|
|
15
|
-
|
|
24
|
+
from localstack.services.stepfunctions.asl.component.state.state_execution.state_map.max_concurrency import (
|
|
25
|
+
MaxConcurrency,
|
|
26
|
+
MaxConcurrencyJSONata,
|
|
27
|
+
MaxConcurrencyPath,
|
|
28
|
+
)
|
|
29
|
+
from localstack.services.stepfunctions.asl.component.state.state_execution.state_map.state_map import (
|
|
30
|
+
StateMap,
|
|
16
31
|
)
|
|
32
|
+
from localstack.services.stepfunctions.asl.component.state.state_execution.state_map.tolerated_failure import (
|
|
33
|
+
ToleratedFailureCountInt,
|
|
34
|
+
ToleratedFailureCountPath,
|
|
35
|
+
ToleratedFailureCountStringJSONata,
|
|
36
|
+
ToleratedFailurePercentage,
|
|
37
|
+
ToleratedFailurePercentagePath,
|
|
38
|
+
ToleratedFailurePercentageStringJSONata,
|
|
39
|
+
)
|
|
40
|
+
from localstack.services.stepfunctions.asl.component.state.state_execution.state_task.state_task import (
|
|
41
|
+
StateTask,
|
|
42
|
+
)
|
|
43
|
+
from localstack.services.stepfunctions.asl.component.state.state_fail.state_fail import StateFail
|
|
17
44
|
from localstack.services.stepfunctions.asl.component.state.state_pass.result import Result
|
|
45
|
+
from localstack.services.stepfunctions.asl.component.state.state_pass.state_pass import StatePass
|
|
46
|
+
from localstack.services.stepfunctions.asl.component.state.state_succeed.state_succeed import (
|
|
47
|
+
StateSucceed,
|
|
48
|
+
)
|
|
18
49
|
from localstack.services.stepfunctions.asl.component.test_state.program.test_state_program import (
|
|
19
50
|
TestStateProgram,
|
|
20
51
|
)
|
|
52
|
+
from localstack.services.stepfunctions.asl.component.test_state.state.common import (
|
|
53
|
+
MockedCommonState,
|
|
54
|
+
)
|
|
55
|
+
from localstack.services.stepfunctions.asl.component.test_state.state.map import (
|
|
56
|
+
MockedStateMap,
|
|
57
|
+
)
|
|
58
|
+
from localstack.services.stepfunctions.asl.component.test_state.state.task import (
|
|
59
|
+
MockedStateTask,
|
|
60
|
+
)
|
|
21
61
|
from localstack.services.stepfunctions.asl.component.test_state.state.test_state_state_props import (
|
|
22
62
|
TestStateStateProps,
|
|
23
63
|
)
|
|
@@ -30,63 +70,96 @@ class InspectionDataKey(enum.Enum):
|
|
|
30
70
|
INPUT = "input"
|
|
31
71
|
AFTER_INPUT_PATH = "afterInputPath"
|
|
32
72
|
AFTER_PARAMETERS = "afterParameters"
|
|
73
|
+
AFTER_ARGUMENTS = "afterArguments"
|
|
33
74
|
RESULT = "result"
|
|
34
75
|
AFTER_RESULT_SELECTOR = "afterResultSelector"
|
|
35
76
|
AFTER_RESULT_PATH = "afterResultPath"
|
|
77
|
+
AFTER_ITEMS_PATH = "afterItemsPath"
|
|
36
78
|
REQUEST = "request"
|
|
37
79
|
RESPONSE = "response"
|
|
38
80
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
method(env, *args, **kwargs)
|
|
43
|
-
env.set_choice_selected(env.next_state_name)
|
|
44
|
-
|
|
45
|
-
return wrapper
|
|
81
|
+
MAX_CONCURRENCY = "maxConcurrency"
|
|
82
|
+
TOLERATED_FAILURE_COUNT = "toleratedFailureCount"
|
|
83
|
+
TOLERATED_FAILURE_PERCENTAGE = "toleratedFailurePercentage"
|
|
46
84
|
|
|
47
85
|
|
|
48
86
|
def _decorated_updates_inspection_data(method, inspection_data_key: InspectionDataKey):
|
|
49
87
|
def wrapper(env: TestStateEnvironment, *args, **kwargs):
|
|
50
88
|
method(env, *args, **kwargs)
|
|
51
|
-
result =
|
|
89
|
+
result = env.stack[-1]
|
|
90
|
+
if not isinstance(result, (int, float)):
|
|
91
|
+
result = to_json_str(result)
|
|
52
92
|
# We know that the enum value used here corresponds to a supported inspection data field by design.
|
|
53
93
|
env.inspection_data[inspection_data_key.value] = result # noqa
|
|
54
94
|
|
|
55
95
|
return wrapper
|
|
56
96
|
|
|
57
97
|
|
|
58
|
-
def _decorate_state_field(state_field: CommonStateField) -> None:
|
|
59
|
-
if isinstance(state_field,
|
|
60
|
-
state_field
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
98
|
+
def _decorate_state_field(state_field: CommonStateField, is_single_state: bool = False) -> None:
|
|
99
|
+
if isinstance(state_field, StateMap):
|
|
100
|
+
MockedStateMap.wrap(state_field, is_single_state)
|
|
101
|
+
elif isinstance(state_field, StateTask):
|
|
102
|
+
MockedStateTask.wrap(state_field, is_single_state)
|
|
103
|
+
elif isinstance(state_field, (StateChoice, StatePass, StateFail, StateSucceed)):
|
|
104
|
+
MockedCommonState.wrap(state_field, is_single_state)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def find_state(state_name: str, states: dict[str, CommonStateField]) -> CommonStateField | None:
|
|
108
|
+
if state_name in states:
|
|
109
|
+
return states[state_name]
|
|
110
|
+
|
|
111
|
+
for state in states.values():
|
|
112
|
+
if isinstance(state, StateMap):
|
|
113
|
+
found_state = find_state(state_name, state.iteration_component._states.states)
|
|
114
|
+
if found_state:
|
|
115
|
+
return found_state
|
|
72
116
|
|
|
73
117
|
|
|
74
118
|
class TestStatePreprocessor(Preprocessor):
|
|
75
|
-
STATE_NAME: Final[str] = "
|
|
119
|
+
STATE_NAME: Final[str] = "StateName"
|
|
120
|
+
_state_name_stack: list[str] = []
|
|
121
|
+
|
|
122
|
+
def to_test_state_program(
|
|
123
|
+
self, tree: ParseTree, state_name: str | None = None
|
|
124
|
+
) -> TestStateProgram:
|
|
125
|
+
if is_production(tree, ASLParser.RULE_state_machine):
|
|
126
|
+
# full definition passed in
|
|
127
|
+
program = self.visitState_machine(ctx=tree)
|
|
128
|
+
state_field = find_state(state_name, program.states.states)
|
|
129
|
+
_decorate_state_field(state_field, False)
|
|
130
|
+
return TestStateProgram(state_field)
|
|
131
|
+
|
|
132
|
+
if is_production(tree, ASLParser.RULE_state_decl_body):
|
|
133
|
+
# single state case
|
|
134
|
+
state_props = self.visitState_decl_body(ctx=tree)
|
|
135
|
+
state_field = self._common_state_field_of(state_props=state_props)
|
|
136
|
+
_decorate_state_field(state_field, True)
|
|
137
|
+
return TestStateProgram(state_field)
|
|
76
138
|
|
|
77
|
-
|
|
139
|
+
return super().visit(tree)
|
|
140
|
+
|
|
141
|
+
def visitState_decl(self, ctx: ASLParser.State_declContext) -> CommonStateField:
|
|
142
|
+
# if we are parsing a full state machine, we need to record the state_name prior to stepping
|
|
143
|
+
# into the state body definition.
|
|
144
|
+
state_name = self._inner_string_of(parser_rule_context=ctx.string_literal())
|
|
145
|
+
self._state_name_stack.append(state_name)
|
|
146
|
+
state_props: TestStateStateProps = self.visit(ctx.state_decl_body())
|
|
147
|
+
state_field = self._common_state_field_of(state_props=state_props)
|
|
148
|
+
return state_field
|
|
149
|
+
|
|
150
|
+
def visitState_decl_body(self, ctx: ASLParser.State_decl_bodyContext) -> TestStateStateProps:
|
|
78
151
|
self._open_query_language_scope(ctx)
|
|
79
152
|
state_props = TestStateStateProps()
|
|
80
|
-
state_props.name =
|
|
153
|
+
state_props.name = (
|
|
154
|
+
self._state_name_stack.pop(-1) if self._state_name_stack else self.STATE_NAME
|
|
155
|
+
)
|
|
81
156
|
for child in ctx.children:
|
|
82
157
|
cmp = self.visit(child)
|
|
83
158
|
state_props.add(cmp)
|
|
84
|
-
state_field = self._common_state_field_of(state_props=state_props)
|
|
85
159
|
if state_props.get(QueryLanguage) is None:
|
|
86
160
|
state_props.add(self._get_current_query_language())
|
|
87
|
-
_decorate_state_field(state_field)
|
|
88
161
|
self._close_query_language_scope()
|
|
89
|
-
return
|
|
162
|
+
return state_props
|
|
90
163
|
|
|
91
164
|
def visitInput_path_decl(self, ctx: ASLParser.Input_path_declContext) -> InputPath:
|
|
92
165
|
input_path: InputPath = super().visitInput_path_decl(ctx=ctx)
|
|
@@ -129,3 +202,121 @@ class TestStatePreprocessor(Preprocessor):
|
|
|
129
202
|
inspection_data_key=InspectionDataKey.RESULT, # noqa
|
|
130
203
|
)
|
|
131
204
|
return result
|
|
205
|
+
|
|
206
|
+
def visitMax_concurrency_int(self, ctx: ASLParser.Max_concurrency_intContext) -> MaxConcurrency:
|
|
207
|
+
max_concurrency: MaxConcurrency = super().visitMax_concurrency_int(ctx)
|
|
208
|
+
max_concurrency._eval_body = _decorated_updates_inspection_data(
|
|
209
|
+
method=max_concurrency._eval_body,
|
|
210
|
+
inspection_data_key=InspectionDataKey.MAX_CONCURRENCY, # noqa
|
|
211
|
+
)
|
|
212
|
+
return max_concurrency
|
|
213
|
+
|
|
214
|
+
def visitMax_concurrency_jsonata(
|
|
215
|
+
self, ctx: ASLParser.Max_concurrency_jsonataContext
|
|
216
|
+
) -> MaxConcurrencyJSONata:
|
|
217
|
+
max_concurrency_jsonata: MaxConcurrencyJSONata = super().visitMax_concurrency_jsonata(ctx)
|
|
218
|
+
max_concurrency_jsonata._eval_body = _decorated_updates_inspection_data(
|
|
219
|
+
method=max_concurrency_jsonata._eval_body,
|
|
220
|
+
inspection_data_key=InspectionDataKey.MAX_CONCURRENCY, # noqa
|
|
221
|
+
)
|
|
222
|
+
return max_concurrency_jsonata
|
|
223
|
+
|
|
224
|
+
def visitMax_concurrency_path(
|
|
225
|
+
self, ctx: ASLParser.Max_concurrency_declContext
|
|
226
|
+
) -> MaxConcurrencyPath:
|
|
227
|
+
max_concurrency_path: MaxConcurrencyPath = super().visitMax_concurrency_path(ctx)
|
|
228
|
+
max_concurrency_path._eval_body = _decorated_updates_inspection_data(
|
|
229
|
+
method=max_concurrency_path._eval_body,
|
|
230
|
+
inspection_data_key=InspectionDataKey.MAX_CONCURRENCY, # noqa
|
|
231
|
+
)
|
|
232
|
+
return max_concurrency_path
|
|
233
|
+
|
|
234
|
+
def visitTolerated_failure_count_int(self, ctx) -> ToleratedFailureCountInt:
|
|
235
|
+
tolerated_failure_count: ToleratedFailureCountInt = (
|
|
236
|
+
super().visitTolerated_failure_count_int(ctx)
|
|
237
|
+
)
|
|
238
|
+
tolerated_failure_count._eval_body = _decorated_updates_inspection_data(
|
|
239
|
+
method=tolerated_failure_count._eval_body,
|
|
240
|
+
inspection_data_key=InspectionDataKey.TOLERATED_FAILURE_COUNT,
|
|
241
|
+
)
|
|
242
|
+
return tolerated_failure_count
|
|
243
|
+
|
|
244
|
+
def visitTolerated_failure_count_path(self, ctx) -> ToleratedFailureCountPath:
|
|
245
|
+
tolerated_failure_count_path: ToleratedFailureCountPath = (
|
|
246
|
+
super().visitTolerated_failure_count_path(ctx)
|
|
247
|
+
)
|
|
248
|
+
tolerated_failure_count_path._eval_body = _decorated_updates_inspection_data(
|
|
249
|
+
method=tolerated_failure_count_path._eval_body,
|
|
250
|
+
inspection_data_key=InspectionDataKey.TOLERATED_FAILURE_COUNT,
|
|
251
|
+
)
|
|
252
|
+
return tolerated_failure_count_path
|
|
253
|
+
|
|
254
|
+
def visitTolerated_failure_count_string_jsonata(
|
|
255
|
+
self, ctx
|
|
256
|
+
) -> ToleratedFailureCountStringJSONata:
|
|
257
|
+
tolerated_failure_count_jsonata: ToleratedFailureCountStringJSONata = (
|
|
258
|
+
super().visitTolerated_failure_count_string_jsonata(ctx)
|
|
259
|
+
)
|
|
260
|
+
tolerated_failure_count_jsonata._eval_body = _decorated_updates_inspection_data(
|
|
261
|
+
method=tolerated_failure_count_jsonata._eval_body,
|
|
262
|
+
inspection_data_key=InspectionDataKey.TOLERATED_FAILURE_COUNT,
|
|
263
|
+
)
|
|
264
|
+
return tolerated_failure_count_jsonata
|
|
265
|
+
|
|
266
|
+
def visitTolerated_failure_percentage_number(self, ctx) -> ToleratedFailurePercentage:
|
|
267
|
+
tolerated_failure_percentage: ToleratedFailurePercentage = (
|
|
268
|
+
super().visitTolerated_failure_percentage_number(ctx)
|
|
269
|
+
)
|
|
270
|
+
tolerated_failure_percentage._eval_body = _decorated_updates_inspection_data(
|
|
271
|
+
method=tolerated_failure_percentage._eval_body,
|
|
272
|
+
inspection_data_key=InspectionDataKey.TOLERATED_FAILURE_PERCENTAGE,
|
|
273
|
+
)
|
|
274
|
+
return tolerated_failure_percentage
|
|
275
|
+
|
|
276
|
+
def visitTolerated_failure_percentage_path(self, ctx) -> ToleratedFailurePercentagePath:
|
|
277
|
+
tolerated_failure_percentage_path: ToleratedFailurePercentagePath = (
|
|
278
|
+
super().visitTolerated_failure_percentage_path(ctx)
|
|
279
|
+
)
|
|
280
|
+
tolerated_failure_percentage_path._eval_body = _decorated_updates_inspection_data(
|
|
281
|
+
method=tolerated_failure_percentage_path._eval_body,
|
|
282
|
+
inspection_data_key=InspectionDataKey.TOLERATED_FAILURE_PERCENTAGE,
|
|
283
|
+
)
|
|
284
|
+
return tolerated_failure_percentage_path
|
|
285
|
+
|
|
286
|
+
def visitTolerated_failure_percentage_string_jsonata(
|
|
287
|
+
self, ctx
|
|
288
|
+
) -> ToleratedFailurePercentageStringJSONata:
|
|
289
|
+
tolerated_failure_percentage_jsonata: ToleratedFailurePercentageStringJSONata = (
|
|
290
|
+
super().visitTolerated_failure_percentage_string_jsonata(ctx)
|
|
291
|
+
)
|
|
292
|
+
tolerated_failure_percentage_jsonata._eval_body = _decorated_updates_inspection_data(
|
|
293
|
+
method=tolerated_failure_percentage_jsonata._eval_body,
|
|
294
|
+
inspection_data_key=InspectionDataKey.TOLERATED_FAILURE_PERCENTAGE,
|
|
295
|
+
)
|
|
296
|
+
return tolerated_failure_percentage_jsonata
|
|
297
|
+
|
|
298
|
+
def visitItems_path_decl(self, ctx) -> ItemsPath:
|
|
299
|
+
items_path: ItemsPath = super().visitItems_path_decl(ctx)
|
|
300
|
+
items_path._eval_body = _decorated_updates_inspection_data(
|
|
301
|
+
method=items_path._eval_body,
|
|
302
|
+
inspection_data_key=InspectionDataKey.AFTER_ITEMS_PATH,
|
|
303
|
+
)
|
|
304
|
+
return items_path
|
|
305
|
+
|
|
306
|
+
def visitArguments_string_jsonata(self, ctx):
|
|
307
|
+
arguments: ArgumentsStringJSONata = super().visitArguments_string_jsonata(ctx)
|
|
308
|
+
arguments._eval_body = _decorated_updates_inspection_data(
|
|
309
|
+
method=arguments._eval_body,
|
|
310
|
+
inspection_data_key=InspectionDataKey.AFTER_ARGUMENTS,
|
|
311
|
+
)
|
|
312
|
+
return arguments
|
|
313
|
+
|
|
314
|
+
def visitArguments_jsonata_template_value_object(self, ctx):
|
|
315
|
+
arguments: ArgumentsJSONataTemplateValueObject = (
|
|
316
|
+
super().visitArguments_jsonata_template_value_object(ctx)
|
|
317
|
+
)
|
|
318
|
+
arguments._eval_body = _decorated_updates_inspection_data(
|
|
319
|
+
method=arguments._eval_body,
|
|
320
|
+
inspection_data_key=InspectionDataKey.AFTER_ARGUMENTS,
|
|
321
|
+
)
|
|
322
|
+
return arguments
|