Skip to content

Streamline Avro schema registration and compatibility checks in Kafka with the avroschema-wizard-plugin, simplifying testing and integration with ease!

License

Notifications You must be signed in to change notification settings

rudikone/avroschema-wizard-plugin

Repository files navigation

Avroschema-wizard-plugin (Gradle) 🐘

License Language Download

Plugin to interact with schema-registry using API Schema registry.

Simplify schema registration under specific subjects (topic names) and conduct seamless compatibility checks. This plugin streamlines the integration of Avro schemas, enhancing your local testing process and ensuring smooth execution in integration tests and CI pipelines. Use it now to effortlessly manage enrollment and schema validation in your Kafka ecosystem!

License 📄

This plugin is licensed under the MIT License - see the License file for details.

Use cases

The plugin simplifies kafka consumer testing when using avro schemas, and also provides additional features such as compatibility check. It can be used in local testing, as well as in integration tests or CI.

Features:

  • registration of schemes under subjects
  • compatibility check

How to use 👣

build.gradle.kts:

plugins {
    id("io.github.rudikone.avroschema-wizard-plugin") version <version>
}

avroWizardConfig {
    schemaRegistryUrl = "some_url"
    searchAvroFilesPaths = setOf("../some/search/path/1", "../some/search/path/2")
    topicToSchema = mapOf("some-topic-1" to "SomeSchemaName1", "some-topic-2" to "SomeSchemaName2")
    subjectNameStrategy = "TopicNameStrategy"
}

Register schemas:

run

gradle registerAllSchemas

The task will search for files with extension .avsc, whose names (without extension) are passed as topicToSchema map values, in the directories passed to searchAvroFilesPaths, and register schemas by appropriate subjects depending on the subjectNameStrategy value.

Output: Registered <schema_name> with id: <id_from_registry> for <topic_name>

If a schema with the same name is registered under multiple subjects, the id will be assigned to it once. See Documentation

Compatibility check:

run

gradle checkCompatibility

The task will search for files with extension .avsc, whose names (without extension) are passed as topicToSchema map values, in the directories passed to searchAvroFilesPaths, and check the compatibility of the new versions of the schemas by appropriate subjects depending on the subjectNameStrategy value.

OR

run

gradle checkCompatibility --subject=<subject-name> --schema=<schema-name>

The task will search for a file with the extension .avsc, whose name (without extension) is passed as a command line argument (schema), in the directories given in searchAvroFilesPaths, and check if the passed schema is compatible with the schema under the subject passed as a command line argument (subject).

If the subject does not exist, an error will be thrown!

Output: Schema <schema_name> is (not) compatible with the latest schema under subject <subject_name>

Properties:

Name Description Default value
schemaRegistryUrl Schema registry URL "http://localhost:10081"
searchAvroFilesPaths List of directories to search for files with extension .avcs build directory of the project
subjectToSchema Subject (topic) to schema name map -
subjectNameStrategy Subject Name Strategy: TopicNameStrategy, RecordNameStrategy, TopicRecordNameStrategy TopicNameStrategy

Example:

See example module. Run docker-compose, testing plugin tasks. For convenience, you can use schema-registry-ui (http://localhost:8002/ in your browser).

Contributing 🤝

Feel free to open an issue or submit a pull request for any bugs/improvements.

About

Streamline Avro schema registration and compatibility checks in Kafka with the avroschema-wizard-plugin, simplifying testing and integration with ease!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages