Replies: 1 comment 2 replies
-
Not sure why, but I had to explicitly start the container with the .start() method. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm setting up tests using the KeycloakContainer to test a custom provider but running the test goal in maven fails with an error:
java.lang.IllegalStateException: Mapped port can only be obtained after the container is started
at org.testcontainers.shaded.com.google.common.base.Preconditions.checkState(Preconditions.java:174)
at org.testcontainers.containers.ContainerState.getMappedPort(ContainerState.java:149)
at dasniko.testcontainers.keycloak.ExtendableKeycloakContainer.getHttpPort(ExtendableKeycloakContainer.java:398)
at dasniko.testcontainers.keycloak.ExtendableKeycloakContainer.getAuthServerUrl(ExtendableKeycloakContainer.java:386)
at org.iso.keycloak.custom.federation.utils.FederationUtilsProviderTest.givenSpec(FederationUtilsProviderTest.java:91)
at org.iso.keycloak.custom.federation.utils.FederationUtilsProviderTest.testQueryUnauthenticatedUser(FederationUtilsProviderTest.java:32)
The issue is that it seems the test container is not started when test are executed (I need to test custom rest endpoints).
If I start the tests within intelliJ it works just fine:
.....
[main] INFO org.testcontainers.utility.RyukResourceReaper - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
[main] INFO org.testcontainers.DockerClientFactory - Checking the system...
[main] INFO org.testcontainers.DockerClientFactory - ✔︎ Docker server version should be at least 1.6.0
[main] INFO 🐳 [quay.io/keycloak/keycloak:21.0] - Creating container for image: quay.io/keycloak/keycloak:21.0
....
while executing tests with maven, it does not even try to create the keycloak container and executes directly tests.
I hope someone can have hints for me.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions