need programatic way "wipe" eventstore

Hi, I’m dying here, I really need a way to clean my test data for my integration tests. I’m using which is awesome btw. It spins up a browser and pokes and clicks. And of course between each test I need to reset my data. I"ve written tons of code to fire, effectively reversal events. e.g. cancelAppointment, refundPurchase etc. But that is growing heavier and heavier, and there are some things that just don’t reverse well, like purchases. I can refund a purchase but it’s still in the list of purchases, it’s just marked as refunded.
I can, of course clean my readstore no problem as it’s postgres, but my events are still all there throwing errors on the write side. I just don’t know how to automate these tests effectively. Is there anyway I can reset my ES programatically for automated tests?

Why not just use --mem-db and reset?

yes that sounds very nice, I’ve searched the docs pretty well, and there is an entry in the cli args for --mem-db, but no details, and I don’t see anything about reset. is reset a command that I can call on the running instance or something. Please let me know how to use this as it sounds like just what I need.


mem db keeps the whole db in memory (no files) so obviously a restart loses everything :slight_smile:

Yes, but I must do it programatically. I can’t really run cli commands to start and stop the store from within my tests. I need to operate within the api. For starters I have my tests and code containerized. If I could get to the host, then perhaps perform a stop and start on the container that could work but testing framework does not really accomidate that and inside of containers it would be even more difficult.

Have you tried using the EmbeddedEventStore?

What testing Framework are you using?

We had a similar issue, but ended up launching a new process with the desired command line switches (C# and specflow)

I’m using They have a method that allows you to make bash calls, but it says not to use it for starting up your server. So I’ve ignored it but yesterday I just told it to do a docker-compose down and then a docker-compose up in the beforeeach and that seems to work!. That said it takes a good 25 seconds for each test which sucks. I think I can just shut down and restart the ES container but I need to shore up my event handlers as they are getting upset when ES disappears.

Hi Raif, I’ve been doing this for almost a year now.
Your solution will depend on how you’ve setup everything.

In my case, I’m using docker containers for testing.

When I have the docker container setup using --memdb, I issue a cli command to restart it.

If the docker container is setup to use the file system, but doesn’t have a mapped volume, simply removing and replacing the container via cli command does the trick.

In both cases, I then use cli commands that inspect the container state and wait until it has reached “healthy” before starting the tests.

If you have more questions about how I did it this way, just ask.

Its a process. Kill the process, as you are starting it I believe (you mentioned testing) you most likely have the process id, just kill it!