Skip to content

Converting Jenkinsfile to use a docker-compose file #1710

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

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ ml-development-tools/src/test/ml-modules
ml-development-tools/src/test/java/com/marklogic/client/test/dbfunction/generated

.vscode
docker-compose.yaml
docker/
12 changes: 11 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ and add the following (you can override additional properties as necessary):
Note that additional properties are defined via `./tests-app/gradle.properties`, though it is not expected that these
properties will need to be changed.

The application is then deployed via the following command:
The tests require a MarkLogic instance with access to several ports (8000,8001,8002,8012,8014,8020). That instance may
be a local instance or it may be running in a Docker container. If you would like to create a Docker container with the
instance, you may create the container with the following commands (starting in the project root directory):

```
cd test-app
docker-compose up -d --build
cd ..
```

Once you have a MarkLogic instance ready, the application is then deployed via the following command:

./gradlew mlDeploy -i

Expand Down
93 changes: 43 additions & 50 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
@Library('shared-libraries') _

def getJava(){
if(env.JAVA_VERSION=="JAVA17"){
return "/home/builder/java/jdk-17.0.2"
}else if(env.JAVA_VERSION=="JAVA11"){
return "/home/builder/java/jdk-11.0.2"
}else if(env.JAVA_VERSION=="JAVA21"){
if(env.JAVA_VERSION=="JAVA17"){
return "/home/builder/java/jdk-17.0.2"
}else if(env.JAVA_VERSION=="JAVA11"){
return "/home/builder/java/jdk-11.0.2"
}else if(env.JAVA_VERSION=="JAVA21"){
return "/home/builder/java/jdk-21.0.1"
}else{
return "/home/builder/java/openjdk-1.8.0-262"
}
return "/home/builder/java/openjdk-1.8.0-262"
}
}

def runAllTests(String type, String version, Boolean useReverseProxy){
copyRPM type, version
sh 'sudo /usr/local/sbin/mladmin removeforest /space/Forests'
setUpML '$WORKSPACE/xdmp/src/Mark*.rpm'
copyConvertersRPM type,version
setUpMLConverters '$WORKSPACE/xdmp/src/Mark*Converters*.rpm'
def setupDockerMarkLogic(String image){
sh label:'mlsetup', script: '''#!/bin/bash
echo "Removing any running MarkLogic server and clean up MarkLogic data directory"
sudo /usr/local/sbin/mladmin remove
sudo /usr/local/sbin/mladmin cleandata
cd java-client-api/test-app
docker compose down -v || true
echo "Using image: "'''+image+'''
MARKLOGIC_IMAGE='''+image+''' MARKLOGIC_LOGS_VOLUME=marklogicLogs docker compose up -d --build
echo "mlPassword=admin" > gradle-local.properties
echo "Waiting for MarkLogic server to initialize."
sleep 30s
cd ..
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
./gradlew -i mlDeploy mlReloadSchemas
'''
}

sh label:'deploy test app', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cd java-client-api
./gradlew -i mlDeploy mlReloadSchemas -PmlForestDataDirectory=/space
'''
def runAllTests(Boolean useReverseProxy, String image){
setupDockerMarkLogic(image)

if (useReverseProxy) {
sh label:'run marklogic-client-api tests with reverse proxy', script: '''#!/bin/bash
Expand Down Expand Up @@ -155,18 +162,9 @@ pipeline{
}
}
steps {
copyRPM 'Latest','11'
sh 'sudo /usr/local/sbin/mladmin removeforest /space/Forests'
setUpML '$WORKSPACE/xdmp/src/Mark*.rpm'
copyConvertersRPM 'Latest','11'
setUpMLConverters '$WORKSPACE/xdmp/src/Mark*Converters*.rpm'
sh label:'deploy test app', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cd java-client-api
./gradlew -i mlDeploy mlReloadSchemas -PmlForestDataDirectory=/space
'''
setupDockerMarkLogic("ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-11")


sh label:'run marklogic-client-api tests', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
Expand All @@ -177,6 +175,14 @@ pipeline{
'''
junit '**/build/**/TEST*.xml'
}
post{
always{
sh label:'dockerCleanup', script: '''#!/bin/bash
cd java-client-api/test-app
docker compose down -v || true
'''
}
}
}
stage('publish'){
when {
Expand Down Expand Up @@ -205,7 +211,7 @@ pipeline{
}
}
steps {
runAllTests('Release', '11.2.0', false)
runAllTests(false, "ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:11.2.0-ubi")
junit '**/build/**/TEST*.xml'
}
}
Expand All @@ -218,7 +224,7 @@ pipeline{
}
}
steps {
runAllTests('Latest', '11', false)
runAllTests(false, "ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-11")
junit '**/build/**/TEST*.xml'
}
}
Expand All @@ -231,7 +237,7 @@ pipeline{
}
}
steps {
runAllTests('Latest', '11', true)
runAllTests(true, "ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-11")
junit '**/build/**/TEST*.xml'
}
}
Expand All @@ -244,7 +250,7 @@ pipeline{
}
}
steps {
runAllTests('Latest', '12', false)
runAllTests(false, "ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-12")
junit '**/build/**/TEST*.xml'
}
}
Expand All @@ -257,20 +263,7 @@ pipeline{
}
}
steps {
runAllTests('Latest', '10.0', false)
junit '**/build/**/TEST*.xml'
}
}

stage('regressions-10.0-10.2') {
when {
allOf {
branch 'develop'
expression {return params.regressions}
}
}
steps {
runAllTests('Release', '10.0-10.2', false)
runAllTests(false, "ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-10")
junit '**/build/**/TEST*.xml'
}
}
Expand Down
4 changes: 4 additions & 0 deletions test-app/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Defines environment variables for docker-compose.
# Can be overridden via e.g. `MARKLOGIC_TAG=latest-10.0 docker-compose up -d --build`.
MARKLOGIC_IMAGE=progressofficial/marklogic-db:latest
MARKLOGIC_LOGS_VOLUME=./docker/marklogic/logs
21 changes: 21 additions & 0 deletions test-app/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: marklogic-javaclient-test-app

services:

marklogic:
image: "${MARKLOGIC_IMAGE}"
platform: linux/amd64
environment:
- MARKLOGIC_INIT=true
- MARKLOGIC_ADMIN_USERNAME=admin
- MARKLOGIC_ADMIN_PASSWORD=admin
volumes:
- ${MARKLOGIC_LOGS_VOLUME}:/var/opt/MarkLogic/Logs
ports:
- "8000-8002:8000-8002"
- "8012:8012"
- "8014:8014"
- "8020:8020"

volumes:
marklogicLogs: