-
Notifications
You must be signed in to change notification settings - Fork 12
test: validate quickstart config properties #183
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 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4f40436
test: validate quickstart config properties
Emrehzl94 5223267
style: formatting
Emrehzl94 e0f9717
build: remove redundant and unused settings
fbiville 0b524e1
test: add source tests
Emrehzl94 8f4223b
test: change property name
Emrehzl94 40091b9
fix: implement the feedback
Emrehzl94 3523914
fix: implement the feedback
Emrehzl94 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
2 changes: 1 addition & 1 deletion
2
packaging/src/main/distributions/text/config/sink-pattern-relationship-quickstart.properties
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| /* | ||
| * Copyright (c) "Neo4j" | ||
| * Neo4j Sweden AB [https://neo4j.com] | ||
| * | ||
| * 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. | ||
| */ | ||
| import io.kotest.assertions.throwables.shouldNotThrowAny | ||
| import io.kotest.matchers.shouldBe | ||
| import io.kotest.matchers.shouldNotBe | ||
| import io.kotest.matchers.types.shouldBeInstanceOf | ||
| import java.io.File | ||
| import java.io.FileInputStream | ||
| import java.util.* | ||
| import org.junit.jupiter.api.Test | ||
| import org.neo4j.connectors.kafka.sink.SinkConfiguration | ||
| import org.neo4j.connectors.kafka.sink.strategy.pattern.NodePattern | ||
| import org.neo4j.connectors.kafka.sink.strategy.pattern.Pattern | ||
| import org.neo4j.connectors.kafka.sink.strategy.pattern.RelationshipPattern | ||
| import org.neo4j.connectors.kafka.source.SourceConfiguration | ||
| import org.neo4j.cypherdsl.core.renderer.Renderer | ||
|
|
||
| class ConfigPropertiesTest { | ||
|
|
||
| // This test checks that the number of config files is fixed. | ||
| // If a new file is added, the test will fail, reminding the developer to update this test and add | ||
| // unit tests for the new file. | ||
| @Test | ||
| fun `should be specific amount of config files`() { | ||
| val configDirectory = File(BASE_CONFIG_PATH) | ||
| configDirectory.listFiles()!!.size shouldBe 8 | ||
| } | ||
|
|
||
| @Test | ||
| fun `sink cdc schema quick start config should be valid`() { | ||
| val properties = loadConfigProperties("sink-cdc-schema-quickstart.properties") | ||
|
|
||
| properties["connector.class"] shouldBe "org.neo4j.connectors.kafka.sink.Neo4jConnector" | ||
| properties["neo4j.cdc.schema.topics"] shouldNotBe null | ||
|
|
||
| shouldNotThrowAny { SinkConfiguration(properties, Renderer.getDefaultRenderer()) } | ||
Emrehzl94 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @Test | ||
| fun `sink cdc source id quick start config should be valid`() { | ||
| val properties = loadConfigProperties("sink-cdc-source-id-quickstart.properties") | ||
|
|
||
| properties["connector.class"] shouldBe "org.neo4j.connectors.kafka.sink.Neo4jConnector" | ||
| properties["neo4j.cdc.source-id.topics"] shouldNotBe null | ||
|
|
||
| shouldNotThrowAny { SinkConfiguration(properties, Renderer.getDefaultRenderer()) } | ||
| } | ||
|
|
||
| @Test | ||
| fun `sink cud quick start config should be valid`() { | ||
| val properties = loadConfigProperties("sink-cud-quickstart.properties") | ||
|
|
||
| properties["connector.class"] shouldBe "org.neo4j.connectors.kafka.sink.Neo4jConnector" | ||
| properties["neo4j.cud.topics"] shouldNotBe null | ||
|
|
||
| shouldNotThrowAny { SinkConfiguration(properties, Renderer.getDefaultRenderer()) } | ||
| } | ||
|
|
||
| @Test | ||
| fun `sink cypher quick start config should be valid`() { | ||
| val properties = loadConfigProperties("sink-cypher-quickstart.properties") | ||
|
|
||
| properties["connector.class"] shouldBe "org.neo4j.connectors.kafka.sink.Neo4jConnector" | ||
| properties.keys.any { it.startsWith("neo4j.cypher.topic") } shouldBe true | ||
|
|
||
| shouldNotThrowAny { SinkConfiguration(properties, Renderer.getDefaultRenderer()) } | ||
| } | ||
|
|
||
| @Test | ||
| fun `sink pattern node quick start config should be valid`() { | ||
| val properties = loadConfigProperties("sink-pattern-node-quickstart.properties") | ||
|
|
||
| properties["connector.class"] shouldBe "org.neo4j.connectors.kafka.sink.Neo4jConnector" | ||
|
|
||
| val patternKey = properties.keys.first { it.startsWith("neo4j.pattern.topic") } | ||
| patternKey shouldNotBe null | ||
|
|
||
| val parsedPattern = Pattern.parse(properties[patternKey] as String) | ||
| parsedPattern.shouldBeInstanceOf<NodePattern>() | ||
|
|
||
| shouldNotThrowAny { SinkConfiguration(properties, Renderer.getDefaultRenderer()) } | ||
| } | ||
|
|
||
| @Test | ||
| fun `sink pattern relationship quick start config should be valid`() { | ||
| val properties = loadConfigProperties("sink-pattern-relationship-quickstart.properties") | ||
|
|
||
| properties["connector.class"] shouldBe "org.neo4j.connectors.kafka.sink.Neo4jConnector" | ||
|
|
||
| val patternKey = properties.keys.first { it.startsWith("neo4j.pattern.topic") } | ||
| patternKey shouldNotBe null | ||
|
|
||
| val parsedPattern = Pattern.parse(properties[patternKey] as String) | ||
| parsedPattern.shouldBeInstanceOf<RelationshipPattern>() | ||
|
|
||
| shouldNotThrowAny { SinkConfiguration(properties, Renderer.getDefaultRenderer()) } | ||
| } | ||
|
|
||
| @Test | ||
| fun `source cdc quick start config should be valid`() { | ||
| val properties = loadConfigProperties("source-cdc-quickstart.properties") | ||
|
|
||
| properties["connector.class"] shouldBe "org.neo4j.connectors.kafka.source.Neo4jConnector" | ||
| properties["neo4j.source-strategy"] shouldBe "CDC" | ||
| properties.keys.any { it.startsWith("neo4j.cdc.topic") } shouldBe true | ||
|
|
||
| shouldNotThrowAny { SourceConfiguration(properties) } | ||
| } | ||
|
|
||
| @Test | ||
| fun `source query quick start config should be valid`() { | ||
| val properties = loadConfigProperties("source-query-quickstart.properties") | ||
|
|
||
| properties["connector.class"] shouldBe "org.neo4j.connectors.kafka.source.Neo4jConnector" | ||
| properties["neo4j.source-strategy"] shouldBe "QUERY" | ||
| properties["neo4j.query.topic"] shouldNotBe null | ||
| properties["neo4j.query"] shouldNotBe null | ||
|
|
||
| shouldNotThrowAny { SourceConfiguration(properties) } | ||
| } | ||
|
|
||
| private fun loadConfigProperties(fileName: String): Map<String, Any> { | ||
| val properties = Properties() | ||
| FileInputStream("$BASE_CONFIG_PATH/$fileName").use { properties.load(it) } | ||
| val originals = mutableMapOf<String, Any>() | ||
| properties.map { (k, v) -> originals[k as String] = v } | ||
| return originals | ||
| } | ||
|
|
||
| companion object { | ||
| var BASE_CONFIG_PATH: String | ||
|
|
||
| init { | ||
| val properties = Properties() | ||
| ConfigPropertiesTest::class.java.getResourceAsStream("/test.properties").use { | ||
| properties.load(it) | ||
| } | ||
| BASE_CONFIG_PATH = properties.getProperty("quickstart.config.properties.path") | ||
| } | ||
| } | ||
| } | ||
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 @@ | ||
| quickstart.config.properties.path=${project.basedir}/src/main/distributions/text/config |
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.