Giter Site home page Giter Site logo

embeddedkafka / embedded-kafka-schema-registry Goto Github PK

View Code? Open in Web Editor NEW
108.0 7.0 23.0 404 KB

A library that provides in-memory instances of both Kafka and Confluent Schema Registry to run your tests against.

License: MIT License

Scala 100.00%

embedded-kafka-schema-registry's Introduction

embedded-kafka-schema-registry

Maven Central Test Codacy Badge Codacy Coverage Badge Mergify Status Scala Steward badge

A library that provides in-memory instances of both Kafka and Confluent Schema Registry to run your tests against.

Relies on the embedded-kafka library.

Version compatibility matrix

embedded-kafka-schema-registry is available on Maven Central, compiled for Scala 2.12, 2.13 and Scala 3 (since v7.4.0).

Support for Scala 2.11 was dropped by Apache in Kafka v2.5.0.

Versions match the version of Confluent Schema Registry they're built against.

Important known limitation (prior to Kafka v2.8.0)

Prior to v2.8.0 Kafka core was inlining the Scala library, so you couldn't use a different Scala patch version than what Kafka used to compile its jars!

Breaking change: new package name

From v6.2.0 onwards package name has been updated to reflect the library group id (i.e. io.github.embeddedkafka).

Aliases to the old package name have been added, along with a one-time Scalafix rule to ensure the smoothest migration.

embedded-kafka-schema-registry

How to use

  • In your build.sbt file add the following resolvers:
resolvers ++= Seq(
  "confluent" at "https://packages.confluent.io/maven/",
  "jitpack" at "https://jitpack.io"
)
  • In your build.sbt file add the following dependency (replace x.x.x with the appropriate version): "io.github.embeddedkafka" %% "embedded-kafka-schema-registry" % "x.x.x" % Test
  • Have your class extend the EmbeddedKafka trait (from the io.github.embeddedkafka.schemaregistry package).
  • Enclose the code that needs a running instance of Kafka within the withRunningKafka closure.
  • Provide an implicit EmbeddedKafkaConfigImpl (from the same package mentioned before).
class MySpec extends AnyWordSpecLike with Matchers with EmbeddedKafka {

  "runs with embedded kafka and Schema Registry" should {

    "work" in {
      implicit val config = EmbeddedKafkaConfig()

      withRunningKafka {
        // ... code goes here
      }
    }
  }
}
  • In-memory Zookeeper, Kafka, and Schema Registry will be instantiated respectively on port 6000, 6001, and 6002 and automatically shutdown at the end of the test.

embedded-kafka-schema-registry-streams

A library that builds on top of embedded-kafka-schema-registry to offer easy testing of Kafka Streams with Confluent Schema Registry.

It takes care of instantiating and starting your streams as well as closing them after running your test-case code.

How to use

  • In your build.sbt file add the following dependency (replace x.x.x with the appropriate version): "io.github.embeddedkafka" %% "embedded-kafka-schema-registry-streams" % "x.x.x" % Test
  • For most of the cases have your class extend the EmbeddedKafkaStreams trait (from the io.github.embeddedkafka.schemaregistry.streams package). This offers both streams management and easy creation of consumers for asserting resulting messages in output/sink topics.
  • Use EmbeddedKafkaStreams.runStreams and EmbeddedKafka.withConsumer and EmbeddedKafka.withProducer. This allows you to create your own consumers of custom types as seen in the example test.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.