Spring Contracts: Stubs are runnning on port -1 + Failed to construct kafka producer

200 Views Asked by At

I have the Consumer test set up with Embedded Kafka and local Maven stubs. Test props set either via application.properties file or @DynamicPropertySource.

@SpringBootTest(
        webEnvironment = SpringBootTest.WebEnvironment.NONE)
@AutoConfigureStubRunner(
        stubsMode = StubRunnerProperties.StubsMode.LOCAL,
        ids = "com.example:service:+:stubs:8468")
@EmbeddedKafka(topics = "topic")
@ActiveProfiles("test")
public class ConsumerTests

The test fails with:

18:07:26.818 [Test worker] INFO  org.springframework.cloud.contract.stubrunner.AetherStubDownloader - Unpacking stub from JAR [URI: file:/Users/me/.m2/repository/com/example/service/2021.0.0/service-2021.0.0-stubs.jar]
18:07:26.823 [Test worker] INFO  org.springframework.cloud.contract.stubrunner.AetherStubDownloader - Unpacked file to [/var/folders/_n/kc_mgwps6255wyp6z6wsw88m0000gn/T/contracts-1653059246818-0]
18:07:28.287 [Test worker] INFO  org.springframework.cloud.contract.stubrunner.StubServer - Started stub server for project [com.example:service:2021.0.0:stubs] on port -1 with [0] mappings
18:07:28.287 [Test worker] INFO  org.springframework.cloud.contract.stubrunner.StubRunnerExecutor - All stubs are now running RunningStubs [namesAndPorts={com.example:service:2021.0.0:stubs=-1}]
18:07:28.289 [Test worker] INFO  org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'batchStubRunner' of type [org.springframework.cloud.contract.stubrunner.BatchStubRunner] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

.

org.apache.kafka.common.KafkaException: Failed to construct kafka producer
at org.springframework.cloud.contract.verifier.messaging.kafka.KafkaStubMessages.send(KafkaStubMessages.java:72)
    at org.springframework.cloud.contract.verifier.messaging.kafka.KafkaStubMessages.send(KafkaStubMessages.java:92)
    at org.springframework.cloud.contract.stubrunner.spring.LazyMessageVerifier.send(StubRunnerConfiguration.java:198)
    at org.springframework.cloud.contract.stubrunner.StubRunnerExecutor.sendMessage(StubRunnerExecutor.java:252)
    at org.springframework.cloud.contract.stubrunner.StubRunnerExecutor.triggerForDsls(StubRunnerExecutor.java:205)
    at org.springframework.cloud.contract.stubrunner.StubRunnerExecutor.trigger(StubRunnerExecutor.java:191)
    at org.springframework.cloud.contract.stubrunner.StubRunner.trigger(StubRunner.java:152).....
No resolvable bootstrap urls given in bootstrap.servers

While Kafka consumer port looks good in logs, I see no port for producer: org.apache.kafka.clients.producer.ProducerConfig - ProducerConfig values: bootstrap.servers = []

I suspect it could be related to stubs running on port -1 (not running in reality?). Another suspect: no mappings generated as stubs by Producer, I have only contracts in stubs folder. Should there be mappings generated by Producer for Kafka messaging not rest-apis?

Is there a way to check if the stubs are truly accessible?

0

There are 0 best solutions below