question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect Devservices config generated for Keycloak with Testcontainers Cloud

See original GitHub issue

Describe the bug

When using Devservices for Keycloak with Testcontainers Cloud an incorrect config is generated. The detected port mapping is correct, however the injected urls contain the wrong port.

image

The port 65299 is detected in the port mappings, however the config gets port 65224 injected and nothing is listening on this port.

This does work correctly for data services, like PostgreSQL and Kafka, see below.

image

Expected behavior

It does work correctly when using Docker Desktop for Mac instead.

image

Output of $ sudo lsof -i -n -P | grep TCP

com.docke 90705       wjglerum  134u  IPv6 0x3a899d7578da3c87      0t0    TCP *:49887 (LISTEN)
com.docke 90705       wjglerum  135u  IPv6 0x3a899d7578da3587      0t0    TCP 127.0.0.1:49887->127.0.0.1:49888 (ESTABLISHED)
com.docke 90705       wjglerum  136u  IPv6 0x3a899d757a640687      0t0    TCP *:49889 (LISTEN)
com.docke 90705       wjglerum  137u  IPv6 0x3a899d757a643e87      0t0    TCP 127.0.0.1:49889->127.0.0.1:49978 (ESTABLISHED)
com.docke 90705       wjglerum  138u  IPv6 0x3a899d757a63ea87      0t0    TCP [::1]:49889->[::1]:50099 (ESTABLISHED)
com.docke 90705       wjglerum  139u  IPv6 0x3a899d7578d7a887      0t0    TCP [::1]:49889->[::1]:50100 (ESTABLISHED)
com.docke 90705       wjglerum  140u  IPv6 0x3a899d7578d7e087      0t0    TCP [::1]:49889->[::1]:50101 (ESTABLISHED)
com.docke 90705       wjglerum  141u  IPv6 0x3a899d757a641b87      0t0    TCP [::1]:49889->[::1]:50102 (ESTABLISHED)
com.docke 90705       wjglerum  142u  IPv6 0x3a899d757a643787      0t0    TCP [::1]:49889->[::1]:50103 (ESTABLISHED)
com.docke 90705       wjglerum  143u  IPv6 0x3a899d757a643087      0t0    TCP [::1]:49889->[::1]:50104 (ESTABLISHED)

Actual behavior

The app fails with the following exception:

java.net.ConnectException: Connection refused
	at java.base/sun.nio.ch.Net.pollConnect(Native Method)
	at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
	at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946)
	at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337)
	at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:710)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:833)
Resulted in: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /127.0.0.1:65224
Resulted in: io.quarkus.oidc.OIDCException: OIDC Server is not available

Output of $ sudo lsof -i -n -P | grep TCP

testconta  1914       wjglerum    7u  IPv4 0x3a899d7a59a3f38f      0t0    TCP 127.0.0.1:63011 (LISTEN)
testconta  1914       wjglerum   13u  IPv4 0x3a899d7a5994ee3f      0t0    TCP 172.20.10.3:65117->104.26.3.119:443 (ESTABLISHED)
testconta  1914       wjglerum   15u  IPv4 0x3a899d7a59bb338f      0t0    TCP 172.20.10.3:65145->3.228.161.144:443 (ESTABLISHED)
testconta  1914       wjglerum   16u  IPv4 0x3a899d7a5075938f      0t0    TCP 127.0.0.1:65215 (LISTEN)
testconta  1914       wjglerum   17u  IPv4 0x3a899d7a59bd038f      0t0    TCP 172.20.10.3:65144->34.147.124.196:32289 (ESTABLISHED)
testconta  1914       wjglerum   18u  IPv4 0x3a899d7a5074e38f      0t0    TCP 127.0.0.1:65215->127.0.0.1:65216 (ESTABLISHED)
testconta  1914       wjglerum   19u  IPv4 0x3a899d7a59a4638f      0t0    TCP 127.0.0.1:65299 (LISTEN)
testconta  1914       wjglerum   20u  IPv4 0x3a899d7a59a0038f      0t0    TCP 127.0.0.1:63011->127.0.0.1:65347 (ESTABLISHED)

How to Reproduce?

Use Testcontainers Cloud for Mac instead of Docker Desktop for Mac. And start a project from scratch with the OIDC extension.

Output of uname -a or ver

Darwin Willems-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "17.0.3" 2022-04-19 OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7) OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.12.0.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /Users/wjglerum/.m2/wrapper/dists/apache-maven-3.8.6-bin/1ks0nkde5v1pk9vtc31i9d0lcd/apache-maven-3.8.6 Java version: 17.0.3, vendor: Eclipse Adoptium, runtime: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home Default locale: en_NL, platform encoding: UTF-8 OS name: "mac os x", version: "12.5.1", arch: "x86_64", family: "mac"

Additional information

Testcontainers Cloud version 1.3.3

You can probably ask access to their private beta if needed.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
sberyozkincommented, Sep 8, 2022

@kiview It may be an interesting enhancement idea as its API looks nice but it is hard to know it will work without the fixes done by Georgios, both the one built here and the one created by @dasniko are TestContainer instances so perhaps the simplest option is to address this particular issue here. The local implementation makes it a bit more flexible - ex, 19.0.1 is used locally, we can tune start up commands, and we work with the same version to support both WildFly (as we can expect this one being used for a while) and the newer Quarkus based distros - but it is branched out in that project… I propose to discuss it in Discussions for example…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dev Services Overview - Quarkus
When DevServices is enabled Quarkus will attempt to automatically configure and start Keycloak when running in Dev or Test mode and when Docker...
Read more >
Keycloak integration tests in Kie Server (with TestContainers)
KeycloakFixture class, where needed resources for tests (application client, users and their roles) are created in the Keycloak container.
Read more >
Piotr Mińkowski – Page 3 - Piotr's TechBlog - WordPress.com
Before using the client we need to generate classes from schema and .grapql files. ... Such components like Eureka, Spring Cloud Config or...
Read more >
Integration Tests with Keycloak & Testcontainers (& Quarkus)
How to do proper unit and integration testing (and NOT integrated tests) of your Keycloak based application with the help of Testcontainers ......
Read more >
Quarkus 2.5.1.Final 发布-Linuxeden开源社区
... #21728 – Fix rest client invalid config message ... #21673 – Propagate the Maven settings argument when testing codestart-generated projects ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found