Suggestions for end to end testing using axon server.

I have recently migrated my application from Axon 3.x to Axon 4. Previously I would direct axon to use a defined database, one that was set up for dev/production, and was replaced by an in-memory database for end to end testing.

Now that I am using Axon 4 with Axon Server, I am a little unsure how best to handle this setup. Essentially in the dev space, I would like to be able to instantiate a version of axon server with a separate database, just for the case of end to end tests. The closest i’ve gotten to is starting axon server jar in a specified location, using defined paths for the database/events/snapshots (so I can clear them post-test to avoid contamination between tests), leveraging Junit5 callbacks (BeforeAllCallback, AfterAllCallback) and a process builder, however i’m currently having some thread/locking issues, causing the database migration to fail.

I’ll continue to go down this path, but would like to know if there’s perhaps a better way to approach this problem that I have overlooked. Any advice is greatly appreaciated.

Hello Adam,

Axon does not officially provide an in-memory Axon Server option. My opinion is that you can utilize Docker to run Axon Server and integration tests by defining Docker Compose file.
Benefits: You are able to control your environments (Dev, Testing) much better.
Downside: You have to learn Docker API.

I made a small demo application to demonstrate how we can scale Axon applications by utilizing Docker: https://github.com/idugalic/axon-scale-demo/blob/master/docker-compose.monolith.yml . Please note, that this Docker compose file is using persistent Volumes (for the data). You can choose not to specify them in compose file, and have them automatically removed with the container instance removal.

If you would like to run only Axon Server in docker container:

docker run -d --name axonserver -p 8024:8024 -p 8124:8124 axoniq/axonserver

Docker image of Axon Server is officially available on Docker Hub: https://hub.docker.com/r/axoniq/axonserver/

Best,
Ivan

Hi Ivan,

Thanks for the suggestion. I am already utilizing docker for axon server during development. I am able to create a new configuration specifically for integration tests, however my concern was needing to self manage that containers state between integration test runs, and the possibility of contamination between integration tests covering separate areas of functionality. If there was a convenient way I could reset the state of the docker container as part of a junit rule, that would be swell! I have already gone down the route of using a Java docker library to try and spin up a docker container for axon server just for the integration tests, but found it to be troublesome as it was downloading the server image for every test, and unfortunately there's a long running issue with my docker container provider (artifactory) in which often, parts of an image download will fail. This is not a problem when running docker from the cli as it will simply download the missing parts on retry, but when using the library it would attempt the whole thing again and fail time and time again. Due to my environment, I am not able to connect straight to docker hub for the image.

I will continue to investigate what options I have through docker, I was simply hoping for a cleaner, less manual way to perform integration tests when using axon server. Thanks for the help this far.

Hi Adam,

we have seen this usecase before, and it’s (obviously) a valid one. We have a feature on our backlog to allow AxonServer to be started in Dev mode, which enables certain “destructive” features, such as truncating streams and resetting the entire state to “zero”.
For now, we don’t have these features.

As a workaround, you could just run AxonServer as a regular process. Launching an AxonServer instance from Java is not extraordinarily complicated. Just run the command to start the application using the ProcessBuilder API. You’ll be able to start the process in a clean directory for each test suite that you wish to run, or altenetively, pass a temporary folder as the data directory when you start AxonServer.

Hope this helps.
Cheers,

Allard

we have seen this usecase before, and it’s (obviously) a valid one. We have a feature on our backlog to allow AxonServer to be started in Dev mode, which enables certain “destructive” features, such as truncating streams and resetting the entire state to “zero”.
For now, we don’t have these features.

Is still the valid? Or is this issue solved?

regards
Jan

Hi Jan,

The most recent version of Axon Server contains a developer mode.
For specifics around this, I suggest you read the Reference Guide page on the matter, which you can find here.

Hope this clarifies things Jan.

Cheers,
Steven

The most recent version of Axon Server contains a developer mode.
For specifics around this, I suggest you read the Reference Guide page on the matter, which you can find here.

Nice, thanks!