blob: cd19a0a252e2730df73358d8194db53bd1645092 [file] [log] [blame]
vnaumov33747e12020-05-04 17:35:20 +02001package com.mirantis.mk
vnaumov33747e12020-05-04 17:35:20 +02002
azvyagintsevc17d14b2022-06-06 19:06:33 +03003import static groovy.json.JsonOutput.toJson
4
vnaumov33747e12020-05-04 17:35:20 +02005/**
6 *
7 * KaaS Component Testing Utilities
8 *
9 */
10
Владислав Наумовe5345812020-08-12 16:30:20 +020011/**
12 * Check KaaS Core CICD feature flags
13 * such triggers can be used in case of switching between pipelines,
14 * conditions inside pipelines to reduce dependency on jenkins job builder and jenkins job templates itself
15 *
16 * @return (map)[
17 * ffNameEnabled: (bool) True/False
18 * ]
19 */
20def checkCoreCIFeatureFlags() {
21 def common = new com.mirantis.mk.Common()
22 def ff = [
23 build_artifacts_upgrade: false,
24 ]
25
26 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
27 if (commitMsg ==~ /(?s).*\[ci-build-artifacts-upgrade\].*/) {
28 ff['build_artifacts_upgrade'] = true
29 }
30
31 common.infoMsg("Core ci feature flags status: ${ff}")
32 return ff
33}
vnaumov33747e12020-05-04 17:35:20 +020034
35/**
azvyagintseva12230a2020-06-05 13:24:06 +030036 * Determine scope of test suite against per-commit KaaS deployment based on keywords
Владислав Наумов81777472021-03-09 15:14:27 +040037 * 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 +030038 *
39 * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs
40 * Example scheme:
Владислав Наумовe5345812020-08-12 16:30:20 +020041 * 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 +030042 * manage test-suite through Jenkins Job Parameters
43 *
Владислав Наумов6c2afff2020-06-05 12:54:53 +020044 * @return (map)[
45 * deployChildEnabled: (bool) True if need to deploy child cluster during demo-run
46 * runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run
azvyagintseva12230a2020-06-05 13:24:06 +030047 * ]
48 */
vnaumov33747e12020-05-04 17:35:20 +020049def checkDeploymentTestSuite() {
vnaumovbdb90222020-05-04 18:25:50 +020050 def common = new com.mirantis.mk.Common()
51
vnaumov33747e12020-05-04 17:35:20 +020052 // Available triggers and its sane defaults
Владислав Наумов44c64b72020-12-04 20:22:53 +010053 def seedMacOs = env.SEED_MACOS ? env.SEED_MACOS.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020054 def deployChild = env.DEPLOY_CHILD_CLUSTER ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false
55 def upgradeChild = env.UPGRADE_CHILD_CLUSTER ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false
Mikhail Ivanov38ee4382022-01-27 16:21:51 +040056 def mosDeployChild = env.DEPLOY_MOS_CHILD_CLUSTER ? env.DEPLOY_MOS_CHILD_CLUSTER.toBoolean() : false
57 def mosUpgradeChild = env.UPGRADE_MOS_CHILD_CLUSTER ? env.UPGRADE_MOS_CHILD_CLUSTER.toBoolean() : false
Mikhail Ivanov74504372021-05-21 17:01:06 +040058 def customChildRelease = env.KAAS_CHILD_CLUSTER_RELEASE_NAME ? env.KAAS_CHILD_CLUSTER_RELEASE_NAME : ''
slalov021171f2022-03-04 14:48:38 +040059 def mosTfDeploy = env.MOS_TF_DEPLOY ? env.MOS_TF_DEPLOY.toBoolean() : false
Владислав Наумов0dc99252020-11-13 13:30:48 +010060 def attachBYO = env.ATTACH_BYO ? env.ATTACH_BYO.toBoolean() : false
Владислав Наумовcdbd84e2020-12-01 16:51:09 +010061 def upgradeBYO = env.UPGRADE_BYO ? env.UPGRADE_BYO.toBoolean() : false
Vladislav Naumov7930ab22021-11-22 18:24:24 +010062 def runBYOMatrix = env.RUN_BYO_MATRIX ? env.RUN_BYO_MATRIX.toBoolean() : false
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +040063 def defaultBYOOs = env.DEFAULT_BYO_OS ? env.DEFAULT_BYO_OS.toString() : 'ubuntu'
Владислав Наумов6c2afff2020-06-05 12:54:53 +020064 def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
slalov1202bba2022-04-20 22:31:07 +040065 def autoUpgradeMgmt = env.AUTO_UPGRADE_MCC ? env.AUTO_UPGRADE_MCC.toBoolean() : false
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +040066 def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020067 def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +040068 def runUie2eNew = env.RUN_UI_E2E_NEW ? env.RUN_UI_E2E_NEW.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020069 def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
Владислав Наумов9cec55d2021-08-03 15:00:59 +020070 def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +020071 def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false
Mikhail Ivanov2907e4d2022-04-25 16:41:21 +040072 def runProxyChildTest = env.RUN_PROXY_CHILD_TEST ? env.RUN_PROXY_CHILD_TEST.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020073 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
74 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Vladislav Naumov42b71dc2021-11-22 13:09:42 +010075 def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false
slalov13e579c2022-01-31 21:37:02 +040076 def runMaintenanceTest = env.RUN_MAINTENANCE_TEST ? env.RUN_MAINTENANCE_TEST.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020077 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
78 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
79 enabled: false,
80 managementLocation: '',
81 regionLocation: '',
82 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020083
Владислав Наумовb8305e22021-02-10 17:23:12 +010084 // proxy customization
85 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020086 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
87 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020088 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010089 ]
90
Владислав Наумов4eb1da32020-08-31 14:45:16 +020091 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020092 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +020093 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +020094 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +020095 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +020096 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +020097 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +040098 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +020099 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +0300100 def enableBMDemo = true
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400101 def enableArtifactsBuild = true
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400102 def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300103 def enableVsphereUbuntu = env.VSPHERE_DEPLOY_UBUNTU ? env.VSPHERE_DEPLOY_UBUNTU.toBoolean() : false
vnaumov33747e12020-05-04 17:35:20 +0200104
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200105 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +0100106 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
107 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +0200108 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 +0100109 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100110 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
111 seedMacOs = true
112 }
slalov574123e2022-04-06 17:24:19 +0400113 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance || runProxyChildTest) {
vnaumov33747e12020-05-04 17:35:20 +0200114 deployChild = true
115 }
116 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
117 deployChild = true
118 upgradeChild = true
119 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400120 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
121 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400122 // override child version when it set explicitly
123 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400124 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400125 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
126 }
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400127 if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) {
128 mosDeployChild = true
129 }
130 if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) {
131 mosDeployChild = true
132 mosUpgradeChild = true
133 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100134 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
135 attachBYO = true
136 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100137 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
138 attachBYO = true
139 upgradeBYO = true
140 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400141
142 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
143 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 +0100144 runBYOMatrix = true
145
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400146 if (byoDeployMatches.size() > 0) {
147 defaultBYOOs = byoDeployMatches[0][2]
148 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
149 }
150
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100151 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
152 attachBYO = false
153 upgradeBYO = false
154 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400155 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200156 upgradeMgmt = true
157 }
slalov1202bba2022-04-20 22:31:07 +0400158 if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) {
159 autoUpgradeMgmt = true
160 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400161 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
162 enableLMALogging = true
163 }
vnaumov33747e12020-05-04 17:35:20 +0200164 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
165 runUie2e = true
166 }
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400167 if (commitMsg ==~ /(?s).*\[ui-e2e-new\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-new.*/) {
168 runUie2eNew = true
169 }
vnaumov33747e12020-05-04 17:35:20 +0200170 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
171 runMgmtConformance = true
172 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200173 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
174 runMgmtUserControllerTest = true
175 }
slalov574123e2022-04-06 17:24:19 +0400176 if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) {
177 runProxyChildTest = true
178 deployChild = true
179 common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed')
180 }
vnaumov33747e12020-05-04 17:35:20 +0200181 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
182 runChildConformance = true
183 deployChild = true
184 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200185 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
186 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400187 enableLMALogging = true
188 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400189 }
slalov13e579c2022-01-31 21:37:02 +0400190 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
191 runMaintenanceTest = true
192 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200193 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
194 proxyConfig['childOffline'] = true
195 deployChild = true
196 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200197 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
198 proxyConfig['childOffline'] = true
199 proxyConfig['childProxy'] = true
200 deployChild = true
201 }
vnaumov33747e12020-05-04 17:35:20 +0200202 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
203 fetchServiceBinaries = true
204 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200205 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400206 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200207 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 +0400208 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200209 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
210 azureOnAwsDemo = true
211 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
212 }
213 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
214 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
215 attachBYO ||
216 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100217 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200218 seedMacOs ||
219 equinixOnAwsDemo ||
220 azureOnAwsDemo) {
221
vnaumov33747e12020-05-04 17:35:20 +0200222 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200223 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 +0200224 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200225 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200226 equinixOnDemandDemo = true
227 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200228 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200229 equinixMetalV2OnDemandDemo = true
230 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100231 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
232 equinixMetalV2OnDemandDemo = true
233 equinixMetalV2ChildDiffMetro = true
234 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200235 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
236 azureOnDemandDemo = true
237 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200238 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
239 enableOSDemo = false
240 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200241 }
242
azvyagintsev1761bdc2020-09-04 17:24:12 +0300243 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
244 enableBMDemo = false
245 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
246 }
247
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400248 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
249 enableVsphereDemo = false
250 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
251 }
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300252 if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) {
253 enableVsphereUbuntu = true
254 common.warningMsg('Ubuntu will be used to deploy vsphere machines')
255 }
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400256
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400257 if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) {
258 enableArtifactsBuild = false
259 common.errorMsg('artifacts build will be aborted, VF -1 will be set')
260 }
261
vnaumov33747e12020-05-04 17:35:20 +0200262 // TODO (vnaumov) remove below condition after moving all releases to UCP
263 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
264 if (ucpChildMatches.size() > 0) {
265 deployChild = true
266 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
267
268 // TODO(vnaumov) delete after ucp upgrades support
269 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
270 upgradeChild = false
271 }
272
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200273 // multiregional tests
274 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
275 if (multiRegionalMatches.size() > 0) {
276 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
277 }
278 switch (multiregionalMappings['managementLocation']) {
279 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100280 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200281 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100282
283 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
284 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
285 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200286 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200287 case 'os':
288 if (enableOSDemo == false) {
289 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
290 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200291 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200292 case 'vsphere':
293 if (enableVsphereDemo == false) {
294 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
295 }
296 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200297 case 'equinix':
298 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
299 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400300 break
eromanova8c702ae2021-12-24 17:43:12 +0400301 case 'equinixmetalv2':
302 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
303 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400304 break
slalovfd0b7e62021-07-28 18:05:16 +0400305 case 'azure':
306 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
307 azureOnDemandDemo = true
308 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200309 }
310
Владислав Наумовb8305e22021-02-10 17:23:12 +0100311 // CDN configuration
312 def cdnConfig = [
313 mgmt: [
314 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200315 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100316 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200317 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200318 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200319 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100320 ]
321
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400322 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
323 openstackIMC = 'eu'
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400324 }
slalov021171f2022-03-04 14:48:38 +0400325 if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) {
326 openstackIMC = 'eu2'
Mikhail Ivanovf05b8252022-04-27 18:14:03 +0400327 }
328 if (openstackIMC == 'eu' || openstackIMC == 'eu2') {
slalov021171f2022-03-04 14:48:38 +0400329 // use internal-eu because on internal-ci with eu cloud image pull takes much time
330 def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
331 common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}")
332 cdnConfig['mgmt']['openstack'] = cdnRegion
333 }
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400334
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100335 // calculate weight of current demo run to manage lockable resources
336 def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1
337
vnaumov33747e12020-05-04 17:35:20 +0200338 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400339 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100340 CDN deployment configuration: ${cdnConfig}
341 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100342 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200343 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400344 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200345 Child cluster release upgrade scheduled: ${upgradeChild}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400346 MOS child deploy scheduled: ${mosDeployChild}
347 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200348 Child conformance testing scheduled: ${runChildConformance}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100349 Single BYO cluster attachment scheduled: ${attachBYO}
350 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
351 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400352 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200353 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
slalov1202bba2022-04-20 22:31:07 +0400354 Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400355 Mgmt LMA logging enabled: ${enableLMALogging}
vnaumov33747e12020-05-04 17:35:20 +0200356 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200357 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200358 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200359 Mgmt UI e2e testing scheduled: ${runUie2e}
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400360 Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew}
slalov13e579c2022-01-31 21:37:02 +0400361 Maintenance test: ${runMaintenanceTest}
slalov574123e2022-04-06 17:24:19 +0400362 Child proxy test: ${runProxyChildTest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200363 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200364 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200365 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100366 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200367 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200368 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200369 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400370 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200371 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300372 BM provider deployment scheduled: ${enableBMDemo}
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300373 Ubuntu on vSphere scheduled: ${enableVsphereUbuntu}
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400374 Artifacts build scheduled: ${enableArtifactsBuild}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200375 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200376 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100377 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Владислав Наумов81777472021-03-09 15:14:27 +0400378 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200379 return [
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400380 osCloudLocation : openstackIMC,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100381 cdnConfig : cdnConfig,
382 proxyConfig : proxyConfig,
383 useMacOsSeedNode : seedMacOs,
384 deployChildEnabled : deployChild,
385 childDeployCustomRelease : customChildRelease,
386 upgradeChildEnabled : upgradeChild,
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400387 mosDeployChildEnabled : mosDeployChild,
388 mosUpgradeChildEnabled : mosUpgradeChild,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100389 runChildConformanceEnabled : runChildConformance,
390 attachBYOEnabled : attachBYO,
391 upgradeBYOEnabled : upgradeBYO,
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100392 runBYOMatrixEnabled : runBYOMatrix,
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400393 defaultBYOOs : defaultBYOOs,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100394 upgradeMgmtEnabled : upgradeMgmt,
slalov1202bba2022-04-20 22:31:07 +0400395 autoUpgradeMgmtEnabled : autoUpgradeMgmt,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100396 enableLMALoggingEnabled : enableLMALogging,
397 runUie2eEnabled : runUie2e,
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400398 runUie2eNewEnabled : runUie2eNew,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100399 runMgmtConformanceEnabled : runMgmtConformance,
slalov13e579c2022-01-31 21:37:02 +0400400 runMaintenanceTestEnable : runMaintenanceTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100401 runLMATestEnabled : runLMATest,
402 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
slalov574123e2022-04-06 17:24:19 +0400403 runProxyChildTestEnabled : runProxyChildTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100404 fetchServiceBinariesEnabled : fetchServiceBinaries,
405 awsOnDemandDemoEnabled : awsOnDemandDemo,
406 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
407 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
408 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
409 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
410 azureOnDemandDemoEnabled : azureOnDemandDemo,
411 azureOnAwsDemoEnabled : azureOnAwsDemo,
412 vsphereDemoEnabled : enableVsphereDemo,
413 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
414 bmDemoEnabled : enableBMDemo,
415 osDemoEnabled : enableOSDemo,
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300416 vsphereUbuntuEnabled : enableVsphereUbuntu,
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400417 artifactsBuildEnabled : enableArtifactsBuild,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100418 multiregionalConfiguration : multiregionalMappings,
419 demoWeight : demoWeight]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200420}
421
422/**
423 * Determine management and regional setup for demo workflow scenario
424 *
425 *
426 * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]`
427 or Jenkins environment string variable in form like 'aws,os'
428 * @return (map)[
429 enabled: (bool),
430 * managementLocation: (string), //aws,os
431 * regionLocation: (string), //aws,os
432 * ]
433 */
434def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200435 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400436 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
437 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200438
439 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200440 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200441 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
442 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
443 } else {
444 common.infoMsg('Multiregion definition configured via environment variable')
445 clusterTypes = keyword.trim().split(',')
446 }
447
448 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100449 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200450 }
451
Владислав Наумовf793fe32020-09-11 15:19:19 +0200452 def desiredManagementProvider = clusterTypes[0].trim()
453 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200454 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
455 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200456 management providers list - ${supportedManagementProviders}
457 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200458 }
459
460 return [
461 enabled: true,
462 managementLocation: desiredManagementProvider,
463 regionLocation: desiredRegionalProvider,
464 ]
vnaumov33747e12020-05-04 17:35:20 +0200465}
466
467/**
468 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
469
Владислав Наумов81777472021-03-09 15:14:27 +0400470 * 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 +0200471 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
472 * Example scheme:
473 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
474 * manage refspecs through Jenkins Job Parameters
475 *
azvyagintseva12230a2020-06-05 13:24:06 +0300476 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200477 * siPipelines: (string) final refspec for si-pipelines
478 * ]
479 */
480def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200481 def common = new com.mirantis.mk.Common()
482
vnaumov33747e12020-05-04 17:35:20 +0200483 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200484 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
485 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200486 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
487 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200488 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200489
490 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
491 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
492
493 if (siTestMatches.size() > 0) {
494 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400495 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200496 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200497 }
498 if (siPipelinesMatches.size() > 0) {
499 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
500 }
501
502 common.infoMsg("""
503 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
504 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200505 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400506 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200507 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200508}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200509
Владислав Наумов9080f372020-06-08 13:57:16 +0200510/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200511 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200512 * @param configurationFile (str) path to configuration file in yaml format
513 *
514 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
515 * ]
516 */
517def parseKaaSComponentCIParameters(configurationFile){
518 def common = new com.mirantis.mk.Common()
519 def ciConfig = readYaml file: configurationFile
520 def ciSpec = [
521 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
522 ]
523
524 if (ciConfig.containsKey('si-tests-feature-flags')) {
525 common.infoMsg("""SI tests feature flags customization detected,
526 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
527
528 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
529 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200530
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200531 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200532 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
533 }
534
535 common.infoMsg("""Additional ci configuration parsed successfully:
536 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
537 return ciSpec
538}
539
540/**
541 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200542
Владислав Наумов81777472021-03-09 15:14:27 +0400543 * 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 +0200544 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
545 * Example scheme:
546 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
547 * manage refspecs through Jenkins Job Parameters
548 *
549 * @return (map)[ core: (string) final refspec for kaas/core
550 * corePipelines: (string) final refspec for pipelines in kaas/core
551 * ]
552 */
553def checkCustomCoreRefspec() {
554 def common = new com.mirantis.mk.Common()
555
556 // Available triggers and its sane defaults
557 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
558 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
559 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
560 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
561
562 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
563 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
564
565 if (coreMatches.size() > 0) {
566 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
567 }
568 if (corePipelinesMatches.size() > 0) {
569 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
570 }
571
572 common.infoMsg("""
573 kaas/core will be fetched from: ${coreRefspec}
574 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400575 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200576 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
577}
578
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200579
580/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200581 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
582 * needed to forward inside kaas core set of jobs
583 *
584 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
585 * @return (list)[ string(name: '', value: ''),
586 * ]
587 */
588def generateKaaSVarsFromContext(context) {
589 def common = new com.mirantis.mk.Common()
590 def parameters = []
591 def config = readYaml text: context
592
593 config.each { k,v ->
594 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
595 parameters.add(string(name: k, value: v))
596 }
597
598 return parameters
599}
600
601/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200602 * 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 +0400603 * 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 +0200604 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
605 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200606 * @param: component (string) component name [iam, lcm, stacklight]
607 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
608 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200609 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200610def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200611 def common = new com.mirantis.mk.Common()
612 // Determine if custom trigger keywords forwarded from gerrit
613 def triggers = checkDeploymentTestSuite()
614 // Determine SI refspecs
615 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200616 // Determine Core refspecs
617 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200618
Владислав Наумов418042b2020-07-09 18:31:10 +0200619 // Determine component repo ci configuration
620 def ciSpec = [:]
621 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
622 if (fileExists(configurationFile)) {
623 common.infoMsg('Component CI configuration file detected, parsing...')
624 ciSpec = parseKaaSComponentCIParameters(configurationFile)
625 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
626 } else {
627 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200628 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200629 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
630 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200631 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400632
633 def platforms = []
634 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
635 // Currently only vsphere demo is required for IPAM component
636 platforms.add('vsphere')
637 } else {
638 if (triggers.osDemoEnabled) {
639 platforms.add('openstack')
640 }
641 if (triggers.awsOnDemandDemoEnabled) {
642 platforms.add('aws')
643 }
644 if (triggers.equinixOnDemandDemoEnabled) {
645 platforms.add('equinix')
646 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200647 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
648 platforms.add('equinixmetalv2')
649 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200650 if (triggers.azureOnDemandDemoEnabled) {
651 platforms.add('azure')
652 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400653 if (triggers.vsphereDemoEnabled) {
654 platforms.add('vsphere')
655 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400656 }
657
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200658 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200659 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200660 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
661 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200662 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200663 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200664 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
665 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200666 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200667 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400668 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400669 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100670 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200671 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200672 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100673 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200674 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
slalov1202bba2022-04-20 22:31:07 +0400675 booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400676 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200677 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200678 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
slalov13e579c2022-01-31 21:37:02 +0400679 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnable),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200680 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200681 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200682 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
683 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
slalov574123e2022-04-06 17:24:19 +0400684 booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100685 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100686 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100687 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200688 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400689 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200690 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200691 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100692 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400693 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200694 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200695 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Sergey Zhemerdeev9074f6e2022-06-07 12:03:16 +0300696 booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200697 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200698
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200699 // customize multiregional demo
700 if (triggers.multiregionalConfiguration.enabled) {
701 parameters.add(string(name: 'MULTIREGION_SETUP',
702 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
703 ))
704 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200705
Владислав Наумов92288d92020-07-13 18:36:21 +0200706 // Determine component team custom context
707 if (coreContext != '') {
708 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
709 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200710 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200711 }
712
Владислав Наумовaa430612020-06-08 17:18:31 +0200713 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400714
715 platforms.each { platform ->
716 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000717 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400718 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
719 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
720 def build_description = job_info.getDescription()
721 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000722 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200723
Vladislav Naumov5313a202021-04-07 17:13:39 +0000724 if (build_description) {
725 currentBuild.description += build_description
726 }
727 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400728 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000729 }
730 }
731 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200732
733 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400734 if (jobs.size() == 0) {
735 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
736 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200737 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
738 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200739
740 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200741 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200742 currentBuild.result = 'FAILURE'
743 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200744}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200745
746
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400747/**
748 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200749 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400750 *
751 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
752 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
753 * @param: multiregionalConfiguration (map) Multiregional configuration
754 * @return (map) Return aggregated map with lockResources and netMap
755 */
756
757
758def generateLockResources(callBackDemo, triggers) {
759 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200760 def netMap = [
761 vsphere: [:],
762 equinix: [:],
763 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400764 // Define vsphere locklabels with initial quantity
765 def lockLabels = [
766 vsphere_networking_core_ci: 0,
767 vsphere_offline_networking_core_ci: 0,
768 ]
769 def deployChild = triggers.deployChildEnabled
770 def multiregionConfig = triggers.multiregionalConfiguration
771 def runMultiregion = multiregionConfig.enabled
772
773 // Generate vsphere netMap and lockLabels based on demo context
774 switch (callBackDemo) {
775 case 'aws':
776 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
777 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +0400778 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400779
780 // Define netMap for Vsphere region
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400781 if (runMultiregion && multiregionConfig.managementLocation == 'aws') {
782 if (multiregionConfig.regionLocation == 'vsphere') {
783 if (deployChild) {
784 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
785 }
786 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400787 }
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400788
789 if (multiregionConfig.regionLocation == 'azure') {
790 lockLabels['azure_core_ci_queue'] = 1
791 if (deployChild) {
792 lockLabels['azure_core_ci_queue'] += 1
793 }
794 }
795 }
796 if (triggers.azureOnAwsDemoEnabled) {
797 lockLabels['azure_core_ci_queue'] = 1
798 }
799
800 if (triggers.equinixOnAwsDemoEnabled) {
801 lockLabels['equinix_core_ci_queue'] = 1
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400802 }
803 break
804 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200805 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400806 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200807 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400808 }
809 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
810 multiregionConfig.regionLocation == 'vsphere') {
811 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200812 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400813 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200814 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400815 }
816 break
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400817 case 'azure':
818 lockLabels['azure_core_ci_queue'] = triggers.demoWeight
819 if (runMultiregion && multiregionConfig.managementLocation == 'azure') {
820 if (multiregionConfig.regionLocation == 'aws') {
821 lockLabels['aws_core_ci_queue'] = 1
822 if (deployChild) {
823 lockLabels['aws_core_ci_queue'] += 1
824 }
825 }
826
827 if (multiregionConfig.regionLocation == 'equinix') {
828 lockLabels['equinix_core_ci_queue'] = 1
829 if (deployChild) {
830 lockLabels['equinix_core_ci_queue'] +=1
831 }
832 }
833 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400834 default:
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400835 error('Supposed to be called from aws, azure or vsphere demos only')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400836 }
837
838 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
839 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200840 netMap['vsphere'].each { clusterType, netConfig ->
841 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
842 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
843 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
844
845 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400846 lockLabels['vsphere_offline_networking_core_ci']++
847 } else {
848 lockLabels['vsphere_networking_core_ci']++
849 }
850 }
851
852 // generate lock metadata
853 def lockResources = []
854 lockLabels.each { label, quantity ->
855 if (quantity > 0) {
856 def res = [
857 label: label,
858 quantity: quantity,
859 ]
860 lockResources.add(res)
861 }
862 }
863
864 common.infoMsg("""Generated vsphere netMap: ${netMap}
865 Generated lockResources: ${lockResources}""")
866
867 return [
868 netMap: netMap,
869 lockResources: lockResources,
870 ]
871}
872
873/**
874 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
875 * and empty rangeConfig to the this map.
876 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200877 * @param: netMap (string) vsphere, equinix netMap or empty map
878 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400879 * @param: clusterType (string) Vsphere cluster type
880 */
881
Владислав Наумов33e1e812021-08-17 17:09:25 +0200882def addToProviderNetMap (netMap, provider, clusterType) {
883 switch (provider) {
884 case 'equinix':
885 netMap[provider][clusterType] = [
886 vlanConfig: '',
887 ]
888 break
889 case 'vsphere':
890 netMap[provider][clusterType] = [
891 netName: 'default',
892 rangeConfig: '',
893 ]
894 break
895 default:
896 error('Net map locks supported for Equinix/Vsphere providers only')
897 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400898}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +0300899
900/**
901* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
902* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
903* If keyword contains only 'key' part then 'value' is boolean True.
904* This function does not perform keywords validation.
905* First line of a commit message is ignored.
906* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
907* TODO: Remove backslash chars from values if they prepend '[' or ']'.
908**/
909
910List getCIKeywordsFromCommitMsg() {
911 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
912 List commitMsgLines = commitMsg.split('\n')
913 List keywords = []
914 if (commitMsgLines.size() < 2) {
915 return keywords
916 }
917
918 String commitMsgBody = commitMsgLines[1..-1].join('\n')
919
920 // Split commit message body to chunks using '[' or ']' as delimiter,
921 // ignoring them if prepended by backslash (regex negative lookbehind).
922 // Resulting list will have chunks between '[' and ']' at odd indexes.
923 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
924
925 // Iterate chunks by odd indexes only, trim values and split to
926 // <key> / <value> pair where <key> is the part of a sting before the first
927 // whitespace delimiter, and <value> is the rest (may include whitespaces).
928 // If there is no whitespace in the string then this is a 'switch'
929 // and <value> will be boolean True.
930 for (i = 1; i < parts.size(); i += 2) {
931 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
932 keywords.add(['key': key, 'value': value])
933 }
934
935 return keywords
936}
937
938/**
939* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
940* that were specified for given job name. `job-params` keyword has the following structure
941*
942* [job-params <job name> <parameter name> <parameter value>]
943*
944* Return value is a Map that contains those parameters using the following structure:
945*
946* <job name>:
947* <parameter name>: <parameter value>
948*
949**/
950Map getJobsParamsFromCommitMsg() {
951 List keywords = getCIKeywordsFromCommitMsg()
952
953 List jobsParamsList = []
954 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
955 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
956 def (key, value) = params.split(/\s+/, 2)
957 ['name': name, 'key': key, 'value': value]
958 }
959
960 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
961 if (!result.containsKey(it.name)) {
962 result[it.name] = [:]
963 }
964 result[it.name][it.key] = it.value
965 result
966 }
967
968 return jobsParams
969}
970
971
972/**
973* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
974* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
975* uses only those parametes that were set to all jobs (with <job name> == '*') or to
976* a particular job. Parameters set to a particular job have higher precedence.
977*
978* Return value is a Map that contains those parameters:
979*
980* <parameter name>: <parameter value>
981*
982**/
983Map getJobParamsFromCommitMsg(String jobName) {
984 jobsParams = getJobsParamsFromCommitMsg()
985 jobParams = jobsParams.getOrDefault('*', [:])
986 if (jobName) {
987 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
988 }
989 return jobParams
990}
azvyagintsevc17d14b2022-06-06 19:06:33 +0300991
992/** Getting test scheme from text, which should be
993Imput example:
994text="""
995 DATA
996
997 kaas_bm_test_schemas:
998 KAAS_RELEASES_REFSPEC: ''
999 KEY: VAL
1000
1001 DATA
1002 """
1003
1004 Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas'])
1005
1006 Return:
1007 ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL']
1008 **/
1009def parseTextForTestSchemas(Map opts) {
1010 String text = opts.get('text', '')
1011 String keyLine = opts.getOrDefault('keyLine', '')
1012 Map testScheme = [:]
1013 if (!text || !keyLine) {
1014 return [:]
1015 }
1016 if (text =~ /\n$keyLine\n.*/) {
1017 def common = new com.mirantis.mk.Common()
1018 try {
1019 String regExp = '\\n' + keyLine + '\\n'
1020 // regexep block must be followed by empty line
1021 testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}"
1022 common.infoMsg("parseTextForTestSchemas result:\n" + testScheme)
1023 common.mergeEnv(env, toJson(testScheme))
1024 }
1025 catch (Exception e) {
1026 common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}")
1027 throw e
1028 }
1029 }
1030}