I have a Reactor-based Spring Boot Kafka stream processing app that I am working on writing integration tests for. I am using Spring's @EmbeddedKafka
broker. It works great, I have it overriding the bootstrap broker urls that get configured on my reactive processor's consumer & publisher, but what I haven't figured out yet is how to deal with the schema registry for my processor when testing. I'm using Confluent's KafkaAvroSerializer
and KafkaAvroDeserializer
classes and just have the schema.registry.url
field configured in my Spring app configs to get injected into the Kafka properties. I'm using Confluent's MockSchemaRegistryClient
for the test producer and consumer, but what I need is a way to inject this mock client into the actual consumer and producer in my stream processor code, but I see no way to do that. Almost seems like I need something more like an embedded version of the schema registry to point them to like the embedded broker. Our build pipeline does not support spinning up containers otherwise I'd use Docker or Testcontainers. Anyone else solve this already? Any help or suggestions appreciated.
Mocking SchemaRegistryClient in stream processor Consumer
472 Views Asked by NikeAGoGo At
1
I managed to figure this out. If you use a url that begins with
mock://
for your test's SerDes, and you override theschema.registry.url
property in the@SpringBootTest
annotation with the same mock url, then your processor's consumer and producer will also pick up and use this mock schema registry client, and everything just works!