blob: d37c5f2b9daf9612ae42f960d659338918d204e9 [file] [log] [blame]
vnaumov33747e12020-05-04 17:35:20 +02001package com.mirantis.mk
vnaumov33747e12020-05-04 17:35:20 +02002
3/**
4 *
5 * KaaS Component Testing Utilities
6 *
7 */
8
Владислав Наумовe5345812020-08-12 16:30:20 +02009/**
10 * Check KaaS Core CICD feature flags
11 * such triggers can be used in case of switching between pipelines,
12 * conditions inside pipelines to reduce dependency on jenkins job builder and jenkins job templates itself
13 *
14 * @return (map)[
15 * ffNameEnabled: (bool) True/False
16 * ]
17 */
18def checkCoreCIFeatureFlags() {
19 def common = new com.mirantis.mk.Common()
20 def ff = [
21 build_artifacts_upgrade: false,
22 ]
23
24 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
25 if (commitMsg ==~ /(?s).*\[ci-build-artifacts-upgrade\].*/) {
26 ff['build_artifacts_upgrade'] = true
27 }
28
29 common.infoMsg("Core ci feature flags status: ${ff}")
30 return ff
31}
vnaumov33747e12020-05-04 17:35:20 +020032
33/**
azvyagintseva12230a2020-06-05 13:24:06 +030034 * Determine scope of test suite against per-commit KaaS deployment based on keywords
Владислав Наумов5a523ef2020-07-29 13:33:38 +020035 * Keyword list: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/
azvyagintseva12230a2020-06-05 13:24:06 +030036 *
37 * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs
38 * Example scheme:
Владислав Наумовe5345812020-08-12 16:30:20 +020039 * New CR pushed in kubernetes/lcm-ansible -> parsing it'cs commit body and combine test-suite -> trigger deployment jobs from kaas/core
azvyagintseva12230a2020-06-05 13:24:06 +030040 * manage test-suite through Jenkins Job Parameters
41 *
Владислав Наумов6c2afff2020-06-05 12:54:53 +020042 * @return (map)[
43 * deployChildEnabled: (bool) True if need to deploy child cluster during demo-run
44 * runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run
azvyagintseva12230a2020-06-05 13:24:06 +030045 * ]
46 */
vnaumov33747e12020-05-04 17:35:20 +020047def checkDeploymentTestSuite() {
vnaumovbdb90222020-05-04 18:25:50 +020048 def common = new com.mirantis.mk.Common()
49
vnaumov33747e12020-05-04 17:35:20 +020050 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +020051 def deployChild = env.DEPLOY_CHILD_CLUSTER ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false
52 def upgradeChild = env.UPGRADE_CHILD_CLUSTER ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false
53 def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
54 def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
55 def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
56 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
57 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020058 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
59 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
60 enabled: false,
61 managementLocation: '',
62 regionLocation: '',
63 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020064
65 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020066 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумов4eb1da32020-08-31 14:45:16 +020067 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +030068 def enableBMDemo = true
vnaumov33747e12020-05-04 17:35:20 +020069
Владислав Наумов6c2afff2020-06-05 12:54:53 +020070 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +020071 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) {
72 deployChild = true
73 }
74 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
75 deployChild = true
76 upgradeChild = true
77 }
78 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
79 upgradeMgmt = true
80 }
81 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
82 runUie2e = true
83 }
84 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
85 runMgmtConformance = true
86 }
87 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
88 runChildConformance = true
89 deployChild = true
90 }
91 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
92 fetchServiceBinaries = true
93 }
94 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/) {
95 awsOnDemandDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +020096 common.warningMsg('Forced running additional kaas deployment with AWS provider, triggered on patchset using custom keyword: \'[aws-demo]\' ')
97 }
98 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
99 enableOSDemo = false
100 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200101 }
102
azvyagintsev1761bdc2020-09-04 17:24:12 +0300103 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
104 enableBMDemo = false
105 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
106 }
107
vnaumov33747e12020-05-04 17:35:20 +0200108 // TODO (vnaumov) remove below condition after moving all releases to UCP
109 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
110 if (ucpChildMatches.size() > 0) {
111 deployChild = true
112 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
113
114 // TODO(vnaumov) delete after ucp upgrades support
115 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
116 upgradeChild = false
117 }
118
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200119 // multiregional tests
120 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
121 if (multiRegionalMatches.size() > 0) {
122 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
123 }
124 switch (multiregionalMappings['managementLocation']) {
125 case 'aws':
126 awsOnDemandDemo = true
127 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200128 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200129 case 'os':
130 if (enableOSDemo == false) {
131 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
132 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200133 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200134 }
135
vnaumov33747e12020-05-04 17:35:20 +0200136 common.infoMsg("""
137 Child cluster deployment scheduled: ${deployChild}
138 Child cluster release upgrade scheduled: ${upgradeChild}
139 Child conformance testing scheduled: ${runChildConformance}
140 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
141 Mgmt conformance testing scheduled: ${runMgmtConformance}
142 Mgmt UI e2e testing scheduled: ${runUie2e}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200143 AWS provider deployment scheduled: ${awsOnDemandDemo}
144 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300145 BM provider deployment scheduled: ${enableBMDemo}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200146 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200147 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов5a523ef2020-07-29 13:33:38 +0200148 Triggers: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/""")
vnaumov33747e12020-05-04 17:35:20 +0200149 return [
azvyagintseva12230a2020-06-05 13:24:06 +0300150 deployChildEnabled : deployChild,
151 upgradeChildEnabled : upgradeChild,
152 runChildConformanceEnabled : runChildConformance,
153 upgradeMgmtEnabled : upgradeMgmt,
154 runUie2eEnabled : runUie2e,
155 runMgmtConformanceEnabled : runMgmtConformance,
vnaumov33747e12020-05-04 17:35:20 +0200156 fetchServiceBinariesEnabled: fetchServiceBinaries,
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200157 awsOnDemandDemoEnabled : awsOnDemandDemo,
azvyagintsev1761bdc2020-09-04 17:24:12 +0300158 bmDemoEnabled : enableBMDemo,
Владислав Наумовf793fe32020-09-11 15:19:19 +0200159 osDemoEnabled : enableOSDemo,
160 multiregionalConfiguration : multiregionalMappings]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200161}
162
163/**
164 * Determine management and regional setup for demo workflow scenario
165 *
166 *
167 * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]`
168 or Jenkins environment string variable in form like 'aws,os'
169 * @return (map)[
170 enabled: (bool),
171 * managementLocation: (string), //aws,os
172 * regionLocation: (string), //aws,os
173 * ]
174 */
175def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200176 def common = new com.mirantis.mk.Common()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200177 def supportedManagementProviders = ['os', 'aws']
178 def supportedRegionalProviders = ['os']
179
180 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200181 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200182 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
183 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
184 } else {
185 common.infoMsg('Multiregion definition configured via environment variable')
186 clusterTypes = keyword.trim().split(',')
187 }
188
189 if (clusterTypes.size() != 2) {
190 error('Incorrect regions definiton, valid scheme: [miltiregion ${management}, ${region}]')
191 }
192
Владислав Наумовf793fe32020-09-11 15:19:19 +0200193 def desiredManagementProvider = clusterTypes[0].trim()
194 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200195 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
196 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200197 management providers list - ${supportedManagementProviders}
198 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200199 }
200
201 return [
202 enabled: true,
203 managementLocation: desiredManagementProvider,
204 regionLocation: desiredRegionalProvider,
205 ]
vnaumov33747e12020-05-04 17:35:20 +0200206}
207
208/**
209 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
210
Владислав Наумов5a523ef2020-07-29 13:33:38 +0200211 * Keyword list: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/
vnaumov33747e12020-05-04 17:35:20 +0200212 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
213 * Example scheme:
214 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
215 * manage refspecs through Jenkins Job Parameters
216 *
azvyagintseva12230a2020-06-05 13:24:06 +0300217 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200218 * siPipelines: (string) final refspec for si-pipelines
219 * ]
220 */
221def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200222 def common = new com.mirantis.mk.Common()
223
vnaumov33747e12020-05-04 17:35:20 +0200224 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200225 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
226 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200227 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
228 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200229 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200230
231 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
232 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
233
234 if (siTestMatches.size() > 0) {
235 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов2db15e22020-07-14 12:29:22 +0200236 siTestsDockerImage = "docker-dev-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
237 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200238 }
239 if (siPipelinesMatches.size() > 0) {
240 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
241 }
242
243 common.infoMsg("""
244 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
245 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200246 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов5a523ef2020-07-29 13:33:38 +0200247 Keywords: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200248 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200249}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200250
Владислав Наумов9080f372020-06-08 13:57:16 +0200251/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200252 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200253 * @param configurationFile (str) path to configuration file in yaml format
254 *
255 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
256 * ]
257 */
258def parseKaaSComponentCIParameters(configurationFile){
259 def common = new com.mirantis.mk.Common()
260 def ciConfig = readYaml file: configurationFile
261 def ciSpec = [
262 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
263 ]
264
265 if (ciConfig.containsKey('si-tests-feature-flags')) {
266 common.infoMsg("""SI tests feature flags customization detected,
267 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
268
269 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
270 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200271
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200272 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200273 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
274 }
275
276 common.infoMsg("""Additional ci configuration parsed successfully:
277 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
278 return ciSpec
279}
280
281/**
282 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200283
Владислав Наумов5a523ef2020-07-29 13:33:38 +0200284 * Keyword list: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/
Владислав Наумов9080f372020-06-08 13:57:16 +0200285 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
286 * Example scheme:
287 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
288 * manage refspecs through Jenkins Job Parameters
289 *
290 * @return (map)[ core: (string) final refspec for kaas/core
291 * corePipelines: (string) final refspec for pipelines in kaas/core
292 * ]
293 */
294def checkCustomCoreRefspec() {
295 def common = new com.mirantis.mk.Common()
296
297 // Available triggers and its sane defaults
298 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
299 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
300 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
301 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
302
303 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
304 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
305
306 if (coreMatches.size() > 0) {
307 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
308 }
309 if (corePipelinesMatches.size() > 0) {
310 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
311 }
312
313 common.infoMsg("""
314 kaas/core will be fetched from: ${coreRefspec}
315 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов5a523ef2020-07-29 13:33:38 +0200316 Keywords: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200317 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
318}
319
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200320
321/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200322 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
323 * needed to forward inside kaas core set of jobs
324 *
325 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
326 * @return (list)[ string(name: '', value: ''),
327 * ]
328 */
329def generateKaaSVarsFromContext(context) {
330 def common = new com.mirantis.mk.Common()
331 def parameters = []
332 def config = readYaml text: context
333
334 config.each { k,v ->
335 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
336 parameters.add(string(name: k, value: v))
337 }
338
339 return parameters
340}
341
342/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200343 * Trigger KaaS demo jobs based on AWS/OS providers with customized test suite, parsed from external sources (gerrit commit/jj vars)
Владислав Наумов5a523ef2020-07-29 13:33:38 +0200344 * Keyword list: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200345 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
346 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200347 * @param: component (string) component name [iam, lcm, stacklight]
348 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
349 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200350 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200351def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200352 def common = new com.mirantis.mk.Common()
353 // Determine if custom trigger keywords forwarded from gerrit
354 def triggers = checkDeploymentTestSuite()
355 // Determine SI refspecs
356 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200357 // Determine Core refspecs
358 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200359
Владислав Наумов418042b2020-07-09 18:31:10 +0200360 // Determine component repo ci configuration
361 def ciSpec = [:]
362 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
363 if (fileExists(configurationFile)) {
364 common.infoMsg('Component CI configuration file detected, parsing...')
365 ciSpec = parseKaaSComponentCIParameters(configurationFile)
366 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
367 } else {
368 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200369 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200370 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
371 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200372 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200373 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200374 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200375 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
376 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200377 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200378 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200379 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
380 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200381 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200382 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Владислав Наумов080d9412020-07-29 13:05:14 +0200383 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200384 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200385 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
386 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
387 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
388 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Владислав Наумов905dd362020-06-08 16:37:01 +0200389 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200390 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200391
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200392 // customize multiregional demo
393 if (triggers.multiregionalConfiguration.enabled) {
394 parameters.add(string(name: 'MULTIREGION_SETUP',
395 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
396 ))
397 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200398
Владислав Наумов92288d92020-07-13 18:36:21 +0200399 // Determine component team custom context
400 if (coreContext != '') {
401 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
402 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200403 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200404 }
405
Владислав Наумовaa430612020-06-08 17:18:31 +0200406 def jobResults = []
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200407 jobs["kaas-core-openstack-patched-${component}"] = {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200408 try {
409 common.infoMsg('Deploy: patched KaaS demo with Openstack provider')
Владислав Наумов4aa112d2020-06-16 18:52:21 +0200410 os_job_info = build job: "kaas-testing-core-openstack-workflow-${component}", parameters: parameters, wait: true
411 def build_description = os_job_info.getDescription()
Владислав Наумовd044e842020-06-17 15:33:43 +0200412 def build_result = os_job_info.getResult()
413 jobResults.add(build_result)
414
Владислав Наумовf86b1112020-06-09 14:04:48 +0200415 if (build_description) {
416 currentBuild.description += build_description
417 }
418 } finally {
Владислав Наумов6d741fa2020-06-17 17:35:43 +0200419 common.infoMsg('Patched KaaS demo with Openstack provider finished')
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200420 }
421 }
422 if (triggers.awsOnDemandDemoEnabled) {
Владислав Наумов59281952020-07-29 16:43:49 +0200423 common.infoMsg('AWS demo triggered, need to sync artifacts in the public-ci cdn..')
424 switch (component) {
425 case 'iam':
426 build job: 'cdn-binary-dev-replication-iam', propagate: true, wait: true
427 break
428 case 'lcm':
429 build job: 'cdn-binary-dev-replication-lcm', propagate: true, wait: true
430 break
431 }
432
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200433 jobs["kaas-core-aws-patched-${component}"] = {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200434 try {
435 common.infoMsg('Deploy: patched KaaS demo with AWS provider')
Владислав Наумов4aa112d2020-06-16 18:52:21 +0200436 aws_job_info = build job: "kaas-testing-core-aws-workflow-${component}", parameters: parameters, wait: true
437 def build_description = aws_job_info.getDescription()
Владислав Наумовd044e842020-06-17 15:33:43 +0200438 def build_result = aws_job_info.getResult()
439 jobResults.add(build_result)
440
Владислав Наумовf86b1112020-06-09 14:04:48 +0200441 if (build_description) {
442 currentBuild.description += build_description
443 }
444 } finally {
Владислав Наумов6d741fa2020-06-17 17:35:43 +0200445 common.infoMsg('Patched KaaS demo with AWS provider finished')
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200446 }
447 }
448 }
449
450 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
451 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
452 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200453
454 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200455 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200456 currentBuild.result = 'FAILURE'
457 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200458}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200459
460