blob: a2e65f2b1477064cd3c2d3f7a5204d1f206e707b [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
Mikhail Ivanov74504372021-05-21 17:01:06 +040054 def customChildRelease = env.KAAS_CHILD_CLUSTER_RELEASE_NAME ? env.KAAS_CHILD_CLUSTER_RELEASE_NAME : ''
Владислав Наумов0dc99252020-11-13 13:30:48 +010055 def attachBYO = env.ATTACH_BYO ? env.ATTACH_BYO.toBoolean() : false
Владислав Наумовcdbd84e2020-12-01 16:51:09 +010056 def upgradeBYO = env.UPGRADE_BYO ? env.UPGRADE_BYO.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020057 def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +040058 def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020059 def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
60 def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
Владислав Наумов9cec55d2021-08-03 15:00:59 +020061 def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020062 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
63 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020064 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
65 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
66 enabled: false,
67 managementLocation: '',
68 regionLocation: '',
69 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020070
Владислав Наумовb8305e22021-02-10 17:23:12 +010071 // proxy customization
72 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020073 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
74 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020075 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010076 ]
77
Владислав Наумов4eb1da32020-08-31 14:45:16 +020078 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020079 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +020080 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +020081 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +020082 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +020083 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +040084 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +020085 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +030086 def enableBMDemo = true
vnaumov33747e12020-05-04 17:35:20 +020087
Владислав Наумов6c2afff2020-06-05 12:54:53 +020088 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +010089 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
90 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +020091 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 +010092 }
Владислав Наумов44c64b72020-12-04 20:22:53 +010093 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
94 seedMacOs = true
95 }
vnaumov33747e12020-05-04 17:35:20 +020096 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) {
97 deployChild = true
98 }
99 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
100 deployChild = true
101 upgradeChild = true
102 }
Mikhail Ivanov76d69952021-06-04 16:06:45 +0400103 def deployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
Mikhail Ivanov74504372021-05-21 17:01:06 +0400104 if (deployMatches.size() > 0) {
105 // override child version when it set explicitly
106 deployChild = true
Mikhail Ivanoved543492021-05-24 16:26:55 +0400107 customChildRelease = deployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400108 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
109 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100110 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
111 attachBYO = true
112 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100113 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
114 attachBYO = true
115 upgradeBYO = true
116 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400117 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200118 upgradeMgmt = true
119 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400120 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
121 enableLMALogging = true
122 }
vnaumov33747e12020-05-04 17:35:20 +0200123 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
124 runUie2e = true
125 }
126 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
127 runMgmtConformance = true
128 }
129 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
130 runChildConformance = true
131 deployChild = true
132 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200133 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
134 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400135 enableLMALogging = true
136 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400137 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200138 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
139 proxyConfig['childOffline'] = true
140 deployChild = true
141 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200142 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
143 proxyConfig['childOffline'] = true
144 proxyConfig['childProxy'] = true
145 deployChild = true
146 }
vnaumov33747e12020-05-04 17:35:20 +0200147 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
148 fetchServiceBinaries = true
149 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200150 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400151 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200152 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 +0400153 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200154 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
155 azureOnAwsDemo = true
156 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
157 }
158 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
159 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
160 attachBYO ||
161 upgradeBYO ||
162 seedMacOs ||
163 equinixOnAwsDemo ||
164 azureOnAwsDemo) {
165
vnaumov33747e12020-05-04 17:35:20 +0200166 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200167 common.warningMsg('Running additional kaas deployment with AWS provider, may be forced due applied trigger cross dependencies, follow docs to clarify info')
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200168 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200169 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200170 equinixOnDemandDemo = true
171 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200172 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
173 azureOnDemandDemo = true
174 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200175 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
176 enableOSDemo = false
177 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200178 }
179
azvyagintsev1761bdc2020-09-04 17:24:12 +0300180 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
181 enableBMDemo = false
182 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
183 }
184
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400185 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
186 enableVsphereDemo = false
187 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
188 }
189
vnaumov33747e12020-05-04 17:35:20 +0200190 // TODO (vnaumov) remove below condition after moving all releases to UCP
191 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
192 if (ucpChildMatches.size() > 0) {
193 deployChild = true
194 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
195
196 // TODO(vnaumov) delete after ucp upgrades support
197 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
198 upgradeChild = false
199 }
200
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200201 // multiregional tests
202 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
203 if (multiRegionalMatches.size() > 0) {
204 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
205 }
206 switch (multiregionalMappings['managementLocation']) {
207 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100208 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200209 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100210
211 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
212 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
213 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200214 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200215 case 'os':
216 if (enableOSDemo == false) {
217 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
218 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200219 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200220 case 'vsphere':
221 if (enableVsphereDemo == false) {
222 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
223 }
224 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200225 case 'equinix':
226 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
227 equinixOnDemandDemo = true
228 break
slalovfd0b7e62021-07-28 18:05:16 +0400229 case 'azure':
230 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
231 azureOnDemandDemo = true
232 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200233 }
234
Владислав Наумовb8305e22021-02-10 17:23:12 +0100235 // CDN configuration
236 def cdnConfig = [
237 mgmt: [
238 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200239 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100240 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200241 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200242 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200243 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100244 ]
245
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100246 // calculate weight of current demo run to manage lockable resources
247 def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1
248
vnaumov33747e12020-05-04 17:35:20 +0200249 common.infoMsg("""
Владислав Наумовb8305e22021-02-10 17:23:12 +0100250 CDN deployment configuration: ${cdnConfig}
251 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100252 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200253 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400254 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200255 Child cluster release upgrade scheduled: ${upgradeChild}
256 Child conformance testing scheduled: ${runChildConformance}
Владислав Наумов0dc99252020-11-13 13:30:48 +0100257 BYO cluster attachment scheduled: ${attachBYO}
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100258 Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
vnaumov33747e12020-05-04 17:35:20 +0200259 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400260 Mgmt LMA logging enabled: ${enableLMALogging}
vnaumov33747e12020-05-04 17:35:20 +0200261 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200262 LMA testing scheduled: ${runLMATest}
vnaumov33747e12020-05-04 17:35:20 +0200263 Mgmt UI e2e testing scheduled: ${runUie2e}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200264 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200265 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200266 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200267 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200268 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400269 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200270 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300271 BM provider deployment scheduled: ${enableBMDemo}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200272 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200273 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100274 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Владислав Наумов81777472021-03-09 15:14:27 +0400275 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200276 return [
Владислав Наумовb8305e22021-02-10 17:23:12 +0100277 cdnConfig : cdnConfig,
278 proxyConfig : proxyConfig,
Владислав Наумов44c64b72020-12-04 20:22:53 +0100279 useMacOsSeedNode : seedMacOs,
azvyagintseva12230a2020-06-05 13:24:06 +0300280 deployChildEnabled : deployChild,
Mikhail Ivanov74504372021-05-21 17:01:06 +0400281 childDeployCustomRelease : customChildRelease,
azvyagintseva12230a2020-06-05 13:24:06 +0300282 upgradeChildEnabled : upgradeChild,
283 runChildConformanceEnabled : runChildConformance,
Владислав Наумов0dc99252020-11-13 13:30:48 +0100284 attachBYOEnabled : attachBYO,
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100285 upgradeBYOEnabled : upgradeBYO,
azvyagintseva12230a2020-06-05 13:24:06 +0300286 upgradeMgmtEnabled : upgradeMgmt,
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400287 enableLMALoggingEnabled : enableLMALogging,
azvyagintseva12230a2020-06-05 13:24:06 +0300288 runUie2eEnabled : runUie2e,
289 runMgmtConformanceEnabled : runMgmtConformance,
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200290 runLMATestEnabled : runLMATest,
vnaumov33747e12020-05-04 17:35:20 +0200291 fetchServiceBinariesEnabled: fetchServiceBinaries,
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200292 awsOnDemandDemoEnabled : awsOnDemandDemo,
Владислав Наумовe021b022021-05-06 11:26:38 +0200293 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
Владислав Наумовf1665b52021-05-13 10:51:17 +0200294 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200295 azureOnDemandDemoEnabled : azureOnDemandDemo,
Владислав Наумов2d3db332021-06-15 15:19:19 +0200296 azureOnAwsDemoEnabled : azureOnAwsDemo,
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400297 vsphereDemoEnabled : enableVsphereDemo,
298 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
azvyagintsev1761bdc2020-09-04 17:24:12 +0300299 bmDemoEnabled : enableBMDemo,
Владислав Наумовf793fe32020-09-11 15:19:19 +0200300 osDemoEnabled : enableOSDemo,
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100301 multiregionalConfiguration : multiregionalMappings,
302 demoWeight : demoWeight]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200303}
304
305/**
306 * Determine management and regional setup for demo workflow scenario
307 *
308 *
309 * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]`
310 or Jenkins environment string variable in form like 'aws,os'
311 * @return (map)[
312 enabled: (bool),
313 * managementLocation: (string), //aws,os
314 * regionLocation: (string), //aws,os
315 * ]
316 */
317def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200318 def common = new com.mirantis.mk.Common()
slalovde59e312021-07-27 16:25:16 +0400319 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'azure']
slalov19d6e772021-08-09 15:29:04 +0400320 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200321
322 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200323 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200324 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
325 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
326 } else {
327 common.infoMsg('Multiregion definition configured via environment variable')
328 clusterTypes = keyword.trim().split(',')
329 }
330
331 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100332 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200333 }
334
Владислав Наумовf793fe32020-09-11 15:19:19 +0200335 def desiredManagementProvider = clusterTypes[0].trim()
336 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200337 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
338 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200339 management providers list - ${supportedManagementProviders}
340 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200341 }
342
343 return [
344 enabled: true,
345 managementLocation: desiredManagementProvider,
346 regionLocation: desiredRegionalProvider,
347 ]
vnaumov33747e12020-05-04 17:35:20 +0200348}
349
350/**
351 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
352
Владислав Наумов81777472021-03-09 15:14:27 +0400353 * 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 +0200354 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
355 * Example scheme:
356 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
357 * manage refspecs through Jenkins Job Parameters
358 *
azvyagintseva12230a2020-06-05 13:24:06 +0300359 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200360 * siPipelines: (string) final refspec for si-pipelines
361 * ]
362 */
363def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200364 def common = new com.mirantis.mk.Common()
365
vnaumov33747e12020-05-04 17:35:20 +0200366 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200367 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
368 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200369 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
370 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200371 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200372
373 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
374 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
375
376 if (siTestMatches.size() > 0) {
377 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400378 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200379 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200380 }
381 if (siPipelinesMatches.size() > 0) {
382 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
383 }
384
385 common.infoMsg("""
386 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
387 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200388 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400389 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200390 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200391}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200392
Владислав Наумов9080f372020-06-08 13:57:16 +0200393/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200394 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200395 * @param configurationFile (str) path to configuration file in yaml format
396 *
397 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
398 * ]
399 */
400def parseKaaSComponentCIParameters(configurationFile){
401 def common = new com.mirantis.mk.Common()
402 def ciConfig = readYaml file: configurationFile
403 def ciSpec = [
404 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
405 ]
406
407 if (ciConfig.containsKey('si-tests-feature-flags')) {
408 common.infoMsg("""SI tests feature flags customization detected,
409 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
410
411 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
412 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200413
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200414 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200415 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
416 }
417
418 common.infoMsg("""Additional ci configuration parsed successfully:
419 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
420 return ciSpec
421}
422
423/**
424 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200425
Владислав Наумов81777472021-03-09 15:14:27 +0400426 * 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 +0200427 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
428 * Example scheme:
429 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
430 * manage refspecs through Jenkins Job Parameters
431 *
432 * @return (map)[ core: (string) final refspec for kaas/core
433 * corePipelines: (string) final refspec for pipelines in kaas/core
434 * ]
435 */
436def checkCustomCoreRefspec() {
437 def common = new com.mirantis.mk.Common()
438
439 // Available triggers and its sane defaults
440 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
441 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
442 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
443 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
444
445 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
446 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
447
448 if (coreMatches.size() > 0) {
449 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
450 }
451 if (corePipelinesMatches.size() > 0) {
452 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
453 }
454
455 common.infoMsg("""
456 kaas/core will be fetched from: ${coreRefspec}
457 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400458 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200459 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
460}
461
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200462
463/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200464 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
465 * needed to forward inside kaas core set of jobs
466 *
467 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
468 * @return (list)[ string(name: '', value: ''),
469 * ]
470 */
471def generateKaaSVarsFromContext(context) {
472 def common = new com.mirantis.mk.Common()
473 def parameters = []
474 def config = readYaml text: context
475
476 config.each { k,v ->
477 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
478 parameters.add(string(name: k, value: v))
479 }
480
481 return parameters
482}
483
484/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200485 * 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 +0400486 * 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 +0200487 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
488 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200489 * @param: component (string) component name [iam, lcm, stacklight]
490 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
491 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200492 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200493def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200494 def common = new com.mirantis.mk.Common()
495 // Determine if custom trigger keywords forwarded from gerrit
496 def triggers = checkDeploymentTestSuite()
497 // Determine SI refspecs
498 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200499 // Determine Core refspecs
500 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200501
Владислав Наумов418042b2020-07-09 18:31:10 +0200502 // Determine component repo ci configuration
503 def ciSpec = [:]
504 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
505 if (fileExists(configurationFile)) {
506 common.infoMsg('Component CI configuration file detected, parsing...')
507 ciSpec = parseKaaSComponentCIParameters(configurationFile)
508 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
509 } else {
510 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200511 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200512 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
513 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200514 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400515
516 def platforms = []
517 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
518 // Currently only vsphere demo is required for IPAM component
519 platforms.add('vsphere')
520 } else {
521 if (triggers.osDemoEnabled) {
522 platforms.add('openstack')
523 }
524 if (triggers.awsOnDemandDemoEnabled) {
525 platforms.add('aws')
526 }
527 if (triggers.equinixOnDemandDemoEnabled) {
528 platforms.add('equinix')
529 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200530 if (triggers.azureOnDemandDemoEnabled) {
531 platforms.add('azure')
532 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400533 if (triggers.vsphereDemoEnabled) {
534 platforms.add('vsphere')
535 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400536 }
537
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200538 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200539 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200540 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
541 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200542 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200543 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200544 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
545 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200546 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200547 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400548 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100549 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200550 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200551 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100552 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200553 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400554 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200555 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200556 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200557 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200558 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
559 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100560 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100561 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200562 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400563 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200564 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
eromanovad3397512021-04-01 20:19:19 +0400565 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200566 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200567 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200568 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200569
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200570 // customize multiregional demo
571 if (triggers.multiregionalConfiguration.enabled) {
572 parameters.add(string(name: 'MULTIREGION_SETUP',
573 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
574 ))
575 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200576
Владислав Наумов92288d92020-07-13 18:36:21 +0200577 // Determine component team custom context
578 if (coreContext != '') {
579 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
580 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200581 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200582 }
583
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200584 if (triggers.awsOnDemandDemoEnabled ||
585 triggers.equinixOnDemandDemoEnabled ||
586 triggers.azureOnDemandDemoEnabled) {
587
Владислав Наумовe021b022021-05-06 11:26:38 +0200588 common.infoMsg('Public provider demo triggered, need to sync artifacts in the public-ci cdn..')
589 switch (component) {
590 case 'iam':
591 build job: 'cdn-binary-dev-replication-iam', propagate: true, wait: true
592 break
593 case 'lcm':
594 build job: 'cdn-binary-dev-replication-lcm', propagate: true, wait: true
595 break
596 }
597 }
598
Владислав Наумовaa430612020-06-08 17:18:31 +0200599 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400600
601 platforms.each { platform ->
602 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000603 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400604 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
605 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
606 def build_description = job_info.getDescription()
607 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000608 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200609
Vladislav Naumov5313a202021-04-07 17:13:39 +0000610 if (build_description) {
611 currentBuild.description += build_description
612 }
613 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400614 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000615 }
616 }
617 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200618
619 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400620 if (jobs.size() == 0) {
621 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
622 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200623 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
624 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200625
626 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200627 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200628 currentBuild.result = 'FAILURE'
629 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200630}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200631
632
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400633/**
634 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
635 * and generate proper lockResources data and netMap data for vsphere related clusters.
636 *
637 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
638 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
639 * @param: multiregionalConfiguration (map) Multiregional configuration
640 * @return (map) Return aggregated map with lockResources and netMap
641 */
642
643
644def generateLockResources(callBackDemo, triggers) {
645 def common = new com.mirantis.mk.Common()
646 def netMap = [:]
647 // Define vsphere locklabels with initial quantity
648 def lockLabels = [
649 vsphere_networking_core_ci: 0,
650 vsphere_offline_networking_core_ci: 0,
651 ]
652 def deployChild = triggers.deployChildEnabled
653 def multiregionConfig = triggers.multiregionalConfiguration
654 def runMultiregion = multiregionConfig.enabled
655
656 // Generate vsphere netMap and lockLabels based on demo context
657 switch (callBackDemo) {
658 case 'aws':
659 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
660 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
661
662 // Define netMap for Vsphere region
663 if (runMultiregion && multiregionConfig.regionLocation == 'vsphere') {
664 if (deployChild) {
665 addToVsphereNetMap(netMap, 'regional-child')
666 }
667 addToVsphereNetMap(netMap, 'region')
668 }
669 break
670 case 'vsphere':
671 addToVsphereNetMap(netMap, 'mgmt')
672 if (deployChild) {
673 addToVsphereNetMap(netMap, 'child')
674 }
675 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
676 multiregionConfig.regionLocation == 'vsphere') {
677 if (deployChild) {
678 addToVsphereNetMap(netMap, 'regional-child')
679 }
680 addToVsphereNetMap(netMap, 'region')
681 }
682 break
683 default:
684 error('Supposed to be called from aws or vsphere demos only')
685 }
686
687 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
688 // Vsphere labels only
689 netMap.each { clusterType, netConfig ->
Mikhail Ivanovb33207c2021-07-07 15:34:46 +0400690 if (triggers.proxyConfig["${clusterType}Offline"] == true || (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true)) {
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400691 netMap[clusterType]['netName'] = 'offline'
692 lockLabels['vsphere_offline_networking_core_ci']++
693 } else {
694 lockLabels['vsphere_networking_core_ci']++
695 }
696 }
697
698 // generate lock metadata
699 def lockResources = []
700 lockLabels.each { label, quantity ->
701 if (quantity > 0) {
702 def res = [
703 label: label,
704 quantity: quantity,
705 ]
706 lockResources.add(res)
707 }
708 }
709
710 common.infoMsg("""Generated vsphere netMap: ${netMap}
711 Generated lockResources: ${lockResources}""")
712
713 return [
714 netMap: netMap,
715 lockResources: lockResources,
716 ]
717}
718
719/**
720 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
721 * and empty rangeConfig to the this map.
722 *
723 * @param: netMap (string) vsphere netMap or empty map
724 * @param: clusterType (string) Vsphere cluster type
725 */
726
727def addToVsphereNetMap (netMap, clusterType) {
728 netMap[clusterType] = [
729 netName: 'default',
730 rangeConfig: '',
731 ]
732}