From e10120663bf9203d6112242964efe91673e1ffe3 Mon Sep 17 00:00:00 2001 From: linghengqian Date: Mon, 12 Aug 2024 15:50:45 +0800 Subject: [PATCH] Add nativeTest that uses DIGEST-MD5 as SASL mechanism for ElasticJob ZookeeperRegistryCenter under GraalVM Native Image --- pom.xml | 8 + .../docker-java-api/3.3.6/reflect-config.json | 7 + .../zookeeper/3.9.2/jni-config.json | 25 + .../zookeeper/3.9.2/reflect-config.json | 627 ++++++++++++++++++ .../zookeeper/3.9.2/resource-config.json | 38 ++ .../native-image-filter/extra-filter.json | 3 +- test/native/pom.xml | 5 + .../elasticjob/test/natived/TestMain.java | 3 + .../test/natived/it/operation/JavaTest.java | 4 +- .../natived/it/staticd/ZookeeperAuthTest.java | 127 ++++ .../resource-config.json | 8 + .../conf/jaas-server-test-native.conf | 21 + 12 files changed, 873 insertions(+), 3 deletions(-) create mode 100644 reachability-metadata/src/main/resources/META-INF/native-image/com.github.docker-java/docker-java-api/3.3.6/reflect-config.json create mode 100644 reachability-metadata/src/main/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.2/jni-config.json create mode 100644 reachability-metadata/src/main/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.2/resource-config.json create mode 100644 test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/it/staticd/ZookeeperAuthTest.java create mode 100644 test/native/src/test/resources/META-INF/native-image/elasticjob-test-native-test-metadata/resource-config.json create mode 100644 test/native/src/test/resources/test-native/conf/jaas-server-test-native.conf diff --git a/pom.xml b/pom.xml index 9231ff2dc8..e0d2224b99 100644 --- a/pom.xml +++ b/pom.xml @@ -89,6 +89,7 @@ 4.11.0 4.2.0 1.14.18 + 1.20.1 2.2.224 4.0.3 @@ -350,6 +351,13 @@ ${awaitility.version} test + + org.testcontainers + testcontainers-bom + ${testcontainers-bom.version} + pom + import + com.h2database diff --git a/reachability-metadata/src/main/resources/META-INF/native-image/com.github.docker-java/docker-java-api/3.3.6/reflect-config.json b/reachability-metadata/src/main/resources/META-INF/native-image/com.github.docker-java/docker-java-api/3.3.6/reflect-config.json new file mode 100644 index 0000000000..f3f5e1ef24 --- /dev/null +++ b/reachability-metadata/src/main/resources/META-INF/native-image/com.github.docker-java/docker-java-api/3.3.6/reflect-config.json @@ -0,0 +1,7 @@ +[ +{ + "condition":{"typeReachable":"com.github.dockerjava.api.model.RuntimeInfo"}, + "name":"com.github.dockerjava.api.model.RuntimeInfo", + "allPublicConstructors": true +} +] diff --git a/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.2/jni-config.json b/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.2/jni-config.json new file mode 100644 index 0000000000..d3820c073a --- /dev/null +++ b/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.2/jni-config.json @@ -0,0 +1,25 @@ +[ +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"[Lcom.sun.management.internal.DiagnosticCommandArgumentInfo;" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"[Lcom.sun.management.internal.DiagnosticCommandInfo;" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"com.sun.management.internal.DiagnosticCommandArgumentInfo", + "methods":[{"name":"","parameterTypes":["java.lang.String","java.lang.String","java.lang.String","java.lang.String","boolean","boolean","boolean","int"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"com.sun.management.internal.DiagnosticCommandInfo", + "methods":[{"name":"","parameterTypes":["java.lang.String","java.lang.String","java.lang.String","java.lang.String","java.lang.String","java.lang.String","boolean","java.util.List"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.util.Arrays", + "methods":[{"name":"asList","parameterTypes":["java.lang.Object[]"] }] +} +] diff --git a/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.2/reflect-config.json b/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.2/reflect-config.json index a6e52201ca..52733cfa0a 100644 --- a/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.2/reflect-config.json +++ b/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.2/reflect-config.json @@ -1,4 +1,413 @@ [ +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"[B" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"[C" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"[D" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"[F" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"[I" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"[J" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"[Ljava.lang.String;" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"[Ljavax.management.openmbean.CompositeData;" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"[S" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"[Z" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"com.sun.crypto.provider.AESCipher$General", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"com.sun.crypto.provider.ARCFOURCipher", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"com.sun.crypto.provider.ChaCha20Cipher$ChaCha20Poly1305", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"com.sun.crypto.provider.DESCipher", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"com.sun.crypto.provider.DESedeCipher", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"com.sun.crypto.provider.DHParameters", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"com.sun.crypto.provider.GaloisCounterMode$AESGCM", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"com.sun.crypto.provider.TlsMasterSecretGenerator", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"com.sun.management.GarbageCollectorMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"com.sun.management.GcInfo", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"com.sun.management.HotSpotDiagnosticMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"com.sun.management.ThreadMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"com.sun.management.UnixOperatingSystemMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"com.sun.management.VMOption", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"com.sun.management.internal.GarbageCollectorExtImpl", + "queryAllPublicConstructors":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"com.sun.management.internal.HotSpotDiagnostic", + "queryAllPublicConstructors":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"com.sun.management.internal.HotSpotThreadImpl", + "queryAllPublicConstructors":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"com.sun.management.internal.OperatingSystemImpl", + "queryAllPublicConstructors":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.Boolean", + "fields":[{"name":"TYPE"}] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.Byte", + "fields":[{"name":"TYPE"}] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.Character", + "fields":[{"name":"TYPE"}] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.Deprecated", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.Double", + "fields":[{"name":"TYPE"}] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.Float", + "fields":[{"name":"TYPE"}] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.Integer", + "fields":[{"name":"TYPE"}] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.Long", + "fields":[{"name":"TYPE"}] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.Short", + "fields":[{"name":"TYPE"}] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.StackTraceElement", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.String", + "fields":[{"name":"TYPE"}] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.Void", + "fields":[{"name":"TYPE"}] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.BufferPoolMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.ClassLoadingMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.CompilationMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.LockInfo", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.ManagementPermission", + "methods":[{"name":"","parameterTypes":["java.lang.String"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.MemoryMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.MemoryManagerMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.MemoryPoolMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.MemoryUsage", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.MonitorInfo", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.PlatformLoggingMXBean", + "queryAllPublicMethods":true, + "methods":[{"name":"getLoggerLevel","parameterTypes":["java.lang.String"] }, {"name":"getLoggerNames","parameterTypes":[] }, {"name":"getParentLoggerName","parameterTypes":["java.lang.String"] }, {"name":"setLoggerLevel","parameterTypes":["java.lang.String","java.lang.String"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.RuntimeMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.lang.management.ThreadInfo", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.math.BigDecimal" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.math.BigInteger" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"java.security.AlgorithmParametersSpi" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"java.security.KeyStoreSpi" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.util.Date" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory"}, + "name":"java.util.Optional" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.util.PropertyPermission", + "methods":[{"name":"","parameterTypes":["java.lang.String","java.lang.String"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.embedded.ZooKeeperServerEmbeddedImpl"}, + "name":"java.util.concurrent.ForkJoinTask", + "fields":[{"name":"aux"}, {"name":"status"}] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.util.logging.LogManager", + "methods":[{"name":"getLoggingMXBean","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"java.util.logging.LoggingMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"javax.management.MBeanOperationInfo", + "queryAllPublicMethods":true, + "methods":[{"name":"getSignature","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"javax.management.MBeanServerBuilder", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"javax.management.ObjectName" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"javax.management.StandardEmitterMBean", + "methods":[{"name":"cacheMBeanInfo","parameterTypes":["javax.management.MBeanInfo"] }, {"name":"getCachedMBeanInfo","parameterTypes":[] }, {"name":"getMBeanInfo","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"javax.management.openmbean.CompositeData" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"javax.management.openmbean.OpenMBeanOperationInfoSupport" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"javax.management.openmbean.TabularData" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"javax.security.auth.x500.X500Principal", + "fields":[{"name":"thisX500Name"}], + "methods":[{"name":"","parameterTypes":["sun.security.x509.X500Name"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.embedded.ZooKeeperServerEmbeddedImpl"}, + "name":"jdk.internal.misc.Unsafe" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"jdk.management.jfr.ConfigurationInfo", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"jdk.management.jfr.EventTypeInfo", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"jdk.management.jfr.FlightRecorderMXBean", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"jdk.management.jfr.FlightRecorderMXBeanImpl", + "queryAllPublicConstructors":true, + "methods":[{"name":"cacheMBeanInfo","parameterTypes":["javax.management.MBeanInfo"] }, {"name":"getCachedMBeanInfo","parameterTypes":[] }, {"name":"getMBeanInfo","parameterTypes":[] }, {"name":"getNotificationInfo","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"jdk.management.jfr.RecordingInfo", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"jdk.management.jfr.SettingDescriptorInfo", + "queryAllPublicMethods":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory"}, + "name":"org.apache.curator.framework.imps.CuratorFrameworkImpl" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory"}, + "name":"org.apache.curator.shaded.com.google.common.base.Preconditions" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory"}, + "name":"org.apache.shardingsphere.elasticjob.kernel.internal.election.LeaderService" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory"}, + "name":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobScheduleController" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory"}, + "name":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobShutdownHookPlugin" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory"}, + "name":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobShutdownHookPlugin$1" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory"}, + "name":"org.apache.shardingsphere.elasticjob.kernel.internal.storage.JobNodeStorage" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory"}, + "name":"org.apache.shardingsphere.elasticjob.reg.exception.RegExceptionHandler" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory"}, + "name":"org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter" +}, { "condition":{"typeReachable":"org.apache.zookeeper.ZooKeeper"}, "name":"org.apache.zookeeper.ClientCnxnSocketNIO", @@ -48,9 +457,227 @@ "name":"org.apache.zookeeper.server.ZooKeeperServerMXBean", "queryAllPublicMethods":true }, +{ + "condition":{"typeReachable":"org.apache.zookeeper.Login"}, + "name":"org.apache.zookeeper.server.auth.DigestLoginModule", + "methods":[{"name":"","parameterTypes":[] }] +}, { "condition":{"typeReachable":"org.apache.zookeeper.server.watch.WatchManagerFactory"}, "name":"org.apache.zookeeper.server.watch.WatchManager", "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory"}, + "name":"org.quartz.core.QuartzScheduler" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory"}, + "name":"org.quartz.impl.StdScheduler" +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"sun.management.ClassLoadingImpl", + "queryAllPublicConstructors":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"sun.management.CompilationImpl", + "queryAllPublicConstructors":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"sun.management.ManagementFactoryHelper$1", + "queryAllPublicConstructors":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"sun.management.ManagementFactoryHelper$PlatformLoggingImpl", + "queryAllPublicConstructors":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"sun.management.MemoryImpl", + "queryAllPublicConstructors":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"sun.management.MemoryManagerImpl", + "queryAllPublicConstructors":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"sun.management.MemoryPoolImpl", + "queryAllPublicConstructors":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "name":"sun.management.RuntimeImpl", + "queryAllPublicConstructors":true +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.pkcs12.PKCS12KeyStore", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.pkcs12.PKCS12KeyStore$DualFormatPKCS12", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.ServerCnxnFactory"}, + "name":"sun.security.provider.ConfigFile", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.provider.DSA$SHA224withDSA", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.provider.DSA$SHA256withDSA", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.client.ZooKeeperSaslClient$1"}, + "name":"sun.security.provider.MD5", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.provider.NativePRNG", + "methods":[{"name":"","parameterTypes":["java.security.SecureRandomParameters"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.provider.SHA", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.server.auth.DigestAuthenticationProvider"}, + "name":"sun.security.provider.SHA", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.provider.SHA2$SHA224", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.provider.SHA2$SHA256", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.provider.SHA5$SHA384", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.provider.SHA5$SHA512", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.provider.X509Factory", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.rsa.PSSParameters", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.rsa.RSAKeyFactory$Legacy", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.rsa.RSAPSSSignature", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.rsa.RSASignature$SHA224withRSA", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.ssl.KeyManagerFactoryImpl$SunX509", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.ssl.SSLContextImpl$DefaultSSLContext", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.x509.AuthorityInfoAccessExtension", + "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.x509.AuthorityKeyIdentifierExtension", + "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.x509.BasicConstraintsExtension", + "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.x509.CRLDistributionPointsExtension", + "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.x509.CertificatePoliciesExtension", + "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.x509.ExtendedKeyUsageExtension", + "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.x509.IssuerAlternativeNameExtension", + "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.x509.KeyUsageExtension", + "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.x509.NetscapeCertTypeExtension", + "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.x509.PrivateKeyUsageExtension", + "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.x509.SubjectAlternativeNameExtension", + "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] +}, +{ + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "name":"sun.security.x509.SubjectKeyIdentifierExtension", + "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] } ] diff --git a/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.2/resource-config.json b/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.2/resource-config.json new file mode 100644 index 0000000000..7cfc819d5e --- /dev/null +++ b/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.zookeeper/zookeeper/3.9.2/resource-config.json @@ -0,0 +1,38 @@ +{ + "resources":{ + "includes":[{ + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "pattern":"\\QMETA-INF/services/java.lang.System$LoggerFinder\\E" + }, { + "condition":{"typeReachable":"org.apache.zookeeper.common.X509Util"}, + "pattern":"\\QMETA-INF/services/java.net.spi.URLStreamHandlerProvider\\E" + }, { + "condition":{"typeReachable":"org.apache.zookeeper.server.NIOServerCnxnFactory$AbstractSelectThread"}, + "pattern":"\\QMETA-INF/services/java.nio.channels.spi.SelectorProvider\\E" + }, { + "condition":{"typeReachable":"org.apache.zookeeper.Login"}, + "pattern":"\\QMETA-INF/services/javax.security.auth.spi.LoginModule\\E" + }, { + "condition":{"typeReachable":"org.apache.zookeeper.server.auth.DigestLoginModule"}, + "pattern":"java.base:\\Qsun/security/util/Resources_zh.properties\\E" + }, { + "condition":{"typeReachable":"org.apache.zookeeper.server.auth.DigestLoginModule"}, + "pattern":"java.base:\\Qsun/security/util/Resources_zh_Hans.properties\\E" + }, { + "condition":{"typeReachable":"org.apache.zookeeper.server.auth.DigestLoginModule"}, + "pattern":"java.base:\\Qsun/security/util/Resources_zh_Hans_CN.properties\\E" + }, { + "condition":{"typeReachable":"org.apache.zookeeper.jmx.MBeanRegistry"}, + "pattern":"jdk.jfr:\\Qjdk/jfr/internal/query/view.ini\\E" + }]}, + "bundles":[{ + "name":"sun.security.util.Resources", + "locales":["zh-CN"] + }, { + "name":"sun.text.resources.cldr.FormatData", + "locales":["und"] + }, { + "name":"sun.util.resources.cldr.TimeZoneNames", + "locales":["und"] + }] +} diff --git a/test/native/native-image-filter/extra-filter.json b/test/native/native-image-filter/extra-filter.json index dacbc34689..067e093d69 100644 --- a/test/native/native-image-filter/extra-filter.json +++ b/test/native/native-image-filter/extra-filter.json @@ -7,8 +7,9 @@ {"includeClasses": "java.util.Properties"}, {"excludeClasses": "javax.**"}, {"excludeClasses": "org.**"}, - {"includeClasses": "org.apache.shardingsphere.elasticjob.**"}, + {"includeClasses": "org.apache.zookeeper.**"}, {"excludeClasses": "sun.**"}, + {"includeClasses": "sun.security.provider.ConfigFile"}, {"excludeClasses": "org.apache.shardingsphere.elasticjob.test.natived.**"} ], diff --git a/test/native/pom.xml b/test/native/pom.xml index d031f4f768..5ec9c5ea65 100644 --- a/test/native/pom.xml +++ b/test/native/pom.xml @@ -62,6 +62,11 @@ curator-test test + + org.testcontainers + junit-jupiter + test + org.springframework.boot spring-boot-starter-jdbc diff --git a/test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/TestMain.java b/test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/TestMain.java index b704787964..efc11187c1 100644 --- a/test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/TestMain.java +++ b/test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/TestMain.java @@ -20,6 +20,9 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +/** + * Spring Boot Web Server for testing only. + */ @SpringBootApplication public class TestMain { diff --git a/test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/it/operation/JavaTest.java b/test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/it/operation/JavaTest.java index 72305f2afa..841460c0df 100644 --- a/test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/it/operation/JavaTest.java +++ b/test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/it/operation/JavaTest.java @@ -91,9 +91,9 @@ static void beforeAll() throws Exception { client.start(); Awaitility.await().atMost(Duration.ofMillis(500 * 60)).ignoreExceptions().until(client::isConnected); } - firstRegCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration(testingServer.getConnectString(), "elasticjob-test-native-java")); + firstRegCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration(testingServer.getConnectString(), "elasticjob-test-native-operation-java")); firstRegCenter.init(); - secondRegCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration(testingServer.getConnectString(), "elasticjob-test-native-java")); + secondRegCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration(testingServer.getConnectString(), "elasticjob-test-native-operation-java")); secondRegCenter.init(); HikariConfig config = new HikariConfig(); config.setDriverClassName("org.h2.Driver"); diff --git a/test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/it/staticd/ZookeeperAuthTest.java b/test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/it/staticd/ZookeeperAuthTest.java new file mode 100644 index 0000000000..02a34860ca --- /dev/null +++ b/test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/it/staticd/ZookeeperAuthTest.java @@ -0,0 +1,127 @@ +/* + * 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.shardingsphere.elasticjob.test.natived.it.staticd; + +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import org.apache.shardingsphere.elasticjob.api.JobConfiguration; +import org.apache.shardingsphere.elasticjob.bootstrap.type.ScheduleJobBootstrap; +import org.apache.shardingsphere.elasticjob.kernel.tracing.config.TracingConfiguration; +import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter; +import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperConfiguration; +import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter; +import org.apache.shardingsphere.elasticjob.test.natived.commons.job.simple.JavaSimpleJob; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledInNativeImage; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.images.builder.Transferable; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.utility.MountableFile; + +import javax.security.auth.login.AppConfigurationEntry; +import javax.security.auth.login.Configuration; +import javax.sql.DataSource; +import java.time.Duration; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + +@EnabledInNativeImage +@Testcontainers +public class ZookeeperAuthTest { + + @SuppressWarnings("resource") + @Container + private static final GenericContainer CONTAINER = new GenericContainer<>("zookeeper:3.9.2") + .withCopyFileToContainer( + MountableFile.forClasspathResource("test-native/conf/jaas-server-test-native.conf", Transferable.DEFAULT_FILE_MODE), + "/jaas-server-test-native.conf") + .withEnv("JVMFLAGS", "-Djava.security.auth.login.config=/jaas-server-test-native.conf") + .withEnv("ZOO_CFG_EXTRA", "authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider sessionRequireClientSASLAuth=true") + .withExposedPorts(2181); + + @BeforeAll + static void beforeAll() { + Configuration configuration = new Configuration() { + + @Override + public AppConfigurationEntry[] getAppConfigurationEntry(String name) { + Map options = new HashMap<>(); + options.put("username", "bob"); + options.put("password", "bobsecret"); + AppConfigurationEntry entry = new AppConfigurationEntry( + "org.apache.zookeeper.server.auth.DigestLoginModule", + AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, + options); + AppConfigurationEntry[] array = new AppConfigurationEntry[1]; + array[0] = entry; + return array; + } + }; + Configuration.setConfiguration(configuration); + } + + @AfterAll + static void afterAll() { + Configuration.setConfiguration(null); + } + + /** + * For {@link org.apache.curator.test.TestingServer}, a lot of system properties are set in the background, + * refer to SaslDigestAuthOverSSLTest.java . + * Therefore, in order to test Zookeeper Server with SASL mechanism enabled under ElasticJob {@link CoordinatorRegistryCenter}, + * ElasticJob should never start Zookeeper Server through {@link org.apache.curator.test.TestingServer}. + * Running Zookeeper Server and Curator Client in the same JVM process will pollute system properties. + * For more information on this unit test, + * refer to ZooKeeper Administrator's Guide and + * ZooKeeper and SASL , + * + * @throws Exception exception + */ + @Test + void testSaslDigestMd5() throws Exception { + String connectionString = CONTAINER.getHost() + ":" + CONTAINER.getMappedPort(2181); + Thread.sleep(Duration.ofSeconds(5L).toMillis()); + CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter( + new ZookeeperConfiguration(connectionString, "elasticjob-test-native-sasl-digest-md5")); + regCenter.init(); + HikariConfig hikariConfig = new HikariConfig(); + hikariConfig.setDriverClassName("org.h2.Driver"); + hikariConfig.setJdbcUrl("jdbc:h2:mem:job_event_storage"); + hikariConfig.setUsername("sa"); + hikariConfig.setPassword(""); + TracingConfiguration tracingConfig = new TracingConfiguration<>("RDB", new HikariDataSource(hikariConfig)); + ScheduleJobBootstrap jobBootstrap = new ScheduleJobBootstrap( + regCenter, + new JavaSimpleJob(), + JobConfiguration.newBuilder("testSaslDigestMd5", 3) + .cron("0/5 * * * * ?") + .shardingItemParameters("0=Norddorf,1=Bordeaux,2=Somerset") + .addExtraConfigurations(tracingConfig) + .build()); + assertDoesNotThrow(() -> { + jobBootstrap.schedule(); + jobBootstrap.shutdown(); + }); + regCenter.close(); + } +} diff --git a/test/native/src/test/resources/META-INF/native-image/elasticjob-test-native-test-metadata/resource-config.json b/test/native/src/test/resources/META-INF/native-image/elasticjob-test-native-test-metadata/resource-config.json new file mode 100644 index 0000000000..f213375810 --- /dev/null +++ b/test/native/src/test/resources/META-INF/native-image/elasticjob-test-native-test-metadata/resource-config.json @@ -0,0 +1,8 @@ +{ + "resources":{ + "includes":[{ + "condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.test.natived.it.staticd.ZookeeperAuthTest"}, + "pattern":".*test-native/conf/.+\\.conf$" + }]}, + "bundles":[] +} diff --git a/test/native/src/test/resources/test-native/conf/jaas-server-test-native.conf b/test/native/src/test/resources/test-native/conf/jaas-server-test-native.conf new file mode 100644 index 0000000000..667b3bcf64 --- /dev/null +++ b/test/native/src/test/resources/test-native/conf/jaas-server-test-native.conf @@ -0,0 +1,21 @@ +// +// 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. +// + +Server { + org.apache.zookeeper.server.auth.DigestLoginModule required + user_bob="bobsecret"; +};