blob: 62745fc72520047f6d25d5375f25c3ef71699d09 [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
Владислав Наумов81777472021-03-09 15:14:27 +040035 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
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
Владислав Наумов44c64b72020-12-04 20:22:53 +010051 def seedMacOs = env.SEED_MACOS ? env.SEED_MACOS.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020052 def deployChild = env.DEPLOY_CHILD_CLUSTER ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false
53 def upgradeChild = env.UPGRADE_CHILD_CLUSTER ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false
Владислав Наумов0dc99252020-11-13 13:30:48 +010054 def attachBYO = env.ATTACH_BYO ? env.ATTACH_BYO.toBoolean() : false
Владислав Наумовcdbd84e2020-12-01 16:51:09 +010055 def upgradeBYO = env.UPGRADE_BYO ? env.UPGRADE_BYO.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020056 def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
57 def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
58 def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
59 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
60 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020061 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
62 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
63 enabled: false,
64 managementLocation: '',
65 regionLocation: '',
66 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020067
Владислав Наумовb8305e22021-02-10 17:23:12 +010068 // proxy customization
69 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020070 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
71 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020072 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010073 ]
74
Владислав Наумов4eb1da32020-08-31 14:45:16 +020075 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020076 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +020077 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +020078 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +040079 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +020080 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +030081 def enableBMDemo = true
vnaumov33747e12020-05-04 17:35:20 +020082
Владислав Наумов6c2afff2020-06-05 12:54:53 +020083 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +010084 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
85 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +020086 common.warningMsg('Forced running offline mgmt deployment, some provider CDN regions for mgmt deployment may be set to *public-ci* to verify proxy configuration')
Владислав Наумовb8305e22021-02-10 17:23:12 +010087 }
Владислав Наумов44c64b72020-12-04 20:22:53 +010088 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
89 seedMacOs = true
90 }
vnaumov33747e12020-05-04 17:35:20 +020091 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) {
92 deployChild = true
93 }
94 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
95 deployChild = true
96 upgradeChild = true
97 }
Владислав Наумов0dc99252020-11-13 13:30:48 +010098 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
99 attachBYO = true
100 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100101 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
102 attachBYO = true
103 upgradeBYO = true
104 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400105 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200106 upgradeMgmt = true
107 }
108 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
109 runUie2e = true
110 }
111 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
112 runMgmtConformance = true
113 }
114 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
115 runChildConformance = true
116 deployChild = true
117 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200118 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
119 proxyConfig['childOffline'] = true
120 deployChild = true
121 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200122 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
123 proxyConfig['childOffline'] = true
124 proxyConfig['childProxy'] = true
125 deployChild = true
126 }
vnaumov33747e12020-05-04 17:35:20 +0200127 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
128 fetchServiceBinaries = true
129 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200130 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400131 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200132 common.warningMsg('Forced running child cluster deployment on EQUINIX METAL provider based on AWS management cluster, triggered on patchset using custom keyword: \'[equinix-on-aws]\' ')
eromanovadf247c32020-12-25 15:44:13 +0400133 }
134 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ || attachBYO || upgradeBYO || seedMacOs || equinixOnAwsDemo) {
vnaumov33747e12020-05-04 17:35:20 +0200135 awsOnDemandDemo = true
eromanovadf247c32020-12-25 15:44:13 +0400136 if (attachBYO || upgradeBYO || seedMacOs || equinixOnAwsDemo) {
Владислав Наумов44c64b72020-12-04 20:22:53 +0100137 common.warningMsg('Forced running additional kaas deployment with AWS provider, due applied trigger cross dependencies, follow docs to clarify info')
Владислав Наумов0dc99252020-11-13 13:30:48 +0100138 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200139 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200140 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200141 equinixOnDemandDemo = true
142 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200143 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
144 enableOSDemo = false
145 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200146 }
147
azvyagintsev1761bdc2020-09-04 17:24:12 +0300148 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
149 enableBMDemo = false
150 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
151 }
152
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400153 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
154 enableVsphereDemo = false
155 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
156 }
157
vnaumov33747e12020-05-04 17:35:20 +0200158 // TODO (vnaumov) remove below condition after moving all releases to UCP
159 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
160 if (ucpChildMatches.size() > 0) {
161 deployChild = true
162 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
163
164 // TODO(vnaumov) delete after ucp upgrades support
165 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
166 upgradeChild = false
167 }
168
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200169 // multiregional tests
170 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
171 if (multiRegionalMatches.size() > 0) {
172 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
173 }
174 switch (multiregionalMappings['managementLocation']) {
175 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100176 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200177 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100178
179 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
180 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
181 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200182 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200183 case 'os':
184 if (enableOSDemo == false) {
185 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
186 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200187 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200188 case 'equinix':
189 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
190 equinixOnDemandDemo = true
191 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200192 }
193
Владислав Наумовb8305e22021-02-10 17:23:12 +0100194 // CDN configuration
195 def cdnConfig = [
196 mgmt: [
197 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200198 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100199 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200200 equinix: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200201 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100202 ]
203
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100204 // calculate weight of current demo run to manage lockable resources
205 def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1
206
vnaumov33747e12020-05-04 17:35:20 +0200207 common.infoMsg("""
Владислав Наумовb8305e22021-02-10 17:23:12 +0100208 CDN deployment configuration: ${cdnConfig}
209 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100210 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200211 Child cluster deployment scheduled: ${deployChild}
212 Child cluster release upgrade scheduled: ${upgradeChild}
213 Child conformance testing scheduled: ${runChildConformance}
Владислав Наумов0dc99252020-11-13 13:30:48 +0100214 BYO cluster attachment scheduled: ${attachBYO}
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100215 Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
vnaumov33747e12020-05-04 17:35:20 +0200216 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
217 Mgmt conformance testing scheduled: ${runMgmtConformance}
218 Mgmt UI e2e testing scheduled: ${runUie2e}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200219 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200220 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200221 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400222 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200223 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300224 BM provider deployment scheduled: ${enableBMDemo}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200225 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200226 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100227 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Владислав Наумов81777472021-03-09 15:14:27 +0400228 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200229 return [
Владислав Наумовb8305e22021-02-10 17:23:12 +0100230 cdnConfig : cdnConfig,
231 proxyConfig : proxyConfig,
Владислав Наумов44c64b72020-12-04 20:22:53 +0100232 useMacOsSeedNode : seedMacOs,
azvyagintseva12230a2020-06-05 13:24:06 +0300233 deployChildEnabled : deployChild,
234 upgradeChildEnabled : upgradeChild,
235 runChildConformanceEnabled : runChildConformance,
Владислав Наумов0dc99252020-11-13 13:30:48 +0100236 attachBYOEnabled : attachBYO,
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100237 upgradeBYOEnabled : upgradeBYO,
azvyagintseva12230a2020-06-05 13:24:06 +0300238 upgradeMgmtEnabled : upgradeMgmt,
239 runUie2eEnabled : runUie2e,
240 runMgmtConformanceEnabled : runMgmtConformance,
vnaumov33747e12020-05-04 17:35:20 +0200241 fetchServiceBinariesEnabled: fetchServiceBinaries,
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200242 awsOnDemandDemoEnabled : awsOnDemandDemo,
Владислав Наумовe021b022021-05-06 11:26:38 +0200243 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
Владислав Наумовf1665b52021-05-13 10:51:17 +0200244 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400245 vsphereDemoEnabled : enableVsphereDemo,
246 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
azvyagintsev1761bdc2020-09-04 17:24:12 +0300247 bmDemoEnabled : enableBMDemo,
Владислав Наумовf793fe32020-09-11 15:19:19 +0200248 osDemoEnabled : enableOSDemo,
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100249 multiregionalConfiguration : multiregionalMappings,
250 demoWeight : demoWeight]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200251}
252
253/**
254 * Determine management and regional setup for demo workflow scenario
255 *
256 *
257 * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]`
258 or Jenkins environment string variable in form like 'aws,os'
259 * @return (map)[
260 enabled: (bool),
261 * managementLocation: (string), //aws,os
262 * regionLocation: (string), //aws,os
263 * ]
264 */
265def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200266 def common = new com.mirantis.mk.Common()
Владислав Наумов5be02942021-05-13 12:34:37 +0200267 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix']
268 def supportedRegionalProviders = ['os', 'vsphere', 'equinix']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200269
270 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200271 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200272 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
273 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
274 } else {
275 common.infoMsg('Multiregion definition configured via environment variable')
276 clusterTypes = keyword.trim().split(',')
277 }
278
279 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100280 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200281 }
282
Владислав Наумовf793fe32020-09-11 15:19:19 +0200283 def desiredManagementProvider = clusterTypes[0].trim()
284 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200285 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
286 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200287 management providers list - ${supportedManagementProviders}
288 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200289 }
290
291 return [
292 enabled: true,
293 managementLocation: desiredManagementProvider,
294 regionLocation: desiredRegionalProvider,
295 ]
vnaumov33747e12020-05-04 17:35:20 +0200296}
297
298/**
299 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
300
Владислав Наумов81777472021-03-09 15:14:27 +0400301 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
vnaumov33747e12020-05-04 17:35:20 +0200302 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
303 * Example scheme:
304 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
305 * manage refspecs through Jenkins Job Parameters
306 *
azvyagintseva12230a2020-06-05 13:24:06 +0300307 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200308 * siPipelines: (string) final refspec for si-pipelines
309 * ]
310 */
311def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200312 def common = new com.mirantis.mk.Common()
313
vnaumov33747e12020-05-04 17:35:20 +0200314 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200315 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
316 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200317 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
318 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200319 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200320
321 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
322 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
323
324 if (siTestMatches.size() > 0) {
325 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400326 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200327 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200328 }
329 if (siPipelinesMatches.size() > 0) {
330 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
331 }
332
333 common.infoMsg("""
334 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
335 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200336 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400337 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200338 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200339}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200340
Владислав Наумов9080f372020-06-08 13:57:16 +0200341/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200342 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200343 * @param configurationFile (str) path to configuration file in yaml format
344 *
345 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
346 * ]
347 */
348def parseKaaSComponentCIParameters(configurationFile){
349 def common = new com.mirantis.mk.Common()
350 def ciConfig = readYaml file: configurationFile
351 def ciSpec = [
352 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
353 ]
354
355 if (ciConfig.containsKey('si-tests-feature-flags')) {
356 common.infoMsg("""SI tests feature flags customization detected,
357 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
358
359 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
360 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200361
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200362 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200363 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
364 }
365
366 common.infoMsg("""Additional ci configuration parsed successfully:
367 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
368 return ciSpec
369}
370
371/**
372 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200373
Владислав Наумов81777472021-03-09 15:14:27 +0400374 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
Владислав Наумов9080f372020-06-08 13:57:16 +0200375 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
376 * Example scheme:
377 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
378 * manage refspecs through Jenkins Job Parameters
379 *
380 * @return (map)[ core: (string) final refspec for kaas/core
381 * corePipelines: (string) final refspec for pipelines in kaas/core
382 * ]
383 */
384def checkCustomCoreRefspec() {
385 def common = new com.mirantis.mk.Common()
386
387 // Available triggers and its sane defaults
388 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
389 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
390 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
391 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
392
393 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
394 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
395
396 if (coreMatches.size() > 0) {
397 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
398 }
399 if (corePipelinesMatches.size() > 0) {
400 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
401 }
402
403 common.infoMsg("""
404 kaas/core will be fetched from: ${coreRefspec}
405 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400406 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200407 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
408}
409
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200410
411/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200412 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
413 * needed to forward inside kaas core set of jobs
414 *
415 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
416 * @return (list)[ string(name: '', value: ''),
417 * ]
418 */
419def generateKaaSVarsFromContext(context) {
420 def common = new com.mirantis.mk.Common()
421 def parameters = []
422 def config = readYaml text: context
423
424 config.each { k,v ->
425 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
426 parameters.add(string(name: k, value: v))
427 }
428
429 return parameters
430}
431
432/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200433 * Trigger KaaS demo jobs based on AWS/OS providers with customized test suite, parsed from external sources (gerrit commit/jj vars)
Владислав Наумов81777472021-03-09 15:14:27 +0400434 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200435 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
436 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200437 * @param: component (string) component name [iam, lcm, stacklight]
438 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
439 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200440 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200441def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200442 def common = new com.mirantis.mk.Common()
443 // Determine if custom trigger keywords forwarded from gerrit
444 def triggers = checkDeploymentTestSuite()
445 // Determine SI refspecs
446 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200447 // Determine Core refspecs
448 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200449
Владислав Наумов418042b2020-07-09 18:31:10 +0200450 // Determine component repo ci configuration
451 def ciSpec = [:]
452 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
453 if (fileExists(configurationFile)) {
454 common.infoMsg('Component CI configuration file detected, parsing...')
455 ciSpec = parseKaaSComponentCIParameters(configurationFile)
456 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
457 } else {
458 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200459 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200460 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
461 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200462 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200463 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200464 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200465 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
466 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200467 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200468 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200469 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
470 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200471 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200472 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100473 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200474 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200475 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100476 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200477 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200478 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200479 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
480 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
481 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100482 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100483 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200484 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400485 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200486 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
eromanovad3397512021-04-01 20:19:19 +0400487 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200488 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200489
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200490 // customize multiregional demo
491 if (triggers.multiregionalConfiguration.enabled) {
492 parameters.add(string(name: 'MULTIREGION_SETUP',
493 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
494 ))
495 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200496
Владислав Наумов92288d92020-07-13 18:36:21 +0200497 // Determine component team custom context
498 if (coreContext != '') {
499 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
500 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200501 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200502 }
503
Владислав Наумовe021b022021-05-06 11:26:38 +0200504 if (triggers.awsOnDemandDemoEnabled || triggers.equinixOnDemandDemoEnabled) {
505 common.infoMsg('Public provider demo triggered, need to sync artifacts in the public-ci cdn..')
506 switch (component) {
507 case 'iam':
508 build job: 'cdn-binary-dev-replication-iam', propagate: true, wait: true
509 break
510 case 'lcm':
511 build job: 'cdn-binary-dev-replication-lcm', propagate: true, wait: true
512 break
513 }
514 }
515
Владислав Наумовaa430612020-06-08 17:18:31 +0200516 def jobResults = []
Vladislav Naumov5313a202021-04-07 17:13:39 +0000517 if (triggers.osDemoEnabled) {
518 jobs["kaas-core-openstack-patched-${component}"] = {
519 try {
520 common.infoMsg('Deploy: patched KaaS demo with Openstack provider')
521 os_job_info = build job: "kaas-testing-core-openstack-workflow-${component}", parameters: parameters, wait: true
522 def build_description = os_job_info.getDescription()
523 def build_result = os_job_info.getResult()
524 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200525
Vladislav Naumov5313a202021-04-07 17:13:39 +0000526 if (build_description) {
527 currentBuild.description += build_description
528 }
529 } finally {
530 common.infoMsg('Patched KaaS demo with Openstack provider finished')
Владислав Наумовf86b1112020-06-09 14:04:48 +0200531 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200532 }
533 }
534 if (triggers.awsOnDemandDemoEnabled) {
535 jobs["kaas-core-aws-patched-${component}"] = {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200536 try {
537 common.infoMsg('Deploy: patched KaaS demo with AWS provider')
Владислав Наумов4aa112d2020-06-16 18:52:21 +0200538 aws_job_info = build job: "kaas-testing-core-aws-workflow-${component}", parameters: parameters, wait: true
539 def build_description = aws_job_info.getDescription()
Владислав Наумовd044e842020-06-17 15:33:43 +0200540 def build_result = aws_job_info.getResult()
541 jobResults.add(build_result)
542
Владислав Наумовf86b1112020-06-09 14:04:48 +0200543 if (build_description) {
544 currentBuild.description += build_description
545 }
546 } finally {
Владислав Наумов6d741fa2020-06-17 17:35:43 +0200547 common.infoMsg('Patched KaaS demo with AWS provider finished')
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200548 }
549 }
550 }
Владислав Наумовe021b022021-05-06 11:26:38 +0200551 if (triggers.equinixOnDemandDemoEnabled) {
552 jobs["kaas-core-equinix-patched-${component}"] = {
553 try {
554 common.infoMsg('Deploy: patched KaaS demo with Equinix provider')
555 equinix_job_info = build job: "kaas-testing-core-equinix-workflow-${component}", parameters: parameters, wait: true
556 def build_description = equinix_job_info.getDescription()
557 def build_result = equinix_job_info.getResult()
558 jobResults.add(build_result)
559
560 if (build_description) {
561 currentBuild.description += build_description
562 }
563 } finally {
564 common.infoMsg('Patched KaaS demo with Equinix provider finished')
565 }
566 }
567 }
Vladislav Naumov5313a202021-04-07 17:13:39 +0000568 if (triggers.vsphereDemoEnabled) {
569 jobs["kaas-core-vsphere-patched-${component}"] = {
570 try {
571 common.infoMsg('Deploy: patched KaaS demo with VSPHERE provider')
572 vsphere_job_info = build job: "kaas-testing-core-vsphere-workflow-${component}", parameters: parameters, wait: true
573 def build_description = vsphere_job_info.getDescription()
574 def build_result = vsphere_job_info.getResult()
575 jobResults.add(build_result)
576
577 if (build_description) {
578 currentBuild.description += build_description
579 }
580 } finally {
581 common.infoMsg('Patched KaaS demo with VSPHERE provider finished')
582 }
583 }
584 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200585
586 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400587 if (jobs.size() == 0) {
588 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
589 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200590 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
591 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200592
593 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200594 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200595 currentBuild.result = 'FAILURE'
596 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200597}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200598
599