Skip to content

Commit 95dfd85

Browse files
committed
Expermiental runner for wilfly for jdk8
buggy. Need to be tried on all osses and see if it is actually valid somwehre
1 parent 62c57c7 commit 95dfd85

2 files changed

Lines changed: 177 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ lmdbjava for jdk21 and up needs `zig`.
2626
|scala_partest_natives | ok[3]/// | ok[3]/// | ok[3]/// | ok[3]/// | ok[3]/// |
2727
|tomcat-native | ok//// | ok/// | ok/// | ok/// | ok/// |
2828
|wildfly-openssl | s[4] | ok/// | ok/// | ok/// | ok/// |
29+
|wildfly8-openssl | f[6] | s[5] | s[5] | s[5] | s[5] |
2930

3031
[1] !skipped! NativeTest.setBlocking:35 » InaccessibleObject Unable to make field private fi...</br>
3132
-> todo fix in upstream
@@ -37,6 +38,9 @@ lmdbjava for jdk21 and up needs `zig`.
3738

3839
[4] !skipped! older wildfly needed for jdk8</br>
3940
-> todo, fix here hopefully
41+
[5] !skipped! newer wildfly needed for jdk newer then 8</br>
42+
-> intyetnionally jdk8 onlyu
43+
[6] this test currently fails - the goal is to investigate if there is any environemnt where it can pass
4044

4145
# window x86_64/aarch64
4246
Unluckily I do not have windows arround

jni/wildfly8-openssl.sh

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
#!/bin/bash
2+
set -exo pipefail
3+
4+
if [ "0$JDK_MAJOR" -gt 8 ]; then
5+
echo "!skipped! newer wildfly needed for jdk newer then 8"
6+
exit
7+
fi
8+
9+
MVOPTS="--batch-mode"
10+
if [ "x$EX_MVN" == "x" ] ; then
11+
EX_MVN=mvn
12+
fi
13+
14+
15+
function addIgnoreImport() {
16+
if ! grep -e "import org.junit.Ignore" "${1}" ; then #do not create duplicated imports
17+
sed "s/import org.junit.Test;/import org.junit.Test;import org.junit.Ignore;/" -i "${1}"
18+
fi
19+
}
20+
21+
ignoredTests=0
22+
function ignoreMethod() {
23+
local file=$(find -type f | grep "${2}.java$")
24+
grep -e "${1}[(]" "${file}" #check
25+
# do not inject ignore import if nothing will be sed
26+
addIgnoreImport "${file}"
27+
sed "s/${1}[(]/@Ignore ${1}(/g" -i "${file}"
28+
grep -e "@Ignore ${1}[(]" "${file}" #check
29+
let ignoredTests=$ignoredTests+1
30+
}
31+
32+
# for generating patches
33+
GIT=git
34+
#GIT=echo
35+
36+
# both seesm to be failing in same way
37+
#VERSION=1.0.12.Final # last 1.0 on Oct 26, 2020
38+
VERSION=1.1.3.Final # last 1.1 on Sep 30, 2020
39+
rm -rf wildfly8-openssl
40+
mkdir wildfly8-openssl
41+
pushd wildfly8-openssl
42+
wget https://github.com/wildfly-security/wildfly-openssl/archive/refs/tags/${VERSION}.tar.gz
43+
tar -xf ${VERSION}.tar.gz
44+
# generally the testsuite is poorly designed. see SSLTestUtils.java
45+
# it reuses still same port, and do not release it in finally clausule,
46+
# so although it uses setReuseAddress, any first fail will kill all subsequent tests
47+
# as the port seems to survive junit's vm
48+
pushd wildfly-openssl-${VERSION}
49+
$GIT init
50+
$GIT add *
51+
$GIT commit . -m "initial commit"
52+
# this test fails with different crypto policies
53+
ignoreMethod "public void testNoExplicitEnabledProtocols" "BasicOpenSSLEngineTest"
54+
if [ "x$OTOOL_OS_VERSION" = "x7" -a "x$OTOOL_OS_NAME" = "xel" ] ; then
55+
# tls v 1.0 is being removed
56+
ignoreMethod "public void testMultipleEnabledProtocolsWithClientProtocolWithinEnabledRange" "BasicOpenSSLEngineTest"
57+
fi
58+
# this test fails with different crypto policies and there is no JNI at all. However to find wy it fials is interesting TODO.
59+
ignoreMethod "public void testCipherSuiteConverter" "SslCiphersTest"
60+
patch -p1 <<EOF
61+
--- a/java/src/test/java/org/wildfly/openssl/SSLTestUtils.java
62+
+++ a/java/src/test/java/org/wildfly/openssl/SSLTestUtils.java
63+
@@ -41,8 +41,8 @@
64+
public class SSLTestUtils {
65+
66+
public static final String HOST = System.getProperty("org.wildfly.openssl.test.host", "localhost");
67+
- public static final int PORT = Integer.parseInt(System.getProperty("org.wildfly.openssl.test.port", "7677"));
68+
- public static final int SECONDARY_PORT = Integer.parseInt(System.getProperty("org.wildfly.openssl.test.secondary.port", "7687"));
69+
+ public static final int PORT = Integer.parseInt(System.getProperty("org.wildfly.openssl.test.port", ""+findFreePort()));
70+
+ public static final int SECONDARY_PORT = Integer.parseInt(System.getProperty("org.wildfly.openssl.test.secondary.port", ""+findFreePort()));
71+
72+
private static KeyStore loadKeyStore(final String name) throws IOException {
73+
final InputStream stream = BasicOpenSSLEngineTest.class.getClassLoader().getResourceAsStream(name);
74+
@@ -165,6 +165,17 @@
75+
return out.toByteArray();
76+
}
77+
78+
+ public static int findFreePort() {
79+
+ try (ServerSocket socket = new ServerSocket(0)) {
80+
+ int i = socket.getLocalPort();
81+
+ socket.close();
82+
+ Thread.sleep(1000);
83+
+ return i;
84+
+ } catch (Exception e) {
85+
+ }
86+
+ return -1;
87+
+ }
88+
+
89+
public static ServerSocket createServerSocket() throws IOException {
90+
return createServerSocket(PORT);
91+
}
92+
EOF
93+
$GIT commit . -m "excluded some tests"
94+
patch -p1 <<EOF
95+
diff --git a/java/src/test/java/org/wildfly/openssl/AbstractOpenSSLTest.java b/java/src/test/java/org/wildfly/openssl/AbstractOpenSSLTest.java
96+
index 56d2357..f67442a 100644
97+
--- a/java/src/test/java/org/wildfly/openssl/AbstractOpenSSLTest.java
98+
+++ b/java/src/test/java/org/wildfly/openssl/AbstractOpenSSLTest.java
99+
@@ -18,6 +18,7 @@
100+
package org.wildfly.openssl;
101+
102+
import org.junit.BeforeClass;
103+
+import org.junit.Before;
104+
105+
/**
106+
* @author Stuart Douglas
107+
@@ -26,6 +27,12 @@ public class AbstractOpenSSLTest {
108+
109+
private static boolean first = true;
110+
111+
+ @Before
112+
+ public void reinitPorts(){
113+
+ SSLTestUtils.resetPort();
114+
+ SSLTestUtils.resetSecondaryPort();
115+
+ }
116+
+
117+
@BeforeClass
118+
public static void setup() {
119+
if(first) {
120+
diff --git a/java/src/test/java/org/wildfly/openssl/SSLTestUtils.java b/java/src/test/java/org/wildfly/openssl/SSLTestUtils.java
121+
index f7a4261..8c4aa3d 100644
122+
--- a/java/src/test/java/org/wildfly/openssl/SSLTestUtils.java
123+
+++ b/java/src/test/java/org/wildfly/openssl/SSLTestUtils.java
124+
@@ -41,8 +41,24 @@ import javax.net.ssl.TrustManagerFactory;
125+
public class SSLTestUtils {
126+
127+
public static final String HOST = System.getProperty("org.wildfly.openssl.test.host", "localhost");
128+
- public static final int PORT = Integer.parseInt(System.getProperty("org.wildfly.openssl.test.port", ""+findFreePort()));
129+
- public static final int SECONDARY_PORT = Integer.parseInt(System.getProperty("org.wildfly.openssl.test.secondary.port", ""+findFreePort()));
130+
+ public static int PORT = initPort();
131+
+ public static int SECONDARY_PORT = initSecondaryPort();
132+
+
133+
+ private static int initPort() {
134+
+ return Integer.parseInt(System.getProperty("org.wildfly.openssl.test.port", ""+findFreePort()));
135+
+ }
136+
+
137+
+ private static int initSecondaryPort() {
138+
+ return Integer.parseInt(System.getProperty("org.wildfly.openssl.test.secondary.port", ""+findFreePort()));
139+
+ }
140+
+
141+
+ public static void resetPort(){
142+
+ PORT=initPort();
143+
+ }
144+
+
145+
+ public static void resetSecondaryPort(){
146+
+ SECONDARY_PORT=initSecondaryPort();
147+
+ }
148+
149+
private static KeyStore loadKeyStore(final String name) throws IOException {
150+
final InputStream stream = BasicOpenSSLEngineTest.class.getClassLoader().getResourceAsStream(name);
151+
EOF
152+
$GIT commit . -m "make port random/free for each method"
153+
# it is better to set the libssl and libcrypto on our own
154+
# the wildfly-openssl search is just tragic, and the excception throwns out of it are very missleading
155+
# eg "not found ssl library" may be thrown from findCryptoLibray (where findSSL have passed fine)
156+
libssl=$( ls $(find /usr/lib /usr/lib64 -type l | grep libssl | grep -v -e .hmac -e .pc ) | head -n 1) ;
157+
libcrypt=$( ls $(find /usr/lib /usr/lib64 -type l | grep libcrypto | grep -v -e .hmac -e .pc ) | head -n 1) ;
158+
159+
allEnabledSecurity=`mktemp`
160+
echo 'jdk.tls.disabledAlgorithms='> "$allEnabledSecurity"
161+
useAllEnabledSecurity="-Djava.security.properties=$allEnabledSecurity"
162+
163+
#if problems with not freed port persists, run in loop of 2-3 mvn test, and return nonzero only if all fails
164+
if [ "x$OTOOL_OS_NAME" = "xel" -a "x$OTOOL_OS_VERSION" = "x7" ] ; then
165+
scl enable rh-maven36 -- mvn $MVOPTS $clean install $useAllEnabledSecurity -Dorg.wildfly.openssl.path.ssl=$libssl -Dorg.wildfly.openssl.path.crypto=$libcrypt
166+
else
167+
$EX_MVN $MVOPTS clean install $useAllEnabledSecurity -Dorg.wildfly.openssl.path.ssl=$libssl -Dorg.wildfly.openssl.path.crypto=$libcrypt
168+
fi
169+
if which update-crypto-policies 2>/dev/null 1>/dev/null ; then
170+
update-crypto-policies --show
171+
fi
172+
popd
173+
popd

0 commit comments

Comments
 (0)