quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.54k stars 2.61k forks source link

Test log cluttered with "Connection to node -1 ... could not be established. Broker may not be available." #12120

Closed antoniomacri closed 3 years ago

antoniomacri commented 3 years ago

Description Test logs are full of warnings like this:

WARN: [AdminClient clientId=...-8cd9c56a-1348-4528-87a8-265035d94965-admin] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
WARN: [Producer clientId=...-8cd9c56a-1348-4528-87a8-265035d94965-StreamThread-1-producer] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.

I have tests which only use TopologyTestDriver, so there is no need to instantiate Kafka. Furthermore I cannot "unset" kafka-streams.bootstrap-servers.

Is there any way to get rid of those messages?

I've seen I could use KafkaTestResource, but I think it would be better to have a way to prevent it completely.

Thanks, Antonio

rquinio commented 3 years ago

Indeed KStreams TopologyTestDriver tests (whitebox testing without creating any Kafka connections) are run via @QuarkusTest today (ex: TopologyProducerTest ) which starts the application (including TCP connections, thread pools, ...) and rather more suitable for blackbox testing.

I don't know if it would be possible to have a lesser version of @QuarkusTest that only does the initialization (dependency injection, config injection, ...), but does not start the app (i.e. never calls StartupEvent / @Startup producers) ?

antoniomacri commented 3 years ago

In my tests I'm actually using beans which @Observes StartupEvent, so I'd need something different.

cescoffier commented 3 years ago

This issue is rather outdated. It has been fixed in SmallRye Reactive Messaging.

rquinio commented 3 years ago

I think this may have been closed by mistake, as it's quarkus-kstream extension question/issue.

Anyway I've found a solution for this: simply inject a mock of KafkaStreams - a class that extends KafkaStreams and overrides start() to do nothing. The bean being singleton scope, it has to be done via QuarkusTestProfile CDI alternatives.

Actually it would require a change in extension to not initialize a new KafkaStreams if one is provided via test profile.

pantaoran commented 2 years ago

@cescoffier How has this been fixed? I'm using the latest version of Quarkus with the quarkus-kafka-streams dependency, and my logs are still full of these warnings when I'm running unit tests with the TopologyTestDriver. Do I need to configure something to make those go away?

ngc4579 commented 4 months ago

Any progress / further hints on this?

antoniomacri commented 1 month ago

I stil see those logs on Quarkus 3.13.0...

@cescoffier Could it be reopened?

cescoffier commented 3 weeks ago

@antoniomacri can you open a new issue with a reproducer?

cescoffier commented 3 weeks ago

(BTW, this was fixed for the reactive messaging connector, not kafka streams - not sure you can do anything in kafka streams without modifying kafka streams itself).