Skip to content
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

fix: set default neo4j db port #636

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ Thumbs.db
bin
doc/node
doc/node_modules
*/docker/plugins/*
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ open class Neo4jConnectorConfig(configDef: ConfigDef,
authenticationPassword = getPassword(AUTHENTICATION_BASIC_PASSWORD).value()
authenticationKerberosTicket = getPassword(AUTHENTICATION_KERBEROS_TICKET).value()

serverUri = getString(SERVER_URI).split(",").map { URI(it) }
serverUri = getString(SERVER_URI).split(",").map {
val uri = URI(it)
if (uri.port == -1) URI("$it:7687") else uri
}

connectionLivenessCheckTimeout = getLong(CONNECTION_LIVENESS_CHECK_TIMEOUT_MSECS)
connectionMaxConnectionLifetime = getLong(CONNECTION_MAX_CONNECTION_LIFETIME_MSECS)
connectionPoolMaxSize = getInt(CONNECTION_POOL_MAX_SIZE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ class Neo4jSinkConnectorConfigTest {
assertEquals(c, config.serverUri[2].toString())
}

@Test
fun `should return URIs with default port if port does not exist`() {
val a = "bolt://neo4j.com"
val b = "bolt://neo4j2.com"

val originals = mapOf(SinkConnector.TOPICS_CONFIG to "foo",
"${Neo4jSinkConnectorConfig.TOPIC_CYPHER_PREFIX}foo" to "CREATE (p:Person{name: event.firstName})",
Neo4jConnectorConfig.SERVER_URI to "$a,$b")
val config = Neo4jSinkConnectorConfig(originals)

assertEquals("$a:7687", config.serverUri[0].toString())
assertEquals("$b:7687", config.serverUri[1].toString())
}

@Test
fun `should return the configuration with shuffled topic order`() {
val originals = mapOf(SinkConnector.TOPICS_CONFIG to "bar,foo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package streams.kafka.connect.source

import org.apache.kafka.common.config.ConfigException
import org.junit.Test
import streams.kafka.connect.common.Neo4jConnectorConfig
import kotlin.test.assertEquals
import kotlin.test.assertNull

class Neo4jSourceConnectorConfigTest {

Expand Down Expand Up @@ -61,4 +61,21 @@ class Neo4jSourceConnectorConfigTest {
val config = Neo4jSourceConnectorConfig(originals)
assertEquals("", config.streamingProperty)
}

@Test
fun `should return URIs with default port if port does not exist`() {
val a = "bolt://neo4j.com"
val b = "bolt://neo4j2.com"

val originals = mapOf(Neo4jSourceConnectorConfig.SOURCE_TYPE to SourceType.QUERY.toString(),
Neo4jSourceConnectorConfig.SOURCE_TYPE_QUERY to "MATCH (n) RETURN n",
Neo4jSourceConnectorConfig.TOPIC to "topic",
Neo4jSourceConnectorConfig.STREAMING_POLL_INTERVAL to "10",
Neo4jSourceConnectorConfig.STREAMING_FROM to StreamingFrom.NOW.toString(),
Neo4jConnectorConfig.SERVER_URI to "$a,$b")
val config = Neo4jSourceConnectorConfig(originals)

assertEquals("$a:7687", config.serverUri[0].toString())
assertEquals("$b:7687", config.serverUri[1].toString())
}
}