Skip to content

Run Dynamoid tests against AWS Emulator and wait for table deletion in delete_all - #211

Merged
simukappu merged 4 commits into
developfrom
aws-emulator-dynamodb
Nov 13, 2026
Merged

simukappu merged 4 commits into
developfrom
aws-emulator-dynamodb

Conversation

@simukappu

@simukappu simukappu commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Run the Dynamoid tests also against AWS Emulator, and fix a bug that it found.

  • Wait for the table deletion in delete_all of Dynamoid models (bug fix, CHANGELOG 2.7.4). DynamoDB deletes tables asynchronously, so recreating the table could fail and the next operation raised ResourceInUseException. DynamoDB Local deletes tables immediately and hid it; AWS Emulator keeps tables in DELETING like DynamoDB.
  • Truncate DynamoDB tables to clean the test database instead of dropping and recreating them before each example. This also makes the DynamoDB Local jobs faster (RSpec 63 s → 50 s on rails-8.1).
  • Use on-demand capacity mode for DynamoDB tables in tests, since the emulator throttles provisioned tables like DynamoDB.
  • Run Dynamoid tests against AWS Emulator in CI: a new aws-emulator job installs the signature-verified package, starts it with --auth off (it listens only on 127.0.0.1; time-travel specs would otherwise fail SigV4 with RequestTimeTooSkewed), and runs the Dynamoid suite. The Dynamoid endpoint comes from AWS_ENDPOINT_URL when set, otherwise DynamoDB Local on localhost:8000. DynamoDB Local stays the default for the matrix.

On the emulator, 14 examples tagged filter_by_dynamodb_primary_key are skipped: querying index_target_key_created_at with a filter on the table key id (the ids option) is rejected with ValidationException: Filter Expression can only contain non-primary key attributes. DynamoDB Local and real DynamoDB (checked in us-east-1 on 2026-11-13) accept the same query, so this is an emulator difference.

All jobs keep 100% line coverage.

🤖 Generated with Claude Code

DynamoDB deletes tables asynchronously and rejects creating a table while the table with the same name is being deleted. delete_all called delete_table without waiting, so create_table silently failed and the next operation hit ResourceInUseException. DynamoDB Local deletes tables immediately and hid this, while AWS Emulator keeps tables in DELETING status like DynamoDB.
Deleting and re-creating tables before each example waits for the table deletion, which takes seconds on DynamoDB and AWS Emulator. Truncate the tables of Dynamoid models instead, and remove the delete_all calls in specs which are redundant with the cleanup before each example.
The tables had 5 read and write capacity units, and the tests exceeded the provisioned throughput. DynamoDB Local does not throttle requests, while AWS Emulator throttles them like DynamoDB and the SDK retries with backoff, which slowed the tests down.
Add a job running the tests with Dynamoid ORM against AWS Emulator in addition to DynamoDB Local. AWS Emulator models DynamoDB behaviors that DynamoDB Local does not, such as asynchronous table deletion and provisioned throughput. Use AWS_ENDPOINT_URL as the DynamoDB endpoint when it is set, and start AWS Emulator with --auth off since the tests travel in time with signed requests. Skip the examples filtering by IDs, since AWS Emulator rejects Query on global secondary indexes with filter expressions on the primary key of the table.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — aws-emulator-dynamodb into develop

@simukappu
simukappu merged commit acd7ac6 into develop Nov 13, 2026
40 checks passed
@simukappu
simukappu deleted the aws-emulator-dynamodb branch November 13, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants