NIFI-10580 This closes #6867. Upgraded SLF4J from 1.7.36 to 2.0.6

- Upgraded Logback from 1.2.11 to 1.3.5
- Updated Logback DelayingShutdownHook to DefaultShutdownHook
- Disabled Spring Boot Logging System in favor of standard Logback initialization
- Excluded logback-classic from ZooKeeper and other dependencies to avoid conflicts when running tests
- Excluded spring-boot-starter-logging to avoid failures related to Logback 1.2 and Spring Boot 2.7
- Removed ZooKeeperMigratorTest.groovy based on Apache Curator test server usage of Logback 1.2

NIFI-10580 Added logback-core as explicit dependency

- Set logback-core as provided in root configuration
- Added logback-core as compile dependency in assembly configurations

Signed-off-by: Joe Witt <joewitt@apache.org>
This commit is contained in:
exceptionfactory 2023-01-19 13:02:35 -06:00 committed by Joe Witt
parent 8640989ad7
commit 972667461b
No known key found for this signature in database
GPG Key ID: 9093BF854F811A1A
29 changed files with 129 additions and 302 deletions

View File

@ -69,6 +69,11 @@ limitations under the License.
<artifactId>logback-classic</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>

View File

@ -63,6 +63,7 @@
<include>*:commons-io</include>
<include>*:slf4j-api</include>
<include>*:logback-classic</include>
<include>*:logback-core</include>
</includes>
</dependencySet>

View File

@ -64,6 +64,7 @@
<include>*:commons-lang3</include>
<include>*:slf4j-api</include>
<include>*:logback-classic</include>
<include>*:logback-core</include>
</includes>
</dependencySet>

View File

@ -164,6 +164,11 @@ limitations under the License.
<artifactId>logback-classic</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>

View File

@ -113,6 +113,11 @@ language governing permissions and limitations under the License. -->
<artifactId>logback-classic</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>

View File

@ -28,6 +28,7 @@
<include>*:nifi-bootstrap</include>
<include>*:slf4j-api</include>
<include>*:logback-classic</include>
<include>*:logback-core</include>
<include>*:nifi-api</include>
<include>*:nifi-property-protection-api</include>
</includes>

View File

@ -63,6 +63,12 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Override commons-configuration2:2.5 from accumulo-core -->
<dependency>

View File

@ -15,7 +15,7 @@
-->
<configuration scan="true" scanPeriod="30 seconds">
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook" />
<shutdownHook class="ch.qos.logback.core.hook.DefaultShutdownHook" />
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>

View File

@ -90,6 +90,12 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Override ant -->
<dependency>

View File

@ -75,6 +75,12 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Override ant -->
<dependency>

View File

@ -62,6 +62,10 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
@ -163,6 +167,10 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>

View File

@ -74,6 +74,12 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>

View File

@ -102,6 +102,12 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>

View File

@ -72,6 +72,12 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>

View File

@ -64,6 +64,11 @@
<artifactId>logback-classic</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>

View File

@ -50,6 +50,7 @@
<include>*:nifi-registry-bootstrap</include>
<include>*:slf4j-api</include>
<include>*:logback-classic</include>
<include>*:logback-core</include>
</includes>
</dependencySet>

View File

@ -231,6 +231,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>${spring.boot.version}</version>
<exclusions>
<!-- Spring Boot Starter Logging 2 does not support Logback 1.3 -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>

View File

@ -36,6 +36,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring.boot.version}</version>
<exclusions>
<!-- Spring Boot Starter Logging 2 does not support Logback 1.3 -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>

View File

@ -284,6 +284,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
<exclusions>
<!-- Spring Boot Starter Logging 2 does not support Logback 1.3 -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>

View File

@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestCli
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.logging.LoggingSystem;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
@ -56,6 +57,11 @@ public class NiFiRegistryApiApplication extends SpringBootServletInitializer {
public static final String NIFI_REGISTRY_PROPERTIES_ATTRIBUTE = "nifi-registry.properties";
public static final String NIFI_REGISTRY_MASTER_KEY_ATTRIBUTE = "nifi-registry.key";
static {
// Disable Spring Logging abstraction for Spring Boot 2 and SLF4J 2
System.setProperty(LoggingSystem.SYSTEM_PROPERTY, LoggingSystem.NONE);
}
@Autowired
private EventService eventService;

View File

@ -97,6 +97,10 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
@ -239,6 +243,10 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>

View File

@ -65,6 +65,10 @@ language governing permissions and limitations under the License. -->
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</dependency>
</dependencies>
<profiles>
<profile>

View File

@ -85,6 +85,11 @@
<artifactId>logback-classic</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>

View File

@ -152,6 +152,11 @@
<artifactId>logback-classic</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-api</artifactId>

View File

@ -15,7 +15,7 @@
-->
<configuration scan="true" scanPeriod="30 seconds">
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook" />
<shutdownHook class="ch.qos.logback.core.hook.DefaultShutdownHook" />
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>

View File

@ -15,7 +15,7 @@
-->
<configuration scan="true" scanPeriod="30 seconds">
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook" />
<shutdownHook class="ch.qos.logback.core.hook.DefaultShutdownHook" />
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>

View File

@ -15,7 +15,7 @@
-->
<configuration scan="true" scanPeriod="30 seconds">
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook" />
<shutdownHook class="ch.qos.logback.core.hook.DefaultShutdownHook" />
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>

View File

@ -1,296 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.nifi.toolkit.zkmigrator
import com.google.gson.Gson
import com.google.gson.stream.JsonReader
import org.apache.curator.test.TestingServer
import org.apache.curator.utils.ZKPaths
import org.apache.zookeeper.CreateMode
import org.apache.zookeeper.WatchedEvent
import org.apache.zookeeper.ZKUtil
import org.apache.zookeeper.ZooDefs
import org.apache.zookeeper.ZooKeeper
import org.apache.zookeeper.data.Stat
import org.apache.zookeeper.server.auth.DigestAuthenticationProvider
import spock.lang.Ignore
import spock.lang.Specification
import spock.lang.Unroll
import java.nio.charset.StandardCharsets
@Unroll
class ZooKeeperMigratorTest extends Specification {
def "Test auth and jaas usage simultaneously"() {
when:
ZooKeeperMigratorMain.main(['-r', '-z', 'localhost:2181/path', '-a', 'user:pass', '-k', 'jaas.conf'] as String[])
then:
noExceptionThrown()
}
def "Receive from open ZooKeeper"() {
given:
def server = new TestingServer()
def client = new ZooKeeper(server.connectString, 3000, { WatchedEvent watchedEvent ->
})
def migrationPathRoot = '/nifi/components'
ZKPaths.mkdirs(client, migrationPathRoot)
client.setData(migrationPathRoot, 'some data'.bytes, 0)
def componentName = '1'
client.create("$migrationPathRoot/$componentName", 'some data'.bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT)
componentName = '1/a'
client.create("$migrationPathRoot/$componentName", 'some data'.bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL)
componentName = '2'
client.create("$migrationPathRoot/$componentName", 'some data'.bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT)
componentName = '3'
client.create("$migrationPathRoot/$componentName", 'some data'.bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT)
def outputFilePath = 'target/test-data.json'
when:
ZooKeeperMigratorMain.main(['-r', '-z', "$server.connectString$migrationPathRoot", '-f', outputFilePath] as String[])
then:
noExceptionThrown()
def persistedData = new Gson().fromJson(new JsonReader(new FileReader(outputFilePath)), List) as List
persistedData.size() == 6
}
def "Send to open ZooKeeper without ACL migration"() {
given:
def server = new TestingServer()
def client = new ZooKeeper(server.connectString, 3000, { WatchedEvent watchedEvent ->
})
def migrationPathRoot = '/newParent'
when:
ZooKeeperMigratorMain.main(['-s', '-z', "$server.connectString$migrationPathRoot", '-f', 'src/test/resources/test-data.json'] as String[])
then:
noExceptionThrown()
def nodes = ZKPaths.getSortedChildren(client, '/').collect { ZKUtil.listSubTreeBFS(client, "/$it") }.flatten()
nodes.size() == 7
}
def "Send to open ZooKeeper without ACL migration with new multi-node parent"() {
given:
def server = new TestingServer()
def client = new ZooKeeper(server.connectString, 3000, { WatchedEvent watchedEvent ->
})
def migrationPathRoot = '/newParent/node'
when:
ZooKeeperMigratorMain.main(['-s', '-z', "$server.connectString$migrationPathRoot", '-f', 'src/test/resources/test-data.json'] as String[])
then:
noExceptionThrown()
def nodes = ZKPaths.getSortedChildren(client, '/').collect { ZKUtil.listSubTreeBFS(client, "/$it") }.flatten()
nodes.size() == 8
}
def "Receive all nodes from ZooKeeper root"() {
given:
def server = new TestingServer()
def client = new ZooKeeper(server.connectString, 3000, { WatchedEvent watchedEvent ->
})
def migrationPathRoot = '/'
def addedNodePath = 'nifi'
client.create("$migrationPathRoot$addedNodePath", 'some data'.bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT)
def outputFilePath = 'target/test-data-root.json'
when:
ZooKeeperMigratorMain.main(['-r', '-z', "$server.connectString$migrationPathRoot", '-f', outputFilePath] as String[])
then:
noExceptionThrown()
def persistedData = new Gson().fromJson(new JsonReader(new FileReader(outputFilePath)), List) as List
persistedData.size() == 6
}
def "Receive Zookeeper node created with username and password"() {
given:
def server = new TestingServer()
def client = new ZooKeeper(server.connectString, 3000, { WatchedEvent watchedEvent ->
})
def username = 'nifi'
def password = 'nifi'
client.addAuthInfo('digest', "$username:$password".getBytes(StandardCharsets.UTF_8))
def migrationPathRoot = '/nifi'
client.create(migrationPathRoot, 'some data'.bytes, ZooDefs.Ids.CREATOR_ALL_ACL, CreateMode.PERSISTENT)
def outputFilePath = 'target/test-data-user-pass.json'
when:
ZooKeeperMigratorMain.main(['-r', '-z', "$server.connectString$migrationPathRoot", '-f', outputFilePath, '-a', "$username:$password"] as String[])
then:
noExceptionThrown()
def persistedData = new Gson().fromJson(new JsonReader(new FileReader(outputFilePath)), List) as List
persistedData.size() == 2
}
def "Send to Zookeeper a node created with username and password"() {
given:
def server = new TestingServer()
def client = new ZooKeeper(server.connectString, 3000, { WatchedEvent watchedEvent ->
})
def username = 'nifi'
def password = 'nifi'
client.addAuthInfo('digest', "$username:$password".getBytes(StandardCharsets.UTF_8))
def migrationPathRoot = '/newParent'
when:
ZooKeeperMigratorMain.main(['-s', '-z', "$server.connectString$migrationPathRoot", '-f', 'src/test/resources/test-data-user-pass.json', '-a', "$username:$password"] as String[])
then:
noExceptionThrown()
def nodes = ZKPaths.getSortedChildren(client, '/').collect { ZKUtil.listSubTreeBFS(client, "/$it") }.flatten()
nodes.size() == 4
}
def "Send to open Zookeeper with ACL migration"() {
given:
def server = new TestingServer()
def client = new ZooKeeper(server.connectString, 3000, { WatchedEvent watchedEvent ->
})
def migrationPathRoot = '/nifi-open'
when:
ZooKeeperMigratorMain.main(['-s', '-z', "$server.connectString$migrationPathRoot", '-f', 'src/test/resources/test-data-user-pass.json'] as String[])
then:
noExceptionThrown()
def nodes = ZKPaths.getSortedChildren(client, '/').collect { ZKUtil.listSubTreeBFS(client, "/$it") }.flatten()
nodes.size() == 4
}
def "Send to open Zookeeper using existing ACL"() {
given:
def server = new TestingServer()
def securedClient = new ZooKeeper(server.connectString, 3000, { WatchedEvent watchedEvent -> })
def userPass = "nifi:nifi"
securedClient.addAuthInfo("digest",userPass.getBytes(StandardCharsets.UTF_8))
def digest = DigestAuthenticationProvider.generateDigest(userPass)
def migrationPathRoot = '/nifi'
def stat = new Stat()
when:
ZooKeeperMigratorMain.main(['-s', '-z', "$server.connectString$migrationPathRoot", '-f', 'src/test/resources/test-data-user-pass.json','--use-existing-acl'] as String[])
then:
noExceptionThrown()
def acl = securedClient.getACL("/nifi",stat)
acl.get(0).id.scheme == "digest"
acl.get(0).id.id == digest
def nodes = ZKPaths.getSortedChildren(securedClient, '/nifi').collect { ZKUtil.listSubTreeBFS(securedClient, "/$it") }.flatten()
nodes.size() == 0
}
def "Parse Zookeeper connect string and path"() {
when:
def zooKeeperMigrator = new ZooKeeperMigrator("$connectString")
then:
zooKeeperMigrator.zooKeeperEndpointConfig.connectString == connectString
zooKeeperMigrator.zooKeeperEndpointConfig.servers == servers.split(',').collect()
zooKeeperMigrator.zooKeeperEndpointConfig.path == path
where:
connectString | path | servers || _
'127.0.0.1' | '/' | '127.0.0.1' || _
'127.0.0.1,127.0.0.2' | '/' | '127.0.0.1,127.0.0.2' || _
'127.0.0.1/' | '/' | '127.0.0.1' || _
'127.0.0.1,127.0.0.2/' | '/' | '127.0.0.1,127.0.0.2' || _
'127.0.0.1:2181' | '/' | '127.0.0.1:2181' || _
'127.0.0.1,127.0.0.2:2181' | '/' | '127.0.0.1,127.0.0.2:2181' || _
'127.0.0.1:2181/' | '/' | '127.0.0.1:2181' || _
'127.0.0.1,127.0.0.2:2181/' | '/' | '127.0.0.1,127.0.0.2:2181' || _
'127.0.0.1/path' | '/path' | '127.0.0.1' || _
'127.0.0.1,127.0.0.2/path' | '/path' | '127.0.0.1,127.0.0.2' || _
'127.0.0.1/path/node' | '/path/node' | '127.0.0.1' || _
'127.0.0.1,127.0.0.2/path/node' | '/path/node' | '127.0.0.1,127.0.0.2' || _
'127.0.0.1:2181/' | '/' | '127.0.0.1:2181' || _
'127.0.0.1,127.0.0.2:2181/' | '/' | '127.0.0.1,127.0.0.2:2181' || _
'127.0.0.1:2181/path' | '/path' | '127.0.0.1:2181' || _
'127.0.0.1,127.0.0.2:2181/path' | '/path' | '127.0.0.1,127.0.0.2:2181' || _
'127.0.0.1:2181/path/node' | '/path/node' | '127.0.0.1:2181' || _
'127.0.0.1,127.0.0.2:2181/path/node' | '/path/node' | '127.0.0.1,127.0.0.2:2181' || _
'127.0.0.1,127.0.0.2:2182,127.0.0.3:2183' | '/' | '127.0.0.1,127.0.0.2:2182,127.0.0.3:2183' || _
'127.0.0.1,127.0.0.2:2182,127.0.0.3:2183/' | '/' | '127.0.0.1,127.0.0.2:2182,127.0.0.3:2183' || _
'127.0.0.1,127.0.0.2:2182,127.0.0.3:2183/path' | '/path' | '127.0.0.1,127.0.0.2:2182,127.0.0.3:2183' || _
'127.0.0.1,127.0.0.2:2182,127.0.0.3:2183/path/node' | '/path/node' | '127.0.0.1,127.0.0.2:2182,127.0.0.3:2183' || _
}
def "Test ignore source" () {
given:
def server = new TestingServer()
def migrationPathRoot = '/nifi/components'
def connectString = "$server.connectString"
def dataPath = 'target/test-data-ignore-source.json'
def client = new ZooKeeper(server.connectString, 3000, { WatchedEvent watchedEvent ->
})
// Create some znodes under /nifi/components
ZKPaths.mkdirs(client, migrationPathRoot)
client.setData(migrationPathRoot, 'some data'.bytes, 0)
def componentName = '1'
client.create("$migrationPathRoot/$componentName", 'some data'.bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT)
componentName = '1/a'
client.create("$migrationPathRoot/$componentName", 'some data'.bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL)
componentName = '2'
client.create("$migrationPathRoot/$componentName", 'some data'.bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT)
componentName = '3'
client.create("$migrationPathRoot/$componentName", 'some data'.bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT)
when: "data is read from the source zookeeper"
ZooKeeperMigratorMain.main(['-r', '-z', "$connectString$migrationPathRoot", '-f', dataPath] as String[])
then: "verify the data has been written to the output file"
new File(dataPath).exists()
when: "data is sent to the same zookeeper as the the source zookeeper without ignore source"
ZooKeeperMigratorMain.main(['-s', '-z', "$connectString$migrationPathRoot", '-f', dataPath] as String[])
then: "verify that an illegal argument exception is thrown"
thrown(IllegalArgumentException)
when: "data is sent to the same zookeeper as the source zookeeper with ignore source option set"
ZooKeeperMigratorMain.main(['-s', '-z', "$connectString$migrationPathRoot", '-f', dataPath, '--ignore-source', '--use-existing-acl'] as String[])
then: "no exceptions are thrown"
noExceptionThrown()
}
def "Send to same ZooKeeper with different path"() {
def server = new TestingServer()
def connectString = "$server.connectString"
def dataPath = 'target/test-data-different-path.json'
when: "data is read from the source zookeeper"
ZooKeeperMigratorMain.main(['-r', '-z', connectString, '-f', dataPath] as String[])
then: "verify the data has been written to the output file"
new File(dataPath).exists()
when: "data is sent to the same zookeeper as the the source zookeeper with a different path"
ZooKeeperMigratorMain.main(['-s', '-z', "$connectString/new-path", '-f', dataPath] as String[])
then: "no exceptions are thrown"
noExceptionThrown()
}
}

10
pom.xml
View File

@ -118,7 +118,7 @@
<org.apache.httpcomponents.httpcore.version>4.4.15</org.apache.httpcomponents.httpcore.version>
<org.bouncycastle.version>1.71</org.bouncycastle.version>
<testcontainers.version>1.17.6</testcontainers.version>
<org.slf4j.version>1.7.36</org.slf4j.version>
<org.slf4j.version>2.0.6</org.slf4j.version>
<ranger.version>2.3.0</ranger.version>
<jetty.version>9.4.50.v20221201</jetty.version>
<jackson.bom.version>2.14.1</jackson.bom.version>
@ -138,7 +138,7 @@
<aspectj.version>1.9.6</aspectj.version>
<jersey.bom.version>2.36</jersey.bom.version>
<log4j2.version>2.18.0</log4j2.version>
<logback.version>1.2.11</logback.version>
<logback.version>1.3.5</logback.version>
<mockito.version>3.12.4</mockito.version>
<netty.3.version>3.10.6.Final</netty.3.version>
<snakeyaml.version>1.33</snakeyaml.version>
@ -177,6 +177,12 @@
<version>${logback.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>