-
Notifications
You must be signed in to change notification settings - Fork 35
/
Jenkinsfile
297 lines (285 loc) · 11 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
/*
* Copyright (c) 2020-2024 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 -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('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'
}
}
}
}