blob: 53e7517138fca8123a7ae0c2e9d77c174ab87b4e [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
58 def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
59 def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
Victor Ryzhenkin15206592021-06-21 17:38:23 +040060 def runMgmtLMA = env.RUN_MGMT_LMA ? env.RUN_MGMT_LMA.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020061 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
62 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020063 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
64 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
65 enabled: false,
66 managementLocation: '',
67 regionLocation: '',
68 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020069
Владислав Наумовb8305e22021-02-10 17:23:12 +010070 // proxy customization
71 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020072 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
73 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020074 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010075 ]
76
Владислав Наумов4eb1da32020-08-31 14:45:16 +020077 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020078 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +020079 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +020080 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +020081 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +020082 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +040083 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +020084 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +030085 def enableBMDemo = true
vnaumov33747e12020-05-04 17:35:20 +020086
Владислав Наумов6c2afff2020-06-05 12:54:53 +020087 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +010088 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
89 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +020090 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 +010091 }
Владислав Наумов44c64b72020-12-04 20:22:53 +010092 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
93 seedMacOs = true
94 }
vnaumov33747e12020-05-04 17:35:20 +020095 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) {
96 deployChild = true
97 }
98 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
99 deployChild = true
100 upgradeChild = true
101 }
Mikhail Ivanov76d69952021-06-04 16:06:45 +0400102 def deployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
Mikhail Ivanov74504372021-05-21 17:01:06 +0400103 if (deployMatches.size() > 0) {
104 // override child version when it set explicitly
105 deployChild = true
Mikhail Ivanoved543492021-05-24 16:26:55 +0400106 customChildRelease = deployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400107 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
108 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100109 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
110 attachBYO = true
111 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100112 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
113 attachBYO = true
114 upgradeBYO = true
115 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400116 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200117 upgradeMgmt = true
118 }
119 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
120 runUie2e = true
121 }
122 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
123 runMgmtConformance = true
124 }
125 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
126 runChildConformance = true
127 deployChild = true
128 }
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400129 if (commitMsg ==~ /(?s).*\[mgmt-lma\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-lma.*/) {
130 runMgmtLMA = true
131 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200132 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
133 proxyConfig['childOffline'] = true
134 deployChild = true
135 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200136 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
137 proxyConfig['childOffline'] = true
138 proxyConfig['childProxy'] = true
139 deployChild = true
140 }
vnaumov33747e12020-05-04 17:35:20 +0200141 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
142 fetchServiceBinaries = true
143 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200144 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400145 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200146 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 +0400147 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200148 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
149 azureOnAwsDemo = true
150 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
151 }
152 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
153 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
154 attachBYO ||
155 upgradeBYO ||
156 seedMacOs ||
157 equinixOnAwsDemo ||
158 azureOnAwsDemo) {
159
vnaumov33747e12020-05-04 17:35:20 +0200160 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200161 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 +0200162 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200163 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200164 equinixOnDemandDemo = true
165 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200166 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
167 azureOnDemandDemo = true
168 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200169 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
170 enableOSDemo = false
171 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200172 }
173
azvyagintsev1761bdc2020-09-04 17:24:12 +0300174 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
175 enableBMDemo = false
176 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
177 }
178
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400179 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
180 enableVsphereDemo = false
181 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
182 }
183
vnaumov33747e12020-05-04 17:35:20 +0200184 // TODO (vnaumov) remove below condition after moving all releases to UCP
185 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
186 if (ucpChildMatches.size() > 0) {
187 deployChild = true
188 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
189
190 // TODO(vnaumov) delete after ucp upgrades support
191 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
192 upgradeChild = false
193 }
194
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200195 // multiregional tests
196 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
197 if (multiRegionalMatches.size() > 0) {
198 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
199 }
200 switch (multiregionalMappings['managementLocation']) {
201 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100202 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200203 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100204
205 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
206 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
207 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200208 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200209 case 'os':
210 if (enableOSDemo == false) {
211 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
212 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200213 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200214 case 'vsphere':
215 if (enableVsphereDemo == false) {
216 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
217 }
218 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200219 case 'equinix':
220 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
221 equinixOnDemandDemo = true
222 break
slalovfd0b7e62021-07-28 18:05:16 +0400223 case 'azure':
224 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
225 azureOnDemandDemo = true
226 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200227 }
228
Владислав Наумовb8305e22021-02-10 17:23:12 +0100229 // CDN configuration
230 def cdnConfig = [
231 mgmt: [
232 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200233 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100234 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200235 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200236 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200237 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100238 ]
239
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100240 // calculate weight of current demo run to manage lockable resources
241 def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1
242
vnaumov33747e12020-05-04 17:35:20 +0200243 common.infoMsg("""
Владислав Наумовb8305e22021-02-10 17:23:12 +0100244 CDN deployment configuration: ${cdnConfig}
245 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100246 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200247 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400248 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200249 Child cluster release upgrade scheduled: ${upgradeChild}
250 Child conformance testing scheduled: ${runChildConformance}
Владислав Наумов0dc99252020-11-13 13:30:48 +0100251 BYO cluster attachment scheduled: ${attachBYO}
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100252 Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
vnaumov33747e12020-05-04 17:35:20 +0200253 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
254 Mgmt conformance testing scheduled: ${runMgmtConformance}
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400255 Mgmt LMA deployment and testing scheduled: ${runMgmtLMA}
vnaumov33747e12020-05-04 17:35:20 +0200256 Mgmt UI e2e testing scheduled: ${runUie2e}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200257 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200258 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200259 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200260 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200261 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400262 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200263 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300264 BM provider deployment scheduled: ${enableBMDemo}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200265 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200266 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100267 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Владислав Наумов81777472021-03-09 15:14:27 +0400268 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200269 return [
Владислав Наумовb8305e22021-02-10 17:23:12 +0100270 cdnConfig : cdnConfig,
271 proxyConfig : proxyConfig,
Владислав Наумов44c64b72020-12-04 20:22:53 +0100272 useMacOsSeedNode : seedMacOs,
azvyagintseva12230a2020-06-05 13:24:06 +0300273 deployChildEnabled : deployChild,
Mikhail Ivanov74504372021-05-21 17:01:06 +0400274 childDeployCustomRelease : customChildRelease,
azvyagintseva12230a2020-06-05 13:24:06 +0300275 upgradeChildEnabled : upgradeChild,
276 runChildConformanceEnabled : runChildConformance,
Владислав Наумов0dc99252020-11-13 13:30:48 +0100277 attachBYOEnabled : attachBYO,
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100278 upgradeBYOEnabled : upgradeBYO,
azvyagintseva12230a2020-06-05 13:24:06 +0300279 upgradeMgmtEnabled : upgradeMgmt,
280 runUie2eEnabled : runUie2e,
281 runMgmtConformanceEnabled : runMgmtConformance,
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400282 runMgmtLmaEnabled : runMgmtLMA,
vnaumov33747e12020-05-04 17:35:20 +0200283 fetchServiceBinariesEnabled: fetchServiceBinaries,
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200284 awsOnDemandDemoEnabled : awsOnDemandDemo,
Владислав Наумовe021b022021-05-06 11:26:38 +0200285 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
Владислав Наумовf1665b52021-05-13 10:51:17 +0200286 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200287 azureOnDemandDemoEnabled : azureOnDemandDemo,
Владислав Наумов2d3db332021-06-15 15:19:19 +0200288 azureOnAwsDemoEnabled : azureOnAwsDemo,
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400289 vsphereDemoEnabled : enableVsphereDemo,
290 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
azvyagintsev1761bdc2020-09-04 17:24:12 +0300291 bmDemoEnabled : enableBMDemo,
Владислав Наумовf793fe32020-09-11 15:19:19 +0200292 osDemoEnabled : enableOSDemo,
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100293 multiregionalConfiguration : multiregionalMappings,
294 demoWeight : demoWeight]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200295}
296
297/**
298 * Determine management and regional setup for demo workflow scenario
299 *
300 *
301 * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]`
302 or Jenkins environment string variable in form like 'aws,os'
303 * @return (map)[
304 enabled: (bool),
305 * managementLocation: (string), //aws,os
306 * regionLocation: (string), //aws,os
307 * ]
308 */
309def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200310 def common = new com.mirantis.mk.Common()
slalovde59e312021-07-27 16:25:16 +0400311 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'azure']
312 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'bm', 'azure']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200313
314 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200315 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200316 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
317 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
318 } else {
319 common.infoMsg('Multiregion definition configured via environment variable')
320 clusterTypes = keyword.trim().split(',')
321 }
322
323 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100324 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200325 }
326
Владислав Наумовf793fe32020-09-11 15:19:19 +0200327 def desiredManagementProvider = clusterTypes[0].trim()
328 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200329 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
330 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200331 management providers list - ${supportedManagementProviders}
332 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200333 }
334
335 return [
336 enabled: true,
337 managementLocation: desiredManagementProvider,
338 regionLocation: desiredRegionalProvider,
339 ]
vnaumov33747e12020-05-04 17:35:20 +0200340}
341
342/**
343 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
344
Владислав Наумов81777472021-03-09 15:14:27 +0400345 * 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 +0200346 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
347 * Example scheme:
348 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
349 * manage refspecs through Jenkins Job Parameters
350 *
azvyagintseva12230a2020-06-05 13:24:06 +0300351 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200352 * siPipelines: (string) final refspec for si-pipelines
353 * ]
354 */
355def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200356 def common = new com.mirantis.mk.Common()
357
vnaumov33747e12020-05-04 17:35:20 +0200358 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200359 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
360 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200361 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
362 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200363 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200364
365 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
366 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
367
368 if (siTestMatches.size() > 0) {
369 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400370 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200371 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200372 }
373 if (siPipelinesMatches.size() > 0) {
374 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
375 }
376
377 common.infoMsg("""
378 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
379 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200380 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400381 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200382 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200383}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200384
Владислав Наумов9080f372020-06-08 13:57:16 +0200385/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200386 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200387 * @param configurationFile (str) path to configuration file in yaml format
388 *
389 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
390 * ]
391 */
392def parseKaaSComponentCIParameters(configurationFile){
393 def common = new com.mirantis.mk.Common()
394 def ciConfig = readYaml file: configurationFile
395 def ciSpec = [
396 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
397 ]
398
399 if (ciConfig.containsKey('si-tests-feature-flags')) {
400 common.infoMsg("""SI tests feature flags customization detected,
401 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
402
403 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
404 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200405
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200406 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200407 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
408 }
409
410 common.infoMsg("""Additional ci configuration parsed successfully:
411 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
412 return ciSpec
413}
414
415/**
416 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200417
Владислав Наумов81777472021-03-09 15:14:27 +0400418 * 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 +0200419 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
420 * Example scheme:
421 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
422 * manage refspecs through Jenkins Job Parameters
423 *
424 * @return (map)[ core: (string) final refspec for kaas/core
425 * corePipelines: (string) final refspec for pipelines in kaas/core
426 * ]
427 */
428def checkCustomCoreRefspec() {
429 def common = new com.mirantis.mk.Common()
430
431 // Available triggers and its sane defaults
432 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
433 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
434 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
435 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
436
437 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
438 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
439
440 if (coreMatches.size() > 0) {
441 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
442 }
443 if (corePipelinesMatches.size() > 0) {
444 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
445 }
446
447 common.infoMsg("""
448 kaas/core will be fetched from: ${coreRefspec}
449 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400450 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200451 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
452}
453
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200454
455/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200456 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
457 * needed to forward inside kaas core set of jobs
458 *
459 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
460 * @return (list)[ string(name: '', value: ''),
461 * ]
462 */
463def generateKaaSVarsFromContext(context) {
464 def common = new com.mirantis.mk.Common()
465 def parameters = []
466 def config = readYaml text: context
467
468 config.each { k,v ->
469 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
470 parameters.add(string(name: k, value: v))
471 }
472
473 return parameters
474}
475
476/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200477 * 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 +0400478 * 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 +0200479 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
480 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200481 * @param: component (string) component name [iam, lcm, stacklight]
482 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
483 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200484 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200485def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200486 def common = new com.mirantis.mk.Common()
487 // Determine if custom trigger keywords forwarded from gerrit
488 def triggers = checkDeploymentTestSuite()
489 // Determine SI refspecs
490 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200491 // Determine Core refspecs
492 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200493
Владислав Наумов418042b2020-07-09 18:31:10 +0200494 // Determine component repo ci configuration
495 def ciSpec = [:]
496 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
497 if (fileExists(configurationFile)) {
498 common.infoMsg('Component CI configuration file detected, parsing...')
499 ciSpec = parseKaaSComponentCIParameters(configurationFile)
500 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
501 } else {
502 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200503 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200504 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
505 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200506 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400507
508 def platforms = []
509 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
510 // Currently only vsphere demo is required for IPAM component
511 platforms.add('vsphere')
512 } else {
513 if (triggers.osDemoEnabled) {
514 platforms.add('openstack')
515 }
516 if (triggers.awsOnDemandDemoEnabled) {
517 platforms.add('aws')
518 }
519 if (triggers.equinixOnDemandDemoEnabled) {
520 platforms.add('equinix')
521 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200522 if (triggers.azureOnDemandDemoEnabled) {
523 platforms.add('azure')
524 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400525 if (triggers.vsphereDemoEnabled) {
526 platforms.add('vsphere')
527 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400528 }
529
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200530 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200531 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200532 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
533 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200534 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200535 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200536 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
537 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200538 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200539 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400540 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100541 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200542 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200543 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100544 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200545 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200546 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200547 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400548 booleanParam(name: 'RUN_MGMT_LMA', value: triggers.runMgmtLmaEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200549 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
550 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100551 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100552 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200553 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400554 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200555 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
eromanovad3397512021-04-01 20:19:19 +0400556 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200557 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200558 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200559 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200560
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200561 // customize multiregional demo
562 if (triggers.multiregionalConfiguration.enabled) {
563 parameters.add(string(name: 'MULTIREGION_SETUP',
564 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
565 ))
566 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200567
Владислав Наумов92288d92020-07-13 18:36:21 +0200568 // Determine component team custom context
569 if (coreContext != '') {
570 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
571 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200572 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200573 }
574
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200575 if (triggers.awsOnDemandDemoEnabled ||
576 triggers.equinixOnDemandDemoEnabled ||
577 triggers.azureOnDemandDemoEnabled) {
578
Владислав Наумовe021b022021-05-06 11:26:38 +0200579 common.infoMsg('Public provider demo triggered, need to sync artifacts in the public-ci cdn..')
580 switch (component) {
581 case 'iam':
582 build job: 'cdn-binary-dev-replication-iam', propagate: true, wait: true
583 break
584 case 'lcm':
585 build job: 'cdn-binary-dev-replication-lcm', propagate: true, wait: true
586 break
587 }
588 }
589
Владислав Наумовaa430612020-06-08 17:18:31 +0200590 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400591
592 platforms.each { platform ->
593 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000594 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400595 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
596 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
597 def build_description = job_info.getDescription()
598 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000599 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200600
Vladislav Naumov5313a202021-04-07 17:13:39 +0000601 if (build_description) {
602 currentBuild.description += build_description
603 }
604 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400605 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000606 }
607 }
608 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200609
610 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400611 if (jobs.size() == 0) {
612 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
613 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200614 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
615 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200616
617 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200618 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200619 currentBuild.result = 'FAILURE'
620 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200621}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200622
623
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400624/**
625 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
626 * and generate proper lockResources data and netMap data for vsphere related clusters.
627 *
628 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
629 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
630 * @param: multiregionalConfiguration (map) Multiregional configuration
631 * @return (map) Return aggregated map with lockResources and netMap
632 */
633
634
635def generateLockResources(callBackDemo, triggers) {
636 def common = new com.mirantis.mk.Common()
637 def netMap = [:]
638 // Define vsphere locklabels with initial quantity
639 def lockLabels = [
640 vsphere_networking_core_ci: 0,
641 vsphere_offline_networking_core_ci: 0,
642 ]
643 def deployChild = triggers.deployChildEnabled
644 def multiregionConfig = triggers.multiregionalConfiguration
645 def runMultiregion = multiregionConfig.enabled
646
647 // Generate vsphere netMap and lockLabels based on demo context
648 switch (callBackDemo) {
649 case 'aws':
650 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
651 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
652
653 // Define netMap for Vsphere region
654 if (runMultiregion && multiregionConfig.regionLocation == 'vsphere') {
655 if (deployChild) {
656 addToVsphereNetMap(netMap, 'regional-child')
657 }
658 addToVsphereNetMap(netMap, 'region')
659 }
660 break
661 case 'vsphere':
662 addToVsphereNetMap(netMap, 'mgmt')
663 if (deployChild) {
664 addToVsphereNetMap(netMap, 'child')
665 }
666 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
667 multiregionConfig.regionLocation == 'vsphere') {
668 if (deployChild) {
669 addToVsphereNetMap(netMap, 'regional-child')
670 }
671 addToVsphereNetMap(netMap, 'region')
672 }
673 break
674 default:
675 error('Supposed to be called from aws or vsphere demos only')
676 }
677
678 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
679 // Vsphere labels only
680 netMap.each { clusterType, netConfig ->
Mikhail Ivanovb33207c2021-07-07 15:34:46 +0400681 if (triggers.proxyConfig["${clusterType}Offline"] == true || (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true)) {
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400682 netMap[clusterType]['netName'] = 'offline'
683 lockLabels['vsphere_offline_networking_core_ci']++
684 } else {
685 lockLabels['vsphere_networking_core_ci']++
686 }
687 }
688
689 // generate lock metadata
690 def lockResources = []
691 lockLabels.each { label, quantity ->
692 if (quantity > 0) {
693 def res = [
694 label: label,
695 quantity: quantity,
696 ]
697 lockResources.add(res)
698 }
699 }
700
701 common.infoMsg("""Generated vsphere netMap: ${netMap}
702 Generated lockResources: ${lockResources}""")
703
704 return [
705 netMap: netMap,
706 lockResources: lockResources,
707 ]
708}
709
710/**
711 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
712 * and empty rangeConfig to the this map.
713 *
714 * @param: netMap (string) vsphere netMap or empty map
715 * @param: clusterType (string) Vsphere cluster type
716 */
717
718def addToVsphereNetMap (netMap, clusterType) {
719 netMap[clusterType] = [
720 netName: 'default',
721 rangeConfig: '',
722 ]
723}