Skip to content

Conversation

@tiurin
Copy link
Contributor

@tiurin tiurin commented Dec 2, 2025

Motivation

Add validations for mock presence depending on state type.

Closes DRG-310

Changes

Add validations:

  • mock is specified and the tested state is a Pass state
  • mock is specified and the tested state is a Success state
  • mock is specified and the tested state is a Fail state
  • mock is not specified and the tested state is a Map or a Parallel state

Tests

Related

@tiurin tiurin self-assigned this Dec 2, 2025
@tiurin tiurin added aws:stepfunctions AWS Step Functions semver: patch Non-breaking changes which can be included in patch releases docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Dec 2, 2025
@github-actions
Copy link

github-actions bot commented Dec 2, 2025

Test Results - Preflight, Unit

22 889 tests  ±0   21 075 ✅ ±0   6m 32s ⏱️ -11s
     1 suites ±0    1 814 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit 1d472cb. ± Comparison against base commit 84bdd4a.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 20s ⏱️ +2s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 1d472cb. ± Comparison against base commit 84bdd4a.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

LocalStack Community integration with Pro

    2 files  ±    0      2 suites  ±0   21m 58s ⏱️ - 1h 43m 16s
1 711 tests  - 3 393  1 622 ✅  - 3 090  89 💤  - 303  0 ❌ ±0 
1 713 runs   - 3 393  1 622 ✅  - 3 090  91 💤  - 303  0 ❌ ±0 

Results for commit 1d472cb. ± Comparison against base commit 84bdd4a.

This pull request removes 3401 and adds 8 tests. Note that renamed tests count towards both.
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_lambda_dynamodb
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_opensearch_crud
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_search_books
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_setup
tests.aws.scenario.kinesis_firehose.test_kinesis_firehose.TestKinesisFirehoseScenario ‑ test_kinesis_firehose_s3
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_destination_sns
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_infra
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_prefill_dynamodb_table
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input0-SUCCEEDED]
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input1-SUCCEEDED]
…
tests.aws.services.stepfunctions.v2.test_state.test_state_mock_validation.TestStateMockValidation ‑ test_state_type_does_not_accept_mock[mock_error_output-FailState]
tests.aws.services.stepfunctions.v2.test_state.test_state_mock_validation.TestStateMockValidation ‑ test_state_type_does_not_accept_mock[mock_error_output-PassState]
tests.aws.services.stepfunctions.v2.test_state.test_state_mock_validation.TestStateMockValidation ‑ test_state_type_does_not_accept_mock[mock_error_output-SucceedState]
tests.aws.services.stepfunctions.v2.test_state.test_state_mock_validation.TestStateMockValidation ‑ test_state_type_does_not_accept_mock[mock_result-FailState]
tests.aws.services.stepfunctions.v2.test_state.test_state_mock_validation.TestStateMockValidation ‑ test_state_type_does_not_accept_mock[mock_result-PassState]
tests.aws.services.stepfunctions.v2.test_state.test_state_mock_validation.TestStateMockValidation ‑ test_state_type_does_not_accept_mock[mock_result-SucceedState]
tests.aws.services.stepfunctions.v2.test_state.test_state_mock_validation.TestStateMockValidation ‑ test_state_type_requires_mock[MapState]
tests.aws.services.stepfunctions.v2.test_state.test_state_mock_validation.TestStateMockValidation ‑ test_state_type_requires_mock[MapTaskState]

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   39m 30s ⏱️
1 735 tests 1 647 ✅ 88 💤 0 ❌
1 741 runs  1 647 ✅ 94 💤 0 ❌

Results for commit 1d472cb.

♻️ This comment has been updated with latest results.

@tiurin tiurin force-pushed the sfn/feat/test-state-mock-validation branch from 66b9c53 to 11a0e42 Compare December 3, 2025 12:47
@tiurin tiurin changed the title [SFN][TestState] Add mock-related validations [SFN][TestState] Add validations for mock presence depending on state type Dec 4, 2025
@tiurin tiurin marked this pull request as ready for review December 4, 2025 09:11
@tiurin tiurin added the review: merge when ready Signals to the reviewer that a PR can be merged if accepted label Dec 4, 2025
Copy link
Contributor

@gregfurman gregfurman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines +104 to +114
if mock_input is None and isinstance(test_state, (StateMap, StateParallel)):
# This is a literal message when a Map or Parallel state is not accompanied by a mock in a test state request.
# The message is the same for both cases and is not parametrised anyhow.
raise InvalidDefinition(
"TestState API does not support Map or Parallel states. Supported state types include: [Task, Wait, Pass, Succeed, Fail, Choice]"
)

if mock_input is not None and isinstance(test_state, (StatePass, StateFail, StateSucceed)):
raise ValidationException(
f"State type '{test_state.state_type.name}' is not supported when a mock is specified"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would be nice to return early here if mock_input exists.

i.e

if mock_input:
   return

if isinstance(test_state, (StateMap, StateParallel)):
   raise InvalidDefinition(...)

# ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll be refactoring this code with the upcoming validations for mock contents, so this will change 👍

@tiurin tiurin merged commit cb8043c into main Dec 4, 2025
49 checks passed
@tiurin tiurin deleted the sfn/feat/test-state-mock-validation branch December 4, 2025 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws:stepfunctions AWS Step Functions docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes review: merge when ready Signals to the reviewer that a PR can be merged if accepted semver: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants