-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathJenkinsfile
400 lines (388 loc) · 15.8 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
/*
* Copyright (c) 2020-2025 Contributors to Eclipse Foundation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
pipeline {
agent none
options {
buildDiscarder(logRotator(numToKeepStr: '20'))
}
stages {
stage('Build OpenMQ Distribution') {
parallel {
stage('build') {
agent any
tools {
jdk 'temurin-jdk21-latest'
}
steps {
sh './mvnw -V -B -P staging -P dash-licenses -f mq/main clean install -Dbuild.letter=j -Dbuild.number=${BRANCH_NAME}/${GIT_COMMIT}/${BUILD_NUMBER}'
sh './mvnw -B -P staging -f mq/distribution source:jar install'
junit testResults: '**/target/surefire-reports/*.xml', allowEmptyResults: true
dir('mq/dist/bundles') {
stash name: 'built-mq', includes: 'mq.zip'
archiveArtifacts artifacts: 'mq.zip'
}
dir('mq/main') {
archiveArtifacts artifacts: 'dash-summary.txt'
}
}
}
}
post {
always {
node(null) {
recordIssues tools: [ mavenConsole(), javaDoc() ], enabledForFailure: true
}
}
}
}
stage('sanity') {
stages {
stage('sanity - start and shutdown broker') {
matrix {
axes {
axis {
name 'SANITY_JDK_JENKINS_TOOL'
values 'temurin-jdk21-latest'
}
}
stages {
stage('sanity on specific JDK') {
agent any
options {
skipDefaultCheckout()
}
tools {
jdk "${SANITY_JDK_JENKINS_TOOL}"
}
environment {
BROKER_PORT = """${sh(
returnStdout: true,
script: 'echo $(((EXECUTOR_NUMBER + 1) * 20 + 7676))'
).trim()}"""
}
steps {
echo "Sanity test using ${SANITY_JDK_JENKINS_TOOL}"
dir('distribution') {
deleteDir()
}
dir('distribution') {
unstash 'built-mq'
sh 'unzip -q mq.zip'
dir('mq') {
writeFile file: 'admin.pass', text: 'imq.imqcmd.password=admin'
sh 'nohup bin/imqbrokerd -port ${BROKER_PORT} > broker.log 2>&1 &'
retry(count: 3) {
sleep time: 10, unit: 'SECONDS'
script {
def brokerLogText = readFile(file: 'broker.log')
brokerLogText.matches('(?s)^.*Broker .*:.*ready.*$') || error('Looks like broker did not start in time')
}
}
sh 'java -cp lib/jms.jar:lib/imq.jar:examples/helloworld/helloworldmessage -DHelloWorldMessage.receiveTimeoutMillis=5000 -DimqAddressList=mq://localhost:${BROKER_PORT}/jms HelloWorldMessage > hello.log 2>&1'
script {
sh 'cat hello.log'
def logFileText = readFile(file: 'hello.log')
(logFileText.contains('Sending Message: Hello World')
&& logFileText.contains('Read Message: Hello World')) || error('HelloWorldMessage did not produce expected message')
}
}
}
}
post {
always {
dir('distribution') {
dir('mq') {
sh 'bin/imqcmd -b :${BROKER_PORT} -u admin -f -passfile admin.pass shutdown bkr'
sh 'cat broker.log'
}
}
}
}
}
}
}
}
stage('sanity - run cluster') {
agent any
options {
skipDefaultCheckout()
}
tools {
jdk 'temurin-jdk21-latest'
}
steps {
dir('distribution') {
deleteDir()
}
dir('distribution') {
unstash 'built-mq'
sh 'unzip -q mq.zip'
dir('mq') {
writeFile file: 'admin.pass', text: 'imq.imqcmd.password=admin'
script {
for (brokerId in [ 0, 1, 2 ]) {
sh "nohup bin/imqbrokerd -name broker${brokerId} -port ${7670 + brokerId} -cluster :7670,:7671,:7672 > broker${brokerId}.log 2>&1 &"
retry(count: 3) {
sleep time: 10, unit: 'SECONDS'
script {
def brokerLogText = readFile(file: "broker${brokerId}.log")
brokerLogText.matches('(?s)^.*Broker .*:.*ready.*$') || error('Looks like broker did not start in time')
}
}
}
}
script {
sh 'bin/imqcmd -u admin -passfile admin.pass -b :7670 list bkr > clusterlist.log'
sh 'cat clusterlist.log'
def logFileText = readFile(file: 'clusterlist.log')
(logFileText.contains(':7670 OPERATING')
&& logFileText.contains(':7671 OPERATING')
&& logFileText.contains(':7672 OPERATING')
|| error('Cluster list did not produce expected message'))
}
}
}
}
post {
always {
dir('distribution') {
dir('mq') {
script {
for (brokerId in [ 0, 1, 2 ]) {
sh "bin/imqcmd -b :${7670 + brokerId} -u admin -f -passfile admin.pass shutdown bkr"
sh "cat broker${brokerId}.log"
}
}
}
}
}
}
}
stage('sanity - services') {
stages {
stage('sanity - service: wsjms') {
agent any
options {
skipDefaultCheckout()
}
tools {
jdk 'temurin-jdk21-latest'
}
steps {
dir('distribution') {
deleteDir()
}
dir('distribution') {
unstash 'built-mq'
sh 'unzip -q mq.zip'
dir('mq') {
writeFile file: 'admin.pass', text: 'imq.imqcmd.password=admin'
sh 'nohup bin/imqbrokerd -Dimq.service.activelist=wsjms,admin > broker-wsjms.log 2>&1 &'
retry(count: 3) {
sleep time: 10, unit: 'SECONDS'
script {
def brokerLogText = readFile(file: 'broker-wsjms.log')
brokerLogText.matches('(?s)^.*Broker .*:.*ready.*$') || error('Looks like broker did not start in time')
}
}
sh './bin/imqcmd -u admin -passfile admin.pass query dst -t q -n sanity.test.queue 2>&1 | tee queue.query.1.log || true'
// expected Error while performing this operation on the broker - due to queue not existing yet
sh 'grep -q "Could not locate destination sanity.test.queue" queue.query.1.log'
sh '''
java \
-cp lib/jms.jar:lib/imq.jar:lib/tyrus-standalone-client.jar:examples/jms20/syncqueue \
-DimqAddressList=mqws://localhost:7670/wsjms \
SendObjectMsgsToQueue sanity.test.queue 10 \
'''
sh './bin/imqcmd -u admin -passfile admin.pass query dst -t q -n sanity.test.queue | tee queue.query.2.log'
// expected 10 messages queued
sh 'grep -A 1 "Current Number of Messages" queue.query.2.log | grep -q -E "Actual\\s*10"'
sh '''
java \
-cp lib/jms.jar:lib/imq.jar:lib/tyrus-standalone-client.jar:examples/jms20/syncqueue \
-DimqAddressList=mqws://localhost:7670/wsjms \
SyncQueueConsumer sanity.test.queue 10 \
'''
sh './bin/imqcmd -u admin -passfile admin.pass query dst -t q -n sanity.test.queue | tee queue.query.3.log'
// expected 0 messages queued
sh 'grep -A 1 "Current Number of Messages" queue.query.3.log | grep -q -E "Actual\\s*0"'
}
}
}
post {
always {
dir('distribution') {
dir('mq') {
sh 'bin/imqcmd -u admin -f -passfile admin.pass shutdown bkr'
sh 'cat broker-wsjms.log'
}
}
}
}
}
}
}
stage ('sanity - FS JNDI') {
agent any
options {
skipDefaultCheckout()
}
tools {
jdk 'temurin-jdk21-latest'
}
steps {
dir('distribution') {
deleteDir()
}
dir('distribution') {
unstash 'built-mq'
sh 'unzip -q mq.zip'
dir('mq') {
dir('jndi') {
sh '''
../bin/imqobjmgr \
-j "java.naming.provider.url=file://$(pwd)" \
-j "java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory" \
add \
-t xcf \
-l cn=sanityConnFact \
-o "imqAddressList=mq://localhost:7676/jms"
'''
}
}
}
}
}
stage('sanity - MQ-MQ bridge') {
agent any
options {
skipDefaultCheckout()
}
tools {
jdk 'temurin-jdk21-latest'
}
steps {
dir('distribution') {
deleteDir()
}
dir('distribution') {
unstash 'built-mq'
sh 'unzip -q mq.zip'
writeFile file: 'admin.pass', text: 'imq.imqcmd.password=admin\nimq.bridge.admin.password=admin\nimq.imqbridgemgr.password=admin'
dir('mqvar-7676') {
dir('jndi') {
sh '''
../../mq/bin/imqobjmgr \
add -t xcf -l cn=CF7677 -o "imqAddressList=localhost:7677" \
-j "java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory" \
-j "java.naming.provider.url=file://$(pwd)"
'''
}
sh 'sed "s?file:///tmp/mq/?file://$(pwd)/jndi/?" ../mq/examples/jmsbridge/mqtomq/jmsbridge.xml > jmsbridge.xml'
sh 'cat jmsbridge.xml'
}
dir('mqvar-7677') {
sh 'nohup ../mq/bin/imqbrokerd -port 7677 -varhome $(pwd) > broker-7677.log 2>&1 &'
retry(count: 3) {
sleep time: 10, unit: 'SECONDS'
script {
def brokerLogText = readFile(file: 'broker-7677.log')
brokerLogText.matches('(?s)^.*Broker .*:.*ready.*$') || error('Looks like broker 7677 did not start in time')
}
}
}
dir('mqvar-7676') {
sh '''
nohup ../mq/bin/imqbrokerd \
-Dimq.bridge.enabled=true \
-Dimq.bridge.activelist=mqtomq \
-Dimq.bridge.admin.user=admin \
-Dimq.bridge.mqtomq.type=jms \
-Djava.util.logging.config.file=../mq/examples/jmsbridge/mqtomq/logging.properties \
-Dimq.bridge.mqtomq.xmlurl=file://$(pwd)/jmsbridge.xml \
-port 7676 \
-passfile ../admin.pass \
-varhome $(pwd) > broker-7676.log 2>&1 &'''
retry(count: 3) {
sleep time: 10, unit: 'SECONDS'
script {
def brokerLogText = readFile(file: 'broker-7676.log')
brokerLogText.matches('(?s)^.*Broker .*:.*ready.*$') || error('Looks like broker 7676 did not start in time')
}
}
}
}
dir('distribution') {
sh '''
java \
-cp mq/lib/jms.jar:mq/lib/imq.jar:mq/examples/helloworld/helloworldmessage \
-DimqAddressList=mq://localhost:7676/jms \
-DHelloWorldMessage.queueName=myqueue7676 \
-DHelloWorldMessage.receive=false \
HelloWorldMessage | tee hello-send.log 2>&1
'''
sh 'mq/bin/imqcmd -u admin -passfile admin.pass -b localhost:7676 list dst'
sh 'mq/bin/imqcmd -u admin -passfile admin.pass -b localhost:7677 list dst'
sh '''
java \
-cp mq/lib/jms.jar:mq/lib/imq.jar:mq/examples/helloworld/helloworldmessage \
-DimqAddressList=mq://localhost:7677/jms \
-DHelloWorldMessage.queueName=myqueue7677 \
-DHelloWorldMessage.send=false \
-DHelloWorldMessage.receiveTimeoutMillis=5000 \
HelloWorldMessage | tee hello-receive.log 2>&1
'''
sh 'mq/bin/imqcmd -u admin -passfile admin.pass -b localhost:7677 list dst'
sh 'grep "Read Message: Hello World" hello-receive.log'
}
dir('distribution') {
sh 'mq/bin/imqbridgemgr -passfile admin.pass -u admin list bridge'
sh 'mq/bin/imqbridgemgr -passfile admin.pass -u admin list link -bn mqtomq -ln 7676to7677'
sh 'mq/bin/imqbridgemgr -passfile admin.pass -u admin list link -bn mqtomq'
}
}
post {
always {
dir('distribution') {
dir('mqvar-7676') {
sh '../mq/bin/imqcmd -b :7676 -u admin -f -passfile ../admin.pass shutdown bkr'
sh 'cat broker-7676.log'
}
dir('mqvar-7677') {
sh '../mq/bin/imqcmd -b :7677 -u admin -f -passfile ../admin.pass shutdown bkr'
sh 'cat broker-7677.log'
}
}
}
}
}
}
}
stage('Code Coverage') {
agent any
tools {
jdk 'temurin-jdk21-latest'
}
steps {
sh './mvnw -V -B -P staging -f mq/main -P jacoco clean verify'
jacoco execPattern: '**/**.exec',
classPattern: '**/classes',
sourcePattern: '**/src/main/java',
sourceInclusionPattern: '**/*.java'
}
}
}
}