
- Local dynamodb flaky tests how to#
- Local dynamodb flaky tests full#
- Local dynamodb flaky tests code#
Local dynamodb flaky tests full#
To check that your table really is there and available, you can list the table using standard DynamoDb commands (but remembering to specify your endpoint url) $ aws dynamodb list-tables -endpoint-url "TableNames": [Īs far as I'm aware, the full gamut of DynamoDb functionality is available on the local version, below I'm adding a TTL column to my table, as I'd like my items to expire after a specific time: aws dynamodb update-time-to-live -table-name my-local-table -time-to-live-specification "Enabled=true, AttributeName=ttl" -endpoint-url If you're more of a GUI person than a command line person, and you want to see what's going on in your table in terms of records added etc, don't forget about the awesome NoSQL Workbench for DynamoDb available hereĪnd once you've connected you'll be able to view your table, specific records etc. This configuration should match your actual DynamoDb table. I have my table name specified, along with a single HASH key (you could specify a RANGE key here too) and my provisioned throughput.


Let's take a look at that: "TableName": "my-local-table", json file which has the configuration of my table within it. aws dynamodb create-table -cli-input-json file://C:/Users/JMatson/source/repos/DynamoDBConfig.json -endpoint-url In the above example I'm actually passing in a. Your local instance will always be and you use the -endpoint-url parameter to specify it. If your instance start-up works, you should get this response: Initializing DynamoDB Local with the following configurationįrom this point on, you can run normal commands to create a table etc, the only difference is (as you can see below) you pass in the url of your local instance rather than the AWS service. PS C:\dynamodb_local_latest> java -D"=.\DynamoDBLocal_lib" -jar DynamoDBLocal.jar -sharedDb Navigate to that folder, and run the following commands (making sure you have the AWS CLI installed of course :) ). :) Grabbing the goodsįirst up, download the latest version of DynamoDb local from and unpack the zip into the folder of your choice.
Local dynamodb flaky tests how to#
In this mini-tutorial, I'll show you how to get DynamoDb local up and running quickly for a. Thanks to those clever chaps at AWS, there is an awesome local version of DynamoDb just waiting for you to download and install. There's another approach - the one I've come to love - which is running an actual DynamoDb service locally on your machine! You can talk to it the same way using the exact same SDKs/libraries/methods that you talk to your 'real' DynamoDb, the only difference being the URL of the service itself. (The mocked class or method could have attributes the non-mocked one doesn't and vice versa).

Local dynamodb flaky tests code#
When it comes to executing unit tests locally for code which interacts with DynamoDB, what's the best way to ensure that your tests work? You could of course connect to your actual DynamoDb table running in AWS, but ideally you want to be able to run your unit tests independent of AWS, especially if there are networking configurations that could prevent you from doing so.Īnother alternative is to mock the entire DynamoDb service - and that's perfectly fine if it works for you - but it could result in you testing methods that are similar - but not actually the same - as the methods in the class you're testing. AWS DynamoDb is a great NoSQL database service that gives you blistering fast speeds, low latency and the ability to interact with it using a variety of methods from document clients right down to the lowest level API.
