-
Notifications
You must be signed in to change notification settings - Fork 3
#716 fFx schema registry configuration for Kafka source and sink #717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a41807b
#716 Move unit tests out of 'tests' package and use the same package …
yruslan d4d4c6f
#716 Move Schema registry options under 'option' block because some o…
yruslan 4d78acd
#716 Fix config examples and which options are passed to the schema r…
yruslan bbb4a7d
#716 Fix secrets redacting for Schema Registry options.
yruslan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
...en/extras/src/test/scala/za/co/absa/pramen/extras/writer/model/KafkaAvroConfigSuite.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| /* | ||
| * Copyright 2022 ABSA Group Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package za.co.absa.pramen.extras.writer.model | ||
|
|
||
| import com.typesafe.config.ConfigFactory | ||
| import org.scalatest.wordspec.AnyWordSpec | ||
|
|
||
| class KafkaAvroConfigSuite extends AnyWordSpec { | ||
| "fromConfig" should { | ||
| "read a minimalistic config with brokers and schema registry URL" in { | ||
| val conf = ConfigFactory.parseString( | ||
| """kafka.bootstrap.servers = "localhost:9092" | ||
| |schema.registry.url = "localhost:8081" | ||
| |schema.registry.value.naming.strategy = "topic.name" | ||
| |""".stripMargin) | ||
|
|
||
| val kafkaConfig = KafkaAvroConfig.fromConfig(conf) | ||
|
|
||
| assert(kafkaConfig.brokers == "localhost:9092") | ||
| assert(kafkaConfig.schemaRegistryUrl == "localhost:8081") | ||
| assert(kafkaConfig.valueNamingStrategy.namingStrategy == "topic.name") | ||
| assert(kafkaConfig.keyNamingStrategy.isEmpty) | ||
| } | ||
|
|
||
| "read a config with key naming strategy" in { | ||
| val conf = ConfigFactory.parseString( | ||
| """kafka.bootstrap.servers = "localhost:9092" | ||
| |schema.registry.url = "localhost:8081" | ||
| |schema.registry.value.naming.strategy = "topic.name" | ||
| |schema.registry.key.naming.strategy = "topic.name" | ||
| |""".stripMargin) | ||
|
|
||
| val kafkaConfig = KafkaAvroConfig.fromConfig(conf) | ||
|
|
||
| assert(kafkaConfig.brokers == "localhost:9092") | ||
| assert(kafkaConfig.schemaRegistryUrl == "localhost:8081") | ||
| assert(kafkaConfig.valueNamingStrategy.namingStrategy == "topic.name") | ||
| assert(kafkaConfig.keyNamingStrategy.isDefined) | ||
| assert(kafkaConfig.keyNamingStrategy.get.namingStrategy == "topic.name") | ||
| } | ||
|
|
||
| "read a config with record.name naming strategy" in { | ||
| val conf = ConfigFactory.parseString( | ||
| """kafka.bootstrap.servers = "localhost:9092" | ||
| |schema.registry.url = "localhost:8081" | ||
| |schema.registry.value { | ||
| | naming.strategy = "record.name" | ||
| | schema.record.name = "MyRecord" | ||
| | schema.record.namespace = "com.example" | ||
| |} | ||
| |""".stripMargin) | ||
|
|
||
| val kafkaConfig = KafkaAvroConfig.fromConfig(conf) | ||
|
|
||
| assert(kafkaConfig.brokers == "localhost:9092") | ||
| assert(kafkaConfig.schemaRegistryUrl == "localhost:8081") | ||
| assert(kafkaConfig.valueNamingStrategy.namingStrategy == "record.name") | ||
| assert(kafkaConfig.valueNamingStrategy.recordName.contains("MyRecord")) | ||
| assert(kafkaConfig.valueNamingStrategy.recordNamespace.contains("com.example")) | ||
| } | ||
|
|
||
| "read a config with extra auth properties" in { | ||
| val conf = ConfigFactory.parseString( | ||
| """kafka.bootstrap.servers = "localhost:9092" | ||
| |schema.registry.url = "localhost:8081" | ||
| |schema.registry.value.naming.strategy = "topic.name" | ||
| |schema.registry.option { | ||
| | basic.auth.credentials.source = "USER_INFO" | ||
| | basic.auth.user.info = "test:12345" | ||
| | ssl.truststore.location = "cacerts" | ||
| | ssl.truststore.type = "JKS" | ||
| |} | ||
| |""".stripMargin) | ||
|
|
||
| val kafkaConfig = KafkaAvroConfig.fromConfig(conf) | ||
|
|
||
| assert(kafkaConfig.brokers == "localhost:9092") | ||
| assert(kafkaConfig.schemaRegistryUrl == "localhost:8081") | ||
| assert(kafkaConfig.valueNamingStrategy.namingStrategy == "topic.name") | ||
| assert(kafkaConfig.keyNamingStrategy.isEmpty) | ||
| assert(kafkaConfig.schemaRegistryExtraOptions("basic.auth.credentials.source") == "USER_INFO") | ||
| assert(kafkaConfig.schemaRegistryExtraOptions("basic.auth.user.info") == "test:12345") | ||
| assert(kafkaConfig.schemaRegistryExtraOptions("ssl.truststore.location") == "cacerts") | ||
| assert(kafkaConfig.schemaRegistryExtraOptions("ssl.truststore.type") == "JKS") | ||
| } | ||
|
|
||
| "throw an exception when bootstrap servers are missing" in { | ||
| val conf = ConfigFactory.parseString( | ||
| """schema.registry.url = "localhost:8081" | ||
| |schema.registry.value.naming.strategy = "topic.name" | ||
| |""".stripMargin) | ||
|
|
||
| intercept[com.typesafe.config.ConfigException.Missing] { | ||
| KafkaAvroConfig.fromConfig(conf) | ||
| } | ||
| } | ||
|
|
||
| "throw an exception when schema registry URL is missing" in { | ||
| val conf = ConfigFactory.parseString( | ||
| """kafka.bootstrap.servers = "localhost:9092" | ||
| |schema.registry.value.naming.strategy = "topic.name" | ||
| |""".stripMargin) | ||
|
|
||
| intercept[com.typesafe.config.ConfigException.Missing] { | ||
| KafkaAvroConfig.fromConfig(conf) | ||
| } | ||
| } | ||
|
|
||
| "throw an exception when value naming strategy is missing" in { | ||
| val conf = ConfigFactory.parseString( | ||
| """kafka.bootstrap.servers = "localhost:9092" | ||
| |schema.registry.url = "localhost:8081" | ||
| |""".stripMargin) | ||
|
|
||
| intercept[com.typesafe.config.ConfigException.Missing] { | ||
| KafkaAvroConfig.fromConfig(conf) | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.