|
| 1 | +# Durable Execution Python SDK: Durable Execution Telemetry Conformance Tests |
| 2 | + |
| 3 | +This package answers one question. |
| 4 | +Does [`aws-durable-execution-sdk-python-telemetry-exporter`](../aws-durable-execution-sdk-python-telemetry-exporter), with its `CloudWatchLogsExporter`, deliver a complete `DurableExecutionTelemetry` record to CloudWatch Logs for a real Lambda execution? |
| 5 | + |
| 6 | +Unit tests can assert that the plugin builds a record. |
| 7 | +They cannot assert that the record reaches the configured log group on a real invocation. |
| 8 | +They cannot assert that it carries the right identity fields for the deployed function. |
| 9 | +Those are properties of a deployed function. |
| 10 | +So the scenario here is a Lambda function. |
| 11 | +The runner deploys it with the plugin configured and invokes it once. |
| 12 | +It then fetches the record from CloudWatch Logs and checks it against the requirement. |
| 13 | + |
| 14 | +The requirement and the runner live in [`aws/aws-durable-execution-conformance-tests`](https://github.com/aws/aws-durable-execution-conformance-tests), package `aws-durable-execution-conformance-tests-telemetry`. |
| 15 | +This package holds the SDK-specific part: the handler and the SAM template that maps it to the requirement ID. |
| 16 | + |
| 17 | +## Coverage |
| 18 | + |
| 19 | +| Suite | Requirements | What it pins down | |
| 20 | +| ----------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | |
| 21 | +| `telemetry` | `telemetry-1` | One successful single-step execution emits one `SUCCEEDED` record with `input`, `output`, ARN-derived identity fields, and `operationsByName`. | |
| 22 | + |
| 23 | +## Layout |
| 24 | + |
| 25 | +``` |
| 26 | +src/ |
| 27 | + telemetry_1_success.py # single step "increment"; plugin + CloudWatchLogsExporter |
| 28 | + Makefile # build-Telemetry1Success target used by `sam build` |
| 29 | + requirements.txt # core SDK + telemetry exporter, pinned to ${PYTHON_SDK_REF} |
| 30 | +template.yaml # declares TelemetryLogGroupName and creates the group |
| 31 | +tests/ |
| 32 | + test_telemetry_examples.py # guards template -> handler wiring and the parameter contract |
| 33 | +``` |
| 34 | + |
| 35 | +The handler uses the real SDK API only. |
| 36 | +It constructs no record and calls no exporter method. |
| 37 | +A missing or wrong record is the plugin's defect and is the signal the suite measures. |
| 38 | + |
| 39 | +## Template contract |
| 40 | + |
| 41 | +The runner passes `TelemetryLogGroupName` from the extension. |
| 42 | +Extensions have no pre-deploy hook. |
| 43 | +So the template creates the group with an `AWS::Logs::LogGroup` resource, and the function depends on it. |
| 44 | +The group name reaches the handler through `TELEMETRY_LOG_GROUP_NAME`. |
| 45 | +The handler raises at import if that variable is unset. |
| 46 | + |
| 47 | +The `LambdaExecutionRoleArn` role must allow `logs:CreateLogStream` and `logs:PutLogEvents` on the group. |
| 48 | +`AWSLambdaBasicDurableExecutionRolePolicy` grants both on `*`. |
| 49 | + |
| 50 | +## Building locally |
| 51 | + |
| 52 | +Prerequisites: Python 3.13 and the AWS SAM CLI. |
| 53 | + |
| 54 | +`src/requirements.txt` installs both SDK packages from git at `${PYTHON_SDK_REF}`. |
| 55 | +The ref must be a pushed commit that contains the packages. |
| 56 | + |
| 57 | +```bash |
| 58 | +export PYTHON_SDK_REF=$(git rev-parse HEAD) # must already be pushed |
| 59 | +sam build --template packages/aws-durable-execution-sdk-python-conformance-tests-telemetry/template.yaml |
| 60 | +``` |
| 61 | + |
| 62 | +Run the wiring tests from the repository root: |
| 63 | + |
| 64 | +```bash |
| 65 | +hatch run test:all packages/aws-durable-execution-sdk-python-conformance-tests-telemetry/tests |
| 66 | +``` |
| 67 | + |
| 68 | +## Running the suite |
| 69 | + |
| 70 | +Run from a checkout of the conformance repository with the telemetry package installed: |
| 71 | + |
| 72 | +```bash |
| 73 | +durable-execution-conformance \ |
| 74 | + --template <this-repo>/packages/aws-durable-execution-sdk-python-conformance-tests-telemetry/template.yaml \ |
| 75 | + --language python --region us-west-2 --suite telemetry \ |
| 76 | + --report console json \ |
| 77 | + --parameter-overrides LambdaExecutionRoleArn=<role-arn> |
| 78 | +``` |
| 79 | + |
| 80 | +A caller GitHub workflow is a follow-on. |
0 commit comments