Skip to content

Commit 9e6ccf6

Browse files
committed
MLE-24230 Added wait function
Same approach as in the ragplus project, though waiting for up to 2 minutes. Also echo'ing each request so we can look at the logs afterward in Jenkins to see how long we're typically having to wait.
1 parent ff2f974 commit 9e6ccf6

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

Jenkinsfile

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ def runDockerCompose(String markLogicDockerImage) {
3333
cd node-client-api
3434
echo "Running docker compose with MarkLogic image: ''' + markLogicDockerImage + '''"
3535
MARKLOGIC_LOGS_VOLUME=/tmp MARKLOGIC_IMAGE=''' + markLogicDockerImage + ''' docker-compose up -d --build
36-
echo "Waiting 90s for MarkLogic to be ready to accept connections"
37-
sleep 90s;
3836
'''
3937
}
4038

@@ -57,6 +55,27 @@ def runAuditReport() {
5755
'''
5856
}
5957

58+
def waitUntilMarkLogicIsReady() {
59+
script {
60+
timeout(time: 120, unit: 'SECONDS') {
61+
waitUntil(initialRecurrencePeriod: 5000) {
62+
try {
63+
sh 'echo "Checking if MarkLogic is ready..."'
64+
def result = sh(script: 'curl -s -i --anyauth --user admin:admin -X GET http://localhost:8000/v1/ping', returnStdout: true)
65+
if (result.contains('204 No Content')) {
66+
sh 'echo "MarkLogic is ready!"'
67+
return true
68+
} else {
69+
return false
70+
}
71+
} catch(exception){
72+
return false
73+
}
74+
}
75+
}
76+
}
77+
}
78+
6079
def runE2ETests() {
6180
sh label: 'run-e2e-tests', script: '''
6281
export JAVA_HOME=$JAVA_HOME_DIR
@@ -124,6 +143,7 @@ pipeline {
124143
steps {
125144
runAuditReport()
126145
runDockerCompose('ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-12')
146+
waitUntilMarkLogicIsReady()
127147
runTests()
128148
runE2ETests()
129149
}
@@ -147,6 +167,7 @@ pipeline {
147167
agent { label 'nodeclientpool' }
148168
steps {
149169
runDockerCompose('ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-11')
170+
waitUntilMarkLogicIsReady()
150171
runTests()
151172
runE2ETests()
152173
}
@@ -167,6 +188,7 @@ pipeline {
167188
agent { label 'nodeclientpool' }
168189
steps {
169190
runDockerCompose('ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-12')
191+
waitUntilMarkLogicIsReady()
170192
runTests()
171193
runE2ETests()
172194
}
@@ -187,6 +209,7 @@ pipeline {
187209
agent { label 'nodeclientpool' }
188210
steps {
189211
runDockerCompose('ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-10')
212+
waitUntilMarkLogicIsReady()
190213
runTests()
191214
runE2ETests()
192215
}

0 commit comments

Comments
 (0)