Closed PJUllrich closed 4 years ago
EventStore can be used for async tests as long as you don't attempt to reset the database schema between test runs. The issue you have is that Storage.Initializer.reset!/1
will truncate the tables being used by any EventStore operations running concurrently.
I'd suggest one of these approaches:
async: false
.1234
as test-foo-1234
).Commanded provides an in-memory event store adapter which can be used for testing.
GenServer
process. Dynamic Commanded applications (#324), in the next Commanded release, will support isolation for async tests as a separate Commanded application and in-memory event store can be started per test.:test
environment to configure the in-memory event store. Add a new :integration
mix environment configured to use the Postgres EventStore. Then configured the tests to run async in test on (e.g. async: Mix.env() == :test
). This gives you the option to run quickly locally (async in :test
env), but have the same tests run as integration tests in CI or on demand (sync in :integration
env).Thank you! Then I'll wait for the next release and consider which option suits my requirements best :)
I have problems running tests asynchonously (that is in parallel) using the EventStore. I was wondering whether it is possible at all to set up the library in a way that supports async tests.
Currently, whenever I have more than around 5 tests that use the EventStore library for testing, they run into race conditions over the database connection with errors like this:
My current
setup tags
function in my test cases (e.g.DataCase
) looks like this: