forked from Axcient/elastio-snap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
199 lines (176 loc) · 5.16 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
#!groovy
@Library('jenkins-utils-lib') _
def artifactoryRoot = "replibit/elastio/"
def supported_fs = [ 'ext2', 'ext3', 'ext4', 'xfs']
def map_rpm_distro = [
"centos7" : "maipo",
"centos8" : "ootpa",
"centos9" : "plow",
]
def map_deb_distro = [
"ubuntu1804" : "bionic-agent",
"ubuntu2004" : "focal-agent",
"ubuntu2204" : "jammy-agent",
"debian10" : "buster-agent",
"debian11" : "bullseye-agent",
"debian12" : "bookworm-agent",
]
def test_disks = [:]
pipeline
{
agent none
options
{
buildDiscarder(logRotator(numToKeepStr: '10'))
timestamps ()
disableConcurrentBuilds abortPrevious: true
timeout(time: 6, unit: 'HOURS')
}
stages
{
stage('Matrix')
{
// Trigger builds only for pull requests and specific branches.
when
{
beforeAgent true
anyOf
{
branch pattern: '^(build|release|develop|master|staging).*', comparator: "REGEXP"
changeRequest()
}
}
matrix
{
axes
{
axis
{
name 'DISTRO'
values 'debian8', 'debian9', 'debian10', 'debian11', 'debian12',
'amazon2', 'amazon2023',
'centos7', 'centos8', 'centos9',
'alma8', 'alma9',
'fedora31', 'fedora32', 'fedora34', 'fedora35', 'fedora36', 'fedora37', 'fedora38',
'ubuntu1804', 'ubuntu2004', 'ubuntu2204'
}
}
agent {
label "${DISTRO}_template_label"
}
stages
{
stage('Publish packages')
{
when { anyOf {
expression { map_deb_distro[env.DISTRO] != null }
expression { map_rpm_distro[env.DISTRO] != null }
} }
steps
{
lock(label: 'elastio-vmx', quantity: 1, resource : null)
{
publishPackage(artifactoryRoot, map_deb_distro[env.DISTRO], map_rpm_distro[env.DISTRO])
}
}
}
stage('Build kernel module')
{
steps
{
script { test_disks[env.DISTRO] = getTestDisks() }
lock(label: 'elastio-vmx', quantity: 1, resource : null)
{
sh "sudo make"
sh "sudo make install"
}
}
}
stage('Run tests (loop device)') { steps { runTests(supported_fs, "") } }
stage('Run tests on LVM (loop device)') { steps { runTests(supported_fs, "--lvm") } }
stage('Run tests on RAID (loop device)') { steps { runTests(supported_fs, "--raid") } }
stage('Run tests (qcow2 disk)') { steps { runTests(supported_fs, "-d ${test_disks[env.DISTRO][0]}1") } }
stage('Run tests on LVM (qcow2 disks)') { steps { runTests(supported_fs, " -d ${test_disks[env.DISTRO][0]} -d ${test_disks[env.DISTRO][1]} --lvm") } }
stage('Run tests on RAID (qcow2 disks)')
{
// An issue is observed in virtio driver whith XFS and kernel 3.16 on Debian 8. It's a known issue, it happens on
// mount of the raid1 device with XFS even if elastio-snap is not loaded. See https://bugzilla.redhat.com/show_bug.cgi?id=1111290
when { expression { env.DISTRO != 'debian8' } }
steps { runTests(supported_fs, " -d ${test_disks[env.DISTRO][0]} -d ${test_disks[env.DISTRO][1]} --raid") }
}
stage('Run tests multipart (qcow2 disks)') { steps { runTests(supported_fs, "-d ${test_disks[env.DISTRO][0]} -t test_multipart") } }
}
}
}
}
}
def runTests(def supported_fs, String args)
{
catchError(stageResult: 'FAILURE')
{
try
{
for (fs in supported_fs)
{
sh "cd tests && sudo ./elio-test.sh -f ${fs} ${args}"
}
}
catch(e)
{
sh "cat tests/dmesg.log; sudo dmesg -c; sudo lsmod; sudo rmmod elastio_snap; exit 0"
throw e
}
}
}
def pkgMapBranches(String repo)
{
return [
'^develop.*': repo + '-dev',
]
}
def publishDebPackage(String artifactoryRoot, String deb)
{
def outDir = "build_results"
sh """
sudo make deb RELEASE_NUMBER=${env.BUILD_NUMBER}~`lsb_release -s -c`
mkdir -p ${outDir} && sudo mv pkgbuild/DEBS/all/*.deb ${outDir} && sudo mv pkgbuild/DEBS/amd64/*.deb ${outDir}
"""
def nameDistro = deb.replace("-agent", "").capitalize()
deployDeb dir: outDir, map_repo: pkgMapBranches(deb), user: "rbrepo", agent: "rep-agent"
uploadArtifacts files: outDir + "/*.deb", dst: "${artifactoryRoot}", postfix: nameDistro, shortnames: true, retention : true
}
def publishRpmPackage(String artifactoryRoot, String rpm)
{
def outDir = "build_results"
sh """
sudo make rpm RELEASE_NUMBER=${env.BUILD_NUMBER}
mkdir -p ${outDir} && sudo mv pkgbuild/RPMS/noarch/*.rpm ${outDir} && sudo mv pkgbuild/RPMS/x86_64/*.rpm ${outDir}
"""
def nameDistro = rpm.replace("-agent", "").capitalize()
deployRpm dir: outDir, map_repo: pkgMapBranches(rpm), user: "rbrepo", agent: "agent"
uploadArtifacts files: outDir + "/*.rpm", dst: "${artifactoryRoot}", postfix: nameDistro, shortnames: true, retention : true
}
def publishPackage(String artifactoryRoot, String deb, String rpm)
{
catchError(stageResult: 'FAILURE')
{
if (deb != null)
{
publishDebPackage(artifactoryRoot, deb)
}
else if (rpm != null)
{
publishRpmPackage(artifactoryRoot, rpm)
}
}
}
def getTestDisks()
{
// All nodes distro images has two 2GiB disks for tests.
// This code retrieve actual disk names
sh "lsblk -f"
return sh (
script: "sudo fdisk -l | grep 'Disk ' | grep ' 2147483648 bytes' | awk '{print \$2}' | sed 's/://'",
returnStdout: true
).split('\n')
}