java-sdk icon indicating copy to clipboard operation
java-sdk copied to clipboard

Migrate integration tests from process based approach to Testcontainers

Open artur-ciocanu opened this issue 8 months ago • 3 comments

Describe the proposal

Historically Dapr Java SDK used a process based approach for running integration tests. This consisted of the following pieces:

  • JUnite Runner - this would start the IT
  • Maven Exec Plugin - this would actually start the Dapr sidecar
  • Application under test - this is usually either a stub based on WireMock or a Spring Boot application

Java and the JVM ecosystem was and it still is very bad at process management. The ProcessBuilder API is horrendous and to make it properly work it requires a lot of boilerplate and baby sitting. For a quick glimpse you can check DaprRun and Command classes that deal with ProcessBuilder.

More than a half a year ago @salaboy started working on bringing Testcontainers support to Dapr Java SDK. The Testcontainers are currently used quite successfully for testing the newly added Spring Boot integration.

The proposal is to slowly migrate IT tests from the process based mechanism that relies on DaprRun and Maven Exec to Testcontainers based approach.

Tescontainers has all the necessary tools and hooks to make sure that the resources are properly cleaned up, also since Dapr is itself a sidecar Testcontainers and its container focus is natural fit for these types of integration tests.

artur-ciocanu avatar Apr 02 '25 14:04 artur-ciocanu

@cicoyle and @salaboy pleas share your thoughts regarding this proposal.

artur-ciocanu avatar Apr 05 '25 15:04 artur-ciocanu

@artur-ciocanu I agree with this proposal, this was the plan when I started using Testcontainers but to migrate all tests will take quite some time and I think we need to do it progressively. I don't want to stop you from migrating tests, but on my side, there are other priorities first on the list.. If we find flaky tests using the old way, we try to migrate them and make them more stable.

salaboy avatar Apr 07 '25 07:04 salaboy

I am here to help with this proposal :) But I agree with @salaboy, we need to do it progressively!

mcruzdev avatar Apr 07 '25 19:04 mcruzdev