-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
org.apache.curator:curator-framework:5.5.0
- Loading branch information
1 parent
939d438
commit 5952616
Showing
15 changed files
with
608 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
3 changes: 3 additions & 0 deletions
3
metadata/org.apache.curator/curator-framework/5.5.0/index.json
This file contains 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,3 @@ | ||
[ | ||
"reflect-config.json" | ||
] |
84 changes: 84 additions & 0 deletions
84
metadata/org.apache.curator/curator-framework/5.5.0/reflect-config.json
This file contains 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,84 @@ | ||
[ | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.schema.SchemaSetLoader"}, | ||
"name":"com.fasterxml.jackson.databind.ext.Java7SupportImpl", | ||
"methods":[{"name":"<init>","parameterTypes":[] }] | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.NamespaceWatcher"}, | ||
"name":"java.lang.Object", | ||
"methods":[{"name":"toString","parameterTypes":[] }] | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.NamespaceWatcher"}, | ||
"name":"java.lang.StackWalker", | ||
"methods":[ | ||
{"name":"getInstance","parameterTypes":["java.util.Set","int"] }, | ||
{"name":"walk","parameterTypes":["java.util.function.Function"] } | ||
] | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.NamespaceWatcher"}, | ||
"name":"java.lang.StackWalker$Option" | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.NamespaceWatcher"}, | ||
"name":"java.lang.StackWalker$StackFrame", | ||
"methods":[ | ||
{"name":"getClassName","parameterTypes":[] }, | ||
{"name":"getFileName","parameterTypes":[] }, | ||
{"name":"getLineNumber","parameterTypes":[] }, | ||
{"name":"getMethodName","parameterTypes":[] } | ||
] | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.CuratorFrameworkImpl"}, | ||
"name":"java.lang.Throwable", | ||
"methods":[{"name":"getSuppressed","parameterTypes":[] }] | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.ProtectedMode"}, | ||
"name":"java.security.SecureRandomParameters" | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.NamespaceFacadeCache"}, | ||
"name":"org.apache.curator.shaded.com.google.common.util.concurrent.AbstractFuture", | ||
"fields":[ | ||
{"name":"listeners"}, | ||
{"name":"value"}, | ||
{"name":"waiters"} | ||
] | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.NamespaceFacadeCache"}, | ||
"name":"org.apache.curator.shaded.com.google.common.util.concurrent.AbstractFuture$Waiter", | ||
"fields":[ | ||
{"name":"next"}, | ||
{"name":"thread"} | ||
] | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.EnsembleTracker"}, | ||
"name":"org.apache.zookeeper.AddWatchMode" | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.EnsembleTracker"}, | ||
"name":"org.apache.zookeeper.server.quorum.MultipleAddresses", | ||
"methods":[{"name":"getReachableOrOne","parameterTypes":[] }] | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.EnsembleTracker"}, | ||
"name":"org.apache.zookeeper.server.quorum.QuorumPeer$QuorumServer", | ||
"fields":[{"name":"addr"}] | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.NamespaceFacadeCache"}, | ||
"name":"sun.misc.Unsafe", | ||
"allDeclaredFields":true | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.framework.imps.ProtectedMode"}, | ||
"name":"sun.security.provider.NativePRNG", | ||
"methods":[{"name":"<init>","parameterTypes":[] }] | ||
} | ||
] |
This file contains 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,10 @@ | ||
[ | ||
{ | ||
"latest": true, | ||
"metadata-version": "5.5.0", | ||
"module": "org.apache.curator:curator-framework", | ||
"tested-versions": [ | ||
"5.5.0" | ||
] | ||
} | ||
] |
This file contains 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
4 changes: 4 additions & 0 deletions
4
tests/src/org.apache.curator/curator-framework/5.5.0/.gitignore
This file contains 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,4 @@ | ||
gradlew.bat | ||
gradlew | ||
gradle/ | ||
build/ |
39 changes: 39 additions & 0 deletions
39
tests/src/org.apache.curator/curator-framework/5.5.0/build.gradle
This file contains 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,39 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck" | ||
} | ||
|
||
String libraryVersion = tck.testedLibraryVersion.get() | ||
|
||
dependencies { | ||
testImplementation "org.apache.curator:curator-framework:$libraryVersion" | ||
testImplementation 'org.assertj:assertj-core:3.22.0' | ||
testImplementation "org.apache.curator:curator-test:$libraryVersion" | ||
testImplementation 'org.awaitility:awaitility:4.2.0' | ||
testImplementation 'org.apache.zookeeper:zookeeper:3.9.0' | ||
} | ||
|
||
graalvmNative { | ||
agent { | ||
defaultMode = "conditional" | ||
modes { | ||
conditional { | ||
userCodeFilterPath = "user-code-filter.json" | ||
} | ||
} | ||
metadataCopy { | ||
mergeWithExisting = true | ||
inputTaskNames.add("test") | ||
outputDirectories.add("src/test/resources/META-INF/native-image/org.apache.curator/curator-framework") | ||
} | ||
} | ||
metadataRepository { | ||
enabled = true | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
tests/src/org.apache.curator/curator-framework/5.5.0/gradle.properties
This file contains 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,2 @@ | ||
library.version = 5.5.0 | ||
metadata.dir = org.apache.curator/curator-framework/5.5.0/ |
13 changes: 13 additions & 0 deletions
13
tests/src/org.apache.curator/curator-framework/5.5.0/settings.gradle
This file contains 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,13 @@ | ||
pluginManagement { | ||
def tckPath = Objects.requireNonNullElse( | ||
System.getenv("GVM_TCK_TCKDIR"), | ||
"../../../../tck-build-logic" | ||
) | ||
includeBuild(tckPath) | ||
} | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT" | ||
} | ||
|
||
rootProject.name = 'org.apache.curator.curator-framework_tests' |
125 changes: 125 additions & 0 deletions
125
...mework/5.5.0/src/test/java/org_apache_curator/curator_framework/CuratorFrameworkTest.java
This file contains 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,125 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package org_apache_curator.curator_framework; | ||
|
||
import org.apache.curator.framework.CuratorFramework; | ||
import org.apache.curator.framework.CuratorFrameworkFactory; | ||
import org.apache.curator.framework.api.transaction.CuratorOp; | ||
import org.apache.curator.framework.api.transaction.CuratorTransactionResult; | ||
import org.apache.curator.retry.ExponentialBackoffRetry; | ||
import org.apache.zookeeper.CreateMode; | ||
import org.apache.zookeeper.KeeperException; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class CuratorFrameworkTest { | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
EmbedTestingServer.start(); | ||
} | ||
|
||
@Test | ||
void testCreateClient() { | ||
try (CuratorFramework client = CuratorFrameworkFactory.newClient(EmbedTestingServer.getConnectString(), | ||
new ExponentialBackoffRetry(1000, 3))) { | ||
client.start(); | ||
assertDoesNotThrow(() -> client.blockUntilConnected()); | ||
} | ||
try (CuratorFramework client = getCuratorFramework()) { | ||
client.start(); | ||
assertDoesNotThrow(() -> client.blockUntilConnected()); | ||
} | ||
} | ||
|
||
@Test | ||
void testCRUD() { | ||
try (CuratorFramework client = getCuratorFramework()) { | ||
client.start(); | ||
assertDoesNotThrow(() -> client.blockUntilConnected()); | ||
client.create().forPath("/testCreate", new byte[0]); | ||
client.create().withMode(CreateMode.EPHEMERAL).forPath("/testCreateEphemeral", new byte[0]); | ||
client.create().withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath("/testCreateEphemeralSequential", new byte[0]); | ||
client.create().idempotent().forPath("/testCreateIdempotent", new byte[0]); | ||
assertThat(client.getChildren().watched().forPath("/testCreate")).isEmpty(); | ||
assertThat(client.getChildren().watched().forPath("/testCreateEphemeral")).isEmpty(); | ||
assertThrows(KeeperException.NoNodeException.class, () -> client.getChildren().watched().forPath("/testCreateEphemeralSequential")); | ||
assertThat(client.getChildren().watched().forPath("/testCreateIdempotent")).isEmpty(); | ||
client.setData().forPath("/testCreate", "firstTestWord".getBytes(StandardCharsets.UTF_8)); | ||
assertThat(client.getChildren().watched().forPath("/testCreate")).isEmpty(); | ||
client.getCuratorListenable().addListener((client1, event) -> { | ||
}); | ||
client.setData().inBackground().forPath("/testCreate", "secondTestWord".getBytes(StandardCharsets.UTF_8)); | ||
assertThat(client.getChildren().watched().forPath("/testCreate")).isEmpty(); | ||
client.setData().idempotent().withVersion(2).forPath("/testCreate", "thirdTestWord".getBytes(StandardCharsets.UTF_8)); | ||
assertThat(client.getChildren().watched().forPath("/testCreate")).isEmpty(); | ||
client.delete().forPath("/testCreate"); | ||
assertThrows(KeeperException.NoNodeException.class, () -> client.getChildren().watched().forPath("/testCreate")); | ||
client.delete().guaranteed().forPath("/testCreateEphemeral"); | ||
assertThrows(KeeperException.NoNodeException.class, () -> client.getChildren().watched().forPath("/testCreateEphemeral")); | ||
client.delete().idempotent().withVersion(0).forPath("/testCreateIdempotent"); | ||
assertThrows(KeeperException.NoNodeException.class, () -> client.getChildren().watched().forPath("/testCreateIdempotent")); | ||
client.create().forPath("/deleteIdempotentFirst", new byte[0]); | ||
client.create().forPath("/deleteIdempotentSecond", new byte[0]); | ||
client.create().forPath("/deleteIdempotentThird", new byte[0]); | ||
client.delete().idempotent().forPath("/deleteIdempotentFirst"); | ||
client.delete().quietly().withVersion(0).forPath("/deleteIdempotentSecond"); | ||
client.delete().quietly().forPath("/deleteIdempotentThird"); | ||
assertThrows(KeeperException.NoNodeException.class, () -> client.getChildren().watched().forPath("/deleteIdempotentFirst")); | ||
assertThrows(KeeperException.NoNodeException.class, () -> client.getChildren().watched().forPath("/deleteIdempotentSecond")); | ||
assertThrows(KeeperException.NoNodeException.class, () -> client.getChildren().watched().forPath("/deleteIdempotentThird")); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Test | ||
void testTransaction() { | ||
try (CuratorFramework client = getCuratorFramework()) { | ||
client.start(); | ||
assertDoesNotThrow(() -> client.blockUntilConnected()); | ||
client.create().forPath("/testFirst", new byte[0]); | ||
client.create().forPath("/testSecond", new byte[0]); | ||
client.create().forPath("/testSecond/path", new byte[0]); | ||
client.create().forPath("/testThird", new byte[0]); | ||
client.create().forPath("/testThird/testSagittarius", new byte[0]); | ||
client.create().forPath("/testThird/testSagittarius/path", new byte[0]); | ||
CuratorOp createOp = client.transactionOp().create().forPath("/testFirst/path", "some data".getBytes()); | ||
CuratorOp setDataOp = client.transactionOp().setData().forPath("/testSecond/path", "other data".getBytes()); | ||
CuratorOp deleteOp = client.transactionOp().delete().forPath("/testThird/testSagittarius/path"); | ||
List<CuratorTransactionResult> results = client.transaction().forOperations(createOp, setDataOp, deleteOp); | ||
assertThat(results.get(0).getForPath()).isEqualTo("/testFirst/path"); | ||
assertThat(results.get(1).getForPath()).isEqualTo("/testSecond/path"); | ||
assertThat(results.get(2).getForPath()).isEqualTo("/testThird/testSagittarius/path"); | ||
assertThat(results.get(0).getForPath()).isEqualTo("/testFirst/path"); | ||
assertThat(results.get(1).getForPath()).isEqualTo("/testSecond/path"); | ||
assertThat(results.get(2).getForPath()).isEqualTo("/testThird/testSagittarius/path"); | ||
for (CuratorTransactionResult result : results) { | ||
System.out.println(result.getForPath() + " - " + result.getType()); | ||
|
||
} | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
private CuratorFramework getCuratorFramework() { | ||
return CuratorFrameworkFactory.builder() | ||
.connectString(EmbedTestingServer.getConnectString()) | ||
.retryPolicy(new ExponentialBackoffRetry(1000, 3)) | ||
.connectionTimeoutMs(10000) | ||
.sessionTimeoutMs(10000) | ||
.build(); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...ramework/5.5.0/src/test/java/org_apache_curator/curator_framework/EmbedTestingServer.java
This file contains 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,68 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package org_apache_curator.curator_framework; | ||
|
||
import org.apache.curator.CuratorZookeeperClient; | ||
import org.apache.curator.retry.ExponentialBackoffRetry; | ||
import org.apache.curator.test.TestingServer; | ||
import org.apache.zookeeper.KeeperException.ConnectionLossException; | ||
import org.apache.zookeeper.KeeperException.NoNodeException; | ||
import org.apache.zookeeper.KeeperException.NodeExistsException; | ||
import org.awaitility.Awaitility; | ||
|
||
import java.io.IOException; | ||
import java.time.Duration; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public final class EmbedTestingServer { | ||
private static final int PORT = 3192; | ||
private static volatile TestingServer testingServer; | ||
private static final Object INIT_LOCK = new Object(); | ||
|
||
private EmbedTestingServer() { | ||
} | ||
|
||
public static void start() { | ||
if (null != testingServer) { | ||
return; | ||
} | ||
synchronized (INIT_LOCK) { | ||
if (null != testingServer) { | ||
return; | ||
} | ||
try { | ||
testingServer = new TestingServer(PORT, true); | ||
} catch (final Exception ex) { | ||
if (!(ex instanceof ConnectionLossException || ex instanceof NoNodeException || ex instanceof NodeExistsException)) { | ||
throw new RuntimeException(ex); | ||
} | ||
} finally { | ||
Runtime.getRuntime().addShutdownHook(new Thread(() -> { | ||
try { | ||
testingServer.close(); | ||
} catch (final IOException ignored) { | ||
} | ||
})); | ||
} | ||
try (CuratorZookeeperClient client = new CuratorZookeeperClient(getConnectString(), | ||
60 * 1000, 500, null, | ||
new ExponentialBackoffRetry(500, 3, 500 * 3))) { | ||
client.start(); | ||
Awaitility.await() | ||
.atMost(Duration.ofMillis(500 * 60)) | ||
.untilAsserted(() -> assertTrue(client.isConnected())); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
|
||
public static String getConnectString() { | ||
return "localhost:" + PORT; | ||
} | ||
} |
Oops, something went wrong.