blob: 702a4accb7a28497a046ecd2c822be3780aad02f [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 Ivanov38ee4382022-01-27 16:21:51 +040054 def mosDeployChild = env.DEPLOY_MOS_CHILD_CLUSTER ? env.DEPLOY_MOS_CHILD_CLUSTER.toBoolean() : false
55 def mosUpgradeChild = env.UPGRADE_MOS_CHILD_CLUSTER ? env.UPGRADE_MOS_CHILD_CLUSTER.toBoolean() : false
Mikhail Ivanov74504372021-05-21 17:01:06 +040056 def customChildRelease = env.KAAS_CHILD_CLUSTER_RELEASE_NAME ? env.KAAS_CHILD_CLUSTER_RELEASE_NAME : ''
Владислав Наумов0dc99252020-11-13 13:30:48 +010057 def attachBYO = env.ATTACH_BYO ? env.ATTACH_BYO.toBoolean() : false
Владислав Наумовcdbd84e2020-12-01 16:51:09 +010058 def upgradeBYO = env.UPGRADE_BYO ? env.UPGRADE_BYO.toBoolean() : false
Vladislav Naumov7930ab22021-11-22 18:24:24 +010059 def runBYOMatrix = env.RUN_BYO_MATRIX ? env.RUN_BYO_MATRIX.toBoolean() : false
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +040060 def defaultBYOOs = env.DEFAULT_BYO_OS ? env.DEFAULT_BYO_OS.toString() : 'ubuntu'
Владислав Наумов6c2afff2020-06-05 12:54:53 +020061 def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +040062 def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020063 def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
64 def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
Владислав Наумов9cec55d2021-08-03 15:00:59 +020065 def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +020066 def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020067 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
68 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Vladislav Naumov42b71dc2021-11-22 13:09:42 +010069 def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false
slalov13e579c2022-01-31 21:37:02 +040070 def runMaintenanceTest = env.RUN_MAINTENANCE_TEST ? env.RUN_MAINTENANCE_TEST.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020071 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
72 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
73 enabled: false,
74 managementLocation: '',
75 regionLocation: '',
76 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020077
Владислав Наумовb8305e22021-02-10 17:23:12 +010078 // proxy customization
79 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020080 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
81 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020082 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010083 ]
84
Владислав Наумов4eb1da32020-08-31 14:45:16 +020085 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020086 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +020087 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +020088 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +020089 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +020090 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +020091 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +040092 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +020093 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +030094 def enableBMDemo = true
Mikhail Ivanovb6283f72021-11-24 18:34:57 +040095 def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
vnaumov33747e12020-05-04 17:35:20 +020096
Владислав Наумов6c2afff2020-06-05 12:54:53 +020097 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +010098 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
99 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +0200100 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 +0100101 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100102 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
103 seedMacOs = true
104 }
vnaumov33747e12020-05-04 17:35:20 +0200105 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) {
106 deployChild = true
107 }
108 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
109 deployChild = true
110 upgradeChild = true
111 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400112 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
113 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400114 // override child version when it set explicitly
115 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400116 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400117 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
118 }
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400119 if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) {
120 mosDeployChild = true
121 }
122 if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) {
123 mosDeployChild = true
124 mosUpgradeChild = true
125 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100126 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
127 attachBYO = true
128 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100129 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
130 attachBYO = true
131 upgradeBYO = true
132 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400133
134 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
135 if (commitMsg ==~ /(?s).*\[run-byo-matrix\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*run-byo-matrix\.*/ || byoDeployMatches.size() > 0) {
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100136 runBYOMatrix = true
137
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400138 if (byoDeployMatches.size() > 0) {
139 defaultBYOOs = byoDeployMatches[0][2]
140 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
141 }
142
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100143 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
144 attachBYO = false
145 upgradeBYO = false
146 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400147 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200148 upgradeMgmt = true
149 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400150 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
151 enableLMALogging = true
152 }
vnaumov33747e12020-05-04 17:35:20 +0200153 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
154 runUie2e = true
155 }
156 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
157 runMgmtConformance = true
158 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200159 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
160 runMgmtUserControllerTest = true
161 }
vnaumov33747e12020-05-04 17:35:20 +0200162 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
163 runChildConformance = true
164 deployChild = true
165 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200166 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
167 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400168 enableLMALogging = true
169 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400170 }
slalov13e579c2022-01-31 21:37:02 +0400171 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
172 runMaintenanceTest = true
173 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200174 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
175 proxyConfig['childOffline'] = true
176 deployChild = true
177 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200178 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
179 proxyConfig['childOffline'] = true
180 proxyConfig['childProxy'] = true
181 deployChild = true
182 }
vnaumov33747e12020-05-04 17:35:20 +0200183 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
184 fetchServiceBinaries = true
185 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200186 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400187 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200188 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 +0400189 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200190 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
191 azureOnAwsDemo = true
192 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
193 }
194 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
195 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
196 attachBYO ||
197 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100198 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200199 seedMacOs ||
200 equinixOnAwsDemo ||
201 azureOnAwsDemo) {
202
vnaumov33747e12020-05-04 17:35:20 +0200203 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200204 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 +0200205 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200206 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200207 equinixOnDemandDemo = true
208 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200209 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200210 equinixMetalV2OnDemandDemo = true
211 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100212 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
213 equinixMetalV2OnDemandDemo = true
214 equinixMetalV2ChildDiffMetro = true
215 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200216 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
217 azureOnDemandDemo = true
218 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200219 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
220 enableOSDemo = false
221 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200222 }
223
azvyagintsev1761bdc2020-09-04 17:24:12 +0300224 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
225 enableBMDemo = false
226 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
227 }
228
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400229 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
230 enableVsphereDemo = false
231 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
232 }
233
vnaumov33747e12020-05-04 17:35:20 +0200234 // TODO (vnaumov) remove below condition after moving all releases to UCP
235 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
236 if (ucpChildMatches.size() > 0) {
237 deployChild = true
238 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
239
240 // TODO(vnaumov) delete after ucp upgrades support
241 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
242 upgradeChild = false
243 }
244
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200245 // multiregional tests
246 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
247 if (multiRegionalMatches.size() > 0) {
248 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
249 }
250 switch (multiregionalMappings['managementLocation']) {
251 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100252 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200253 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100254
255 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
256 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
257 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200258 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200259 case 'os':
260 if (enableOSDemo == false) {
261 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
262 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200263 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200264 case 'vsphere':
265 if (enableVsphereDemo == false) {
266 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
267 }
268 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200269 case 'equinix':
270 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
271 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400272 break
eromanova8c702ae2021-12-24 17:43:12 +0400273 case 'equinixmetalv2':
274 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
275 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400276 break
slalovfd0b7e62021-07-28 18:05:16 +0400277 case 'azure':
278 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
279 azureOnDemandDemo = true
280 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200281 }
282
Владислав Наумовb8305e22021-02-10 17:23:12 +0100283 // CDN configuration
284 def cdnConfig = [
285 mgmt: [
286 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200287 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100288 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200289 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200290 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200291 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100292 ]
293
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400294 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
295 openstackIMC = 'eu'
296 // use internal-eu because on internal-ci with eu cloud image pull takes much time
297 def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
298 common.infoMsg("eu-demo was triggered, force switching CDN region to ${cdnRegion}")
299 cdnConfig['mgmt']['openstack'] = cdnRegion
300 }
301
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100302 // calculate weight of current demo run to manage lockable resources
303 def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1
304
vnaumov33747e12020-05-04 17:35:20 +0200305 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400306 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100307 CDN deployment configuration: ${cdnConfig}
308 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100309 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200310 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400311 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200312 Child cluster release upgrade scheduled: ${upgradeChild}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400313 MOS child deploy scheduled: ${mosDeployChild}
314 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200315 Child conformance testing scheduled: ${runChildConformance}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100316 Single BYO cluster attachment scheduled: ${attachBYO}
317 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
318 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400319 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200320 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400321 Mgmt LMA logging enabled: ${enableLMALogging}
vnaumov33747e12020-05-04 17:35:20 +0200322 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200323 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200324 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200325 Mgmt UI e2e testing scheduled: ${runUie2e}
slalov13e579c2022-01-31 21:37:02 +0400326 Maintenance test: ${runMaintenanceTest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200327 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200328 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200329 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100330 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200331 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200332 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200333 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400334 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200335 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300336 BM provider deployment scheduled: ${enableBMDemo}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200337 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200338 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100339 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Владислав Наумов81777472021-03-09 15:14:27 +0400340 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200341 return [
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400342 osCloudLocation : openstackIMC,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100343 cdnConfig : cdnConfig,
344 proxyConfig : proxyConfig,
345 useMacOsSeedNode : seedMacOs,
346 deployChildEnabled : deployChild,
347 childDeployCustomRelease : customChildRelease,
348 upgradeChildEnabled : upgradeChild,
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400349 mosDeployChildEnabled : mosDeployChild,
350 mosUpgradeChildEnabled : mosUpgradeChild,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100351 runChildConformanceEnabled : runChildConformance,
352 attachBYOEnabled : attachBYO,
353 upgradeBYOEnabled : upgradeBYO,
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100354 runBYOMatrixEnabled : runBYOMatrix,
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400355 defaultBYOOs : defaultBYOOs,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100356 upgradeMgmtEnabled : upgradeMgmt,
357 enableLMALoggingEnabled : enableLMALogging,
358 runUie2eEnabled : runUie2e,
359 runMgmtConformanceEnabled : runMgmtConformance,
slalov13e579c2022-01-31 21:37:02 +0400360 runMaintenanceTestEnable : runMaintenanceTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100361 runLMATestEnabled : runLMATest,
362 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
363 fetchServiceBinariesEnabled : fetchServiceBinaries,
364 awsOnDemandDemoEnabled : awsOnDemandDemo,
365 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
366 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
367 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
368 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
369 azureOnDemandDemoEnabled : azureOnDemandDemo,
370 azureOnAwsDemoEnabled : azureOnAwsDemo,
371 vsphereDemoEnabled : enableVsphereDemo,
372 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
373 bmDemoEnabled : enableBMDemo,
374 osDemoEnabled : enableOSDemo,
375 multiregionalConfiguration : multiregionalMappings,
376 demoWeight : demoWeight]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200377}
378
379/**
380 * Determine management and regional setup for demo workflow scenario
381 *
382 *
383 * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]`
384 or Jenkins environment string variable in form like 'aws,os'
385 * @return (map)[
386 enabled: (bool),
387 * managementLocation: (string), //aws,os
388 * regionLocation: (string), //aws,os
389 * ]
390 */
391def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200392 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400393 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
394 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200395
396 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200397 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200398 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
399 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
400 } else {
401 common.infoMsg('Multiregion definition configured via environment variable')
402 clusterTypes = keyword.trim().split(',')
403 }
404
405 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100406 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200407 }
408
Владислав Наумовf793fe32020-09-11 15:19:19 +0200409 def desiredManagementProvider = clusterTypes[0].trim()
410 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200411 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
412 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200413 management providers list - ${supportedManagementProviders}
414 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200415 }
416
417 return [
418 enabled: true,
419 managementLocation: desiredManagementProvider,
420 regionLocation: desiredRegionalProvider,
421 ]
vnaumov33747e12020-05-04 17:35:20 +0200422}
423
424/**
425 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
426
Владислав Наумов81777472021-03-09 15:14:27 +0400427 * 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 +0200428 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
429 * Example scheme:
430 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
431 * manage refspecs through Jenkins Job Parameters
432 *
azvyagintseva12230a2020-06-05 13:24:06 +0300433 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200434 * siPipelines: (string) final refspec for si-pipelines
435 * ]
436 */
437def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200438 def common = new com.mirantis.mk.Common()
439
vnaumov33747e12020-05-04 17:35:20 +0200440 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200441 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
442 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200443 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
444 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200445 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200446
447 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
448 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
449
450 if (siTestMatches.size() > 0) {
451 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400452 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200453 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200454 }
455 if (siPipelinesMatches.size() > 0) {
456 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
457 }
458
459 common.infoMsg("""
460 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
461 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200462 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400463 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200464 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200465}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200466
Владислав Наумов9080f372020-06-08 13:57:16 +0200467/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200468 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200469 * @param configurationFile (str) path to configuration file in yaml format
470 *
471 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
472 * ]
473 */
474def parseKaaSComponentCIParameters(configurationFile){
475 def common = new com.mirantis.mk.Common()
476 def ciConfig = readYaml file: configurationFile
477 def ciSpec = [
478 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
479 ]
480
481 if (ciConfig.containsKey('si-tests-feature-flags')) {
482 common.infoMsg("""SI tests feature flags customization detected,
483 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
484
485 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
486 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200487
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200488 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200489 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
490 }
491
492 common.infoMsg("""Additional ci configuration parsed successfully:
493 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
494 return ciSpec
495}
496
497/**
498 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200499
Владислав Наумов81777472021-03-09 15:14:27 +0400500 * 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 +0200501 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
502 * Example scheme:
503 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
504 * manage refspecs through Jenkins Job Parameters
505 *
506 * @return (map)[ core: (string) final refspec for kaas/core
507 * corePipelines: (string) final refspec for pipelines in kaas/core
508 * ]
509 */
510def checkCustomCoreRefspec() {
511 def common = new com.mirantis.mk.Common()
512
513 // Available triggers and its sane defaults
514 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
515 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
516 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
517 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
518
519 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
520 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
521
522 if (coreMatches.size() > 0) {
523 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
524 }
525 if (corePipelinesMatches.size() > 0) {
526 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
527 }
528
529 common.infoMsg("""
530 kaas/core will be fetched from: ${coreRefspec}
531 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400532 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200533 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
534}
535
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200536
537/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200538 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
539 * needed to forward inside kaas core set of jobs
540 *
541 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
542 * @return (list)[ string(name: '', value: ''),
543 * ]
544 */
545def generateKaaSVarsFromContext(context) {
546 def common = new com.mirantis.mk.Common()
547 def parameters = []
548 def config = readYaml text: context
549
550 config.each { k,v ->
551 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
552 parameters.add(string(name: k, value: v))
553 }
554
555 return parameters
556}
557
558/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200559 * 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 +0400560 * 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 +0200561 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
562 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200563 * @param: component (string) component name [iam, lcm, stacklight]
564 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
565 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200566 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200567def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200568 def common = new com.mirantis.mk.Common()
569 // Determine if custom trigger keywords forwarded from gerrit
570 def triggers = checkDeploymentTestSuite()
571 // Determine SI refspecs
572 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200573 // Determine Core refspecs
574 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200575
Владислав Наумов418042b2020-07-09 18:31:10 +0200576 // Determine component repo ci configuration
577 def ciSpec = [:]
578 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
579 if (fileExists(configurationFile)) {
580 common.infoMsg('Component CI configuration file detected, parsing...')
581 ciSpec = parseKaaSComponentCIParameters(configurationFile)
582 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
583 } else {
584 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200585 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200586 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
587 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200588 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400589
590 def platforms = []
591 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
592 // Currently only vsphere demo is required for IPAM component
593 platforms.add('vsphere')
594 } else {
595 if (triggers.osDemoEnabled) {
596 platforms.add('openstack')
597 }
598 if (triggers.awsOnDemandDemoEnabled) {
599 platforms.add('aws')
600 }
601 if (triggers.equinixOnDemandDemoEnabled) {
602 platforms.add('equinix')
603 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200604 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
605 platforms.add('equinixmetalv2')
606 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200607 if (triggers.azureOnDemandDemoEnabled) {
608 platforms.add('azure')
609 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400610 if (triggers.vsphereDemoEnabled) {
611 platforms.add('vsphere')
612 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400613 }
614
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200615 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200616 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200617 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
618 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200619 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200620 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200621 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
622 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200623 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200624 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400625 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400626 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100627 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200628 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200629 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100630 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200631 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400632 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200633 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200634 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
slalov13e579c2022-01-31 21:37:02 +0400635 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnable),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200636 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200637 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200638 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
639 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100640 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100641 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100642 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200643 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400644 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200645 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200646 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100647 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400648 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200649 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200650 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200651 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200652
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200653 // customize multiregional demo
654 if (triggers.multiregionalConfiguration.enabled) {
655 parameters.add(string(name: 'MULTIREGION_SETUP',
656 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
657 ))
658 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200659
Владислав Наумов92288d92020-07-13 18:36:21 +0200660 // Determine component team custom context
661 if (coreContext != '') {
662 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
663 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200664 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200665 }
666
Владислав Наумовaa430612020-06-08 17:18:31 +0200667 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400668
669 platforms.each { platform ->
670 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000671 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400672 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
673 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
674 def build_description = job_info.getDescription()
675 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000676 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200677
Vladislav Naumov5313a202021-04-07 17:13:39 +0000678 if (build_description) {
679 currentBuild.description += build_description
680 }
681 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400682 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000683 }
684 }
685 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200686
687 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400688 if (jobs.size() == 0) {
689 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
690 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200691 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
692 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200693
694 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200695 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200696 currentBuild.result = 'FAILURE'
697 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200698}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200699
700
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400701/**
702 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200703 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400704 *
705 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
706 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
707 * @param: multiregionalConfiguration (map) Multiregional configuration
708 * @return (map) Return aggregated map with lockResources and netMap
709 */
710
711
712def generateLockResources(callBackDemo, triggers) {
713 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200714 def netMap = [
715 vsphere: [:],
716 equinix: [:],
717 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400718 // Define vsphere locklabels with initial quantity
719 def lockLabels = [
720 vsphere_networking_core_ci: 0,
721 vsphere_offline_networking_core_ci: 0,
722 ]
723 def deployChild = triggers.deployChildEnabled
724 def multiregionConfig = triggers.multiregionalConfiguration
725 def runMultiregion = multiregionConfig.enabled
726
727 // Generate vsphere netMap and lockLabels based on demo context
728 switch (callBackDemo) {
729 case 'aws':
730 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
731 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +0400732 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400733
734 // Define netMap for Vsphere region
Владислав Наумовf60480d2021-10-15 14:04:01 +0200735 if (runMultiregion && multiregionConfig.managementLocation == 'aws' &&
736 multiregionConfig.regionLocation == 'vsphere') {
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400737 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200738 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400739 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200740 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400741 }
742 break
743 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200744 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400745 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200746 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400747 }
748 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
749 multiregionConfig.regionLocation == 'vsphere') {
750 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200751 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400752 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200753 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400754 }
755 break
756 default:
757 error('Supposed to be called from aws or vsphere demos only')
758 }
759
760 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
761 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200762 netMap['vsphere'].each { clusterType, netConfig ->
763 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
764 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
765 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
766
767 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400768 lockLabels['vsphere_offline_networking_core_ci']++
769 } else {
770 lockLabels['vsphere_networking_core_ci']++
771 }
772 }
773
774 // generate lock metadata
775 def lockResources = []
776 lockLabels.each { label, quantity ->
777 if (quantity > 0) {
778 def res = [
779 label: label,
780 quantity: quantity,
781 ]
782 lockResources.add(res)
783 }
784 }
785
786 common.infoMsg("""Generated vsphere netMap: ${netMap}
787 Generated lockResources: ${lockResources}""")
788
789 return [
790 netMap: netMap,
791 lockResources: lockResources,
792 ]
793}
794
795/**
796 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
797 * and empty rangeConfig to the this map.
798 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200799 * @param: netMap (string) vsphere, equinix netMap or empty map
800 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400801 * @param: clusterType (string) Vsphere cluster type
802 */
803
Владислав Наумов33e1e812021-08-17 17:09:25 +0200804def addToProviderNetMap (netMap, provider, clusterType) {
805 switch (provider) {
806 case 'equinix':
807 netMap[provider][clusterType] = [
808 vlanConfig: '',
809 ]
810 break
811 case 'vsphere':
812 netMap[provider][clusterType] = [
813 netName: 'default',
814 rangeConfig: '',
815 ]
816 break
817 default:
818 error('Net map locks supported for Equinix/Vsphere providers only')
819 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400820}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +0300821
822/**
823* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
824* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
825* If keyword contains only 'key' part then 'value' is boolean True.
826* This function does not perform keywords validation.
827* First line of a commit message is ignored.
828* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
829* TODO: Remove backslash chars from values if they prepend '[' or ']'.
830**/
831
832List getCIKeywordsFromCommitMsg() {
833 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
834 List commitMsgLines = commitMsg.split('\n')
835 List keywords = []
836 if (commitMsgLines.size() < 2) {
837 return keywords
838 }
839
840 String commitMsgBody = commitMsgLines[1..-1].join('\n')
841
842 // Split commit message body to chunks using '[' or ']' as delimiter,
843 // ignoring them if prepended by backslash (regex negative lookbehind).
844 // Resulting list will have chunks between '[' and ']' at odd indexes.
845 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
846
847 // Iterate chunks by odd indexes only, trim values and split to
848 // <key> / <value> pair where <key> is the part of a sting before the first
849 // whitespace delimiter, and <value> is the rest (may include whitespaces).
850 // If there is no whitespace in the string then this is a 'switch'
851 // and <value> will be boolean True.
852 for (i = 1; i < parts.size(); i += 2) {
853 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
854 keywords.add(['key': key, 'value': value])
855 }
856
857 return keywords
858}
859
860/**
861* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
862* that were specified for given job name. `job-params` keyword has the following structure
863*
864* [job-params <job name> <parameter name> <parameter value>]
865*
866* Return value is a Map that contains those parameters using the following structure:
867*
868* <job name>:
869* <parameter name>: <parameter value>
870*
871**/
872Map getJobsParamsFromCommitMsg() {
873 List keywords = getCIKeywordsFromCommitMsg()
874
875 List jobsParamsList = []
876 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
877 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
878 def (key, value) = params.split(/\s+/, 2)
879 ['name': name, 'key': key, 'value': value]
880 }
881
882 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
883 if (!result.containsKey(it.name)) {
884 result[it.name] = [:]
885 }
886 result[it.name][it.key] = it.value
887 result
888 }
889
890 return jobsParams
891}
892
893
894/**
895* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
896* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
897* uses only those parametes that were set to all jobs (with <job name> == '*') or to
898* a particular job. Parameters set to a particular job have higher precedence.
899*
900* Return value is a Map that contains those parameters:
901*
902* <parameter name>: <parameter value>
903*
904**/
905Map getJobParamsFromCommitMsg(String jobName) {
906 jobsParams = getJobsParamsFromCommitMsg()
907 jobParams = jobsParams.getOrDefault('*', [:])
908 if (jobName) {
909 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
910 }
911 return jobParams
912}