blob: 6b2dccf9c5f256493212fb1cd6ea652aa222241d [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
slalov0a4947a2022-06-09 15:44:35 +040077 def runContainerregistryTest = env.RUN_CONTAINER_REGISTRY_TEST ? env.RUN_CONTAINER_REGISTRY_TEST.toBoolean() : false
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +030078 def runMgmtDeleteMasterTest = env.RUN_MGMT_DELETE_MASTER_TEST ? env.RUN_MGMT_DELETE_MASTER_TEST.toBoolean() : false
79 def runRgnlDeleteMasterTest = env.RUN_RGNL_DELETE_MASTER_TEST ? env.RUN_RGNL_DELETE_MASTER_TEST.toBoolean() : false
80 def runChildDeleteMasterTest = env.RUN_CHILD_DELETE_MASTER_TEST ? env.RUN_CHILD_DELETE_MASTER_TEST.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020081 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
82 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
83 enabled: false,
84 managementLocation: '',
85 regionLocation: '',
86 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020087
Владислав Наумовb8305e22021-02-10 17:23:12 +010088 // proxy customization
89 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020090 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
91 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020092 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010093 ]
94
Владислав Наумов4eb1da32020-08-31 14:45:16 +020095 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020096 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +020097 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +020098 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +020099 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +0200100 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200101 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400102 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200103 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +0300104 def enableBMDemo = true
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400105 def enableArtifactsBuild = true
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400106 def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300107 def enableVsphereUbuntu = env.VSPHERE_DEPLOY_UBUNTU ? env.VSPHERE_DEPLOY_UBUNTU.toBoolean() : false
vnaumov33747e12020-05-04 17:35:20 +0200108
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200109 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +0100110 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
111 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +0200112 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 +0100113 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100114 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
115 seedMacOs = true
116 }
slalov574123e2022-04-06 17:24:19 +0400117 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance || runProxyChildTest) {
vnaumov33747e12020-05-04 17:35:20 +0200118 deployChild = true
119 }
120 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
121 deployChild = true
122 upgradeChild = true
123 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400124 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
125 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400126 // override child version when it set explicitly
127 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400128 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400129 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
130 }
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400131 if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) {
132 mosDeployChild = true
133 }
134 if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) {
135 mosDeployChild = true
136 mosUpgradeChild = true
137 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100138 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
139 attachBYO = true
140 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100141 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
142 attachBYO = true
143 upgradeBYO = true
144 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400145
146 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
147 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 +0100148 runBYOMatrix = true
149
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400150 if (byoDeployMatches.size() > 0) {
151 defaultBYOOs = byoDeployMatches[0][2]
152 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
153 }
154
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100155 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
156 attachBYO = false
157 upgradeBYO = false
158 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400159 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200160 upgradeMgmt = true
161 }
slalov1202bba2022-04-20 22:31:07 +0400162 if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) {
163 autoUpgradeMgmt = true
164 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400165 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
166 enableLMALogging = true
167 }
vnaumov33747e12020-05-04 17:35:20 +0200168 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
169 runUie2e = true
170 }
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400171 if (commitMsg ==~ /(?s).*\[ui-e2e-new\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-new.*/) {
172 runUie2eNew = true
173 }
vnaumov33747e12020-05-04 17:35:20 +0200174 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
175 runMgmtConformance = true
176 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200177 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
178 runMgmtUserControllerTest = true
179 }
slalov574123e2022-04-06 17:24:19 +0400180 if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) {
181 runProxyChildTest = true
182 deployChild = true
183 common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed')
184 }
vnaumov33747e12020-05-04 17:35:20 +0200185 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
186 runChildConformance = true
187 deployChild = true
188 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200189 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
190 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400191 enableLMALogging = true
192 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400193 }
slalov13e579c2022-01-31 21:37:02 +0400194 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
195 runMaintenanceTest = true
196 }
slalov0a4947a2022-06-09 15:44:35 +0400197 if (commitMsg ==~ /(?s).*\[container-registry-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*container-registry-test.*/) {
198 runContainerregistryTest = true
199 }
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300200 if (commitMsg ==~ /(?s).*\[mgmt-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-delete-master-test.*/) {
201 runMgmtDeleteMasterTest = true
202 }
203 if (commitMsg ==~ /(?s).*\[rgnl-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*rgnl-delete-master-test.*/) {
204 runRgnlDeleteMasterTest = true
205 }
206 if (commitMsg ==~ /(?s).*\[child-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-delete-master-test.*/) {
207 runChildDeleteMasterTest = true
208 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200209 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
210 proxyConfig['childOffline'] = true
211 deployChild = true
212 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200213 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
214 proxyConfig['childOffline'] = true
215 proxyConfig['childProxy'] = true
216 deployChild = true
217 }
vnaumov33747e12020-05-04 17:35:20 +0200218 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
219 fetchServiceBinaries = true
220 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200221 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400222 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200223 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 +0400224 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200225 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
226 azureOnAwsDemo = true
227 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
228 }
229 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
230 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
231 attachBYO ||
232 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100233 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200234 seedMacOs ||
235 equinixOnAwsDemo ||
236 azureOnAwsDemo) {
237
vnaumov33747e12020-05-04 17:35:20 +0200238 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200239 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 +0200240 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200241 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200242 equinixOnDemandDemo = true
243 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200244 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200245 equinixMetalV2OnDemandDemo = true
246 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100247 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
248 equinixMetalV2OnDemandDemo = true
249 equinixMetalV2ChildDiffMetro = true
250 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200251 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
252 azureOnDemandDemo = true
253 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200254 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
255 enableOSDemo = false
256 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200257 }
258
azvyagintsev1761bdc2020-09-04 17:24:12 +0300259 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
260 enableBMDemo = false
261 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
262 }
263
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400264 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
265 enableVsphereDemo = false
266 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
267 }
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300268 if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) {
269 enableVsphereUbuntu = true
270 common.warningMsg('Ubuntu will be used to deploy vsphere machines')
271 }
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400272
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400273 if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) {
274 enableArtifactsBuild = false
275 common.errorMsg('artifacts build will be aborted, VF -1 will be set')
276 }
277
vnaumov33747e12020-05-04 17:35:20 +0200278 // TODO (vnaumov) remove below condition after moving all releases to UCP
279 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
280 if (ucpChildMatches.size() > 0) {
281 deployChild = true
282 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
283
284 // TODO(vnaumov) delete after ucp upgrades support
285 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
286 upgradeChild = false
287 }
288
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200289 // multiregional tests
290 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
291 if (multiRegionalMatches.size() > 0) {
292 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
293 }
294 switch (multiregionalMappings['managementLocation']) {
295 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100296 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200297 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100298
299 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
300 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
301 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200302 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200303 case 'os':
304 if (enableOSDemo == false) {
305 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
306 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200307 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200308 case 'vsphere':
309 if (enableVsphereDemo == false) {
310 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
311 }
312 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200313 case 'equinix':
314 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
315 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400316 break
eromanova8c702ae2021-12-24 17:43:12 +0400317 case 'equinixmetalv2':
318 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
319 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400320 break
slalovfd0b7e62021-07-28 18:05:16 +0400321 case 'azure':
322 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
323 azureOnDemandDemo = true
324 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200325 }
326
Владислав Наумовb8305e22021-02-10 17:23:12 +0100327 // CDN configuration
328 def cdnConfig = [
329 mgmt: [
330 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200331 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100332 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200333 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200334 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200335 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100336 ]
337
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400338 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
339 openstackIMC = 'eu'
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400340 }
slalov021171f2022-03-04 14:48:38 +0400341 if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) {
342 openstackIMC = 'eu2'
Mikhail Ivanovf05b8252022-04-27 18:14:03 +0400343 }
344 if (openstackIMC == 'eu' || openstackIMC == 'eu2') {
slalov021171f2022-03-04 14:48:38 +0400345 // use internal-eu because on internal-ci with eu cloud image pull takes much time
346 def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
347 common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}")
348 cdnConfig['mgmt']['openstack'] = cdnRegion
349 }
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400350
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100351 // calculate weight of current demo run to manage lockable resources
352 def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1
353
vnaumov33747e12020-05-04 17:35:20 +0200354 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400355 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100356 CDN deployment configuration: ${cdnConfig}
357 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100358 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200359 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400360 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200361 Child cluster release upgrade scheduled: ${upgradeChild}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400362 MOS child deploy scheduled: ${mosDeployChild}
363 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200364 Child conformance testing scheduled: ${runChildConformance}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100365 Single BYO cluster attachment scheduled: ${attachBYO}
366 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
367 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400368 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200369 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
slalov1202bba2022-04-20 22:31:07 +0400370 Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400371 Mgmt LMA logging enabled: ${enableLMALogging}
vnaumov33747e12020-05-04 17:35:20 +0200372 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200373 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200374 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200375 Mgmt UI e2e testing scheduled: ${runUie2e}
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400376 Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew}
slalov13e579c2022-01-31 21:37:02 +0400377 Maintenance test: ${runMaintenanceTest}
slalov0a4947a2022-06-09 15:44:35 +0400378 Container Registry test: ${runContainerregistryTest}
slalov574123e2022-04-06 17:24:19 +0400379 Child proxy test: ${runProxyChildTest}
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300380 Delete mgmt master node test: ${runMgmtDeleteMasterTest}
381 Delete rgnl master node test: ${runRgnlDeleteMasterTest}
382 Delete child master node test: ${runChildDeleteMasterTest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200383 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200384 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200385 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100386 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200387 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200388 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200389 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400390 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200391 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300392 BM provider deployment scheduled: ${enableBMDemo}
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300393 Ubuntu on vSphere scheduled: ${enableVsphereUbuntu}
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400394 Artifacts build scheduled: ${enableArtifactsBuild}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200395 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200396 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100397 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Владислав Наумов81777472021-03-09 15:14:27 +0400398 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200399 return [
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400400 osCloudLocation : openstackIMC,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100401 cdnConfig : cdnConfig,
402 proxyConfig : proxyConfig,
403 useMacOsSeedNode : seedMacOs,
404 deployChildEnabled : deployChild,
405 childDeployCustomRelease : customChildRelease,
406 upgradeChildEnabled : upgradeChild,
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400407 mosDeployChildEnabled : mosDeployChild,
408 mosUpgradeChildEnabled : mosUpgradeChild,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100409 runChildConformanceEnabled : runChildConformance,
410 attachBYOEnabled : attachBYO,
411 upgradeBYOEnabled : upgradeBYO,
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100412 runBYOMatrixEnabled : runBYOMatrix,
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400413 defaultBYOOs : defaultBYOOs,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100414 upgradeMgmtEnabled : upgradeMgmt,
slalov1202bba2022-04-20 22:31:07 +0400415 autoUpgradeMgmtEnabled : autoUpgradeMgmt,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100416 enableLMALoggingEnabled : enableLMALogging,
417 runUie2eEnabled : runUie2e,
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400418 runUie2eNewEnabled : runUie2eNew,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100419 runMgmtConformanceEnabled : runMgmtConformance,
slalov0a4947a2022-06-09 15:44:35 +0400420 runMaintenanceTestEnabled : runMaintenanceTest,
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300421 runContainerregistryTestEnabled : runContainerregistryTest,
422 runMgmtDeleteMasterTestEnabled : runMgmtDeleteMasterTest,
423 runRgnlDeleteMasterTestEnabled : runRgnlDeleteMasterTest,
424 runChildDeleteMasterTestEnabled : runChildDeleteMasterTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100425 runLMATestEnabled : runLMATest,
426 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
slalov574123e2022-04-06 17:24:19 +0400427 runProxyChildTestEnabled : runProxyChildTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100428 fetchServiceBinariesEnabled : fetchServiceBinaries,
429 awsOnDemandDemoEnabled : awsOnDemandDemo,
430 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
431 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
432 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
433 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
434 azureOnDemandDemoEnabled : azureOnDemandDemo,
435 azureOnAwsDemoEnabled : azureOnAwsDemo,
436 vsphereDemoEnabled : enableVsphereDemo,
437 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
438 bmDemoEnabled : enableBMDemo,
439 osDemoEnabled : enableOSDemo,
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300440 vsphereUbuntuEnabled : enableVsphereUbuntu,
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400441 artifactsBuildEnabled : enableArtifactsBuild,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100442 multiregionalConfiguration : multiregionalMappings,
443 demoWeight : demoWeight]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200444}
445
446/**
447 * Determine management and regional setup for demo workflow scenario
448 *
449 *
450 * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]`
451 or Jenkins environment string variable in form like 'aws,os'
452 * @return (map)[
453 enabled: (bool),
454 * managementLocation: (string), //aws,os
455 * regionLocation: (string), //aws,os
456 * ]
457 */
458def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200459 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400460 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
461 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200462
463 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200464 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200465 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
466 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
467 } else {
468 common.infoMsg('Multiregion definition configured via environment variable')
469 clusterTypes = keyword.trim().split(',')
470 }
471
472 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100473 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200474 }
475
Владислав Наумовf793fe32020-09-11 15:19:19 +0200476 def desiredManagementProvider = clusterTypes[0].trim()
477 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200478 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
479 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200480 management providers list - ${supportedManagementProviders}
481 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200482 }
483
484 return [
485 enabled: true,
486 managementLocation: desiredManagementProvider,
487 regionLocation: desiredRegionalProvider,
488 ]
vnaumov33747e12020-05-04 17:35:20 +0200489}
490
491/**
492 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
493
Владислав Наумов81777472021-03-09 15:14:27 +0400494 * 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 +0200495 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
496 * Example scheme:
497 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
498 * manage refspecs through Jenkins Job Parameters
499 *
azvyagintseva12230a2020-06-05 13:24:06 +0300500 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200501 * siPipelines: (string) final refspec for si-pipelines
502 * ]
503 */
504def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200505 def common = new com.mirantis.mk.Common()
506
vnaumov33747e12020-05-04 17:35:20 +0200507 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200508 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
509 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200510 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
511 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200512 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200513
514 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
515 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
516
517 if (siTestMatches.size() > 0) {
518 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400519 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200520 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200521 }
522 if (siPipelinesMatches.size() > 0) {
523 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
524 }
525
526 common.infoMsg("""
527 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
528 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200529 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400530 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200531 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200532}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200533
Владислав Наумов9080f372020-06-08 13:57:16 +0200534/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200535 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200536 * @param configurationFile (str) path to configuration file in yaml format
537 *
538 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
539 * ]
540 */
541def parseKaaSComponentCIParameters(configurationFile){
542 def common = new com.mirantis.mk.Common()
543 def ciConfig = readYaml file: configurationFile
544 def ciSpec = [
545 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
546 ]
547
548 if (ciConfig.containsKey('si-tests-feature-flags')) {
549 common.infoMsg("""SI tests feature flags customization detected,
550 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
551
552 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
553 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200554
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200555 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200556 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
557 }
558
559 common.infoMsg("""Additional ci configuration parsed successfully:
560 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
561 return ciSpec
562}
563
564/**
565 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200566
Владислав Наумов81777472021-03-09 15:14:27 +0400567 * 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 +0200568 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
569 * Example scheme:
570 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
571 * manage refspecs through Jenkins Job Parameters
572 *
573 * @return (map)[ core: (string) final refspec for kaas/core
574 * corePipelines: (string) final refspec for pipelines in kaas/core
575 * ]
576 */
577def checkCustomCoreRefspec() {
578 def common = new com.mirantis.mk.Common()
579
580 // Available triggers and its sane defaults
581 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
582 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
583 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
584 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
585
586 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
587 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
588
589 if (coreMatches.size() > 0) {
590 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
591 }
592 if (corePipelinesMatches.size() > 0) {
593 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
594 }
595
596 common.infoMsg("""
597 kaas/core will be fetched from: ${coreRefspec}
598 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400599 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200600 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
601}
602
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200603
604/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200605 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
606 * needed to forward inside kaas core set of jobs
607 *
608 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
609 * @return (list)[ string(name: '', value: ''),
610 * ]
611 */
612def generateKaaSVarsFromContext(context) {
613 def common = new com.mirantis.mk.Common()
614 def parameters = []
615 def config = readYaml text: context
616
617 config.each { k,v ->
618 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
619 parameters.add(string(name: k, value: v))
620 }
621
622 return parameters
623}
624
625/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200626 * 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 +0400627 * 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 +0200628 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
629 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200630 * @param: component (string) component name [iam, lcm, stacklight]
631 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
632 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200633 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200634def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200635 def common = new com.mirantis.mk.Common()
636 // Determine if custom trigger keywords forwarded from gerrit
637 def triggers = checkDeploymentTestSuite()
638 // Determine SI refspecs
639 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200640 // Determine Core refspecs
641 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200642
Владислав Наумов418042b2020-07-09 18:31:10 +0200643 // Determine component repo ci configuration
644 def ciSpec = [:]
645 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
646 if (fileExists(configurationFile)) {
647 common.infoMsg('Component CI configuration file detected, parsing...')
648 ciSpec = parseKaaSComponentCIParameters(configurationFile)
649 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
650 } else {
651 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200652 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200653 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
654 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200655 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400656
657 def platforms = []
658 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
659 // Currently only vsphere demo is required for IPAM component
660 platforms.add('vsphere')
661 } else {
662 if (triggers.osDemoEnabled) {
663 platforms.add('openstack')
664 }
665 if (triggers.awsOnDemandDemoEnabled) {
666 platforms.add('aws')
667 }
668 if (triggers.equinixOnDemandDemoEnabled) {
669 platforms.add('equinix')
670 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200671 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
672 platforms.add('equinixmetalv2')
673 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200674 if (triggers.azureOnDemandDemoEnabled) {
675 platforms.add('azure')
676 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400677 if (triggers.vsphereDemoEnabled) {
678 platforms.add('vsphere')
679 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400680 }
681
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200682 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200683 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200684 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
685 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200686 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200687 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200688 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
689 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200690 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200691 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400692 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400693 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100694 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200695 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200696 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100697 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200698 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
slalov1202bba2022-04-20 22:31:07 +0400699 booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400700 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200701 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200702 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
slalov0a4947a2022-06-09 15:44:35 +0400703 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnabled),
704 booleanParam(name: 'RUN_CONTAINER_REGISTRY_TEST', value: triggers.runContainerregistryTestEnabled),
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300705 booleanParam(name: 'RUN_MGMT_DELETE_MASTER_TEST', value: triggers.runMgmtDeleteMasterTestEnabled),
706 booleanParam(name: 'RUN_RGNL_DELETE_MASTER_TEST', value: triggers.runRgnlDeleteMasterTestEnabled),
707 booleanParam(name: 'RUN_CHILD_DELETE_MASTER_TEST', value: triggers.runChildDeleteMasterTestEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200708 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200709 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200710 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
711 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
slalov574123e2022-04-06 17:24:19 +0400712 booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100713 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100714 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100715 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200716 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400717 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200718 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200719 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100720 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400721 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200722 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200723 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Sergey Zhemerdeev9074f6e2022-06-07 12:03:16 +0300724 booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200725 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200726
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200727 // customize multiregional demo
728 if (triggers.multiregionalConfiguration.enabled) {
729 parameters.add(string(name: 'MULTIREGION_SETUP',
730 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
731 ))
732 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200733
Владислав Наумов92288d92020-07-13 18:36:21 +0200734 // Determine component team custom context
735 if (coreContext != '') {
736 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
737 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200738 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200739 }
740
Владислав Наумовaa430612020-06-08 17:18:31 +0200741 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400742
743 platforms.each { platform ->
744 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000745 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400746 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
747 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
748 def build_description = job_info.getDescription()
749 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000750 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200751
Vladislav Naumov5313a202021-04-07 17:13:39 +0000752 if (build_description) {
753 currentBuild.description += build_description
754 }
755 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400756 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000757 }
758 }
759 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200760
761 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400762 if (jobs.size() == 0) {
763 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
764 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200765 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
766 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200767
768 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200769 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200770 currentBuild.result = 'FAILURE'
771 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200772}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200773
774
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400775/**
776 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200777 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400778 *
779 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
780 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
781 * @param: multiregionalConfiguration (map) Multiregional configuration
782 * @return (map) Return aggregated map with lockResources and netMap
783 */
784
785
786def generateLockResources(callBackDemo, triggers) {
787 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200788 def netMap = [
789 vsphere: [:],
790 equinix: [:],
791 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400792 // Define vsphere locklabels with initial quantity
793 def lockLabels = [
794 vsphere_networking_core_ci: 0,
795 vsphere_offline_networking_core_ci: 0,
796 ]
797 def deployChild = triggers.deployChildEnabled
slalov27833272022-06-30 02:13:50 +0400798 def testUiVsphere = triggers.runUie2eEnabled
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400799 def multiregionConfig = triggers.multiregionalConfiguration
800 def runMultiregion = multiregionConfig.enabled
801
802 // Generate vsphere netMap and lockLabels based on demo context
803 switch (callBackDemo) {
804 case 'aws':
805 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
806 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +0400807 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400808
809 // Define netMap for Vsphere region
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400810 if (runMultiregion && multiregionConfig.managementLocation == 'aws') {
811 if (multiregionConfig.regionLocation == 'vsphere') {
812 if (deployChild) {
813 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
814 }
815 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400816 }
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400817
818 if (multiregionConfig.regionLocation == 'azure') {
819 lockLabels['azure_core_ci_queue'] = 1
820 if (deployChild) {
821 lockLabels['azure_core_ci_queue'] += 1
822 }
823 }
824 }
825 if (triggers.azureOnAwsDemoEnabled) {
826 lockLabels['azure_core_ci_queue'] = 1
827 }
828
829 if (triggers.equinixOnAwsDemoEnabled) {
830 lockLabels['equinix_core_ci_queue'] = 1
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400831 }
832 break
833 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200834 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
slalov27833272022-06-30 02:13:50 +0400835 if (deployChild || testUiVsphere) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200836 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400837 }
838 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
839 multiregionConfig.regionLocation == 'vsphere') {
840 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200841 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400842 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200843 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400844 }
845 break
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400846 case 'azure':
847 lockLabels['azure_core_ci_queue'] = triggers.demoWeight
848 if (runMultiregion && multiregionConfig.managementLocation == 'azure') {
849 if (multiregionConfig.regionLocation == 'aws') {
850 lockLabels['aws_core_ci_queue'] = 1
851 if (deployChild) {
852 lockLabels['aws_core_ci_queue'] += 1
853 }
854 }
855
856 if (multiregionConfig.regionLocation == 'equinix') {
857 lockLabels['equinix_core_ci_queue'] = 1
858 if (deployChild) {
859 lockLabels['equinix_core_ci_queue'] +=1
860 }
861 }
862 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400863 default:
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400864 error('Supposed to be called from aws, azure or vsphere demos only')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400865 }
866
867 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
868 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200869 netMap['vsphere'].each { clusterType, netConfig ->
870 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
871 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
872 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
873
874 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400875 lockLabels['vsphere_offline_networking_core_ci']++
876 } else {
877 lockLabels['vsphere_networking_core_ci']++
878 }
879 }
880
881 // generate lock metadata
882 def lockResources = []
883 lockLabels.each { label, quantity ->
884 if (quantity > 0) {
885 def res = [
886 label: label,
887 quantity: quantity,
888 ]
889 lockResources.add(res)
890 }
891 }
892
893 common.infoMsg("""Generated vsphere netMap: ${netMap}
894 Generated lockResources: ${lockResources}""")
895
896 return [
897 netMap: netMap,
898 lockResources: lockResources,
899 ]
900}
901
902/**
903 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
904 * and empty rangeConfig to the this map.
905 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200906 * @param: netMap (string) vsphere, equinix netMap or empty map
907 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400908 * @param: clusterType (string) Vsphere cluster type
909 */
910
Владислав Наумов33e1e812021-08-17 17:09:25 +0200911def addToProviderNetMap (netMap, provider, clusterType) {
912 switch (provider) {
913 case 'equinix':
914 netMap[provider][clusterType] = [
915 vlanConfig: '',
916 ]
917 break
918 case 'vsphere':
919 netMap[provider][clusterType] = [
920 netName: 'default',
921 rangeConfig: '',
922 ]
923 break
924 default:
925 error('Net map locks supported for Equinix/Vsphere providers only')
926 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400927}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +0300928
929/**
930* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
931* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
932* If keyword contains only 'key' part then 'value' is boolean True.
933* This function does not perform keywords validation.
934* First line of a commit message is ignored.
935* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
936* TODO: Remove backslash chars from values if they prepend '[' or ']'.
937**/
938
939List getCIKeywordsFromCommitMsg() {
940 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
941 List commitMsgLines = commitMsg.split('\n')
942 List keywords = []
943 if (commitMsgLines.size() < 2) {
944 return keywords
945 }
946
947 String commitMsgBody = commitMsgLines[1..-1].join('\n')
948
949 // Split commit message body to chunks using '[' or ']' as delimiter,
950 // ignoring them if prepended by backslash (regex negative lookbehind).
951 // Resulting list will have chunks between '[' and ']' at odd indexes.
952 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
953
954 // Iterate chunks by odd indexes only, trim values and split to
955 // <key> / <value> pair where <key> is the part of a sting before the first
956 // whitespace delimiter, and <value> is the rest (may include whitespaces).
957 // If there is no whitespace in the string then this is a 'switch'
958 // and <value> will be boolean True.
959 for (i = 1; i < parts.size(); i += 2) {
960 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
961 keywords.add(['key': key, 'value': value])
962 }
963
964 return keywords
965}
966
967/**
968* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
969* that were specified for given job name. `job-params` keyword has the following structure
970*
971* [job-params <job name> <parameter name> <parameter value>]
972*
973* Return value is a Map that contains those parameters using the following structure:
974*
975* <job name>:
976* <parameter name>: <parameter value>
977*
978**/
979Map getJobsParamsFromCommitMsg() {
980 List keywords = getCIKeywordsFromCommitMsg()
981
982 List jobsParamsList = []
983 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
984 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
985 def (key, value) = params.split(/\s+/, 2)
986 ['name': name, 'key': key, 'value': value]
987 }
988
989 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
990 if (!result.containsKey(it.name)) {
991 result[it.name] = [:]
992 }
993 result[it.name][it.key] = it.value
994 result
995 }
996
997 return jobsParams
998}
999
1000
1001/**
1002* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
1003* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
1004* uses only those parametes that were set to all jobs (with <job name> == '*') or to
1005* a particular job. Parameters set to a particular job have higher precedence.
1006*
1007* Return value is a Map that contains those parameters:
1008*
1009* <parameter name>: <parameter value>
1010*
1011**/
1012Map getJobParamsFromCommitMsg(String jobName) {
1013 jobsParams = getJobsParamsFromCommitMsg()
1014 jobParams = jobsParams.getOrDefault('*', [:])
1015 if (jobName) {
1016 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
1017 }
1018 return jobParams
1019}
azvyagintsevc17d14b2022-06-06 19:06:33 +03001020
1021/** Getting test scheme from text, which should be
1022Imput example:
1023text="""
1024 DATA
1025
1026 kaas_bm_test_schemas:
1027 KAAS_RELEASES_REFSPEC: ''
1028 KEY: VAL
1029
1030 DATA
1031 """
1032
1033 Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas'])
1034
1035 Return:
1036 ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL']
1037 **/
1038def parseTextForTestSchemas(Map opts) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001039 String text = opts.getOrDefault('text', '')
azvyagintsevc17d14b2022-06-06 19:06:33 +03001040 String keyLine = opts.getOrDefault('keyLine', '')
1041 Map testScheme = [:]
1042 if (!text || !keyLine) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001043 return testScheme
azvyagintsevc17d14b2022-06-06 19:06:33 +03001044 }
1045 if (text =~ /\n$keyLine\n.*/) {
1046 def common = new com.mirantis.mk.Common()
1047 try {
1048 String regExp = '\\n' + keyLine + '\\n'
1049 // regexep block must be followed by empty line
1050 testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}"
1051 common.infoMsg("parseTextForTestSchemas result:\n" + testScheme)
1052 common.mergeEnv(env, toJson(testScheme))
1053 }
1054 catch (Exception e) {
1055 common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}")
1056 throw e
1057 }
1058 }
azvyagintsevd96aac22022-06-10 14:23:26 +03001059 return testScheme
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +03001060}