Skip to content

Latest commit

 

History

History
163 lines (134 loc) · 10.1 KB

README.md

File metadata and controls

163 lines (134 loc) · 10.1 KB

schemaregistry-junit

GitHub Actions Status FOSSA Status Quality Gate Status Coverage

Library Version Documentation Vulnerability
schemaregistry-junit5 Maven Central Javadocs Known Vulnerabilities
schemaregistry-junit4 Maven Central Javadocs Known Vulnerabilities
schemaregistry-junit-core Maven Central Javadocs Known Vulnerabilities

Are you tired of waiting for Docker containers to fire up while testing your Kafka solution? Or are you tired of waiting for an ephemeral environment to start? Are you looking for a solution to reduce the time you are loosing waiting for Apache Kafka Cluster and Confluent Schema Registry to start while testing? schemaregistry-junit is the answer! By pairing schemaregistry-junit together with kafka-junit, you can speed up your tests and shorten the feedback loop by reducing the time wasted waiting for Docker containers or ephemeral environments to start. schemaregistry-junit lets you run a fully working Confluent Schema Registry in-memory. The server lifecycle is fully automated via JUnit extensions. A fluent DSL is provided to configure the Confluent Schema Registry.

This project was inspired by kafka-junit.

Features

Installation

The easiest way to include schemaregistry-junit in your project(s) is via Maven dependency. Binary, Sources and Javadocs are all available in Maven Central.

For JUnit 5

Maven

Example POM

<!-- Declare schemaregistry-junit5 dependency -->
<dependency>
  <groupId>io.github.data-rocks-team</groupId>
  <artifactId>schemaregistry-junit5</artifactId>
  <version>0.1.1</version>
</dependency>

<!-- Include Confluent Schema-Registry -->
<dependency>
  <groupId>io.confluent</groupId>
  <artifactId>kafka-schema-registry</artifactId>
  <version>X.X.X</version>
</dependency>
Gradle

Example build.gradle

testImplementation 'io.github.data-rocks-team:schemaregistry-junit5:0.1.1'
testImplementation 'io.confluent:kafka-schema-registry:X.X.X'

For JUnit 4

Maven

Example POM

<!-- Declare schemaregistry-junit5 dependency -->
<dependency>
  <groupId>io.github.data-rocks-team</groupId>
  <artifactId>schemaregistry-junit4</artifactId>
  <version>0.1.1</version>
</dependency>

<!-- Include Confluent Schema-Registry -->
<dependency>
  <groupId>io.confluent</groupId>
  <artifactId>kafka-schema-registry</artifactId>
  <version>X.X.X</version>
</dependency>
Gradle

Example build.gradle

testImplementation 'io.github.data-rocks-team:schemaregistry-junit4:0.1.1'
testImplementation 'io.confluent:kafka-schema-registry:X.X.X'

How it works

Given a class using SharedSchemaRegistryTestResource, before all tests start, JUnit calls the start function. This function replicates the behaviour of SchemaRegistryMain.java, which first validates the settings and then starts the server. When all tests have been executed, independently of the test results, JUnit calls the shutdown function, which will shut the server down. Logs generated by the server are redirected to the terminal.

Regression testing

Confluent Version Regression test
4.x.x Actions Status
5.x.x Actions Status
6.x.x Actions Status
7.x.x Actions Status

Every build is automatically tested against the latest patch version of every minor version since 4.0.0. For more details, check regression-test.

Before compiling any example, run ./gradlew setDependenciesForRegressionTesting in the main project. This gradle task will ensure that the regression tests will use the same dependency versions used in the main project. To ensure that setDependenciesForExample works as expected, dependencies version should be defined in the ext {} section in the main build.gradle and the example project should define versions as nameOfTheDependencyVersion = PLACEHOLDER (see regression-test/build.gradle).

Upon bumping a major or minor version of io.confluent:kafka-schema-registry, a new regression test should be added under regression-test.

Examples

Before compiling any example, run ./gradlew setDependenciesForExample in the main project. This gradle task will ensure that the example project will use the same dependency versions used in the main project. To ensure that setDependenciesForExample works as expected, dependencies version should be defined in the ext {} section in the main build.gradle and the example project should define versions as nameOfTheDependencyVersion = PLACEHOLDER (an example can be found here).

Contributing

Found a bug? You've got an awesome feature you want to add? We welcome contributions!

Feedback

Any questions or suggestions? Get in touch!

Tweet LinkedIn

Blog post

License

MIT view license

FOSSA Status