blob: 45f9a6ee6f277fd154970d3ff2c893d577feface [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
Sergey Lalovacec3c12022-07-20 16:00:14 +0400110 def equinixMetalV2Metro = env.EQUINIX_MGMT_METRO ? env.EQUINIX_MGMT_METRO : ''
vnaumov33747e12020-05-04 17:35:20 +0200111
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200112 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +0100113 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
114 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +0200115 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 +0100116 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100117 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
118 seedMacOs = true
119 }
slalov574123e2022-04-06 17:24:19 +0400120 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance || runProxyChildTest) {
vnaumov33747e12020-05-04 17:35:20 +0200121 deployChild = true
122 }
123 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
124 deployChild = true
125 upgradeChild = true
126 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400127 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
128 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400129 // override child version when it set explicitly
130 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400131 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400132 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
133 }
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400134 if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) {
135 mosDeployChild = true
136 }
137 if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) {
138 mosDeployChild = true
139 mosUpgradeChild = true
140 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100141 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
142 attachBYO = true
143 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100144 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
145 attachBYO = true
146 upgradeBYO = true
147 }
Sergey Lalovacec3c12022-07-20 16:00:14 +0400148 if (commitMsg ==~ /(?s).*\[ui-test-on-all-providers\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-test-on-all-providers.*/) {
149 enableVsphereDemo = true
150 enableOSDemo = true
151 awsOnDemandDemo = true
152 azureOnDemandDemo = true
153 equinixOnDemandDemo = true
154 equinixMetalV2OnDemandDemo = true
155 runUie2e = true
Sergey Lalovacec3c12022-07-20 16:00:14 +0400156 // Edit after fix PRODX-3961
157 enableBMDemo = false
158 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400159 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
160 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 +0100161 runBYOMatrix = true
162
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400163 if (byoDeployMatches.size() > 0) {
164 defaultBYOOs = byoDeployMatches[0][2]
165 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
166 }
167
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100168 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
169 attachBYO = false
170 upgradeBYO = false
171 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400172 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200173 upgradeMgmt = true
174 }
slalov1202bba2022-04-20 22:31:07 +0400175 if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) {
176 autoUpgradeMgmt = true
177 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400178 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
179 enableLMALogging = true
180 }
vnaumov33747e12020-05-04 17:35:20 +0200181 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
182 runUie2e = true
183 }
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400184 if (commitMsg ==~ /(?s).*\[ui-e2e-new\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-new.*/) {
185 runUie2eNew = true
186 }
vnaumov33747e12020-05-04 17:35:20 +0200187 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
188 runMgmtConformance = true
189 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200190 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
191 runMgmtUserControllerTest = true
192 }
slalov574123e2022-04-06 17:24:19 +0400193 if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) {
194 runProxyChildTest = true
195 deployChild = true
196 common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed')
197 }
vnaumov33747e12020-05-04 17:35:20 +0200198 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
199 runChildConformance = true
200 deployChild = true
201 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200202 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
203 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400204 enableLMALogging = true
205 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400206 }
slalov13e579c2022-01-31 21:37:02 +0400207 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
208 runMaintenanceTest = true
209 }
slalov0a4947a2022-06-09 15:44:35 +0400210 if (commitMsg ==~ /(?s).*\[container-registry-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*container-registry-test.*/) {
211 runContainerregistryTest = true
212 }
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300213 if (commitMsg ==~ /(?s).*\[mgmt-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-delete-master-test.*/) {
214 runMgmtDeleteMasterTest = true
215 }
216 if (commitMsg ==~ /(?s).*\[rgnl-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*rgnl-delete-master-test.*/) {
217 runRgnlDeleteMasterTest = true
218 }
219 if (commitMsg ==~ /(?s).*\[child-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-delete-master-test.*/) {
220 runChildDeleteMasterTest = true
221 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200222 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
223 proxyConfig['childOffline'] = true
224 deployChild = true
225 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200226 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
227 proxyConfig['childOffline'] = true
228 proxyConfig['childProxy'] = true
229 deployChild = true
230 }
vnaumov33747e12020-05-04 17:35:20 +0200231 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
232 fetchServiceBinaries = true
233 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200234 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400235 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200236 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 +0400237 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200238 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
239 azureOnAwsDemo = true
240 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
241 }
242 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
243 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
244 attachBYO ||
245 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100246 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200247 seedMacOs ||
248 equinixOnAwsDemo ||
249 azureOnAwsDemo) {
250
vnaumov33747e12020-05-04 17:35:20 +0200251 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200252 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 +0200253 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200254 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200255 equinixOnDemandDemo = true
256 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200257 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200258 equinixMetalV2OnDemandDemo = true
259 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100260 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
261 equinixMetalV2OnDemandDemo = true
262 equinixMetalV2ChildDiffMetro = true
263 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200264 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
265 azureOnDemandDemo = true
266 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200267 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
268 enableOSDemo = false
269 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200270 }
271
azvyagintsev1761bdc2020-09-04 17:24:12 +0300272 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
273 enableBMDemo = false
274 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
275 }
276
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400277 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
278 enableVsphereDemo = false
279 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
280 }
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300281 if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) {
282 enableVsphereUbuntu = true
283 common.warningMsg('Ubuntu will be used to deploy vsphere machines')
284 }
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400285
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400286 if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) {
287 enableArtifactsBuild = false
288 common.errorMsg('artifacts build will be aborted, VF -1 will be set')
289 }
290
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300291 if (commitMsg ==~ /(?s).*\[child-os-boot-from-volume\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-os-boot-from-volume\.*/) {
292 childOsBootFromVolume = true
293 common.warningMsg('OS will be booted from Ceph volumes')
294 }
295
vnaumov33747e12020-05-04 17:35:20 +0200296 // TODO (vnaumov) remove below condition after moving all releases to UCP
297 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
298 if (ucpChildMatches.size() > 0) {
299 deployChild = true
300 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
301
302 // TODO(vnaumov) delete after ucp upgrades support
303 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
304 upgradeChild = false
305 }
306
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200307 // multiregional tests
308 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
309 if (multiRegionalMatches.size() > 0) {
310 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
311 }
312 switch (multiregionalMappings['managementLocation']) {
313 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100314 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200315 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100316
317 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
318 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
319 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200320 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200321 case 'os':
322 if (enableOSDemo == false) {
323 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
324 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200325 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200326 case 'vsphere':
327 if (enableVsphereDemo == false) {
328 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
329 }
330 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200331 case 'equinix':
332 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
333 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400334 break
eromanova8c702ae2021-12-24 17:43:12 +0400335 case 'equinixmetalv2':
336 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
337 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400338 break
slalovfd0b7e62021-07-28 18:05:16 +0400339 case 'azure':
340 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
341 azureOnDemandDemo = true
342 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200343 }
344
Владислав Наумовb8305e22021-02-10 17:23:12 +0100345 // CDN configuration
346 def cdnConfig = [
347 mgmt: [
348 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200349 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100350 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200351 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200352 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200353 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100354 ]
355
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400356 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
357 openstackIMC = 'eu'
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400358 }
slalov021171f2022-03-04 14:48:38 +0400359 if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) {
360 openstackIMC = 'eu2'
Mikhail Ivanovf05b8252022-04-27 18:14:03 +0400361 }
362 if (openstackIMC == 'eu' || openstackIMC == 'eu2') {
slalov021171f2022-03-04 14:48:38 +0400363 // use internal-eu because on internal-ci with eu cloud image pull takes much time
364 def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
365 common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}")
366 cdnConfig['mgmt']['openstack'] = cdnRegion
367 }
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400368
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100369 // calculate weight of current demo run to manage lockable resources
Sergey Lalov4128aba2022-08-17 12:58:33 +0400370 def demoWeight = deployChild ? 3 : 2 // management = 1 + 1 ui child, child += 1
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100371
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400372 if (commitMsg ==~ /(?s).*\[bootstrapv2-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv2-scenario\.*/) {
373 bootstrapV2Scenario = true
374 }
375
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300376 // parse equinixmetalv2-metro trigger
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300377 def equinixMetalV2MetroMatcher = (commitMsg =~ /\[equinixmetalv2-metro(\s+.*)?\]/)
378 if (equinixMetalV2OnDemandDemo && equinixMetalV2MetroMatcher.size() > 0) {
Sergey Zhemerdeevcc785e42022-07-22 17:15:47 +0300379 equinixMetalV2Metro = equinixMetalV2MetroMatcher[0][1].trim().toLowerCase()
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300380 common.infoMsg("Forced Equnix mgmt deployment using custom metro ${equinixMetalV2Metro}")
381 }
382
vnaumov33747e12020-05-04 17:35:20 +0200383 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400384 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100385 CDN deployment configuration: ${cdnConfig}
386 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100387 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200388 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400389 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200390 Child cluster release upgrade scheduled: ${upgradeChild}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400391 MOS child deploy scheduled: ${mosDeployChild}
392 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200393 Child conformance testing scheduled: ${runChildConformance}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100394 Single BYO cluster attachment scheduled: ${attachBYO}
395 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
396 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400397 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200398 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
slalov1202bba2022-04-20 22:31:07 +0400399 Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400400 Mgmt LMA logging enabled: ${enableLMALogging}
vnaumov33747e12020-05-04 17:35:20 +0200401 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200402 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200403 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200404 Mgmt UI e2e testing scheduled: ${runUie2e}
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400405 Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew}
slalov13e579c2022-01-31 21:37:02 +0400406 Maintenance test: ${runMaintenanceTest}
slalov0a4947a2022-06-09 15:44:35 +0400407 Container Registry test: ${runContainerregistryTest}
slalov574123e2022-04-06 17:24:19 +0400408 Child proxy test: ${runProxyChildTest}
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300409 Delete mgmt master node test: ${runMgmtDeleteMasterTest}
410 Delete rgnl master node test: ${runRgnlDeleteMasterTest}
411 Delete child master node test: ${runChildDeleteMasterTest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200412 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200413 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200414 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100415 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Sergey Zhemerdeev019c45a2022-08-13 00:09:07 +0300416 EquinixmetalV2 mgmt will be deployed on the metro: ${equinixMetalV2Metro?:'auto'}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200417 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200418 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200419 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400420 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200421 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300422 BM provider deployment scheduled: ${enableBMDemo}
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300423 Ubuntu on vSphere scheduled: ${enableVsphereUbuntu}
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400424 Artifacts build scheduled: ${enableArtifactsBuild}
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300425 Boot OS child from Ceph volumes: ${childOsBootFromVolume}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200426 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200427 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100428 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400429 Bootstrap v2 scenario enabled: ${bootstrapV2Scenario}
Владислав Наумов81777472021-03-09 15:14:27 +0400430 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200431 return [
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400432 osCloudLocation : openstackIMC,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100433 cdnConfig : cdnConfig,
434 proxyConfig : proxyConfig,
435 useMacOsSeedNode : seedMacOs,
436 deployChildEnabled : deployChild,
437 childDeployCustomRelease : customChildRelease,
438 upgradeChildEnabled : upgradeChild,
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400439 mosDeployChildEnabled : mosDeployChild,
440 mosUpgradeChildEnabled : mosUpgradeChild,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100441 runChildConformanceEnabled : runChildConformance,
442 attachBYOEnabled : attachBYO,
443 upgradeBYOEnabled : upgradeBYO,
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100444 runBYOMatrixEnabled : runBYOMatrix,
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400445 defaultBYOOs : defaultBYOOs,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100446 upgradeMgmtEnabled : upgradeMgmt,
slalov1202bba2022-04-20 22:31:07 +0400447 autoUpgradeMgmtEnabled : autoUpgradeMgmt,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100448 enableLMALoggingEnabled : enableLMALogging,
449 runUie2eEnabled : runUie2e,
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400450 runUie2eNewEnabled : runUie2eNew,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100451 runMgmtConformanceEnabled : runMgmtConformance,
slalov0a4947a2022-06-09 15:44:35 +0400452 runMaintenanceTestEnabled : runMaintenanceTest,
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300453 runContainerregistryTestEnabled : runContainerregistryTest,
454 runMgmtDeleteMasterTestEnabled : runMgmtDeleteMasterTest,
455 runRgnlDeleteMasterTestEnabled : runRgnlDeleteMasterTest,
456 runChildDeleteMasterTestEnabled : runChildDeleteMasterTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100457 runLMATestEnabled : runLMATest,
458 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
slalov574123e2022-04-06 17:24:19 +0400459 runProxyChildTestEnabled : runProxyChildTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100460 fetchServiceBinariesEnabled : fetchServiceBinaries,
461 awsOnDemandDemoEnabled : awsOnDemandDemo,
462 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
463 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
464 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
465 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
466 azureOnDemandDemoEnabled : azureOnDemandDemo,
467 azureOnAwsDemoEnabled : azureOnAwsDemo,
468 vsphereDemoEnabled : enableVsphereDemo,
469 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
470 bmDemoEnabled : enableBMDemo,
471 osDemoEnabled : enableOSDemo,
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300472 vsphereUbuntuEnabled : enableVsphereUbuntu,
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400473 artifactsBuildEnabled : enableArtifactsBuild,
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300474 childOsBootFromVolume : childOsBootFromVolume,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100475 multiregionalConfiguration : multiregionalMappings,
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400476 demoWeight : demoWeight,
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300477 bootstrapV2Scenario : bootstrapV2Scenario,
478 equinixMetalV2Metro : equinixMetalV2Metro]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200479}
480
481/**
482 * Determine management and regional setup for demo workflow scenario
483 *
484 *
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300485 * @param: keyword (string) string , represents keyword trigger, specified in gerrit commit body, like `[multiregion aws,os]`
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200486 or Jenkins environment string variable in form like 'aws,os'
487 * @return (map)[
488 enabled: (bool),
489 * managementLocation: (string), //aws,os
490 * regionLocation: (string), //aws,os
491 * ]
492 */
493def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200494 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400495 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
496 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200497
498 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200499 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200500 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
501 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
502 } else {
503 common.infoMsg('Multiregion definition configured via environment variable')
504 clusterTypes = keyword.trim().split(',')
505 }
506
507 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100508 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200509 }
510
Владислав Наумовf793fe32020-09-11 15:19:19 +0200511 def desiredManagementProvider = clusterTypes[0].trim()
512 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200513 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
514 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200515 management providers list - ${supportedManagementProviders}
516 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200517 }
518
519 return [
520 enabled: true,
521 managementLocation: desiredManagementProvider,
522 regionLocation: desiredRegionalProvider,
523 ]
vnaumov33747e12020-05-04 17:35:20 +0200524}
525
526/**
527 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
528
Владислав Наумов81777472021-03-09 15:14:27 +0400529 * 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 +0200530 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
531 * Example scheme:
532 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
533 * manage refspecs through Jenkins Job Parameters
534 *
azvyagintseva12230a2020-06-05 13:24:06 +0300535 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200536 * siPipelines: (string) final refspec for si-pipelines
537 * ]
538 */
539def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200540 def common = new com.mirantis.mk.Common()
541
vnaumov33747e12020-05-04 17:35:20 +0200542 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200543 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
544 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200545 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
546 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200547 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200548
549 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
550 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
551
552 if (siTestMatches.size() > 0) {
553 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400554 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200555 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200556 }
557 if (siPipelinesMatches.size() > 0) {
558 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
559 }
560
561 common.infoMsg("""
562 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
563 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200564 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400565 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200566 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200567}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200568
Владислав Наумов9080f372020-06-08 13:57:16 +0200569/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200570 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200571 * @param configurationFile (str) path to configuration file in yaml format
572 *
573 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
574 * ]
575 */
576def parseKaaSComponentCIParameters(configurationFile){
577 def common = new com.mirantis.mk.Common()
578 def ciConfig = readYaml file: configurationFile
579 def ciSpec = [
580 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
581 ]
582
583 if (ciConfig.containsKey('si-tests-feature-flags')) {
584 common.infoMsg("""SI tests feature flags customization detected,
585 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
586
587 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
588 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200589
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200590 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200591 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
592 }
593
594 common.infoMsg("""Additional ci configuration parsed successfully:
595 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
596 return ciSpec
597}
598
599/**
600 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200601
Владислав Наумов81777472021-03-09 15:14:27 +0400602 * 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 +0200603 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
604 * Example scheme:
605 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
606 * manage refspecs through Jenkins Job Parameters
607 *
608 * @return (map)[ core: (string) final refspec for kaas/core
609 * corePipelines: (string) final refspec for pipelines in kaas/core
610 * ]
611 */
612def checkCustomCoreRefspec() {
613 def common = new com.mirantis.mk.Common()
614
615 // Available triggers and its sane defaults
616 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
617 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
618 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
619 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
620
621 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
622 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
623
624 if (coreMatches.size() > 0) {
625 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
626 }
627 if (corePipelinesMatches.size() > 0) {
628 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
629 }
630
631 common.infoMsg("""
632 kaas/core will be fetched from: ${coreRefspec}
633 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400634 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200635 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
636}
637
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200638
639/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200640 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
641 * needed to forward inside kaas core set of jobs
642 *
643 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
644 * @return (list)[ string(name: '', value: ''),
645 * ]
646 */
647def generateKaaSVarsFromContext(context) {
648 def common = new com.mirantis.mk.Common()
649 def parameters = []
650 def config = readYaml text: context
651
652 config.each { k,v ->
653 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
654 parameters.add(string(name: k, value: v))
655 }
656
657 return parameters
658}
659
660/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200661 * 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 +0400662 * 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 +0200663 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
664 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200665 * @param: component (string) component name [iam, lcm, stacklight]
666 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
667 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200668 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200669def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200670 def common = new com.mirantis.mk.Common()
671 // Determine if custom trigger keywords forwarded from gerrit
672 def triggers = checkDeploymentTestSuite()
673 // Determine SI refspecs
674 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200675 // Determine Core refspecs
676 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200677
Владислав Наумов418042b2020-07-09 18:31:10 +0200678 // Determine component repo ci configuration
679 def ciSpec = [:]
680 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
681 if (fileExists(configurationFile)) {
682 common.infoMsg('Component CI configuration file detected, parsing...')
683 ciSpec = parseKaaSComponentCIParameters(configurationFile)
684 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
685 } else {
686 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200687 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200688 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
689 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200690 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400691
692 def platforms = []
693 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
694 // Currently only vsphere demo is required for IPAM component
695 platforms.add('vsphere')
696 } else {
697 if (triggers.osDemoEnabled) {
698 platforms.add('openstack')
699 }
700 if (triggers.awsOnDemandDemoEnabled) {
701 platforms.add('aws')
702 }
703 if (triggers.equinixOnDemandDemoEnabled) {
704 platforms.add('equinix')
705 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200706 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
707 platforms.add('equinixmetalv2')
708 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200709 if (triggers.azureOnDemandDemoEnabled) {
710 platforms.add('azure')
711 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400712 if (triggers.vsphereDemoEnabled) {
713 platforms.add('vsphere')
714 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400715 }
716
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200717 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200718 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200719 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
720 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200721 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200722 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200723 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
724 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200725 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200726 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400727 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400728 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100729 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200730 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200731 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100732 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200733 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
slalov1202bba2022-04-20 22:31:07 +0400734 booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400735 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200736 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200737 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
slalov0a4947a2022-06-09 15:44:35 +0400738 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnabled),
739 booleanParam(name: 'RUN_CONTAINER_REGISTRY_TEST', value: triggers.runContainerregistryTestEnabled),
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300740 booleanParam(name: 'RUN_MGMT_DELETE_MASTER_TEST', value: triggers.runMgmtDeleteMasterTestEnabled),
741 booleanParam(name: 'RUN_RGNL_DELETE_MASTER_TEST', value: triggers.runRgnlDeleteMasterTestEnabled),
742 booleanParam(name: 'RUN_CHILD_DELETE_MASTER_TEST', value: triggers.runChildDeleteMasterTestEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200743 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200744 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200745 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
746 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
slalov574123e2022-04-06 17:24:19 +0400747 booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100748 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100749 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100750 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200751 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400752 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200753 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200754 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100755 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400756 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200757 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200758 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Sergey Zhemerdeev9074f6e2022-06-07 12:03:16 +0300759 booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200760 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200761
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200762 // customize multiregional demo
763 if (triggers.multiregionalConfiguration.enabled) {
764 parameters.add(string(name: 'MULTIREGION_SETUP',
765 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
766 ))
767 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200768
Владислав Наумов92288d92020-07-13 18:36:21 +0200769 // Determine component team custom context
770 if (coreContext != '') {
771 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
772 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200773 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200774 }
775
Владислав Наумовaa430612020-06-08 17:18:31 +0200776 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400777
778 platforms.each { platform ->
779 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000780 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400781 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
782 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
783 def build_description = job_info.getDescription()
784 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000785 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200786
Vladislav Naumov5313a202021-04-07 17:13:39 +0000787 if (build_description) {
788 currentBuild.description += build_description
789 }
790 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400791 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000792 }
793 }
794 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200795
796 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400797 if (jobs.size() == 0) {
798 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
799 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200800 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
801 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200802
803 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200804 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200805 currentBuild.result = 'FAILURE'
806 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200807}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200808
809
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400810/**
811 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200812 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400813 *
814 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
815 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
816 * @param: multiregionalConfiguration (map) Multiregional configuration
817 * @return (map) Return aggregated map with lockResources and netMap
818 */
819
820
821def generateLockResources(callBackDemo, triggers) {
822 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200823 def netMap = [
824 vsphere: [:],
825 equinix: [:],
826 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400827 // Define vsphere locklabels with initial quantity
828 def lockLabels = [
829 vsphere_networking_core_ci: 0,
830 vsphere_offline_networking_core_ci: 0,
831 ]
832 def deployChild = triggers.deployChildEnabled
slalov27833272022-06-30 02:13:50 +0400833 def testUiVsphere = triggers.runUie2eEnabled
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400834 def multiregionConfig = triggers.multiregionalConfiguration
835 def runMultiregion = multiregionConfig.enabled
836
837 // Generate vsphere netMap and lockLabels based on demo context
838 switch (callBackDemo) {
839 case 'aws':
840 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
841 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +0400842 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400843
844 // Define netMap for Vsphere region
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400845 if (runMultiregion && multiregionConfig.managementLocation == 'aws') {
846 if (multiregionConfig.regionLocation == 'vsphere') {
847 if (deployChild) {
848 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
849 }
850 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400851 }
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400852
853 if (multiregionConfig.regionLocation == 'azure') {
854 lockLabels['azure_core_ci_queue'] = 1
855 if (deployChild) {
856 lockLabels['azure_core_ci_queue'] += 1
857 }
858 }
859 }
860 if (triggers.azureOnAwsDemoEnabled) {
861 lockLabels['azure_core_ci_queue'] = 1
862 }
863
864 if (triggers.equinixOnAwsDemoEnabled) {
865 lockLabels['equinix_core_ci_queue'] = 1
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400866 }
867 break
868 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200869 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
slalov27833272022-06-30 02:13:50 +0400870 if (deployChild || testUiVsphere) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200871 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400872 }
873 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
874 multiregionConfig.regionLocation == 'vsphere') {
875 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200876 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400877 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200878 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400879 }
880 break
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400881 case 'azure':
882 lockLabels['azure_core_ci_queue'] = triggers.demoWeight
883 if (runMultiregion && multiregionConfig.managementLocation == 'azure') {
884 if (multiregionConfig.regionLocation == 'aws') {
885 lockLabels['aws_core_ci_queue'] = 1
886 if (deployChild) {
887 lockLabels['aws_core_ci_queue'] += 1
888 }
889 }
890
891 if (multiregionConfig.regionLocation == 'equinix') {
892 lockLabels['equinix_core_ci_queue'] = 1
893 if (deployChild) {
894 lockLabels['equinix_core_ci_queue'] +=1
895 }
896 }
897 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400898 default:
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400899 error('Supposed to be called from aws, azure or vsphere demos only')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400900 }
901
902 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
903 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200904 netMap['vsphere'].each { clusterType, netConfig ->
905 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
906 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
907 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
908
909 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400910 lockLabels['vsphere_offline_networking_core_ci']++
911 } else {
912 lockLabels['vsphere_networking_core_ci']++
913 }
914 }
915
916 // generate lock metadata
917 def lockResources = []
918 lockLabels.each { label, quantity ->
919 if (quantity > 0) {
920 def res = [
921 label: label,
922 quantity: quantity,
923 ]
924 lockResources.add(res)
925 }
926 }
927
928 common.infoMsg("""Generated vsphere netMap: ${netMap}
929 Generated lockResources: ${lockResources}""")
930
931 return [
932 netMap: netMap,
933 lockResources: lockResources,
934 ]
935}
936
937/**
938 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
939 * and empty rangeConfig to the this map.
940 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200941 * @param: netMap (string) vsphere, equinix netMap or empty map
942 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400943 * @param: clusterType (string) Vsphere cluster type
944 */
945
Владислав Наумов33e1e812021-08-17 17:09:25 +0200946def addToProviderNetMap (netMap, provider, clusterType) {
947 switch (provider) {
948 case 'equinix':
949 netMap[provider][clusterType] = [
950 vlanConfig: '',
951 ]
952 break
953 case 'vsphere':
954 netMap[provider][clusterType] = [
955 netName: 'default',
956 rangeConfig: '',
957 ]
958 break
959 default:
960 error('Net map locks supported for Equinix/Vsphere providers only')
961 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400962}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +0300963
964/**
965* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
966* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
967* If keyword contains only 'key' part then 'value' is boolean True.
968* This function does not perform keywords validation.
969* First line of a commit message is ignored.
970* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
971* TODO: Remove backslash chars from values if they prepend '[' or ']'.
972**/
973
974List getCIKeywordsFromCommitMsg() {
975 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
976 List commitMsgLines = commitMsg.split('\n')
977 List keywords = []
978 if (commitMsgLines.size() < 2) {
979 return keywords
980 }
981
982 String commitMsgBody = commitMsgLines[1..-1].join('\n')
983
984 // Split commit message body to chunks using '[' or ']' as delimiter,
985 // ignoring them if prepended by backslash (regex negative lookbehind).
986 // Resulting list will have chunks between '[' and ']' at odd indexes.
987 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
988
989 // Iterate chunks by odd indexes only, trim values and split to
990 // <key> / <value> pair where <key> is the part of a sting before the first
991 // whitespace delimiter, and <value> is the rest (may include whitespaces).
992 // If there is no whitespace in the string then this is a 'switch'
993 // and <value> will be boolean True.
994 for (i = 1; i < parts.size(); i += 2) {
995 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
996 keywords.add(['key': key, 'value': value])
997 }
998
999 return keywords
1000}
1001
1002/**
1003* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
1004* that were specified for given job name. `job-params` keyword has the following structure
1005*
1006* [job-params <job name> <parameter name> <parameter value>]
1007*
1008* Return value is a Map that contains those parameters using the following structure:
1009*
1010* <job name>:
1011* <parameter name>: <parameter value>
1012*
1013**/
1014Map getJobsParamsFromCommitMsg() {
1015 List keywords = getCIKeywordsFromCommitMsg()
1016
1017 List jobsParamsList = []
1018 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
1019 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
1020 def (key, value) = params.split(/\s+/, 2)
1021 ['name': name, 'key': key, 'value': value]
1022 }
1023
1024 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
1025 if (!result.containsKey(it.name)) {
1026 result[it.name] = [:]
1027 }
1028 result[it.name][it.key] = it.value
1029 result
1030 }
1031
1032 return jobsParams
1033}
1034
1035
1036/**
1037* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
1038* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
1039* uses only those parametes that were set to all jobs (with <job name> == '*') or to
1040* a particular job. Parameters set to a particular job have higher precedence.
1041*
1042* Return value is a Map that contains those parameters:
1043*
1044* <parameter name>: <parameter value>
1045*
1046**/
1047Map getJobParamsFromCommitMsg(String jobName) {
1048 jobsParams = getJobsParamsFromCommitMsg()
1049 jobParams = jobsParams.getOrDefault('*', [:])
1050 if (jobName) {
1051 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
1052 }
1053 return jobParams
1054}
azvyagintsevc17d14b2022-06-06 19:06:33 +03001055
1056/** Getting test scheme from text, which should be
1057Imput example:
1058text="""
1059 DATA
1060
1061 kaas_bm_test_schemas:
1062 KAAS_RELEASES_REFSPEC: ''
1063 KEY: VAL
1064
1065 DATA
1066 """
1067
1068 Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas'])
1069
1070 Return:
1071 ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL']
1072 **/
1073def parseTextForTestSchemas(Map opts) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001074 String text = opts.getOrDefault('text', '')
azvyagintsevc17d14b2022-06-06 19:06:33 +03001075 String keyLine = opts.getOrDefault('keyLine', '')
1076 Map testScheme = [:]
1077 if (!text || !keyLine) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001078 return testScheme
azvyagintsevc17d14b2022-06-06 19:06:33 +03001079 }
1080 if (text =~ /\n$keyLine\n.*/) {
1081 def common = new com.mirantis.mk.Common()
1082 try {
1083 String regExp = '\\n' + keyLine + '\\n'
1084 // regexep block must be followed by empty line
1085 testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}"
1086 common.infoMsg("parseTextForTestSchemas result:\n" + testScheme)
1087 common.mergeEnv(env, toJson(testScheme))
1088 }
1089 catch (Exception e) {
1090 common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}")
1091 throw e
1092 }
1093 }
azvyagintsevd96aac22022-06-10 14:23:26 +03001094 return testScheme
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +03001095}
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001096
1097
1098/**
1099* getEquinixMetrosWithCapacity returns list of Equinix metros using specified
1100* instance type (nodeType) and desired count of instances (nodeCount) in a metro.
1101* Function downloads metal CLI from the
1102* https://github.com/equinix/metal-cli/releases/download/v0.9.0/metal-linux-amd64
1103* Empty list is returned in case of errors.
1104*
1105* @param: nodeCount (int) Desired count of instances
1106* @param: nodeType (string) Instance type
1107* @return ([]string) List of selected metros
1108*
1109**/
1110def getEquinixMetrosWithCapacity(nodeCount = 10, nodeType = 'c3.small.x86', version = '0.9.0') {
1111 def common = new com.mirantis.mk.Common()
1112 def metalUrl = "https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux"
1113 def metros = []
1114 def out = ''
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001115 def retries = 10 // number of retries
1116 def i = 0
1117 def delay = 60 // 1 minute sleep
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001118 try {
1119 sh "curl -o metal -# ${metalUrl} && chmod +x metal"
1120 withCredentials([string(credentialsId: env.KAAS_EQUINIX_API_TOKEN, variable: 'KAAS_EQUINIX_API_TOKEN')]) {
1121 sh 'echo "project-id: ${KAAS_EQUINIX_PROJECT_ID}\ntoken: ${KAAS_EQUINIX_API_TOKEN}" >metal.yaml'
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001122 }
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001123 common.infoMsg("Selecting available Equinix metro with free ${nodeCount} ${nodeType} hosts")
1124 while (metros.size() == 0 && i < retries) {
1125 common.infoMsg("Try ${i+1}/${retries} ...")
1126 if (i > 0 ) { // skip sleep on first step
1127 sleep(delay)
1128 }
1129 out = sh(script: "./metal --config metal.yaml capacity get -m -P ${nodeType}|awk '/${nodeType}/ {print \$2}'|paste -s -d,|xargs ./metal --config metal.yaml capacity check -P ${nodeType} -q ${nodeCount} -m|grep true|awk '{print \$2}'|paste -s -d,", returnStdout: true).trim()
1130 metros = out.tokenize(',')
1131 i++
1132 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001133 } catch (Exception e) {
1134 common.errorMsg "Exception: '${e}'"
1135 return []
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001136 } finally {
1137 sh 'rm metal.yaml'
1138 }
1139 if (metros.size() > 0) {
1140 common.infoMsg("Selected metros: ${metros}")
1141 } else {
1142 common.warningMsg('No any metros have been selected !!! :(')
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001143 }
1144 return metros
1145}