DataDog / dd-trace-java

Datadog APM client for Java
https://docs.datadoghq.com/tracing/languages/java
Apache License 2.0
588 stars 290 forks source link

Use real docker IP on lettuce tests #7785

Closed amarziali closed 1 month ago

amarziali commented 1 month ago

What Does This Do

Lettuce tests are quite flaky because:

io.lettuce.core.RedisConnectionException: Unable to connect to 127.0.0.1/<unresolved>:32794
    at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:45)
    at io.lettuce.core.AbstractRedisClient.getConnection(AbstractRedisClient.java:233)
    at io.lettuce.core.RedisClient.connectStandalone(RedisClient.java:253)
    at io.lettuce.core.RedisClient.connect(RedisClient.java:202)
    at io.lettuce.core.RedisClient.connect(RedisClient.java:188)
    at Lettuce5ReactiveClientTest.setup(Lettuce5ReactiveClientTest.groovy:58)
    Suppressed: java.lang.NullPointerException: Cannot invoke method close() on null object
        at Lettuce5ReactiveClientTest.cleanup(Lettuce5ReactiveClientTest.groovy:70)
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /127.0.0.1:32794
    at sun.nio.ch.Net.pollConnectNow(Net.java:682)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:973)
    at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:353)
    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:633)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:545)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:499)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)
    at java.lang.Thread.run(Thread.java:1583)
Caused by: java.net.ConnectException: Connection refused
    ... 11 more

We already use the same container on vertx-redis and redisson but they don't fail. The difference I could spot is that in lettuce we hardcode the docker ip to 127.0.0.1. In this PR we take the address provided by testcontainers (that's always a good idea generally speaking)

Motivation

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]