Skip to content

Commit b7ed4b8

Browse files
committed
Run tests against multiple JDK versions
1 parent 1899321 commit b7ed4b8

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

Dockerfile.test

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM eclipse-temurin:23-jdk
1+
ARG JDK_VERSION=23
2+
3+
FROM eclipse-temurin:${JDK_VERSION}-jdk
24

35
MAINTAINER Conjur Inc
46

Jenkinsfile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,31 @@ pipeline {
125125
}
126126
}
127127

128-
stage('Run tests and archive test results') {
128+
stage('Run tests (JDK8)') {
129129
environment {
130130
INFRAPOOL_REGISTRY_URL = "registry.tld"
131+
INFRAPOOL_JDK_VERSION = "8"
132+
}
133+
steps {
134+
script {
135+
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh './bin/test.sh'
136+
}
137+
}
138+
}
139+
140+
stage('Run tests and archive results (JDK23)') {
141+
environment {
142+
INFRAPOOL_REGISTRY_URL = "registry.tld"
143+
INFRAPOOL_JDK_VERSION = "23"
131144
}
132145
steps {
133146
script {
134147
lock("api-java-${env.NODE_NAME}") {
135148
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh './bin/test.sh'
136-
INFRAPOOL_EXECUTORV2_AGENT_0.agentStash includes: 'target/surefire-reports/*.xml', name: 'test-results'
149+
INFRAPOOL_EXECUTORV2_AGENT_0.agentStash includes: 'target/surefire-reports/*.xml', name: "test-results"
137150
unstash 'test-results'
138151
}
139152
}
140-
141153
junit 'target/surefire-reports/*.xml'
142154
}
143155
}

bin/test.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ source bin/utils.sh
66
trap finish EXIT
77

88
export REGISTRY_URL=${INFRAPOOL_REGISTRY_URL:-"docker.io"}
9+
export JDK_VERSION=${INFRAPOOL_JDK_VERSION:-8}
910

1011
function main() {
1112
finish
@@ -33,7 +34,7 @@ function runOss () {
3334

3435
# Build DAP test container & start the cluster
3536
function createDAPTestEnvironment() {
36-
docker compose build --pull client cuke-master test-dap
37+
docker compose build --pull client cuke-master test-dap --build-arg JDK_VERSION="${JDK_VERSION:-8}"
3738
export CONJUR_APPLIANCE_URL="https://cuke-master"
3839
docker compose up -d client cuke-master test-dap
3940

@@ -94,6 +95,13 @@ function initializeDapCert() {
9495

9596
# Import cert converted above into keystore
9697
JAVA_PATH=$(docker exec ${dap_test_cid} sh -c 'echo $JAVA_HOME')
98+
99+
# If Java 8, append /jre to the path
100+
JAVA_VERSION=$(docker exec ${dap_test_cid} sh -c '$JAVA_HOME/bin/java -version 2>&1 | head -n 1')
101+
if [[ "$JAVA_VERSION" == *"1.8"* ]]; then
102+
JAVA_PATH="${JAVA_PATH}/jre"
103+
fi
104+
97105
import_command="keytool \
98106
-import \
99107
-alias cuke-master -v \

bin/utils.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function createOssEnvironment() {
66
echo '------------------------------------------------------------'
77

88
# Build OSS test container & start the cluster
9-
docker compose build --pull client conjur postgres test test-https conjur-proxy-nginx
9+
docker compose build --pull client conjur postgres test test-https conjur-proxy-nginx --build-arg JDK_VERSION="${JDK_VERSION:-8}"
1010
export CONJUR_APPLIANCE_URL="http://conjur"
1111
docker compose up -d client conjur postgres test-https
1212

@@ -81,6 +81,13 @@ function initializeOssCert() {
8181

8282
# Import cert converted above into keystore
8383
JAVA_PATH=$(docker exec ${conjur_test_cid} sh -c 'echo $JAVA_HOME')
84+
85+
# If Java 8, append /jre to the path
86+
JAVA_VERSION=$(docker exec ${dap_test_cid} sh -c '$JAVA_HOME/bin/java -version 2>&1 | head -n 1')
87+
if [[ "$JAVA_VERSION" == *"1.8"* ]]; then
88+
JAVA_PATH="${JAVA_PATH}/jre"
89+
fi
90+
8491
import_command="keytool \
8592
-import \
8693
-alias cucumber \

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ services:
5858
build:
5959
context: .
6060
dockerfile: Dockerfile.test
61+
args:
62+
JDK_VERSION: ${JDK_VERSION:-8}
6163
volumes:
6264
- ./target:/conjurinc/api-java/target
6365
environment:
@@ -69,6 +71,8 @@ services:
6971
build:
7072
context: .
7173
dockerfile: Dockerfile.test
74+
args:
75+
JDK_VERSION: ${JDK_VERSION:-8}
7276
volumes:
7377
- ./target:/conjurinc/api-java/target
7478
- ./test-cert:/test-cert
@@ -84,6 +88,8 @@ services:
8488
build:
8589
context: .
8690
dockerfile: Dockerfile.test
91+
args:
92+
JDK_VERSION: ${JDK_VERSION:-8}
8793
volumes:
8894
- ./target:/conjurinc/api-java/target
8995
- ./test-cert:/test-cert

0 commit comments

Comments
 (0)