Data seeding of microservices

Viewed 28

In order to perform testing in feature branches, sometimes it's needed to recreate data from scratch, e.g:

  • An experimental branch irreversibly transforms data on some testing environment, so before testing another branch it's needed to refill the databases/buckets

  • When testing, one microservice calls other microservice api and changes "that other" service data, so we want to always start testing on clean environment.

In case of monoliths, usually it's as easy as:

  1. Create a dump
  2. When needed, drop the database and apply the dump after (or in the middle of, depending on the dump last migration) migrations

But it's getting much harder when we're talking about microservice architecture:

  1. Each microservice uses its own database(s).
  2. It means we have N databases with some denormalized data.
  3. Some microservices have links to entities of another microservice, so it's important that all the dumps are coherent and consistent.
  4. Different teams own different services, so it's much harder to agree on how and when to update the initial data dumps so that dumps are consistent across the services.

I'm looking for some best practices on this. Do we have anything better than trying to make snapshots of all databases at once?

0 Answers
Related