blob: 8dfb102e3965c8f094248f750285f77b25d6afae [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
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +020062 def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020063 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
64 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020065 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
66 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
67 enabled: false,
68 managementLocation: '',
69 regionLocation: '',
70 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020071
Владислав Наумовb8305e22021-02-10 17:23:12 +010072 // proxy customization
73 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020074 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
75 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020076 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010077 ]
78
Владислав Наумов4eb1da32020-08-31 14:45:16 +020079 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020080 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +020081 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +020082 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +020083 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +020084 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +040085 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +020086 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +030087 def enableBMDemo = true
vnaumov33747e12020-05-04 17:35:20 +020088
Владислав Наумов6c2afff2020-06-05 12:54:53 +020089 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +010090 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
91 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +020092 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 +010093 }
Владислав Наумов44c64b72020-12-04 20:22:53 +010094 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
95 seedMacOs = true
96 }
vnaumov33747e12020-05-04 17:35:20 +020097 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) {
98 deployChild = true
99 }
100 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
101 deployChild = true
102 upgradeChild = true
103 }
Mikhail Ivanov76d69952021-06-04 16:06:45 +0400104 def deployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
Mikhail Ivanov74504372021-05-21 17:01:06 +0400105 if (deployMatches.size() > 0) {
106 // override child version when it set explicitly
107 deployChild = true
Mikhail Ivanoved543492021-05-24 16:26:55 +0400108 customChildRelease = deployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400109 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
110 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100111 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
112 attachBYO = true
113 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100114 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
115 attachBYO = true
116 upgradeBYO = true
117 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400118 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200119 upgradeMgmt = true
120 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400121 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
122 enableLMALogging = true
123 }
vnaumov33747e12020-05-04 17:35:20 +0200124 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
125 runUie2e = true
126 }
127 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
128 runMgmtConformance = true
129 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200130 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
131 runMgmtUserControllerTest = true
132 }
vnaumov33747e12020-05-04 17:35:20 +0200133 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
134 runChildConformance = true
135 deployChild = true
136 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200137 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
138 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400139 enableLMALogging = true
140 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400141 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200142 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
143 proxyConfig['childOffline'] = true
144 deployChild = true
145 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200146 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
147 proxyConfig['childOffline'] = true
148 proxyConfig['childProxy'] = true
149 deployChild = true
150 }
vnaumov33747e12020-05-04 17:35:20 +0200151 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
152 fetchServiceBinaries = true
153 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200154 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400155 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200156 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 +0400157 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200158 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
159 azureOnAwsDemo = true
160 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
161 }
162 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
163 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
164 attachBYO ||
165 upgradeBYO ||
166 seedMacOs ||
167 equinixOnAwsDemo ||
168 azureOnAwsDemo) {
169
vnaumov33747e12020-05-04 17:35:20 +0200170 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200171 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 +0200172 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200173 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200174 equinixOnDemandDemo = true
175 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200176 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
177 azureOnDemandDemo = true
178 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200179 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
180 enableOSDemo = false
181 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200182 }
183
azvyagintsev1761bdc2020-09-04 17:24:12 +0300184 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
185 enableBMDemo = false
186 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
187 }
188
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400189 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
190 enableVsphereDemo = false
191 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
192 }
193
vnaumov33747e12020-05-04 17:35:20 +0200194 // TODO (vnaumov) remove below condition after moving all releases to UCP
195 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
196 if (ucpChildMatches.size() > 0) {
197 deployChild = true
198 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
199
200 // TODO(vnaumov) delete after ucp upgrades support
201 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
202 upgradeChild = false
203 }
204
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200205 // multiregional tests
206 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
207 if (multiRegionalMatches.size() > 0) {
208 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
209 }
210 switch (multiregionalMappings['managementLocation']) {
211 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100212 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200213 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100214
215 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
216 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
217 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200218 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200219 case 'os':
220 if (enableOSDemo == false) {
221 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
222 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200223 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200224 case 'vsphere':
225 if (enableVsphereDemo == false) {
226 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
227 }
228 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200229 case 'equinix':
230 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
231 equinixOnDemandDemo = true
232 break
slalovfd0b7e62021-07-28 18:05:16 +0400233 case 'azure':
234 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
235 azureOnDemandDemo = true
236 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200237 }
238
Владислав Наумовb8305e22021-02-10 17:23:12 +0100239 // CDN configuration
240 def cdnConfig = [
241 mgmt: [
242 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200243 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100244 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200245 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200246 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200247 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100248 ]
249
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100250 // calculate weight of current demo run to manage lockable resources
251 def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1
252
vnaumov33747e12020-05-04 17:35:20 +0200253 common.infoMsg("""
Владислав Наумовb8305e22021-02-10 17:23:12 +0100254 CDN deployment configuration: ${cdnConfig}
255 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100256 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200257 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400258 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200259 Child cluster release upgrade scheduled: ${upgradeChild}
260 Child conformance testing scheduled: ${runChildConformance}
Владислав Наумов0dc99252020-11-13 13:30:48 +0100261 BYO cluster attachment scheduled: ${attachBYO}
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100262 Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
vnaumov33747e12020-05-04 17:35:20 +0200263 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400264 Mgmt LMA logging enabled: ${enableLMALogging}
vnaumov33747e12020-05-04 17:35:20 +0200265 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200266 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200267 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200268 Mgmt UI e2e testing scheduled: ${runUie2e}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200269 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200270 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200271 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200272 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200273 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400274 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200275 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300276 BM provider deployment scheduled: ${enableBMDemo}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200277 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200278 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100279 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Владислав Наумов81777472021-03-09 15:14:27 +0400280 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200281 return [
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200282 cdnConfig : cdnConfig,
283 proxyConfig : proxyConfig,
284 useMacOsSeedNode : seedMacOs,
285 deployChildEnabled : deployChild,
286 childDeployCustomRelease : customChildRelease,
287 upgradeChildEnabled : upgradeChild,
288 runChildConformanceEnabled : runChildConformance,
289 attachBYOEnabled : attachBYO,
290 upgradeBYOEnabled : upgradeBYO,
291 upgradeMgmtEnabled : upgradeMgmt,
292 enableLMALoggingEnabled : enableLMALogging,
293 runUie2eEnabled : runUie2e,
294 runMgmtConformanceEnabled : runMgmtConformance,
295 runLMATestEnabled : runLMATest,
296 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
297 fetchServiceBinariesEnabled : fetchServiceBinaries,
298 awsOnDemandDemoEnabled : awsOnDemandDemo,
299 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
300 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
301 azureOnDemandDemoEnabled : azureOnDemandDemo,
302 azureOnAwsDemoEnabled : azureOnAwsDemo,
303 vsphereDemoEnabled : enableVsphereDemo,
304 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
305 bmDemoEnabled : enableBMDemo,
306 osDemoEnabled : enableOSDemo,
307 multiregionalConfiguration : multiregionalMappings,
308 demoWeight : demoWeight]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200309}
310
311/**
312 * Determine management and regional setup for demo workflow scenario
313 *
314 *
315 * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]`
316 or Jenkins environment string variable in form like 'aws,os'
317 * @return (map)[
318 enabled: (bool),
319 * managementLocation: (string), //aws,os
320 * regionLocation: (string), //aws,os
321 * ]
322 */
323def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200324 def common = new com.mirantis.mk.Common()
slalovde59e312021-07-27 16:25:16 +0400325 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'azure']
slalov19d6e772021-08-09 15:29:04 +0400326 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200327
328 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200329 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200330 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
331 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
332 } else {
333 common.infoMsg('Multiregion definition configured via environment variable')
334 clusterTypes = keyword.trim().split(',')
335 }
336
337 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100338 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200339 }
340
Владислав Наумовf793fe32020-09-11 15:19:19 +0200341 def desiredManagementProvider = clusterTypes[0].trim()
342 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200343 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
344 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200345 management providers list - ${supportedManagementProviders}
346 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200347 }
348
349 return [
350 enabled: true,
351 managementLocation: desiredManagementProvider,
352 regionLocation: desiredRegionalProvider,
353 ]
vnaumov33747e12020-05-04 17:35:20 +0200354}
355
356/**
357 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
358
Владислав Наумов81777472021-03-09 15:14:27 +0400359 * 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 +0200360 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
361 * Example scheme:
362 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
363 * manage refspecs through Jenkins Job Parameters
364 *
azvyagintseva12230a2020-06-05 13:24:06 +0300365 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200366 * siPipelines: (string) final refspec for si-pipelines
367 * ]
368 */
369def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200370 def common = new com.mirantis.mk.Common()
371
vnaumov33747e12020-05-04 17:35:20 +0200372 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200373 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
374 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200375 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
376 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200377 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200378
379 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
380 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
381
382 if (siTestMatches.size() > 0) {
383 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400384 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200385 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200386 }
387 if (siPipelinesMatches.size() > 0) {
388 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
389 }
390
391 common.infoMsg("""
392 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
393 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200394 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400395 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200396 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200397}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200398
Владислав Наумов9080f372020-06-08 13:57:16 +0200399/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200400 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200401 * @param configurationFile (str) path to configuration file in yaml format
402 *
403 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
404 * ]
405 */
406def parseKaaSComponentCIParameters(configurationFile){
407 def common = new com.mirantis.mk.Common()
408 def ciConfig = readYaml file: configurationFile
409 def ciSpec = [
410 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
411 ]
412
413 if (ciConfig.containsKey('si-tests-feature-flags')) {
414 common.infoMsg("""SI tests feature flags customization detected,
415 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
416
417 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
418 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200419
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200420 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200421 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
422 }
423
424 common.infoMsg("""Additional ci configuration parsed successfully:
425 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
426 return ciSpec
427}
428
429/**
430 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200431
Владислав Наумов81777472021-03-09 15:14:27 +0400432 * 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 +0200433 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
434 * Example scheme:
435 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
436 * manage refspecs through Jenkins Job Parameters
437 *
438 * @return (map)[ core: (string) final refspec for kaas/core
439 * corePipelines: (string) final refspec for pipelines in kaas/core
440 * ]
441 */
442def checkCustomCoreRefspec() {
443 def common = new com.mirantis.mk.Common()
444
445 // Available triggers and its sane defaults
446 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
447 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
448 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
449 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
450
451 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
452 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
453
454 if (coreMatches.size() > 0) {
455 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
456 }
457 if (corePipelinesMatches.size() > 0) {
458 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
459 }
460
461 common.infoMsg("""
462 kaas/core will be fetched from: ${coreRefspec}
463 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400464 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200465 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
466}
467
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200468
469/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200470 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
471 * needed to forward inside kaas core set of jobs
472 *
473 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
474 * @return (list)[ string(name: '', value: ''),
475 * ]
476 */
477def generateKaaSVarsFromContext(context) {
478 def common = new com.mirantis.mk.Common()
479 def parameters = []
480 def config = readYaml text: context
481
482 config.each { k,v ->
483 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
484 parameters.add(string(name: k, value: v))
485 }
486
487 return parameters
488}
489
490/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200491 * 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 +0400492 * 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 +0200493 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
494 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200495 * @param: component (string) component name [iam, lcm, stacklight]
496 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
497 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200498 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200499def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200500 def common = new com.mirantis.mk.Common()
501 // Determine if custom trigger keywords forwarded from gerrit
502 def triggers = checkDeploymentTestSuite()
503 // Determine SI refspecs
504 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200505 // Determine Core refspecs
506 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200507
Владислав Наумов418042b2020-07-09 18:31:10 +0200508 // Determine component repo ci configuration
509 def ciSpec = [:]
510 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
511 if (fileExists(configurationFile)) {
512 common.infoMsg('Component CI configuration file detected, parsing...')
513 ciSpec = parseKaaSComponentCIParameters(configurationFile)
514 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
515 } else {
516 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200517 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200518 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
519 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200520 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400521
522 def platforms = []
523 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
524 // Currently only vsphere demo is required for IPAM component
525 platforms.add('vsphere')
526 } else {
527 if (triggers.osDemoEnabled) {
528 platforms.add('openstack')
529 }
530 if (triggers.awsOnDemandDemoEnabled) {
531 platforms.add('aws')
532 }
533 if (triggers.equinixOnDemandDemoEnabled) {
534 platforms.add('equinix')
535 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200536 if (triggers.azureOnDemandDemoEnabled) {
537 platforms.add('azure')
538 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400539 if (triggers.vsphereDemoEnabled) {
540 platforms.add('vsphere')
541 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400542 }
543
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200544 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200545 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200546 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
547 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200548 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200549 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200550 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
551 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200552 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200553 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400554 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100555 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200556 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200557 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100558 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200559 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400560 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200561 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200562 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200563 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200564 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200565 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
566 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100567 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100568 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200569 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400570 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200571 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
eromanovad3397512021-04-01 20:19:19 +0400572 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200573 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200574 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200575 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200576
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200577 // customize multiregional demo
578 if (triggers.multiregionalConfiguration.enabled) {
579 parameters.add(string(name: 'MULTIREGION_SETUP',
580 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
581 ))
582 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200583
Владислав Наумов92288d92020-07-13 18:36:21 +0200584 // Determine component team custom context
585 if (coreContext != '') {
586 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
587 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200588 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200589 }
590
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200591 if (triggers.awsOnDemandDemoEnabled ||
592 triggers.equinixOnDemandDemoEnabled ||
593 triggers.azureOnDemandDemoEnabled) {
594
Владислав Наумовe021b022021-05-06 11:26:38 +0200595 common.infoMsg('Public provider demo triggered, need to sync artifacts in the public-ci cdn..')
596 switch (component) {
597 case 'iam':
598 build job: 'cdn-binary-dev-replication-iam', propagate: true, wait: true
599 break
600 case 'lcm':
601 build job: 'cdn-binary-dev-replication-lcm', propagate: true, wait: true
602 break
603 }
604 }
605
Владислав Наумовaa430612020-06-08 17:18:31 +0200606 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400607
608 platforms.each { platform ->
609 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000610 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400611 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
612 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
613 def build_description = job_info.getDescription()
614 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000615 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200616
Vladislav Naumov5313a202021-04-07 17:13:39 +0000617 if (build_description) {
618 currentBuild.description += build_description
619 }
620 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400621 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000622 }
623 }
624 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200625
626 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400627 if (jobs.size() == 0) {
628 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
629 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200630 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
631 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200632
633 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200634 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200635 currentBuild.result = 'FAILURE'
636 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200637}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200638
639
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400640/**
641 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200642 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400643 *
644 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
645 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
646 * @param: multiregionalConfiguration (map) Multiregional configuration
647 * @return (map) Return aggregated map with lockResources and netMap
648 */
649
650
651def generateLockResources(callBackDemo, triggers) {
652 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200653 def netMap = [
654 vsphere: [:],
655 equinix: [:],
656 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400657 // Define vsphere locklabels with initial quantity
658 def lockLabels = [
659 vsphere_networking_core_ci: 0,
660 vsphere_offline_networking_core_ci: 0,
661 ]
662 def deployChild = triggers.deployChildEnabled
663 def multiregionConfig = triggers.multiregionalConfiguration
664 def runMultiregion = multiregionConfig.enabled
665
666 // Generate vsphere netMap and lockLabels based on demo context
667 switch (callBackDemo) {
668 case 'aws':
669 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
670 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
671
672 // Define netMap for Vsphere region
673 if (runMultiregion && multiregionConfig.regionLocation == 'vsphere') {
674 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200675 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400676 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200677 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400678 }
679 break
680 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200681 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400682 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200683 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400684 }
685 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
686 multiregionConfig.regionLocation == 'vsphere') {
687 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200688 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400689 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200690 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400691 }
692 break
693 default:
694 error('Supposed to be called from aws or vsphere demos only')
695 }
696
697 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
698 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200699 netMap['vsphere'].each { clusterType, netConfig ->
700 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
701 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
702 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
703
704 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400705 lockLabels['vsphere_offline_networking_core_ci']++
706 } else {
707 lockLabels['vsphere_networking_core_ci']++
708 }
709 }
710
711 // generate lock metadata
712 def lockResources = []
713 lockLabels.each { label, quantity ->
714 if (quantity > 0) {
715 def res = [
716 label: label,
717 quantity: quantity,
718 ]
719 lockResources.add(res)
720 }
721 }
722
723 common.infoMsg("""Generated vsphere netMap: ${netMap}
724 Generated lockResources: ${lockResources}""")
725
726 return [
727 netMap: netMap,
728 lockResources: lockResources,
729 ]
730}
731
732/**
733 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
734 * and empty rangeConfig to the this map.
735 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200736 * @param: netMap (string) vsphere, equinix netMap or empty map
737 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400738 * @param: clusterType (string) Vsphere cluster type
739 */
740
Владислав Наумов33e1e812021-08-17 17:09:25 +0200741def addToProviderNetMap (netMap, provider, clusterType) {
742 switch (provider) {
743 case 'equinix':
744 netMap[provider][clusterType] = [
745 vlanConfig: '',
746 ]
747 break
748 case 'vsphere':
749 netMap[provider][clusterType] = [
750 netName: 'default',
751 rangeConfig: '',
752 ]
753 break
754 default:
755 error('Net map locks supported for Equinix/Vsphere providers only')
756 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400757}