-
Notifications
You must be signed in to change notification settings - Fork 92
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-client:5.5.0
- Loading branch information
1 parent
939d438
commit a925f9c
Showing
14 changed files
with
525 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
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" | ||
] |
29 changes: 29 additions & 0 deletions
29
metadata/org.apache.curator/curator-client/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,29 @@ | ||
[ | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.retry.RetryForever"}, | ||
"name":"java.lang.Object", | ||
"methods":[{"name":"toString","parameterTypes":[] }] | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.retry.RetryForever"}, | ||
"name":"java.lang.StackWalker", | ||
"methods":[ | ||
{"name":"getInstance","parameterTypes":["java.util.Set","int"] }, | ||
{"name":"walk","parameterTypes":["java.util.function.Function"] } | ||
] | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.retry.RetryForever"}, | ||
"name":"java.lang.StackWalker$Option" | ||
}, | ||
{ | ||
"condition":{"typeReachable":"org.apache.curator.retry.RetryForever"}, | ||
"name":"java.lang.StackWalker$StackFrame", | ||
"methods":[ | ||
{"name":"getClassName","parameterTypes":[] }, | ||
{"name":"getFileName","parameterTypes":[] }, | ||
{"name":"getLineNumber","parameterTypes":[] }, | ||
{"name":"getMethodName","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-client", | ||
"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
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-client/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-client:$libraryVersion" | ||
testImplementation 'org.assertj:assertj-core:3.22.0' | ||
testImplementation 'org.awaitility:awaitility:4.2.0' | ||
testImplementation "org.apache.curator:curator-test:$libraryVersion" | ||
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-client") | ||
} | ||
} | ||
metadataRepository { | ||
enabled = true | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
tests/src/org.apache.curator/curator-client/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-client/5.5.0/ |
13 changes: 13 additions & 0 deletions
13
tests/src/org.apache.curator/curator-client/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-client_tests' |
131 changes: 131 additions & 0 deletions
131
...rator-client/5.5.0/src/test/java/org_apache_curator/curator_client/CuratorClientTest.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,131 @@ | ||
/* | ||
* 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_client; | ||
|
||
import org.apache.curator.CuratorZookeeperClient; | ||
import org.apache.curator.RetryLoop; | ||
import org.apache.curator.RetryPolicy; | ||
import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; | ||
import org.apache.curator.retry.ExponentialBackoffRetry; | ||
import org.apache.curator.retry.RetryNTimes; | ||
import org.apache.curator.retry.RetryOneTime; | ||
import org.apache.curator.retry.RetryUntilElapsed; | ||
import org.apache.curator.utils.DefaultZookeeperFactory; | ||
import org.apache.zookeeper.CreateMode; | ||
import org.apache.zookeeper.ZooDefs; | ||
import org.awaitility.Awaitility; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.Duration; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class CuratorClientTest { | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
EmbedTestingServer.start(); | ||
} | ||
|
||
@Test | ||
void testConstructor() throws Exception { | ||
try (CuratorZookeeperClient client = getCuratorZookeeperClient()) { | ||
client.start(); | ||
client.blockUntilConnectedOrTimedOut(); | ||
String path = client.getZooKeeper().create("/testConstructor", new byte[]{1, 2, 3}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); | ||
assertEquals(path, "/testConstructor"); | ||
} | ||
} | ||
|
||
@Test | ||
void testGetZooKeeper() throws Exception { | ||
try (CuratorZookeeperClient client = getCuratorZookeeperClient()) { | ||
client.start(); | ||
assertThat(client.getZooKeeper()).isNotNull(); | ||
} | ||
} | ||
|
||
@Test | ||
void testIsConnected() throws Exception { | ||
try (CuratorZookeeperClient client = getCuratorZookeeperClient()) { | ||
client.start(); | ||
Awaitility.await() | ||
.atMost(Duration.ofMillis(4000)) | ||
.untilAsserted(() -> assertTrue(client.isConnected())); | ||
} | ||
} | ||
|
||
@Test | ||
void testBlockUntilConnectedOrTimedOut() throws Exception { | ||
try (CuratorZookeeperClient client = getCuratorZookeeperClient()) { | ||
client.start(); | ||
client.blockUntilConnectedOrTimedOut(); | ||
String path = client.getZooKeeper().create("/testBlockUntilConnectedOrTimedOut", new byte[]{1, 2, 3}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); | ||
assertEquals(path, "/testBlockUntilConnectedOrTimedOut"); | ||
} | ||
} | ||
|
||
@Test | ||
void testClose() { | ||
assertDoesNotThrow(() -> { | ||
CuratorZookeeperClient client = getCuratorZookeeperClient(); | ||
client.start(); | ||
client.blockUntilConnectedOrTimedOut(); | ||
client.close(); | ||
}); | ||
} | ||
|
||
@Test | ||
void testSetRetryPolicy() throws Exception { | ||
try (CuratorZookeeperClient client = getCuratorZookeeperClient()) { | ||
client.start(); | ||
client.blockUntilConnectedOrTimedOut(); | ||
RetryPolicy originRetryPolicy = client.getRetryPolicy(); | ||
client.setRetryPolicy(new ExponentialBackoffRetry(1, 1)); | ||
client.setRetryPolicy(new RetryNTimes(1, 1)); | ||
client.setRetryPolicy(new RetryOneTime(1)); | ||
client.setRetryPolicy(new RetryUntilElapsed(1, 1)); | ||
client.setRetryPolicy(originRetryPolicy); | ||
String path = client.getZooKeeper().create("/testSetRetryPolicy", new byte[]{1, 2, 3}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); | ||
assertEquals(path, "/testSetRetryPolicy"); | ||
} | ||
} | ||
|
||
@Test | ||
void testNewRetryLoop() throws Exception { | ||
try (CuratorZookeeperClient client = getCuratorZookeeperClient()) { | ||
client.start(); | ||
int loopCount = 0; | ||
RetryLoop retryLoop = client.newRetryLoop(); | ||
while (retryLoop.shouldContinue()) { | ||
++loopCount; | ||
if (loopCount > 2) { | ||
fail(); | ||
break; | ||
} | ||
try { | ||
client.getZooKeeper().create("/testNewRetryLoop", new byte[]{1, 2, 3}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); | ||
retryLoop.markComplete(); | ||
} catch (Exception e) { | ||
retryLoop.takeException(e); | ||
} | ||
} | ||
assertTrue(loopCount > 0); | ||
} | ||
} | ||
|
||
private CuratorZookeeperClient getCuratorZookeeperClient() { | ||
return new CuratorZookeeperClient(new DefaultZookeeperFactory(), | ||
new FixedEnsembleProvider(EmbedTestingServer.getConnectString()), | ||
10000, 10000, null, new RetryOneTime(1), false); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...ator-client/5.5.0/src/test/java/org_apache_curator/curator_client/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_client; | ||
|
||
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 = 3191; | ||
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; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...test/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.0/jni-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,7 @@ | ||
[ | ||
{ | ||
"condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, | ||
"name":"java.util.Arrays", | ||
"methods":[{"name":"asList","parameterTypes":["java.lang.Object[]"] }] | ||
} | ||
] |
Oops, something went wrong.