-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for org.apache.curator:curator-client:5.5.0
#381
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file doesn't contain any curator client metadata. It contains only
java.lang
related metadata which don't have to be added to this file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your reminder. Due to some unreasonable Warnings and failed nativeTests in the past 10 months, I always thought that these
java.**
andsun.**
must be defined in GraalVM Reachability Metadata. I've done further testing at linghengqian/graalvm-trace-metadata-smoketest@ce5c7cb and Provides built-in GraalVM Reachability Metadata and nativeTest on Elasticjob Bootstrap apache/shardingsphere-elasticjob#2268 , curator-client and curator-recipes of has none of failed nativeTest.I will close this PR. Other related PRs will be processed in the future. Maybe tomorrow.