eclipse-hono / hono

Eclipse Hono™ Project
https://eclipse.dev/hono
Eclipse Public License 2.0
452 stars 137 forks source link

Running integration tests twice, first with remote_cache and then embedded_cache, fails #3624

Open StFS opened 6 months ago

StFS commented 6 months ago

After building Hono and containers, I go to the tests/ directory and run the integration tests there. If I first run the remote_cache (default) profile, the tests pass fine. But if I then run the embedded_cache profile (without running mvn clean in between), the command-router is unable to start as it tries to connect to the infinispan remote cache with invalid configuration.

Here are the commands that I used with a summary of the results:

cd eclipse-hono
# assume we are now in a clean master checkout of the hono project
mvn install -Pbuild-docker-image,metrics-prometheus -DskipTests=true
# build succeeds
cd tests
mvn verify -Prun-tests,coap-only
# tests run fine and use the remote_cache (infinispan / hotrod)
mvn verify -Prun-tests,coap-only,embedded_cache
# tests fail with an error that the remote cache is being configured (which it shouldn't)

The workaround for this is to run mvn clean in between runs (which can also be achieved by adding the clean target to the second Maven command in the above block, that is mvn clean verify -Prun-tests,coap-only,embedded_cache)

sophokles73 commented 5 months ago

I guess this is because we build only one Command Router image for running the ITs and add the selected cache configuration to the image. When you initially ran the tests with the remote cache, the hono-service-command-router-test image is built and the config from the remote-cache folder is added. When you then run the tests with the embedded cache, Maven thinks that the image is already there and does not need to be rebuilt. You might be able to solve this by including the cache profile name into the image name (https://github.com/eclipse-hono/hono/blob/09af700c68a310d56254e98d9805d05c85e49684/tests/pom.xml#L1500)