+}
+
#include "Util.h"
#include "LibCMocks.h"
#include "ZKMocks.h"
@@ -218,6 +222,10 @@ class Zookeeper_reconfig : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(testcycleNextServer);
CPPUNIT_TEST(testMigrateOrNot);
CPPUNIT_TEST(testMigrationCycle);
+ CPPUNIT_TEST(testAddrVecContainsIPv4);
+#ifdef AF_INET6
+ CPPUNIT_TEST(testAddrVecContainsIPv6);
+#endif
// In threaded mode each 'create' is a thread -- it's not practical to create
// 10,000 threads to test load balancing. The load balancing code can easily
@@ -609,6 +617,81 @@ class Zookeeper_reconfig : public CPPUNIT_NS::TestFixture
numServers = 9;
updateAllClientsAndServers(numServers);
}
+
+ /**
+ * This tests that client can detect server's ipv4 address change.
+ *
+ * (1) We generate some address and put in addr, which saddr point to
+ * (2) Add all addresses that differ by one bit from the source
+ * (3) Add same address, but set ipv6 protocol
+ * (4) Ensure, that our address is not equal to any of generated,
+ * and that it equals to itself
+ */
+ void testAddrVecContainsIPv4() {
+ addrvec_t vec;
+ addrvec_init(&vec);
+
+ sockaddr_storage addr;
+ sockaddr_in* saddr = (sockaddr_in*)&addr;
+ saddr->sin_family = AF_INET;
+ saddr->sin_port = htons((u_short)1234);
+ saddr->sin_addr.s_addr = INADDR_ANY;
+
+ CPPUNIT_ASSERT(sizeof(saddr->sin_addr.s_addr) == 4);
+
+ for (int i = 0; i < 32; i++) {
+ saddr->sin_addr.s_addr ^= (1 << i);
+ addrvec_append(&vec, &addr);
+ saddr->sin_addr.s_addr ^= (1 << i);
+ }
+
+ saddr->sin_family = AF_INET6;
+ addrvec_append(&vec, &addr);
+ saddr->sin_family = AF_INET;
+
+ CPPUNIT_ASSERT(!addrvec_contains(&vec, &addr));
+ addrvec_append(&vec, &addr);
+ CPPUNIT_ASSERT(addrvec_contains(&vec, &addr));
+ addrvec_free(&vec);
+ }
+
+ /**
+ * This tests that client can detect server's ipv6 address change.
+ *
+ * Same logic as in previous testAddrVecContainsIPv4 method,
+ * but we keep in mind, that ipv6 is 128-bit long.
+ */
+#ifdef AF_INET6
+ void testAddrVecContainsIPv6() {
+ addrvec_t vec;
+ addrvec_init(&vec);
+
+ sockaddr_storage addr;
+ sockaddr_in6* saddr = (sockaddr_in6*)&addr;
+ saddr->sin6_family = AF_INET6;
+ saddr->sin6_port = htons((u_short)1234);
+ saddr->sin6_addr = in6addr_any;
+
+ CPPUNIT_ASSERT(sizeof(saddr->sin6_addr.s6_addr) == 16);
+
+ for (int i = 0; i < 16; i++) {
+ for (int j = 0; j < 8; j++) {
+ saddr->sin6_addr.s6_addr[i] ^= (1 << j);
+ addrvec_append(&vec, &addr);
+ saddr->sin6_addr.s6_addr[i] ^= (1 << j);
+ }
+ }
+
+ saddr->sin6_family = AF_INET;
+ addrvec_append(&vec, &addr);
+ saddr->sin6_family = AF_INET6;
+
+ CPPUNIT_ASSERT(!addrvec_contains(&vec, &addr));
+ addrvec_append(&vec, &addr);
+ CPPUNIT_ASSERT(addrvec_contains(&vec, &addr));
+ addrvec_free(&vec);
+ }
+#endif
};
CPPUNIT_TEST_SUITE_REGISTRATION(Zookeeper_reconfig);
diff --git a/zookeeper-compatibility-tests/pom.xml b/zookeeper-compatibility-tests/pom.xml
new file mode 100644
index 00000000000..dc4a97295a6
--- /dev/null
+++ b/zookeeper-compatibility-tests/pom.xml
@@ -0,0 +1,58 @@
+
+
+
+
+ com.linkedin.zookeeper
+ parent
+ 3.6.2
+
+ pom
+ 4.0.0
+
+ zookeeper-compatibility-tests
+
+
+ zookeeper-compatibility-tests-curator
+
+
+ Apache ZooKeeper - Compatibility Tests
+ Module for various compatibility tests
+
+
+
+
+ org.apache.maven.plugins
+ maven-install-plugin
+
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+ true
+
+
+
+
+
diff --git a/zookeeper-compatibility-tests/zookeeper-compatibility-tests-curator/pom.xml b/zookeeper-compatibility-tests/zookeeper-compatibility-tests-curator/pom.xml
new file mode 100644
index 00000000000..889f9a0ea54
--- /dev/null
+++ b/zookeeper-compatibility-tests/zookeeper-compatibility-tests-curator/pom.xml
@@ -0,0 +1,77 @@
+
+
+
+
+ com.linkedin.zookeeper
+ zookeeper-compatibility-tests
+ 3.6.2
+
+ 4.0.0
+
+ zookeeper-compatibility-tests-curator
+
+ Apache ZooKeeper - Compatibility Tests - Curator
+ Module for Apache Curator compatibility tests
+
+
+ 5.0.0
+
+
+
+
+ com.linkedin.zookeeper
+ zookeeper
+ ${project.version}
+
+
+
+ org.apache.curator
+ curator-recipes
+ ${apache-curator-version}
+
+
+ com.linkedin.zookeeper
+ zookeeper
+
+
+ test
+
+
+
+ org.apache.curator
+ curator-test
+ ${apache-curator-version}
+
+
+ com.linkedin.zookeeper
+ zookeeper
+
+
+ test
+
+
+
+ junit
+ junit
+ test
+
+
+
\ No newline at end of file
diff --git a/zookeeper-compatibility-tests/zookeeper-compatibility-tests-curator/src/test/java/org/apache/zookeeper/compatibility/TestApacheCuratorCompatibility.java b/zookeeper-compatibility-tests/zookeeper-compatibility-tests-curator/src/test/java/org/apache/zookeeper/compatibility/TestApacheCuratorCompatibility.java
new file mode 100644
index 00000000000..b60a0042244
--- /dev/null
+++ b/zookeeper-compatibility-tests/zookeeper-compatibility-tests-curator/src/test/java/org/apache/zookeeper/compatibility/TestApacheCuratorCompatibility.java
@@ -0,0 +1,77 @@
+/**
+ * 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.zookeeper.compatibility;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.framework.recipes.cache.CuratorCache;
+import org.apache.curator.retry.RetryOneTime;
+import org.apache.curator.test.TestingServer;
+import org.junit.Test;
+
+/**
+ * Make sure minimal Apache Curator APIs work correctly. As it's a widely used ZooKeeper
+ * client library we should not break it.
+ */
+public class TestApacheCuratorCompatibility {
+ private static final int TIMEOUT_MS = 5000;
+
+ @Test
+ public void testBasicUsageOfApisAndRecipes() throws Exception {
+ try (TestingServer server = new TestingServer()) {
+ RetryOneTime retryPolicy = new RetryOneTime(1);
+ try (CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), retryPolicy)) {
+ try (CuratorCache cache = CuratorCache.build(client, "/base/path")) {
+ client.start();
+ cache.start();
+
+ BlockingQueue paths = new LinkedBlockingQueue<>();
+ cache.listenable().addListener((dummy1, dummy2, data) -> paths.add(data.getPath()));
+
+ client.create().creatingParentsIfNeeded().forPath("/base/path/1");
+ client.create().creatingParentsIfNeeded().forPath("/base/path/2");
+ client.create().creatingParentsIfNeeded().forPath("/base/path/1/a");
+ client.create().creatingParentsIfNeeded().forPath("/base/path/2/a");
+
+ assertEquals("/base/path", poll(paths));
+ assertEquals("/base/path/1", poll(paths));
+ assertEquals("/base/path/2", poll(paths));
+ assertEquals("/base/path/1/a", poll(paths));
+ assertEquals("/base/path/2/a", poll(paths));
+ }
+ }
+ }
+ }
+
+ private static String poll(BlockingQueue queue) {
+ try {
+ String value = queue.poll(TIMEOUT_MS, TimeUnit.MILLISECONDS);
+ assertNotNull("Event poll timed out", value);
+ return value;
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/zookeeper-contrib/build-contrib.xml b/zookeeper-contrib/build-contrib.xml
index 70bb8644f52..34f3c9b03b3 100644
--- a/zookeeper-contrib/build-contrib.xml
+++ b/zookeeper-contrib/build-contrib.xml
@@ -32,7 +32,7 @@
-
+
@@ -47,7 +47,7 @@
-
+
@@ -179,7 +179,7 @@
-
+
@@ -190,7 +190,7 @@
-
diff --git a/zookeeper-contrib/ivysettings.xml b/zookeeper-contrib/ivysettings.xml
new file mode 100644
index 00000000000..15c98b6ec4e
--- /dev/null
+++ b/zookeeper-contrib/ivysettings.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/zookeeper-contrib/pom.xml b/zookeeper-contrib/pom.xml
index 075363f3cfb..2a52e06da58 100755
--- a/zookeeper-contrib/pom.xml
+++ b/zookeeper-contrib/pom.xml
@@ -22,12 +22,11 @@
4.0.0
- org.apache.zookeeper
+ com.linkedin.zookeeper
parent
- 3.6.0-SNAPSHOT
+ 3.6.2
- org.apache.zookeeper
zookeeper-contrib
pom
Apache ZooKeeper - Contrib
@@ -35,24 +34,31 @@
Contrib projects to Apache ZooKeeper