Testing PersistentEntity migrations

I would like to automatically test PersistentEntity migrations, but it looks like there is no easy way to do this:

  1. The PersistentEntityTestDriver does not seem to serialize and deserialize events, so it doesn’t use the migrations at all
  2. When using the TestServer there is no easy way to add “old” events into my event store, except maybe if I add “test-only” command handlers that do it for me (which doesn’t seem like a great solution IMO).

Ideally, I would like to start a TestServer with a prepopulated Cassandra instance, but that does not seem to be possible. Is there any other way to automate testing of migrations that I’m not aware of?

Hi @sander,

there is not out-of-the-box feature to tests migrations, no. There’s an open issue where some users posted a few ideas if that’s helpful.


Hi Ignasi,

Thanks for your answer, I saw the issue you linked and it caused me to try multiple things, like inserting old events manually by using the CassandraSession from the TestServer (which kind of worked), but eventually I settled for a solution that represents the production scenario the closest.

I ended up hooking up a CassandraContainer from testcontainers to the TestServer by overriding the port in the config, which worked fine. The container has an initialization script that mimics the current state of the event store, and I can use the TestServer to verify that the system is able to replay the migrated events.

1 Like