This is an automated email from the ASF dual-hosted git repository.

tison pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/curator.git


The following commit(s) were added to refs/heads/master by this push:
     new 8fb978d0 CURATOR-596. Support ZooKeeper 3.7.1 (#426)
8fb978d0 is described below

commit 8fb978d0ff4569c80dae19514e8605eca6e80cfc
Author: Kezhu Wang <[email protected]>
AuthorDate: Thu Jul 14 13:34:59 2022 +0800

    CURATOR-596. Support ZooKeeper 3.7.1 (#426)
    
    Co-authored-by: tison <[email protected]>
---
 curator-client/pom.xml                             |  11 +
 .../curator/{TestIs36.java => TestIs37.java}       |  24 ++-
 .../curator/framework/imps/TestReadOnly.java       |  13 +-
 curator-test-zk36/pom.xml                          | 229 +++++++++++++++++++++
 .../java/org/apache/curator/zk36}/TestIs36.java    |   8 +-
 .../src/test/resources/log4j.properties            |  27 +++
 .../apache/curator/test/QuorumConfigBuilder.java   |   3 +
 .../test/compatibility/CuratorTestBase.java        |   1 +
 pom.xml                                            |  10 +-
 9 files changed, 312 insertions(+), 14 deletions(-)

diff --git a/curator-client/pom.xml b/curator-client/pom.xml
index 2599650d..a9467ee8 100644
--- a/curator-client/pom.xml
+++ b/curator-client/pom.xml
@@ -121,6 +121,17 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 </project>
diff --git a/curator-client/src/test/java/org/apache/curator/TestIs36.java 
b/curator-client/src/test/java/org/apache/curator/TestIs37.java
similarity index 63%
copy from curator-client/src/test/java/org/apache/curator/TestIs36.java
copy to curator-client/src/test/java/org/apache/curator/TestIs37.java
index e7489a31..55c5690c 100644
--- a/curator-client/src/test/java/org/apache/curator/TestIs36.java
+++ b/curator-client/src/test/java/org/apache/curator/TestIs37.java
@@ -18,22 +18,26 @@
  */
 package org.apache.curator;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
 import org.apache.curator.test.compatibility.CuratorTestBase;
-import org.apache.curator.utils.Compatibility;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.proto.WhoAmIResponse;
 import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-public class TestIs36 extends CuratorTestBase
+public class TestIs37 extends CuratorTestBase
 {
+    /**
+     * Ensure that ZooKeeper is 3.7 or above.
+     *
+     * <p>It uses reflection to get {@link WhoAmIResponse} which was 
introduced in 3.7.0.
+     *
+     * @see <a 
href="https://issues.apache.org/jira/browse/ZOOKEEPER-3969";>ZOOKEEPER-3969</a>
+     */
     @Test
-    @Tag(zk36Group)
-    public void testIsZk36()
-    {
-        assertTrue(Compatibility.hasGetReachableOrOneMethod());
-        assertTrue(Compatibility.hasAddrField());
-        assertTrue(Compatibility.hasPersistentWatchers());
+    @Tag(zk37Group)
+    public void testIsZk37() throws Exception {
+        
assertNotNull(Class.forName("org.apache.zookeeper.proto.WhoAmIResponse"));
     }
 
     @Override
diff --git 
a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java
 
b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java
index 2af98b26..21a9130a 100644
--- 
a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java
+++ 
b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java
@@ -65,17 +65,26 @@ public class TestReadOnly extends BaseClassForTests
         TestingCluster cluster = createAndStartCluster(3);
         try
         {
+            final CountDownLatch lostLatch = new CountDownLatch(1);
             client = 
CuratorFrameworkFactory.newClient(cluster.getConnectString(), timing.session(), 
timing.connection(), new RetryOneTime(100));
             client.start();
             client.checkExists().forPath("/");
-            client.close();
-            client = null;
+            client.getConnectionStateListenable().addListener(new 
ConnectionStateListener() {
+                @Override
+                public void stateChanged(CuratorFramework client, 
ConnectionState newState) {
+                    if (newState == ConnectionState.LOST) {
+                        lostLatch.countDown();
+                    }
+                }
+            });
 
             Iterator<InstanceSpec> iterator = 
cluster.getInstances().iterator();
             for ( int i = 0; i < 2; ++i )
             {
                 cluster.killServer(iterator.next());
             }
+            timing.awaitLatch(lostLatch);
+            client.close();
 
             client = CuratorFrameworkFactory.builder()
                 .connectString(cluster.getConnectString())
diff --git a/curator-test-zk36/pom.xml b/curator-test-zk36/pom.xml
new file mode 100644
index 00000000..0c30553e
--- /dev/null
+++ b/curator-test-zk36/pom.xml
@@ -0,0 +1,229 @@
+<?xml version="1.0" encoding="UTF-8"?><!--
+    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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <parent>
+        <groupId>org.apache.curator</groupId>
+        <artifactId>apache-curator</artifactId>
+        <version>5.4.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>curator-test-zk36</artifactId>
+
+    <properties>
+        <zookeeper-36-version>3.6.3</zookeeper-36-version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-framework</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.zookeeper</groupId>
+                    <artifactId>zookeeper</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-x-async</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.zookeeper</groupId>
+                    <artifactId>zookeeper</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-recipes</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.zookeeper</groupId>
+                    <artifactId>zookeeper</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.zookeeper</groupId>
+            <artifactId>zookeeper</artifactId>
+            <version>${zookeeper-36-version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.sun.jmx</groupId>
+                    <artifactId>jmxri</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.sun.jdmk</groupId>
+                    <artifactId>jmxtools</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>javax.jms</groupId>
+                    <artifactId>jms</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-test</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.zookeeper</groupId>
+                    <artifactId>zookeeper</artifactId>
+                </exclusion>
+            </exclusions>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-recipes</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.zookeeper</groupId>
+                    <artifactId>zookeeper</artifactId>
+                </exclusion>
+            </exclusions>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-framework</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.zookeeper</groupId>
+                    <artifactId>zookeeper</artifactId>
+                </exclusion>
+            </exclusions>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-client</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.zookeeper</groupId>
+                    <artifactId>zookeeper</artifactId>
+                </exclusion>
+            </exclusions>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-math</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.dataformat</groupId>
+            <artifactId>jackson-dataformat-yaml</artifactId>
+            <version>${jackson-version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.awaitility</groupId>
+            <artifactId>awaitility</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>deploy</phase>
+                        <configuration>
+                            <skip>true</skip>
+                        </configuration>
+                        <goals>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <dependenciesToScan>
+                        
<dependency>org.apache.curator:curator-framework</dependency>
+                        
<dependency>org.apache.curator:curator-recipes</dependency>
+                        
<dependency>org.apache.curator:curator-client</dependency>
+                    </dependenciesToScan>
+                    <groups>zk36,zk35TestCompatibility</groups>
+                    <excludedGroups>zk37</excludedGroups>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/curator-client/src/test/java/org/apache/curator/TestIs36.java 
b/curator-test-zk36/src/test/java/org/apache/curator/zk36/TestIs36.java
similarity index 79%
rename from curator-client/src/test/java/org/apache/curator/TestIs36.java
rename to curator-test-zk36/src/test/java/org/apache/curator/zk36/TestIs36.java
index e7489a31..51888c05 100644
--- a/curator-client/src/test/java/org/apache/curator/TestIs36.java
+++ b/curator-test-zk36/src/test/java/org/apache/curator/zk36/TestIs36.java
@@ -16,9 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.curator;
+package org.apache.curator.zk36;
 
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import org.apache.curator.test.compatibility.CuratorTestBase;
 import org.apache.curator.utils.Compatibility;
@@ -34,6 +36,10 @@ public class TestIs36 extends CuratorTestBase
         assertTrue(Compatibility.hasGetReachableOrOneMethod());
         assertTrue(Compatibility.hasAddrField());
         assertTrue(Compatibility.hasPersistentWatchers());
+        try {
+            Class.forName("org.apache.zookeeper.proto.WhoAmIResponse");
+            fail("WhoAmIResponse is introduced after ZooKeeper 3.7");
+        } catch (ClassNotFoundException ignore) {}
     }
 
     @Override
diff --git a/curator-test-zk36/src/test/resources/log4j.properties 
b/curator-test-zk36/src/test/resources/log4j.properties
new file mode 100644
index 00000000..2a85e0d1
--- /dev/null
+++ b/curator-test-zk36/src/test/resources/log4j.properties
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+
+log4j.rootLogger=ERROR, console
+
+log4j.logger.org.apache.curator=DEBUG, console
+log4j.additivity.org.apache.curator=false
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%-5p %c %x %m [%t]%n
diff --git 
a/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java 
b/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java
index fbfe8646..2300efc9 100644
--- 
a/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java
+++ 
b/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java
@@ -106,6 +106,9 @@ public class QuorumConfigBuilder implements Closeable
         }
 
         Properties properties = new Properties();
+        String localSessionsEnabled = 
System.getProperty("readonlymode.enabled", "false");
+        properties.setProperty("localSessionsEnabled", localSessionsEnabled);
+        properties.setProperty("localSessionsUpgradingEnabled", 
localSessionsEnabled);
         properties.setProperty("initLimit", "10");
         properties.setProperty("syncLimit", "5");
         properties.setProperty("dataDir", 
spec.getDataDirectory().getCanonicalPath());
diff --git 
a/curator-test/src/main/java/org/apache/curator/test/compatibility/CuratorTestBase.java
 
b/curator-test/src/main/java/org/apache/curator/test/compatibility/CuratorTestBase.java
index 093a3ce3..1fcd0d0e 100644
--- 
a/curator-test/src/main/java/org/apache/curator/test/compatibility/CuratorTestBase.java
+++ 
b/curator-test/src/main/java/org/apache/curator/test/compatibility/CuratorTestBase.java
@@ -23,6 +23,7 @@ import org.apache.curator.test.BaseClassForTests;
 public class CuratorTestBase extends BaseClassForTests
 {
     public static final String zk36Group = "zk36";
+    public static final String zk37Group = "zk37";
     public static final String zk35TestCompatibilityGroup = 
"zk35TestCompatibility";
 
     protected final Timing2 timing = new Timing2();
diff --git a/pom.xml b/pom.xml
index 60465cac..83f02732 100644
--- a/pom.xml
+++ b/pom.xml
@@ -69,7 +69,7 @@
         <redirectTestOutputToFile>true</redirectTestOutputToFile>
 
         <!-- versions -->
-        <zookeeper-version>3.6.3</zookeeper-version>
+        <zookeeper-version>3.7.1</zookeeper-version>
         <maven-bundle-plugin-version>5.1.4</maven-bundle-plugin-version>
         <maven-compiler-plugin-version>3.10.0</maven-compiler-plugin-version>
         
<maven-dependency-plugin-version>3.2.0</maven-dependency-plugin-version>
@@ -359,6 +359,7 @@
         <module>curator-x-discovery-server</module>
         <module>curator-x-async</module>
         <module>curator-test-zk35</module>
+        <module>curator-test-zk36</module>
     </modules>
 
     <dependencyManagement>
@@ -387,6 +388,13 @@
                 <version>${project.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>org.apache.curator</groupId>
+                <artifactId>curator-client</artifactId>
+                <type>test-jar</type>
+                <version>${project.version}</version>
+            </dependency>
+
             <dependency>
                 <groupId>org.apache.curator</groupId>
                 <artifactId>curator-framework</artifactId>

Reply via email to