Files
floci/compatibility-tests/sdk-test-python
Mario Toffia 534571b2a3 feat(iot): route shadow events through topic rules (#5260)
* feat(iot): route shadow events through topic rules

Successful classic and named shadow changes, from the REST API and from MQTT
reserved topics, now reach the topic rules engine and MQTT subscribers on the
AWS response topics with AWS payload shapes. Shadow documents keep metadata,
clientid() reports N/A for messages without an MQTT client, and MQTT rejected
responses carry the numeric status code.

Closes floci-io/floci#5256

* fix(iot): compute the shadow delta through nested objects

GetThingShadow and the update/delta event compared desired and reported only at the top level, so one differing nested field put the whole desired object in the delta. AWS compares nested objects key by key and arrays whole, and the delta event carries the stored desired metadata of exactly the delta values.

* fix(iot): give a shadow stored without metadata its leaf metadata

A shadow persisted before metadata was kept now reads back with a metadata mirror of its state stamped with its stored timestamp, so GetThingShadow and the update/documents and update/delta events carry metadata for its existing leaves, as AWS does for every state leaf.

* fix(iot): reject a shadow name outside the AWS pattern

A whitespace-only shadow name no longer addresses the classic shadow, so DELETE ?name=%20 cannot delete it. As on AWS, an empty name is the classic shadow and any name that is not 1 to 64 of [a-zA-Z0-9:_-] fails with InvalidRequestException.

* fix(iot): ignore a shadow request on a named topic with an invalid name

As on AWS, an MQTT request on $aws/things/<thing>/shadow/name/<name>/<op> whose name is not a valid shadow name, empty included, is not a shadow request: nothing is published and the classic shadow is untouched. Before, an empty name updated the classic shadow and a blank one was rejected on the classic shadow's topic.

* docs(iot): note that wildcard rule filters receive shadow events

Verified on AWS IoT: rules FROM '#' and '+/things/<thing>/shadow/#' receive the $aws shadow update events. Adds a test locking in the existing matcher behavior.

* fix(iot): keep only the most recent recorded publish events

The recorder kept every publish, and shadow events now go through it too. Only tests read it, so it now keeps the most recent 1,000 events and drops the oldest.

* test(iot): read shadow rule queues without the 5s poll

* fix(iot): match AWS shadow names, delta numbers and clientToken echo

Accept the reserved $package shadow name and reject any other name containing $ with 'Invalid shadow name : <name>'; a name failing the pattern answers 'Bad Request'. Compare delta numbers as AWS does (equal when both double and long values are, integers beyond long exactly), which also stops a number beyond the double range failing the update, and echo a whitespace clientToken.
2026-10-16 20:47:34 -04:00
..

sdk-test-python

Compatibility tests for Floci using boto3 (1.37.1).

Services Covered

Group Description
ssm Parameter Store — put, get, label, history, path, tags
sqs Queues, send/receive/delete, DLQ, visibility
sns Topics, subscriptions, publish, SQS delivery
s3 Buckets, objects, tagging, copy, batch delete
s3-cors CORS configuration
s3-notifications S3 → SQS event notifications
dynamodb Tables, CRUD, batch, TTL, tags
lambda Create/invoke/update/delete functions
iam Users, roles, policies, access keys
sts GetCallerIdentity, AssumeRole, GetSessionToken
secretsmanager Create/get/put/list/delete secrets, versioning, tags
kms Keys, aliases, encrypt/decrypt, data keys, sign/verify
kinesis Streams, shards, PutRecord/GetRecords
cloudwatch-metrics PutMetricData, ListMetrics, GetMetricStatistics, alarms
cloudformation-naming Auto physical name generation, explicit name precedence, cross-reference
cognito User pools, clients, AdminCreateUser, InitiateAuth, GetUser
elbv2 Listener certificates resolved against IAM and ACM

Requirements

  • Python 3.9+
  • pip

Running

pip install -r requirements.txt

# All groups
pytest tests/ --junit-xml=test-results/junit.xml

# Specific tests
pytest tests/test_s3.py

# Via just (from compatibility-tests/)
just test-python

Configuration

Variable Default Description
FLOCI_ENDPOINT http://localhost:4566 Floci emulator endpoint

AWS credentials are always test / test / us-east-1.

Opt-in metric filter replay against AWS

tests/metric_filter_replay.py is a standalone script, not a test: pytest does not collect it, and tests/test_metric_filter_replay.py checks its logic offline with the network blocked. It does not change conftest.py, and FLOCI_TARGET=aws does not select real AWS.

From the repository root, with the declared requirements installed:

python -m pytest compatibility-tests/sdk-test-python/tests/test_metric_filter_replay.py

# Against a local Floci
python compatibility-tests/sdk-test-python/tests/metric_filter_replay.py \
  --endpoint http://127.0.0.1:4566 --region eu-west-1 \
  --timeout 30 --stable-seconds 2 --poll-interval 1

Real AWS mode requires all three safety arguments. It creates billable CloudWatch metrics and a tagged log group, and metric series cannot be deleted; they remain until AWS ages them out.

python compatibility-tests/sdk-test-python/tests/metric_filter_replay.py \
  --aws --profile YOUR_DISPOSABLE_TEST_PROFILE --region eu-west-1 \
  --ack-live-writes I_ACCEPT_AWS_WRITES

Only commercial AWS regions are accepted, the clients pin the official regional endpoints, and the group is deleted in finally only after its ownership tag is verified. A cleanup failure exits nonzero and prints the group name. Credentials, account ids, profile names and raw service errors are never printed.

The expected values come from tests/fixtures/metric-filter-publishing-aws.json, a byte-identical copy of the root fixture src/test/resources/cloudwatchlogs/metric-filter-publishing-aws.json; the root CloudWatchLogsMetricFilterFixturePackagingTest fails when either SDK module copy drifts. The replay ingests each scenario into its own backdated minute, runs the quiet-default scenario last with no later ingestion, and accepts a result only after every expected series, absent series and the idle minute after the quiet one have stayed stable for a full window (AWS defaults: 240 second deadline, 30 second window). Output is JSON lines of observations, not a regenerated fixture.

Docker

docker build -t floci-sdk-python .
docker run --rm --network host floci-sdk-python

# Custom endpoint (macOS/Windows)
docker run --rm -e FLOCI_ENDPOINT=http://host.docker.internal:4566 floci-sdk-python