blob: c9d9a6864f90dcb1da21832141d1b4d75d834e7c [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
Vladislav Naumov42b71dc2021-11-22 13:09:42 +010065 def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020066 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
67 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
68 enabled: false,
69 managementLocation: '',
70 regionLocation: '',
71 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020072
Владислав Наумовb8305e22021-02-10 17:23:12 +010073 // proxy customization
74 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020075 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
76 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020077 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010078 ]
79
Владислав Наумов4eb1da32020-08-31 14:45:16 +020080 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020081 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +020082 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +020083 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +020084 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +020085 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +020086 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +040087 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +020088 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +030089 def enableBMDemo = true
vnaumov33747e12020-05-04 17:35:20 +020090
Владислав Наумов6c2afff2020-06-05 12:54:53 +020091 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +010092 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
93 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +020094 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 +010095 }
Владислав Наумов44c64b72020-12-04 20:22:53 +010096 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
97 seedMacOs = true
98 }
vnaumov33747e12020-05-04 17:35:20 +020099 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) {
100 deployChild = true
101 }
102 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
103 deployChild = true
104 upgradeChild = true
105 }
Mikhail Ivanov76d69952021-06-04 16:06:45 +0400106 def deployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
Mikhail Ivanov74504372021-05-21 17:01:06 +0400107 if (deployMatches.size() > 0) {
108 // override child version when it set explicitly
109 deployChild = true
Mikhail Ivanoved543492021-05-24 16:26:55 +0400110 customChildRelease = deployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400111 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
112 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100113 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
114 attachBYO = true
115 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100116 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
117 attachBYO = true
118 upgradeBYO = true
119 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400120 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200121 upgradeMgmt = true
122 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400123 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
124 enableLMALogging = true
125 }
vnaumov33747e12020-05-04 17:35:20 +0200126 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
127 runUie2e = true
128 }
129 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
130 runMgmtConformance = true
131 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200132 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
133 runMgmtUserControllerTest = true
134 }
vnaumov33747e12020-05-04 17:35:20 +0200135 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
136 runChildConformance = true
137 deployChild = true
138 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200139 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
140 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400141 enableLMALogging = true
142 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400143 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200144 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
145 proxyConfig['childOffline'] = true
146 deployChild = true
147 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200148 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
149 proxyConfig['childOffline'] = true
150 proxyConfig['childProxy'] = true
151 deployChild = true
152 }
vnaumov33747e12020-05-04 17:35:20 +0200153 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
154 fetchServiceBinaries = true
155 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200156 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400157 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200158 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 +0400159 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200160 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
161 azureOnAwsDemo = true
162 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
163 }
164 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
165 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
166 attachBYO ||
167 upgradeBYO ||
168 seedMacOs ||
169 equinixOnAwsDemo ||
170 azureOnAwsDemo) {
171
vnaumov33747e12020-05-04 17:35:20 +0200172 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200173 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 +0200174 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200175 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200176 equinixOnDemandDemo = true
177 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200178 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200179 equinixMetalV2OnDemandDemo = true
180 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100181 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
182 equinixMetalV2OnDemandDemo = true
183 equinixMetalV2ChildDiffMetro = true
184 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200185 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
186 azureOnDemandDemo = true
187 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200188 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
189 enableOSDemo = false
190 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200191 }
192
azvyagintsev1761bdc2020-09-04 17:24:12 +0300193 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
194 enableBMDemo = false
195 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
196 }
197
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400198 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
199 enableVsphereDemo = false
200 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
201 }
202
vnaumov33747e12020-05-04 17:35:20 +0200203 // TODO (vnaumov) remove below condition after moving all releases to UCP
204 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
205 if (ucpChildMatches.size() > 0) {
206 deployChild = true
207 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
208
209 // TODO(vnaumov) delete after ucp upgrades support
210 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
211 upgradeChild = false
212 }
213
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200214 // multiregional tests
215 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
216 if (multiRegionalMatches.size() > 0) {
217 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
218 }
219 switch (multiregionalMappings['managementLocation']) {
220 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100221 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200222 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100223
224 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
225 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
226 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200227 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200228 case 'os':
229 if (enableOSDemo == false) {
230 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
231 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200232 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200233 case 'vsphere':
234 if (enableVsphereDemo == false) {
235 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
236 }
237 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200238 case 'equinix':
239 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
240 equinixOnDemandDemo = true
241 break
slalovfd0b7e62021-07-28 18:05:16 +0400242 case 'azure':
243 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
244 azureOnDemandDemo = true
245 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200246 }
247
Владислав Наумовb8305e22021-02-10 17:23:12 +0100248 // CDN configuration
249 def cdnConfig = [
250 mgmt: [
251 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200252 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100253 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200254 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200255 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200256 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100257 ]
258
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100259 // calculate weight of current demo run to manage lockable resources
260 def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1
261
vnaumov33747e12020-05-04 17:35:20 +0200262 common.infoMsg("""
Владислав Наумовb8305e22021-02-10 17:23:12 +0100263 CDN deployment configuration: ${cdnConfig}
264 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100265 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200266 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400267 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200268 Child cluster release upgrade scheduled: ${upgradeChild}
269 Child conformance testing scheduled: ${runChildConformance}
Владислав Наумов0dc99252020-11-13 13:30:48 +0100270 BYO cluster attachment scheduled: ${attachBYO}
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100271 Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
vnaumov33747e12020-05-04 17:35:20 +0200272 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400273 Mgmt LMA logging enabled: ${enableLMALogging}
vnaumov33747e12020-05-04 17:35:20 +0200274 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200275 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200276 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200277 Mgmt UI e2e testing scheduled: ${runUie2e}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200278 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200279 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200280 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100281 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200282 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200283 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200284 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400285 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200286 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300287 BM provider deployment scheduled: ${enableBMDemo}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200288 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200289 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100290 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Владислав Наумов81777472021-03-09 15:14:27 +0400291 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200292 return [
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100293 cdnConfig : cdnConfig,
294 proxyConfig : proxyConfig,
295 useMacOsSeedNode : seedMacOs,
296 deployChildEnabled : deployChild,
297 childDeployCustomRelease : customChildRelease,
298 upgradeChildEnabled : upgradeChild,
299 runChildConformanceEnabled : runChildConformance,
300 attachBYOEnabled : attachBYO,
301 upgradeBYOEnabled : upgradeBYO,
302 upgradeMgmtEnabled : upgradeMgmt,
303 enableLMALoggingEnabled : enableLMALogging,
304 runUie2eEnabled : runUie2e,
305 runMgmtConformanceEnabled : runMgmtConformance,
306 runLMATestEnabled : runLMATest,
307 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
308 fetchServiceBinariesEnabled : fetchServiceBinaries,
309 awsOnDemandDemoEnabled : awsOnDemandDemo,
310 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
311 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
312 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
313 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
314 azureOnDemandDemoEnabled : azureOnDemandDemo,
315 azureOnAwsDemoEnabled : azureOnAwsDemo,
316 vsphereDemoEnabled : enableVsphereDemo,
317 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
318 bmDemoEnabled : enableBMDemo,
319 osDemoEnabled : enableOSDemo,
320 multiregionalConfiguration : multiregionalMappings,
321 demoWeight : demoWeight]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200322}
323
324/**
325 * Determine management and regional setup for demo workflow scenario
326 *
327 *
328 * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]`
329 or Jenkins environment string variable in form like 'aws,os'
330 * @return (map)[
331 enabled: (bool),
332 * managementLocation: (string), //aws,os
333 * regionLocation: (string), //aws,os
334 * ]
335 */
336def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200337 def common = new com.mirantis.mk.Common()
slalovde59e312021-07-27 16:25:16 +0400338 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'azure']
slalov19d6e772021-08-09 15:29:04 +0400339 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200340
341 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200342 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200343 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
344 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
345 } else {
346 common.infoMsg('Multiregion definition configured via environment variable')
347 clusterTypes = keyword.trim().split(',')
348 }
349
350 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100351 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200352 }
353
Владислав Наумовf793fe32020-09-11 15:19:19 +0200354 def desiredManagementProvider = clusterTypes[0].trim()
355 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200356 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
357 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200358 management providers list - ${supportedManagementProviders}
359 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200360 }
361
362 return [
363 enabled: true,
364 managementLocation: desiredManagementProvider,
365 regionLocation: desiredRegionalProvider,
366 ]
vnaumov33747e12020-05-04 17:35:20 +0200367}
368
369/**
370 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
371
Владислав Наумов81777472021-03-09 15:14:27 +0400372 * 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 +0200373 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
374 * Example scheme:
375 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
376 * manage refspecs through Jenkins Job Parameters
377 *
azvyagintseva12230a2020-06-05 13:24:06 +0300378 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200379 * siPipelines: (string) final refspec for si-pipelines
380 * ]
381 */
382def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200383 def common = new com.mirantis.mk.Common()
384
vnaumov33747e12020-05-04 17:35:20 +0200385 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200386 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
387 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200388 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
389 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200390 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200391
392 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
393 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
394
395 if (siTestMatches.size() > 0) {
396 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400397 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200398 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200399 }
400 if (siPipelinesMatches.size() > 0) {
401 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
402 }
403
404 common.infoMsg("""
405 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
406 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200407 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400408 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200409 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200410}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200411
Владислав Наумов9080f372020-06-08 13:57:16 +0200412/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200413 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200414 * @param configurationFile (str) path to configuration file in yaml format
415 *
416 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
417 * ]
418 */
419def parseKaaSComponentCIParameters(configurationFile){
420 def common = new com.mirantis.mk.Common()
421 def ciConfig = readYaml file: configurationFile
422 def ciSpec = [
423 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
424 ]
425
426 if (ciConfig.containsKey('si-tests-feature-flags')) {
427 common.infoMsg("""SI tests feature flags customization detected,
428 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
429
430 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
431 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200432
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200433 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200434 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
435 }
436
437 common.infoMsg("""Additional ci configuration parsed successfully:
438 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
439 return ciSpec
440}
441
442/**
443 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200444
Владислав Наумов81777472021-03-09 15:14:27 +0400445 * 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 +0200446 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
447 * Example scheme:
448 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
449 * manage refspecs through Jenkins Job Parameters
450 *
451 * @return (map)[ core: (string) final refspec for kaas/core
452 * corePipelines: (string) final refspec for pipelines in kaas/core
453 * ]
454 */
455def checkCustomCoreRefspec() {
456 def common = new com.mirantis.mk.Common()
457
458 // Available triggers and its sane defaults
459 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
460 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
461 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
462 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
463
464 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
465 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
466
467 if (coreMatches.size() > 0) {
468 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
469 }
470 if (corePipelinesMatches.size() > 0) {
471 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
472 }
473
474 common.infoMsg("""
475 kaas/core will be fetched from: ${coreRefspec}
476 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400477 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200478 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
479}
480
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200481
482/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200483 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
484 * needed to forward inside kaas core set of jobs
485 *
486 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
487 * @return (list)[ string(name: '', value: ''),
488 * ]
489 */
490def generateKaaSVarsFromContext(context) {
491 def common = new com.mirantis.mk.Common()
492 def parameters = []
493 def config = readYaml text: context
494
495 config.each { k,v ->
496 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
497 parameters.add(string(name: k, value: v))
498 }
499
500 return parameters
501}
502
503/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200504 * 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 +0400505 * 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 +0200506 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
507 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200508 * @param: component (string) component name [iam, lcm, stacklight]
509 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
510 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200511 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200512def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200513 def common = new com.mirantis.mk.Common()
514 // Determine if custom trigger keywords forwarded from gerrit
515 def triggers = checkDeploymentTestSuite()
516 // Determine SI refspecs
517 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200518 // Determine Core refspecs
519 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200520
Владислав Наумов418042b2020-07-09 18:31:10 +0200521 // Determine component repo ci configuration
522 def ciSpec = [:]
523 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
524 if (fileExists(configurationFile)) {
525 common.infoMsg('Component CI configuration file detected, parsing...')
526 ciSpec = parseKaaSComponentCIParameters(configurationFile)
527 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
528 } else {
529 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200530 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200531 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
532 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200533 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400534
535 def platforms = []
536 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
537 // Currently only vsphere demo is required for IPAM component
538 platforms.add('vsphere')
539 } else {
540 if (triggers.osDemoEnabled) {
541 platforms.add('openstack')
542 }
543 if (triggers.awsOnDemandDemoEnabled) {
544 platforms.add('aws')
545 }
546 if (triggers.equinixOnDemandDemoEnabled) {
547 platforms.add('equinix')
548 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200549 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
550 platforms.add('equinixmetalv2')
551 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200552 if (triggers.azureOnDemandDemoEnabled) {
553 platforms.add('azure')
554 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400555 if (triggers.vsphereDemoEnabled) {
556 platforms.add('vsphere')
557 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400558 }
559
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200560 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200561 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200562 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
563 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200564 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200565 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200566 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
567 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200568 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200569 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400570 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100571 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200572 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200573 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100574 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200575 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400576 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200577 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200578 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200579 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200580 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200581 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
582 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100583 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100584 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200585 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400586 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200587 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200588 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100589 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400590 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200591 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200592 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200593 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200594
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200595 // customize multiregional demo
596 if (triggers.multiregionalConfiguration.enabled) {
597 parameters.add(string(name: 'MULTIREGION_SETUP',
598 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
599 ))
600 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200601
Владислав Наумов92288d92020-07-13 18:36:21 +0200602 // Determine component team custom context
603 if (coreContext != '') {
604 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
605 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200606 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200607 }
608
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200609 if (triggers.awsOnDemandDemoEnabled ||
610 triggers.equinixOnDemandDemoEnabled ||
611 triggers.azureOnDemandDemoEnabled) {
612
Владислав Наумовe021b022021-05-06 11:26:38 +0200613 common.infoMsg('Public provider demo triggered, need to sync artifacts in the public-ci cdn..')
614 switch (component) {
615 case 'iam':
616 build job: 'cdn-binary-dev-replication-iam', propagate: true, wait: true
617 break
618 case 'lcm':
619 build job: 'cdn-binary-dev-replication-lcm', propagate: true, wait: true
620 break
621 }
622 }
623
Владислав Наумовaa430612020-06-08 17:18:31 +0200624 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400625
626 platforms.each { platform ->
627 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000628 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400629 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
630 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
631 def build_description = job_info.getDescription()
632 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000633 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200634
Vladislav Naumov5313a202021-04-07 17:13:39 +0000635 if (build_description) {
636 currentBuild.description += build_description
637 }
638 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400639 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000640 }
641 }
642 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200643
644 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400645 if (jobs.size() == 0) {
646 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
647 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200648 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
649 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200650
651 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200652 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200653 currentBuild.result = 'FAILURE'
654 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200655}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200656
657
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400658/**
659 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200660 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400661 *
662 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
663 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
664 * @param: multiregionalConfiguration (map) Multiregional configuration
665 * @return (map) Return aggregated map with lockResources and netMap
666 */
667
668
669def generateLockResources(callBackDemo, triggers) {
670 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200671 def netMap = [
672 vsphere: [:],
673 equinix: [:],
674 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400675 // Define vsphere locklabels with initial quantity
676 def lockLabels = [
677 vsphere_networking_core_ci: 0,
678 vsphere_offline_networking_core_ci: 0,
679 ]
680 def deployChild = triggers.deployChildEnabled
681 def multiregionConfig = triggers.multiregionalConfiguration
682 def runMultiregion = multiregionConfig.enabled
683
684 // Generate vsphere netMap and lockLabels based on demo context
685 switch (callBackDemo) {
686 case 'aws':
687 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
688 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
689
690 // Define netMap for Vsphere region
Владислав Наумовf60480d2021-10-15 14:04:01 +0200691 if (runMultiregion && multiregionConfig.managementLocation == 'aws' &&
692 multiregionConfig.regionLocation == 'vsphere') {
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400693 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200694 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400695 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200696 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400697 }
698 break
699 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200700 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400701 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200702 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400703 }
704 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
705 multiregionConfig.regionLocation == 'vsphere') {
706 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200707 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400708 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200709 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400710 }
711 break
712 default:
713 error('Supposed to be called from aws or vsphere demos only')
714 }
715
716 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
717 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200718 netMap['vsphere'].each { clusterType, netConfig ->
719 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
720 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
721 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
722
723 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400724 lockLabels['vsphere_offline_networking_core_ci']++
725 } else {
726 lockLabels['vsphere_networking_core_ci']++
727 }
728 }
729
730 // generate lock metadata
731 def lockResources = []
732 lockLabels.each { label, quantity ->
733 if (quantity > 0) {
734 def res = [
735 label: label,
736 quantity: quantity,
737 ]
738 lockResources.add(res)
739 }
740 }
741
742 common.infoMsg("""Generated vsphere netMap: ${netMap}
743 Generated lockResources: ${lockResources}""")
744
745 return [
746 netMap: netMap,
747 lockResources: lockResources,
748 ]
749}
750
751/**
752 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
753 * and empty rangeConfig to the this map.
754 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200755 * @param: netMap (string) vsphere, equinix netMap or empty map
756 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400757 * @param: clusterType (string) Vsphere cluster type
758 */
759
Владислав Наумов33e1e812021-08-17 17:09:25 +0200760def addToProviderNetMap (netMap, provider, clusterType) {
761 switch (provider) {
762 case 'equinix':
763 netMap[provider][clusterType] = [
764 vlanConfig: '',
765 ]
766 break
767 case 'vsphere':
768 netMap[provider][clusterType] = [
769 netName: 'default',
770 rangeConfig: '',
771 ]
772 break
773 default:
774 error('Net map locks supported for Equinix/Vsphere providers only')
775 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400776}