dapr / java-sdk

Dapr SDK for Java
Apache License 2.0
260 stars 206 forks source link

Replace system tests with Testcontainers #834

Open MatejNedic opened 1 year ago

MatejNedic commented 1 year ago

Currently, system test take docker compose to run and are not that easy to manage. Instead maintaining another pom, integration tests with Testcontainers could be used. This would mimic system tests, but would also be much easier to execute and maintain.

eddumelendez commented 1 year ago

JFTR, there is a repository which contain the example used at Spring IO https://github.com/salaboy/dapr-testcontainers

ejba commented 1 year ago

I started working on this issue on my own initiative, I hope you don't mind.

I followed the example suggested by @eddumelendez. Since TestContainer randomizes exposed ports from host perspective by design (if I'm not wrong), I thought adapting DaprClass to start a new daprd container (instead of using dapr cli) is the easiest way to keep external components (such kafka and mongodb) in the component configuration files.

daprd logs an error message that it cannot use mongodb as a state storage component because it requires the transaction feature which is only available in mongodb replica sets. However, the docker-compose files mentioned in the Run all dependent services generated during build section will launch a single instance of mongodb. So, am I doing something wrong by copying all of component config files into the container, like the dapr-testcontainers repo examples?

MatejNedic commented 1 year ago

Hey @ejba , just for clarification I am not a maintainer on this project. This was only the suggestion I made since when I was contributing to Dapr Java SDK I noticed this. Please check with @artursouza if this is something the Dapr team wants/is beneficial to them.