blob: 7ae301b1c6fc123d06523e1628a8605eefee9fb0 [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
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300108 def childOsBootFromVolume = env.OPENSTACK_BOOT_FROM_VOLUME ? env.OPENSTACK_BOOT_FROM_VOLUME.toBoolean() : false
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400109 def bootstrapV2Scenario = env.BOOTSTRAP_V2_ENABLED ? env.BOOTSTRAP_V2_ENABLED.toBoolean() : false
vnaumov33747e12020-05-04 17:35:20 +0200110
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200111 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +0100112 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
113 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +0200114 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 +0100115 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100116 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
117 seedMacOs = true
118 }
slalov574123e2022-04-06 17:24:19 +0400119 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance || runProxyChildTest) {
vnaumov33747e12020-05-04 17:35:20 +0200120 deployChild = true
121 }
122 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
123 deployChild = true
124 upgradeChild = true
125 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400126 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
127 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400128 // override child version when it set explicitly
129 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400130 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400131 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
132 }
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400133 if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) {
134 mosDeployChild = true
135 }
136 if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) {
137 mosDeployChild = true
138 mosUpgradeChild = true
139 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100140 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
141 attachBYO = true
142 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100143 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
144 attachBYO = true
145 upgradeBYO = true
146 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400147
148 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
149 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 +0100150 runBYOMatrix = true
151
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400152 if (byoDeployMatches.size() > 0) {
153 defaultBYOOs = byoDeployMatches[0][2]
154 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
155 }
156
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100157 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
158 attachBYO = false
159 upgradeBYO = false
160 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400161 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200162 upgradeMgmt = true
163 }
slalov1202bba2022-04-20 22:31:07 +0400164 if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) {
165 autoUpgradeMgmt = true
166 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400167 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
168 enableLMALogging = true
169 }
vnaumov33747e12020-05-04 17:35:20 +0200170 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
171 runUie2e = true
172 }
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400173 if (commitMsg ==~ /(?s).*\[ui-e2e-new\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-new.*/) {
174 runUie2eNew = true
175 }
vnaumov33747e12020-05-04 17:35:20 +0200176 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
177 runMgmtConformance = true
178 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200179 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
180 runMgmtUserControllerTest = true
181 }
slalov574123e2022-04-06 17:24:19 +0400182 if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) {
183 runProxyChildTest = true
184 deployChild = true
185 common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed')
186 }
vnaumov33747e12020-05-04 17:35:20 +0200187 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
188 runChildConformance = true
189 deployChild = true
190 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200191 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
192 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400193 enableLMALogging = true
194 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400195 }
slalov13e579c2022-01-31 21:37:02 +0400196 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
197 runMaintenanceTest = true
198 }
slalov0a4947a2022-06-09 15:44:35 +0400199 if (commitMsg ==~ /(?s).*\[container-registry-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*container-registry-test.*/) {
200 runContainerregistryTest = true
201 }
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300202 if (commitMsg ==~ /(?s).*\[mgmt-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-delete-master-test.*/) {
203 runMgmtDeleteMasterTest = true
204 }
205 if (commitMsg ==~ /(?s).*\[rgnl-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*rgnl-delete-master-test.*/) {
206 runRgnlDeleteMasterTest = true
207 }
208 if (commitMsg ==~ /(?s).*\[child-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-delete-master-test.*/) {
209 runChildDeleteMasterTest = true
210 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200211 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
212 proxyConfig['childOffline'] = true
213 deployChild = true
214 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200215 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
216 proxyConfig['childOffline'] = true
217 proxyConfig['childProxy'] = true
218 deployChild = true
219 }
vnaumov33747e12020-05-04 17:35:20 +0200220 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
221 fetchServiceBinaries = true
222 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200223 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400224 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200225 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 +0400226 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200227 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
228 azureOnAwsDemo = true
229 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
230 }
231 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
232 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
233 attachBYO ||
234 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100235 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200236 seedMacOs ||
237 equinixOnAwsDemo ||
238 azureOnAwsDemo) {
239
vnaumov33747e12020-05-04 17:35:20 +0200240 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200241 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 +0200242 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200243 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200244 equinixOnDemandDemo = true
245 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200246 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200247 equinixMetalV2OnDemandDemo = true
248 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100249 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
250 equinixMetalV2OnDemandDemo = true
251 equinixMetalV2ChildDiffMetro = true
252 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200253 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
254 azureOnDemandDemo = true
255 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200256 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
257 enableOSDemo = false
258 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200259 }
260
azvyagintsev1761bdc2020-09-04 17:24:12 +0300261 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
262 enableBMDemo = false
263 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
264 }
265
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400266 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
267 enableVsphereDemo = false
268 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
269 }
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300270 if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) {
271 enableVsphereUbuntu = true
272 common.warningMsg('Ubuntu will be used to deploy vsphere machines')
273 }
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400274
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400275 if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) {
276 enableArtifactsBuild = false
277 common.errorMsg('artifacts build will be aborted, VF -1 will be set')
278 }
279
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300280 if (commitMsg ==~ /(?s).*\[child-os-boot-from-volume\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-os-boot-from-volume\.*/) {
281 childOsBootFromVolume = true
282 common.warningMsg('OS will be booted from Ceph volumes')
283 }
284
vnaumov33747e12020-05-04 17:35:20 +0200285 // TODO (vnaumov) remove below condition after moving all releases to UCP
286 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
287 if (ucpChildMatches.size() > 0) {
288 deployChild = true
289 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
290
291 // TODO(vnaumov) delete after ucp upgrades support
292 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
293 upgradeChild = false
294 }
295
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200296 // multiregional tests
297 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
298 if (multiRegionalMatches.size() > 0) {
299 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
300 }
301 switch (multiregionalMappings['managementLocation']) {
302 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100303 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200304 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100305
306 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
307 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
308 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200309 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200310 case 'os':
311 if (enableOSDemo == false) {
312 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
313 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200314 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200315 case 'vsphere':
316 if (enableVsphereDemo == false) {
317 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
318 }
319 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200320 case 'equinix':
321 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
322 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400323 break
eromanova8c702ae2021-12-24 17:43:12 +0400324 case 'equinixmetalv2':
325 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
326 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400327 break
slalovfd0b7e62021-07-28 18:05:16 +0400328 case 'azure':
329 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
330 azureOnDemandDemo = true
331 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200332 }
333
Владислав Наумовb8305e22021-02-10 17:23:12 +0100334 // CDN configuration
335 def cdnConfig = [
336 mgmt: [
337 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200338 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100339 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200340 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200341 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200342 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100343 ]
344
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400345 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
346 openstackIMC = 'eu'
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400347 }
slalov021171f2022-03-04 14:48:38 +0400348 if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) {
349 openstackIMC = 'eu2'
Mikhail Ivanovf05b8252022-04-27 18:14:03 +0400350 }
351 if (openstackIMC == 'eu' || openstackIMC == 'eu2') {
slalov021171f2022-03-04 14:48:38 +0400352 // use internal-eu because on internal-ci with eu cloud image pull takes much time
353 def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
354 common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}")
355 cdnConfig['mgmt']['openstack'] = cdnRegion
356 }
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400357
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100358 // calculate weight of current demo run to manage lockable resources
359 def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1
360
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400361 if (commitMsg ==~ /(?s).*\[bootstrapv2-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv2-scenario\.*/) {
362 bootstrapV2Scenario = true
363 }
364
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300365 // parse equinixmetalv2-metro trigger
366 def equinixMetalV2Metro = env.EQUINIX_MGMT_METRO ? env.EQUINIX_MGMT_METRO : ''
367 def equinixMetalV2MetroMatcher = (commitMsg =~ /\[equinixmetalv2-metro(\s+.*)?\]/)
368 if (equinixMetalV2OnDemandDemo && equinixMetalV2MetroMatcher.size() > 0) {
369 equinixMetalV2Metro = equinixMetalV2MetroMatcher[0][0].trim()
370 common.infoMsg("Forced Equnix mgmt deployment using custom metro ${equinixMetalV2Metro}")
371 }
372
vnaumov33747e12020-05-04 17:35:20 +0200373 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400374 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100375 CDN deployment configuration: ${cdnConfig}
376 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100377 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200378 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400379 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200380 Child cluster release upgrade scheduled: ${upgradeChild}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400381 MOS child deploy scheduled: ${mosDeployChild}
382 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200383 Child conformance testing scheduled: ${runChildConformance}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100384 Single BYO cluster attachment scheduled: ${attachBYO}
385 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
386 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400387 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200388 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
slalov1202bba2022-04-20 22:31:07 +0400389 Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400390 Mgmt LMA logging enabled: ${enableLMALogging}
vnaumov33747e12020-05-04 17:35:20 +0200391 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200392 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200393 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200394 Mgmt UI e2e testing scheduled: ${runUie2e}
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400395 Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew}
slalov13e579c2022-01-31 21:37:02 +0400396 Maintenance test: ${runMaintenanceTest}
slalov0a4947a2022-06-09 15:44:35 +0400397 Container Registry test: ${runContainerregistryTest}
slalov574123e2022-04-06 17:24:19 +0400398 Child proxy test: ${runProxyChildTest}
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300399 Delete mgmt master node test: ${runMgmtDeleteMasterTest}
400 Delete rgnl master node test: ${runRgnlDeleteMasterTest}
401 Delete child master node test: ${runChildDeleteMasterTest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200402 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200403 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200404 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100405 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300406 EquinixmetalV2 mgmt will be deployed on the ${equinixMetalV2Metro} metro
Владислав Наумовf1665b52021-05-13 10:51:17 +0200407 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200408 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200409 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400410 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200411 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300412 BM provider deployment scheduled: ${enableBMDemo}
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300413 Ubuntu on vSphere scheduled: ${enableVsphereUbuntu}
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400414 Artifacts build scheduled: ${enableArtifactsBuild}
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300415 Boot OS child from Ceph volumes: ${childOsBootFromVolume}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200416 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200417 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100418 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400419 Bootstrap v2 scenario enabled: ${bootstrapV2Scenario}
Владислав Наумов81777472021-03-09 15:14:27 +0400420 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200421 return [
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400422 osCloudLocation : openstackIMC,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100423 cdnConfig : cdnConfig,
424 proxyConfig : proxyConfig,
425 useMacOsSeedNode : seedMacOs,
426 deployChildEnabled : deployChild,
427 childDeployCustomRelease : customChildRelease,
428 upgradeChildEnabled : upgradeChild,
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400429 mosDeployChildEnabled : mosDeployChild,
430 mosUpgradeChildEnabled : mosUpgradeChild,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100431 runChildConformanceEnabled : runChildConformance,
432 attachBYOEnabled : attachBYO,
433 upgradeBYOEnabled : upgradeBYO,
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100434 runBYOMatrixEnabled : runBYOMatrix,
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400435 defaultBYOOs : defaultBYOOs,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100436 upgradeMgmtEnabled : upgradeMgmt,
slalov1202bba2022-04-20 22:31:07 +0400437 autoUpgradeMgmtEnabled : autoUpgradeMgmt,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100438 enableLMALoggingEnabled : enableLMALogging,
439 runUie2eEnabled : runUie2e,
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400440 runUie2eNewEnabled : runUie2eNew,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100441 runMgmtConformanceEnabled : runMgmtConformance,
slalov0a4947a2022-06-09 15:44:35 +0400442 runMaintenanceTestEnabled : runMaintenanceTest,
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300443 runContainerregistryTestEnabled : runContainerregistryTest,
444 runMgmtDeleteMasterTestEnabled : runMgmtDeleteMasterTest,
445 runRgnlDeleteMasterTestEnabled : runRgnlDeleteMasterTest,
446 runChildDeleteMasterTestEnabled : runChildDeleteMasterTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100447 runLMATestEnabled : runLMATest,
448 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
slalov574123e2022-04-06 17:24:19 +0400449 runProxyChildTestEnabled : runProxyChildTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100450 fetchServiceBinariesEnabled : fetchServiceBinaries,
451 awsOnDemandDemoEnabled : awsOnDemandDemo,
452 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
453 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
454 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
455 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
456 azureOnDemandDemoEnabled : azureOnDemandDemo,
457 azureOnAwsDemoEnabled : azureOnAwsDemo,
458 vsphereDemoEnabled : enableVsphereDemo,
459 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
460 bmDemoEnabled : enableBMDemo,
461 osDemoEnabled : enableOSDemo,
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300462 vsphereUbuntuEnabled : enableVsphereUbuntu,
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400463 artifactsBuildEnabled : enableArtifactsBuild,
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300464 childOsBootFromVolume : childOsBootFromVolume,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100465 multiregionalConfiguration : multiregionalMappings,
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400466 demoWeight : demoWeight,
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300467 bootstrapV2Scenario : bootstrapV2Scenario,
468 equinixMetalV2Metro : equinixMetalV2Metro]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200469}
470
471/**
472 * Determine management and regional setup for demo workflow scenario
473 *
474 *
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300475 * @param: keyword (string) string , represents keyword trigger, specified in gerrit commit body, like `[multiregion aws,os]`
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200476 or Jenkins environment string variable in form like 'aws,os'
477 * @return (map)[
478 enabled: (bool),
479 * managementLocation: (string), //aws,os
480 * regionLocation: (string), //aws,os
481 * ]
482 */
483def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200484 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400485 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
486 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200487
488 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200489 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200490 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
491 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
492 } else {
493 common.infoMsg('Multiregion definition configured via environment variable')
494 clusterTypes = keyword.trim().split(',')
495 }
496
497 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100498 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200499 }
500
Владислав Наумовf793fe32020-09-11 15:19:19 +0200501 def desiredManagementProvider = clusterTypes[0].trim()
502 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200503 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
504 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200505 management providers list - ${supportedManagementProviders}
506 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200507 }
508
509 return [
510 enabled: true,
511 managementLocation: desiredManagementProvider,
512 regionLocation: desiredRegionalProvider,
513 ]
vnaumov33747e12020-05-04 17:35:20 +0200514}
515
516/**
517 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
518
Владислав Наумов81777472021-03-09 15:14:27 +0400519 * 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 +0200520 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
521 * Example scheme:
522 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
523 * manage refspecs through Jenkins Job Parameters
524 *
azvyagintseva12230a2020-06-05 13:24:06 +0300525 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200526 * siPipelines: (string) final refspec for si-pipelines
527 * ]
528 */
529def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200530 def common = new com.mirantis.mk.Common()
531
vnaumov33747e12020-05-04 17:35:20 +0200532 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200533 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
534 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200535 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
536 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200537 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200538
539 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
540 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
541
542 if (siTestMatches.size() > 0) {
543 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400544 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200545 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200546 }
547 if (siPipelinesMatches.size() > 0) {
548 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
549 }
550
551 common.infoMsg("""
552 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
553 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200554 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400555 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200556 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200557}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200558
Владислав Наумов9080f372020-06-08 13:57:16 +0200559/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200560 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200561 * @param configurationFile (str) path to configuration file in yaml format
562 *
563 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
564 * ]
565 */
566def parseKaaSComponentCIParameters(configurationFile){
567 def common = new com.mirantis.mk.Common()
568 def ciConfig = readYaml file: configurationFile
569 def ciSpec = [
570 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
571 ]
572
573 if (ciConfig.containsKey('si-tests-feature-flags')) {
574 common.infoMsg("""SI tests feature flags customization detected,
575 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
576
577 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
578 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200579
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200580 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200581 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
582 }
583
584 common.infoMsg("""Additional ci configuration parsed successfully:
585 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
586 return ciSpec
587}
588
589/**
590 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200591
Владислав Наумов81777472021-03-09 15:14:27 +0400592 * 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 +0200593 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
594 * Example scheme:
595 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
596 * manage refspecs through Jenkins Job Parameters
597 *
598 * @return (map)[ core: (string) final refspec for kaas/core
599 * corePipelines: (string) final refspec for pipelines in kaas/core
600 * ]
601 */
602def checkCustomCoreRefspec() {
603 def common = new com.mirantis.mk.Common()
604
605 // Available triggers and its sane defaults
606 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
607 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
608 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
609 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
610
611 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
612 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
613
614 if (coreMatches.size() > 0) {
615 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
616 }
617 if (corePipelinesMatches.size() > 0) {
618 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
619 }
620
621 common.infoMsg("""
622 kaas/core will be fetched from: ${coreRefspec}
623 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400624 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200625 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
626}
627
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200628
629/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200630 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
631 * needed to forward inside kaas core set of jobs
632 *
633 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
634 * @return (list)[ string(name: '', value: ''),
635 * ]
636 */
637def generateKaaSVarsFromContext(context) {
638 def common = new com.mirantis.mk.Common()
639 def parameters = []
640 def config = readYaml text: context
641
642 config.each { k,v ->
643 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
644 parameters.add(string(name: k, value: v))
645 }
646
647 return parameters
648}
649
650/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200651 * 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 +0400652 * 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 +0200653 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
654 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200655 * @param: component (string) component name [iam, lcm, stacklight]
656 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
657 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200658 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200659def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200660 def common = new com.mirantis.mk.Common()
661 // Determine if custom trigger keywords forwarded from gerrit
662 def triggers = checkDeploymentTestSuite()
663 // Determine SI refspecs
664 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200665 // Determine Core refspecs
666 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200667
Владислав Наумов418042b2020-07-09 18:31:10 +0200668 // Determine component repo ci configuration
669 def ciSpec = [:]
670 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
671 if (fileExists(configurationFile)) {
672 common.infoMsg('Component CI configuration file detected, parsing...')
673 ciSpec = parseKaaSComponentCIParameters(configurationFile)
674 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
675 } else {
676 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200677 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200678 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
679 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200680 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400681
682 def platforms = []
683 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
684 // Currently only vsphere demo is required for IPAM component
685 platforms.add('vsphere')
686 } else {
687 if (triggers.osDemoEnabled) {
688 platforms.add('openstack')
689 }
690 if (triggers.awsOnDemandDemoEnabled) {
691 platforms.add('aws')
692 }
693 if (triggers.equinixOnDemandDemoEnabled) {
694 platforms.add('equinix')
695 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200696 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
697 platforms.add('equinixmetalv2')
698 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200699 if (triggers.azureOnDemandDemoEnabled) {
700 platforms.add('azure')
701 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400702 if (triggers.vsphereDemoEnabled) {
703 platforms.add('vsphere')
704 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400705 }
706
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200707 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200708 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200709 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
710 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200711 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200712 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200713 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
714 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200715 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200716 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400717 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400718 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100719 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200720 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200721 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100722 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200723 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
slalov1202bba2022-04-20 22:31:07 +0400724 booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400725 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200726 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200727 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
slalov0a4947a2022-06-09 15:44:35 +0400728 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnabled),
729 booleanParam(name: 'RUN_CONTAINER_REGISTRY_TEST', value: triggers.runContainerregistryTestEnabled),
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300730 booleanParam(name: 'RUN_MGMT_DELETE_MASTER_TEST', value: triggers.runMgmtDeleteMasterTestEnabled),
731 booleanParam(name: 'RUN_RGNL_DELETE_MASTER_TEST', value: triggers.runRgnlDeleteMasterTestEnabled),
732 booleanParam(name: 'RUN_CHILD_DELETE_MASTER_TEST', value: triggers.runChildDeleteMasterTestEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200733 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200734 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200735 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
736 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
slalov574123e2022-04-06 17:24:19 +0400737 booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100738 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100739 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100740 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200741 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400742 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200743 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200744 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100745 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400746 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200747 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200748 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Sergey Zhemerdeev9074f6e2022-06-07 12:03:16 +0300749 booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200750 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200751
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200752 // customize multiregional demo
753 if (triggers.multiregionalConfiguration.enabled) {
754 parameters.add(string(name: 'MULTIREGION_SETUP',
755 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
756 ))
757 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200758
Владислав Наумов92288d92020-07-13 18:36:21 +0200759 // Determine component team custom context
760 if (coreContext != '') {
761 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
762 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200763 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200764 }
765
Владислав Наумовaa430612020-06-08 17:18:31 +0200766 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400767
768 platforms.each { platform ->
769 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000770 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400771 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
772 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
773 def build_description = job_info.getDescription()
774 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000775 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200776
Vladislav Naumov5313a202021-04-07 17:13:39 +0000777 if (build_description) {
778 currentBuild.description += build_description
779 }
780 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400781 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000782 }
783 }
784 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200785
786 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400787 if (jobs.size() == 0) {
788 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
789 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200790 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
791 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200792
793 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200794 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200795 currentBuild.result = 'FAILURE'
796 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200797}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200798
799
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400800/**
801 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200802 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400803 *
804 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
805 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
806 * @param: multiregionalConfiguration (map) Multiregional configuration
807 * @return (map) Return aggregated map with lockResources and netMap
808 */
809
810
811def generateLockResources(callBackDemo, triggers) {
812 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200813 def netMap = [
814 vsphere: [:],
815 equinix: [:],
816 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400817 // Define vsphere locklabels with initial quantity
818 def lockLabels = [
819 vsphere_networking_core_ci: 0,
820 vsphere_offline_networking_core_ci: 0,
821 ]
822 def deployChild = triggers.deployChildEnabled
823 def multiregionConfig = triggers.multiregionalConfiguration
824 def runMultiregion = multiregionConfig.enabled
825
826 // Generate vsphere netMap and lockLabels based on demo context
827 switch (callBackDemo) {
828 case 'aws':
829 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
830 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +0400831 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400832
833 // Define netMap for Vsphere region
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400834 if (runMultiregion && multiregionConfig.managementLocation == 'aws') {
835 if (multiregionConfig.regionLocation == 'vsphere') {
836 if (deployChild) {
837 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
838 }
839 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400840 }
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400841
842 if (multiregionConfig.regionLocation == 'azure') {
843 lockLabels['azure_core_ci_queue'] = 1
844 if (deployChild) {
845 lockLabels['azure_core_ci_queue'] += 1
846 }
847 }
848 }
849 if (triggers.azureOnAwsDemoEnabled) {
850 lockLabels['azure_core_ci_queue'] = 1
851 }
852
853 if (triggers.equinixOnAwsDemoEnabled) {
854 lockLabels['equinix_core_ci_queue'] = 1
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400855 }
856 break
857 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200858 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400859 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200860 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400861 }
862 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
863 multiregionConfig.regionLocation == 'vsphere') {
864 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200865 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400866 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200867 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400868 }
869 break
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400870 case 'azure':
871 lockLabels['azure_core_ci_queue'] = triggers.demoWeight
872 if (runMultiregion && multiregionConfig.managementLocation == 'azure') {
873 if (multiregionConfig.regionLocation == 'aws') {
874 lockLabels['aws_core_ci_queue'] = 1
875 if (deployChild) {
876 lockLabels['aws_core_ci_queue'] += 1
877 }
878 }
879
880 if (multiregionConfig.regionLocation == 'equinix') {
881 lockLabels['equinix_core_ci_queue'] = 1
882 if (deployChild) {
883 lockLabels['equinix_core_ci_queue'] +=1
884 }
885 }
886 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400887 default:
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400888 error('Supposed to be called from aws, azure or vsphere demos only')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400889 }
890
891 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
892 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200893 netMap['vsphere'].each { clusterType, netConfig ->
894 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
895 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
896 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
897
898 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400899 lockLabels['vsphere_offline_networking_core_ci']++
900 } else {
901 lockLabels['vsphere_networking_core_ci']++
902 }
903 }
904
905 // generate lock metadata
906 def lockResources = []
907 lockLabels.each { label, quantity ->
908 if (quantity > 0) {
909 def res = [
910 label: label,
911 quantity: quantity,
912 ]
913 lockResources.add(res)
914 }
915 }
916
917 common.infoMsg("""Generated vsphere netMap: ${netMap}
918 Generated lockResources: ${lockResources}""")
919
920 return [
921 netMap: netMap,
922 lockResources: lockResources,
923 ]
924}
925
926/**
927 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
928 * and empty rangeConfig to the this map.
929 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200930 * @param: netMap (string) vsphere, equinix netMap or empty map
931 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400932 * @param: clusterType (string) Vsphere cluster type
933 */
934
Владислав Наумов33e1e812021-08-17 17:09:25 +0200935def addToProviderNetMap (netMap, provider, clusterType) {
936 switch (provider) {
937 case 'equinix':
938 netMap[provider][clusterType] = [
939 vlanConfig: '',
940 ]
941 break
942 case 'vsphere':
943 netMap[provider][clusterType] = [
944 netName: 'default',
945 rangeConfig: '',
946 ]
947 break
948 default:
949 error('Net map locks supported for Equinix/Vsphere providers only')
950 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400951}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +0300952
953/**
954* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
955* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
956* If keyword contains only 'key' part then 'value' is boolean True.
957* This function does not perform keywords validation.
958* First line of a commit message is ignored.
959* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
960* TODO: Remove backslash chars from values if they prepend '[' or ']'.
961**/
962
963List getCIKeywordsFromCommitMsg() {
964 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
965 List commitMsgLines = commitMsg.split('\n')
966 List keywords = []
967 if (commitMsgLines.size() < 2) {
968 return keywords
969 }
970
971 String commitMsgBody = commitMsgLines[1..-1].join('\n')
972
973 // Split commit message body to chunks using '[' or ']' as delimiter,
974 // ignoring them if prepended by backslash (regex negative lookbehind).
975 // Resulting list will have chunks between '[' and ']' at odd indexes.
976 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
977
978 // Iterate chunks by odd indexes only, trim values and split to
979 // <key> / <value> pair where <key> is the part of a sting before the first
980 // whitespace delimiter, and <value> is the rest (may include whitespaces).
981 // If there is no whitespace in the string then this is a 'switch'
982 // and <value> will be boolean True.
983 for (i = 1; i < parts.size(); i += 2) {
984 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
985 keywords.add(['key': key, 'value': value])
986 }
987
988 return keywords
989}
990
991/**
992* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
993* that were specified for given job name. `job-params` keyword has the following structure
994*
995* [job-params <job name> <parameter name> <parameter value>]
996*
997* Return value is a Map that contains those parameters using the following structure:
998*
999* <job name>:
1000* <parameter name>: <parameter value>
1001*
1002**/
1003Map getJobsParamsFromCommitMsg() {
1004 List keywords = getCIKeywordsFromCommitMsg()
1005
1006 List jobsParamsList = []
1007 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
1008 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
1009 def (key, value) = params.split(/\s+/, 2)
1010 ['name': name, 'key': key, 'value': value]
1011 }
1012
1013 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
1014 if (!result.containsKey(it.name)) {
1015 result[it.name] = [:]
1016 }
1017 result[it.name][it.key] = it.value
1018 result
1019 }
1020
1021 return jobsParams
1022}
1023
1024
1025/**
1026* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
1027* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
1028* uses only those parametes that were set to all jobs (with <job name> == '*') or to
1029* a particular job. Parameters set to a particular job have higher precedence.
1030*
1031* Return value is a Map that contains those parameters:
1032*
1033* <parameter name>: <parameter value>
1034*
1035**/
1036Map getJobParamsFromCommitMsg(String jobName) {
1037 jobsParams = getJobsParamsFromCommitMsg()
1038 jobParams = jobsParams.getOrDefault('*', [:])
1039 if (jobName) {
1040 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
1041 }
1042 return jobParams
1043}
azvyagintsevc17d14b2022-06-06 19:06:33 +03001044
1045/** Getting test scheme from text, which should be
1046Imput example:
1047text="""
1048 DATA
1049
1050 kaas_bm_test_schemas:
1051 KAAS_RELEASES_REFSPEC: ''
1052 KEY: VAL
1053
1054 DATA
1055 """
1056
1057 Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas'])
1058
1059 Return:
1060 ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL']
1061 **/
1062def parseTextForTestSchemas(Map opts) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001063 String text = opts.getOrDefault('text', '')
azvyagintsevc17d14b2022-06-06 19:06:33 +03001064 String keyLine = opts.getOrDefault('keyLine', '')
1065 Map testScheme = [:]
1066 if (!text || !keyLine) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001067 return testScheme
azvyagintsevc17d14b2022-06-06 19:06:33 +03001068 }
1069 if (text =~ /\n$keyLine\n.*/) {
1070 def common = new com.mirantis.mk.Common()
1071 try {
1072 String regExp = '\\n' + keyLine + '\\n'
1073 // regexep block must be followed by empty line
1074 testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}"
1075 common.infoMsg("parseTextForTestSchemas result:\n" + testScheme)
1076 common.mergeEnv(env, toJson(testScheme))
1077 }
1078 catch (Exception e) {
1079 common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}")
1080 throw e
1081 }
1082 }
azvyagintsevd96aac22022-06-10 14:23:26 +03001083 return testScheme
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +03001084}