diff --git a/.github/workflows/conformance-tests.yml b/.github/workflows/conformance-tests.yml index 4479d64d..3977329c 100644 --- a/.github/workflows/conformance-tests.yml +++ b/.github/workflows/conformance-tests.yml @@ -95,7 +95,7 @@ jobs: run: python3 scripts/build_examples.py - name: Install conformance runner - run: pip install aws-durable-execution-conformance-tests==0.1.0 + run: pip install "git+https://github.com/aws/aws-durable-execution-conformance-tests.git@main#subdirectory=packages/aws-durable-execution-conformance-tests" - name: Inject Lambda execution role into template env: diff --git a/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/child/child_large_payload.py b/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/child/child_large_payload.py index c58ac3f5..5ee759aa 100644 --- a/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/child/child_large_payload.py +++ b/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/child/child_large_payload.py @@ -24,7 +24,12 @@ def generate_data(_step_context: StepContext) -> str: @durable_with_child_context def large_data_processor(ctx: DurableContext, *, input_1: str) -> str: - print(input_1, flush=True) + # Log through the child context logger so the record carries the execution + # ARN. The context logger de-duplicates while the context is replaying, so + # rebind the replay source to enable replay logging: the child body re-runs + # in ReplayChildren mode to rebuild the large result, and that re-execution + # emits no history events, making the log the only evidence it happened. + ctx.logger.with_is_replaying(lambda: False).info(input_1) step_result: str = ctx.step(generate_data()) # Build a large result (>256KB) from the small step result large_result = step_result * 6 # ~300KB diff --git a/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/child/child_print_only.py b/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/child/child_print_only.py index b6433e06..a7db06de 100644 --- a/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/child/child_print_only.py +++ b/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/child/child_print_only.py @@ -1,4 +1,4 @@ -"""3-17: Child context with print only (verify no re-execution on replay).""" +"""3-17: Child context with durable logger only (verify no re-execution on replay).""" from typing import Any @@ -11,8 +11,12 @@ @durable_with_child_context -def print_child(_ctx: DurableContext, *, input_1: str) -> str: - print(input_1, flush=True) +def print_child(ctx: DurableContext, *, input_1: str) -> str: + # Log through the child context logger so the record carries the execution + # ARN. Rebinding the replay source enables replay logging, which is what + # makes this assertion meaningful: under the default de-duplication an + # incorrect second child execution would be suppressed and still count 1. + ctx.logger.with_is_replaying(lambda: False).info(input_1) return input_1 diff --git a/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/step/step_at_most_once_no_retry.py b/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/step/step_at_most_once_no_retry.py index fe43ca91..13aec0f8 100644 --- a/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/step/step_at_most_once_no_retry.py +++ b/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/step/step_at_most_once_no_retry.py @@ -15,8 +15,10 @@ @durable_step -def at_most_once_flaky_step(_step_context: StepContext, *, input_1: str) -> str: - print(input_1, flush=True) +def at_most_once_flaky_step(step_context: StepContext, *, input_1: str) -> str: + # Log through the step context logger so the record carries the execution + # ARN and can be correlated to this durable execution in CloudWatch. + step_context.logger.info(input_1) time.sleep(1) # Allow time for logs to flush to CloudWatch os._exit(1) # Simulate Lambda crash return "unreachable" diff --git a/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/step/step_at_most_once_with_retry.py b/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/step/step_at_most_once_with_retry.py index f1dad7c2..906ad0d2 100644 --- a/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/step/step_at_most_once_with_retry.py +++ b/packages/aws-durable-execution-sdk-python-conformance-tests/handlers/step/step_at_most_once_with_retry.py @@ -19,8 +19,9 @@ @durable_step def at_most_once_step(step_context: StepContext, *, input_1: str) -> str: - # Print input to stdout each time step executes - print(input_1, flush=True) + # Log the input through the step context logger each time the step executes + # so each record carries the execution ARN for CloudWatch correlation. + step_context.logger.info(input_1) time.sleep(1) # Allow time for logs to flush to CloudWatch # The attempt number is the SDK's built-in durable counter from the step diff --git a/packages/aws-durable-execution-sdk-python-conformance-tests/template_child.yaml b/packages/aws-durable-execution-sdk-python-conformance-tests/template_child.yaml index 5cd41742..f1bb2473 100644 --- a/packages/aws-durable-execution-sdk-python-conformance-tests/template_child.yaml +++ b/packages/aws-durable-execution-sdk-python-conformance-tests/template_child.yaml @@ -5,6 +5,13 @@ Globals: Runtime: python3.13 Timeout: 60 MemorySize: 128 + # The conformance runner correlates CloudWatch records to a durable + # execution with a JSON filter on the executionArn field the SDK context + # logger attaches. That field only survives under the JSON log format. + LoggingConfig: + LogFormat: JSON + ApplicationLogLevel: INFO + SystemLogLevel: INFO Resources: DurableFunctionRole: Type: AWS::IAM::Role diff --git a/packages/aws-durable-execution-sdk-python-conformance-tests/template_step.yaml b/packages/aws-durable-execution-sdk-python-conformance-tests/template_step.yaml index 66a34169..e7ecf112 100644 --- a/packages/aws-durable-execution-sdk-python-conformance-tests/template_step.yaml +++ b/packages/aws-durable-execution-sdk-python-conformance-tests/template_step.yaml @@ -5,6 +5,13 @@ Globals: Runtime: python3.13 Timeout: 60 MemorySize: 128 + # The conformance runner correlates CloudWatch records to a durable + # execution with a JSON filter on the executionArn field the SDK context + # logger attaches. That field only survives under the JSON log format. + LoggingConfig: + LogFormat: JSON + ApplicationLogLevel: INFO + SystemLogLevel: INFO Resources: DurableFunctionRole: Type: AWS::IAM::Role