microcks / microcks-quarkus

Quarkus extension that enables embedding Microcks as a DevService managing mocks for dependencies and contract-testing your API endpoints
https://microcks.io
Apache License 2.0
15 stars 3 forks source link

Keycloak timeout with latest Quarkus version #49

Closed szape89 closed 2 months ago

szape89 commented 2 months ago

Describe the bug

Since the latest Quarkus version I get a Keycloak timeout when running tests.

I tested the following versions:

Expected behavior

No error.

Actual behavior

[ERROR] Test.test ยป Runtime java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor#startKeycloakContainer threw an exception: java.lang.RuntimeException: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image quay.io/keycloak/keycloak:25.0.0 at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.startKeycloakContainer(KeycloakDevServicesProcessor.java:250) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849) at io.quarkus.builder.BuildContext.run(BuildContext.java:256) at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521) at java.base/java.lang.Thread.run(Thread.java:1583) at org.jboss.threads.JBossThread.run(JBossThread.java:483) Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image quay.io/keycloak/keycloak:25.0.0 at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:359) at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:330) at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.lambda$startContainer$4(KeycloakDevServicesProcessor.java:377) at java.base/java.util.Optional.orElseGet(Optional.java:364) at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.startContainer(KeycloakDevServicesProcessor.java:402) at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.startKeycloakContainer(KeycloakDevServicesProcessor.java:198) ... 10 more Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88) at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:344) ... 15 more Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:563) at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:354) at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81) ... 16 more Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 2 at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:533) ... 18 more Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '.*Keycloak.*started.*' at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47) at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52) at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:909) at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:500) ... 18 more

How to Reproduce?

Use Quarkus 3.13.0 + Microcks 0.2.6

Microcks version or git rev

0.2.6

Install method (docker-compose, helm chart, operator, docker-desktop extension,...)

mvn package

Additional information

No response

github-actions[bot] commented 2 months ago

๐Ÿ‘‹ @szape89

Welcome to the Microcks community! ๐Ÿ’–

Thanks and congrats ๐ŸŽ‰ for opening your first issue here! Be sure to follow the issue template or please update it accordingly.

๐Ÿ“ข If you're using Microcks in your organization, please add your company name to this list. ๐Ÿ™ It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community ๐Ÿ™Œ"

Hope you have a great time there!

๐ŸŒŸ ~~~~~ ๐ŸŒŸ

๐Ÿ“ข If you like Microcks, please โญ star โญ our repo to support it!

๐Ÿ™ It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

lbroudoux commented 2 months ago

Hello, looks like it is related to #48.

48 explicit the error messages when running with Keycloak 24.0.4 and this one explains what happens when running with Keycloak 25.0.0. Errors are slightly different but the fix is the same: tuning the network on which the container is made available.

For the record, Keycloak 25.0.0 container fails starting with this error in the container logs:

2024-08-02 08:08:39 Changes detected in configuration. Updating the server image.
2024-08-02 08:08:39 Updating the configuration and installing your custom providers, if any. Please wait.
2024-08-02 08:09:02 2024-08-02 06:09:02,540 INFO  [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 20199ms
2024-08-02 08:09:02 Server configuration updated and persisted. Run the following command to review the configuration:
2024-08-02 08:09:02 
2024-08-02 08:09:02     kc.sh show-config
2024-08-02 08:09:02 
2024-08-02 08:09:02 Next time you run the server, just run:
2024-08-02 08:09:02 
2024-08-02 08:09:02     kc.sh start --http-enabled=true --hostname-strict=false --spi-user-profile-declarative-user-profile-config-file=/opt/keycloak/upconfig.json --hostname-port=61848 --optimized
2024-08-02 08:09:02 
2024-08-02 08:09:03 Disabled option: '--hostname-port'. Available only when hostname:v1 feature is enabled
2024-08-02 08:09:03 Possible solutions: --hostname, --hostname-admin, --hostname-backchannel-dynamic, --hostname-strict, --hostname-debug
2024-08-02 08:09:03 Try 'kc.sh start --help' for more information on the available options.
2024-08-02 08:09:03 Specify '--help-all' to obtain information on all options and their availability.
lbroudoux commented 2 months ago

A fix in Quarkus has been submitted here: https://github.com/quarkusio/quarkus/pull/42288

lbroudoux commented 2 months ago

PR has now been merged. We have to wait for the next Quarkus release. Keeping this open in the mean time.

szape89 commented 2 months ago

Latest 3.13.1 version of Quarkus containing the bugfix resolves the reported issue. Thank you!