dimanche 21 février 2021

How to populate DynamoDB for testing

I'm currently looking into AWS for a project, and trying to work out how to do automated testing.

My current setup is to deploy the infrastructure at the start of the tests - I'm using Terraform so an ephemeral environment is easy. Then I'm going to run API level and UI level E2E tests against this and finally tear it all down.

For the most part this is fairly straightforward - it's not really any different to a normal monolith, just needing to deploy infrastructure first and get the addresses of it.

What I'm struggling with is setting up the data to test with. Both in terms of inserting data and removing it.

Inserting into DynamoDB (and Cognito, etc) with the AWS SDK is relatively easy, but it does mean that the test framework needs to know the names of every data store needed for the entire application. That's not a huge issue though.

Deleting from these data stores seems much harder. All the answers im seeing seems to suggest that to truncate one, you're best off actually deleting the table and recreating it. This seems to completely defeat the point of using Terraform for creating the infrastructure.

The alternative seems to be to scan for all the records and delete them one at a time, which isn't especially efficient.

Is there a better way to achieve all this? What do people normally do for this? Am I just missing something?

Cheers

Aucun commentaire:

Enregistrer un commentaire