blob: 0bff92db63cf7d656f80ec18051783a368a71198 [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 Lalov46deb442022-08-18 12:11:03 +0400370 def demoWeight = deployChild ? 2 : 1 // management = 1, child += 1
371 if (runUie2e) {
372 demoWeight += 1
373 }
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100374
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400375 if (commitMsg ==~ /(?s).*\[bootstrapv2-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv2-scenario\.*/) {
376 bootstrapV2Scenario = true
377 }
378
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300379 // parse equinixmetalv2-metro trigger
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300380 def equinixMetalV2MetroMatcher = (commitMsg =~ /\[equinixmetalv2-metro(\s+.*)?\]/)
381 if (equinixMetalV2OnDemandDemo && equinixMetalV2MetroMatcher.size() > 0) {
Sergey Zhemerdeevcc785e42022-07-22 17:15:47 +0300382 equinixMetalV2Metro = equinixMetalV2MetroMatcher[0][1].trim().toLowerCase()
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300383 common.infoMsg("Forced Equnix mgmt deployment using custom metro ${equinixMetalV2Metro}")
384 }
385
vnaumov33747e12020-05-04 17:35:20 +0200386 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400387 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100388 CDN deployment configuration: ${cdnConfig}
389 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100390 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200391 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400392 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200393 Child cluster release upgrade scheduled: ${upgradeChild}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400394 MOS child deploy scheduled: ${mosDeployChild}
395 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200396 Child conformance testing scheduled: ${runChildConformance}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100397 Single BYO cluster attachment scheduled: ${attachBYO}
398 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
399 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400400 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200401 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
slalov1202bba2022-04-20 22:31:07 +0400402 Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400403 Mgmt LMA logging enabled: ${enableLMALogging}
vnaumov33747e12020-05-04 17:35:20 +0200404 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200405 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200406 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200407 Mgmt UI e2e testing scheduled: ${runUie2e}
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400408 Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew}
slalov13e579c2022-01-31 21:37:02 +0400409 Maintenance test: ${runMaintenanceTest}
slalov0a4947a2022-06-09 15:44:35 +0400410 Container Registry test: ${runContainerregistryTest}
slalov574123e2022-04-06 17:24:19 +0400411 Child proxy test: ${runProxyChildTest}
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300412 Delete mgmt master node test: ${runMgmtDeleteMasterTest}
413 Delete rgnl master node test: ${runRgnlDeleteMasterTest}
414 Delete child master node test: ${runChildDeleteMasterTest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200415 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200416 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200417 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100418 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Sergey Zhemerdeev019c45a2022-08-13 00:09:07 +0300419 EquinixmetalV2 mgmt will be deployed on the metro: ${equinixMetalV2Metro?:'auto'}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200420 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200421 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200422 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400423 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200424 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300425 BM provider deployment scheduled: ${enableBMDemo}
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300426 Ubuntu on vSphere scheduled: ${enableVsphereUbuntu}
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400427 Artifacts build scheduled: ${enableArtifactsBuild}
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300428 Boot OS child from Ceph volumes: ${childOsBootFromVolume}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200429 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200430 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100431 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400432 Bootstrap v2 scenario enabled: ${bootstrapV2Scenario}
Владислав Наумов81777472021-03-09 15:14:27 +0400433 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200434 return [
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400435 osCloudLocation : openstackIMC,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100436 cdnConfig : cdnConfig,
437 proxyConfig : proxyConfig,
438 useMacOsSeedNode : seedMacOs,
439 deployChildEnabled : deployChild,
440 childDeployCustomRelease : customChildRelease,
441 upgradeChildEnabled : upgradeChild,
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400442 mosDeployChildEnabled : mosDeployChild,
443 mosUpgradeChildEnabled : mosUpgradeChild,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100444 runChildConformanceEnabled : runChildConformance,
445 attachBYOEnabled : attachBYO,
446 upgradeBYOEnabled : upgradeBYO,
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100447 runBYOMatrixEnabled : runBYOMatrix,
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400448 defaultBYOOs : defaultBYOOs,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100449 upgradeMgmtEnabled : upgradeMgmt,
slalov1202bba2022-04-20 22:31:07 +0400450 autoUpgradeMgmtEnabled : autoUpgradeMgmt,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100451 enableLMALoggingEnabled : enableLMALogging,
452 runUie2eEnabled : runUie2e,
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400453 runUie2eNewEnabled : runUie2eNew,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100454 runMgmtConformanceEnabled : runMgmtConformance,
slalov0a4947a2022-06-09 15:44:35 +0400455 runMaintenanceTestEnabled : runMaintenanceTest,
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300456 runContainerregistryTestEnabled : runContainerregistryTest,
457 runMgmtDeleteMasterTestEnabled : runMgmtDeleteMasterTest,
458 runRgnlDeleteMasterTestEnabled : runRgnlDeleteMasterTest,
459 runChildDeleteMasterTestEnabled : runChildDeleteMasterTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100460 runLMATestEnabled : runLMATest,
461 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
slalov574123e2022-04-06 17:24:19 +0400462 runProxyChildTestEnabled : runProxyChildTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100463 fetchServiceBinariesEnabled : fetchServiceBinaries,
464 awsOnDemandDemoEnabled : awsOnDemandDemo,
465 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
466 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
467 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
468 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
469 azureOnDemandDemoEnabled : azureOnDemandDemo,
470 azureOnAwsDemoEnabled : azureOnAwsDemo,
471 vsphereDemoEnabled : enableVsphereDemo,
472 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
473 bmDemoEnabled : enableBMDemo,
474 osDemoEnabled : enableOSDemo,
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300475 vsphereUbuntuEnabled : enableVsphereUbuntu,
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400476 artifactsBuildEnabled : enableArtifactsBuild,
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300477 childOsBootFromVolume : childOsBootFromVolume,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100478 multiregionalConfiguration : multiregionalMappings,
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400479 demoWeight : demoWeight,
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300480 bootstrapV2Scenario : bootstrapV2Scenario,
481 equinixMetalV2Metro : equinixMetalV2Metro]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200482}
483
484/**
485 * Determine management and regional setup for demo workflow scenario
486 *
487 *
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300488 * @param: keyword (string) string , represents keyword trigger, specified in gerrit commit body, like `[multiregion aws,os]`
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200489 or Jenkins environment string variable in form like 'aws,os'
490 * @return (map)[
491 enabled: (bool),
492 * managementLocation: (string), //aws,os
493 * regionLocation: (string), //aws,os
494 * ]
495 */
496def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200497 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400498 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
499 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200500
501 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200502 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200503 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
504 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
505 } else {
506 common.infoMsg('Multiregion definition configured via environment variable')
507 clusterTypes = keyword.trim().split(',')
508 }
509
510 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100511 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200512 }
513
Владислав Наумовf793fe32020-09-11 15:19:19 +0200514 def desiredManagementProvider = clusterTypes[0].trim()
515 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200516 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
517 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200518 management providers list - ${supportedManagementProviders}
519 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200520 }
521
522 return [
523 enabled: true,
524 managementLocation: desiredManagementProvider,
525 regionLocation: desiredRegionalProvider,
526 ]
vnaumov33747e12020-05-04 17:35:20 +0200527}
528
529/**
530 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
531
Владислав Наумов81777472021-03-09 15:14:27 +0400532 * 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 +0200533 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
534 * Example scheme:
535 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
536 * manage refspecs through Jenkins Job Parameters
537 *
azvyagintseva12230a2020-06-05 13:24:06 +0300538 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200539 * siPipelines: (string) final refspec for si-pipelines
540 * ]
541 */
542def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200543 def common = new com.mirantis.mk.Common()
544
vnaumov33747e12020-05-04 17:35:20 +0200545 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200546 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
547 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200548 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
549 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200550 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200551
552 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
553 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
554
555 if (siTestMatches.size() > 0) {
556 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400557 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200558 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200559 }
560 if (siPipelinesMatches.size() > 0) {
561 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
562 }
563
564 common.infoMsg("""
565 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
566 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200567 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400568 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200569 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200570}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200571
Владислав Наумов9080f372020-06-08 13:57:16 +0200572/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200573 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200574 * @param configurationFile (str) path to configuration file in yaml format
575 *
576 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
577 * ]
578 */
579def parseKaaSComponentCIParameters(configurationFile){
580 def common = new com.mirantis.mk.Common()
581 def ciConfig = readYaml file: configurationFile
582 def ciSpec = [
583 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
584 ]
585
586 if (ciConfig.containsKey('si-tests-feature-flags')) {
587 common.infoMsg("""SI tests feature flags customization detected,
588 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
589
590 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
591 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200592
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200593 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200594 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
595 }
596
597 common.infoMsg("""Additional ci configuration parsed successfully:
598 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
599 return ciSpec
600}
601
602/**
603 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200604
Владислав Наумов81777472021-03-09 15:14:27 +0400605 * 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 +0200606 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
607 * Example scheme:
608 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
609 * manage refspecs through Jenkins Job Parameters
610 *
611 * @return (map)[ core: (string) final refspec for kaas/core
612 * corePipelines: (string) final refspec for pipelines in kaas/core
613 * ]
614 */
615def checkCustomCoreRefspec() {
616 def common = new com.mirantis.mk.Common()
617
618 // Available triggers and its sane defaults
619 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
620 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
621 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
622 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
623
624 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
625 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
626
627 if (coreMatches.size() > 0) {
628 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
629 }
630 if (corePipelinesMatches.size() > 0) {
631 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
632 }
633
634 common.infoMsg("""
635 kaas/core will be fetched from: ${coreRefspec}
636 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400637 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200638 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
639}
640
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200641
642/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200643 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
644 * needed to forward inside kaas core set of jobs
645 *
646 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
647 * @return (list)[ string(name: '', value: ''),
648 * ]
649 */
650def generateKaaSVarsFromContext(context) {
651 def common = new com.mirantis.mk.Common()
652 def parameters = []
653 def config = readYaml text: context
654
655 config.each { k,v ->
656 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
657 parameters.add(string(name: k, value: v))
658 }
659
660 return parameters
661}
662
663/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200664 * 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 +0400665 * 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 +0200666 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
667 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200668 * @param: component (string) component name [iam, lcm, stacklight]
669 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
670 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200671 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200672def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200673 def common = new com.mirantis.mk.Common()
674 // Determine if custom trigger keywords forwarded from gerrit
675 def triggers = checkDeploymentTestSuite()
676 // Determine SI refspecs
677 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200678 // Determine Core refspecs
679 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200680
Владислав Наумов418042b2020-07-09 18:31:10 +0200681 // Determine component repo ci configuration
682 def ciSpec = [:]
683 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
684 if (fileExists(configurationFile)) {
685 common.infoMsg('Component CI configuration file detected, parsing...')
686 ciSpec = parseKaaSComponentCIParameters(configurationFile)
687 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
688 } else {
689 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200690 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200691 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
692 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200693 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400694
695 def platforms = []
696 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
697 // Currently only vsphere demo is required for IPAM component
698 platforms.add('vsphere')
699 } else {
700 if (triggers.osDemoEnabled) {
701 platforms.add('openstack')
702 }
703 if (triggers.awsOnDemandDemoEnabled) {
704 platforms.add('aws')
705 }
706 if (triggers.equinixOnDemandDemoEnabled) {
707 platforms.add('equinix')
708 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200709 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
710 platforms.add('equinixmetalv2')
711 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200712 if (triggers.azureOnDemandDemoEnabled) {
713 platforms.add('azure')
714 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400715 if (triggers.vsphereDemoEnabled) {
716 platforms.add('vsphere')
717 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400718 }
719
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200720 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200721 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200722 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
723 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200724 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200725 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200726 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
727 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200728 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200729 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400730 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400731 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100732 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200733 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200734 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100735 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200736 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
slalov1202bba2022-04-20 22:31:07 +0400737 booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400738 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200739 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200740 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
slalov0a4947a2022-06-09 15:44:35 +0400741 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnabled),
742 booleanParam(name: 'RUN_CONTAINER_REGISTRY_TEST', value: triggers.runContainerregistryTestEnabled),
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300743 booleanParam(name: 'RUN_MGMT_DELETE_MASTER_TEST', value: triggers.runMgmtDeleteMasterTestEnabled),
744 booleanParam(name: 'RUN_RGNL_DELETE_MASTER_TEST', value: triggers.runRgnlDeleteMasterTestEnabled),
745 booleanParam(name: 'RUN_CHILD_DELETE_MASTER_TEST', value: triggers.runChildDeleteMasterTestEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200746 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200747 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200748 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
749 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
slalov574123e2022-04-06 17:24:19 +0400750 booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100751 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100752 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100753 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200754 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400755 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200756 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200757 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100758 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400759 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200760 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200761 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Sergey Zhemerdeev9074f6e2022-06-07 12:03:16 +0300762 booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200763 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200764
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200765 // customize multiregional demo
766 if (triggers.multiregionalConfiguration.enabled) {
767 parameters.add(string(name: 'MULTIREGION_SETUP',
768 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
769 ))
770 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200771
Владислав Наумов92288d92020-07-13 18:36:21 +0200772 // Determine component team custom context
773 if (coreContext != '') {
774 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
775 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200776 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200777 }
778
Владислав Наумовaa430612020-06-08 17:18:31 +0200779 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400780
781 platforms.each { platform ->
782 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000783 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400784 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
785 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
786 def build_description = job_info.getDescription()
787 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000788 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200789
Vladislav Naumov5313a202021-04-07 17:13:39 +0000790 if (build_description) {
791 currentBuild.description += build_description
792 }
793 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400794 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000795 }
796 }
797 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200798
799 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400800 if (jobs.size() == 0) {
801 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
802 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200803 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
804 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200805
806 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200807 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200808 currentBuild.result = 'FAILURE'
809 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200810}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200811
812
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400813/**
814 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200815 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400816 *
817 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
818 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
819 * @param: multiregionalConfiguration (map) Multiregional configuration
820 * @return (map) Return aggregated map with lockResources and netMap
821 */
822
823
824def generateLockResources(callBackDemo, triggers) {
825 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200826 def netMap = [
827 vsphere: [:],
828 equinix: [:],
829 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400830 // Define vsphere locklabels with initial quantity
831 def lockLabels = [
832 vsphere_networking_core_ci: 0,
833 vsphere_offline_networking_core_ci: 0,
834 ]
835 def deployChild = triggers.deployChildEnabled
slalov27833272022-06-30 02:13:50 +0400836 def testUiVsphere = triggers.runUie2eEnabled
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400837 def multiregionConfig = triggers.multiregionalConfiguration
838 def runMultiregion = multiregionConfig.enabled
839
840 // Generate vsphere netMap and lockLabels based on demo context
841 switch (callBackDemo) {
842 case 'aws':
843 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
844 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +0400845 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400846
847 // Define netMap for Vsphere region
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400848 if (runMultiregion && multiregionConfig.managementLocation == 'aws') {
849 if (multiregionConfig.regionLocation == 'vsphere') {
850 if (deployChild) {
851 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
852 }
853 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400854 }
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400855
856 if (multiregionConfig.regionLocation == 'azure') {
857 lockLabels['azure_core_ci_queue'] = 1
858 if (deployChild) {
859 lockLabels['azure_core_ci_queue'] += 1
860 }
861 }
862 }
863 if (triggers.azureOnAwsDemoEnabled) {
864 lockLabels['azure_core_ci_queue'] = 1
865 }
866
867 if (triggers.equinixOnAwsDemoEnabled) {
868 lockLabels['equinix_core_ci_queue'] = 1
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400869 }
870 break
871 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200872 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
slalov27833272022-06-30 02:13:50 +0400873 if (deployChild || testUiVsphere) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200874 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400875 }
876 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
877 multiregionConfig.regionLocation == 'vsphere') {
878 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200879 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400880 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200881 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400882 }
883 break
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400884 case 'azure':
885 lockLabels['azure_core_ci_queue'] = triggers.demoWeight
886 if (runMultiregion && multiregionConfig.managementLocation == 'azure') {
887 if (multiregionConfig.regionLocation == 'aws') {
888 lockLabels['aws_core_ci_queue'] = 1
889 if (deployChild) {
890 lockLabels['aws_core_ci_queue'] += 1
891 }
892 }
893
894 if (multiregionConfig.regionLocation == 'equinix') {
895 lockLabels['equinix_core_ci_queue'] = 1
896 if (deployChild) {
897 lockLabels['equinix_core_ci_queue'] +=1
898 }
899 }
900 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400901 default:
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400902 error('Supposed to be called from aws, azure or vsphere demos only')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400903 }
904
905 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
906 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200907 netMap['vsphere'].each { clusterType, netConfig ->
908 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
909 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
910 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
911
912 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400913 lockLabels['vsphere_offline_networking_core_ci']++
914 } else {
915 lockLabels['vsphere_networking_core_ci']++
916 }
917 }
918
919 // generate lock metadata
920 def lockResources = []
921 lockLabels.each { label, quantity ->
922 if (quantity > 0) {
923 def res = [
924 label: label,
925 quantity: quantity,
926 ]
927 lockResources.add(res)
928 }
929 }
930
931 common.infoMsg("""Generated vsphere netMap: ${netMap}
932 Generated lockResources: ${lockResources}""")
933
934 return [
935 netMap: netMap,
936 lockResources: lockResources,
937 ]
938}
939
940/**
941 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
942 * and empty rangeConfig to the this map.
943 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200944 * @param: netMap (string) vsphere, equinix netMap or empty map
945 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400946 * @param: clusterType (string) Vsphere cluster type
947 */
948
Владислав Наумов33e1e812021-08-17 17:09:25 +0200949def addToProviderNetMap (netMap, provider, clusterType) {
950 switch (provider) {
951 case 'equinix':
952 netMap[provider][clusterType] = [
953 vlanConfig: '',
954 ]
955 break
956 case 'vsphere':
957 netMap[provider][clusterType] = [
958 netName: 'default',
959 rangeConfig: '',
960 ]
961 break
962 default:
963 error('Net map locks supported for Equinix/Vsphere providers only')
964 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400965}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +0300966
967/**
968* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
969* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
970* If keyword contains only 'key' part then 'value' is boolean True.
971* This function does not perform keywords validation.
972* First line of a commit message is ignored.
973* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
974* TODO: Remove backslash chars from values if they prepend '[' or ']'.
975**/
976
977List getCIKeywordsFromCommitMsg() {
978 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
979 List commitMsgLines = commitMsg.split('\n')
980 List keywords = []
981 if (commitMsgLines.size() < 2) {
982 return keywords
983 }
984
985 String commitMsgBody = commitMsgLines[1..-1].join('\n')
986
987 // Split commit message body to chunks using '[' or ']' as delimiter,
988 // ignoring them if prepended by backslash (regex negative lookbehind).
989 // Resulting list will have chunks between '[' and ']' at odd indexes.
990 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
991
992 // Iterate chunks by odd indexes only, trim values and split to
993 // <key> / <value> pair where <key> is the part of a sting before the first
994 // whitespace delimiter, and <value> is the rest (may include whitespaces).
995 // If there is no whitespace in the string then this is a 'switch'
996 // and <value> will be boolean True.
997 for (i = 1; i < parts.size(); i += 2) {
998 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
999 keywords.add(['key': key, 'value': value])
1000 }
1001
1002 return keywords
1003}
1004
1005/**
1006* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
1007* that were specified for given job name. `job-params` keyword has the following structure
1008*
1009* [job-params <job name> <parameter name> <parameter value>]
1010*
1011* Return value is a Map that contains those parameters using the following structure:
1012*
1013* <job name>:
1014* <parameter name>: <parameter value>
1015*
1016**/
1017Map getJobsParamsFromCommitMsg() {
1018 List keywords = getCIKeywordsFromCommitMsg()
1019
1020 List jobsParamsList = []
1021 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
1022 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
1023 def (key, value) = params.split(/\s+/, 2)
1024 ['name': name, 'key': key, 'value': value]
1025 }
1026
1027 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
1028 if (!result.containsKey(it.name)) {
1029 result[it.name] = [:]
1030 }
1031 result[it.name][it.key] = it.value
1032 result
1033 }
1034
1035 return jobsParams
1036}
1037
1038
1039/**
1040* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
1041* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
1042* uses only those parametes that were set to all jobs (with <job name> == '*') or to
1043* a particular job. Parameters set to a particular job have higher precedence.
1044*
1045* Return value is a Map that contains those parameters:
1046*
1047* <parameter name>: <parameter value>
1048*
1049**/
1050Map getJobParamsFromCommitMsg(String jobName) {
1051 jobsParams = getJobsParamsFromCommitMsg()
1052 jobParams = jobsParams.getOrDefault('*', [:])
1053 if (jobName) {
1054 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
1055 }
1056 return jobParams
1057}
azvyagintsevc17d14b2022-06-06 19:06:33 +03001058
1059/** Getting test scheme from text, which should be
1060Imput example:
1061text="""
1062 DATA
1063
1064 kaas_bm_test_schemas:
1065 KAAS_RELEASES_REFSPEC: ''
1066 KEY: VAL
1067
1068 DATA
1069 """
1070
1071 Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas'])
1072
1073 Return:
1074 ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL']
1075 **/
1076def parseTextForTestSchemas(Map opts) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001077 String text = opts.getOrDefault('text', '')
azvyagintsevc17d14b2022-06-06 19:06:33 +03001078 String keyLine = opts.getOrDefault('keyLine', '')
1079 Map testScheme = [:]
1080 if (!text || !keyLine) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001081 return testScheme
azvyagintsevc17d14b2022-06-06 19:06:33 +03001082 }
1083 if (text =~ /\n$keyLine\n.*/) {
1084 def common = new com.mirantis.mk.Common()
1085 try {
1086 String regExp = '\\n' + keyLine + '\\n'
1087 // regexep block must be followed by empty line
1088 testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}"
1089 common.infoMsg("parseTextForTestSchemas result:\n" + testScheme)
1090 common.mergeEnv(env, toJson(testScheme))
1091 }
1092 catch (Exception e) {
1093 common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}")
1094 throw e
1095 }
1096 }
azvyagintsevd96aac22022-06-10 14:23:26 +03001097 return testScheme
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +03001098}
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001099
1100
1101/**
1102* getEquinixMetrosWithCapacity returns list of Equinix metros using specified
1103* instance type (nodeType) and desired count of instances (nodeCount) in a metro.
1104* Function downloads metal CLI from the
1105* https://github.com/equinix/metal-cli/releases/download/v0.9.0/metal-linux-amd64
1106* Empty list is returned in case of errors.
1107*
1108* @param: nodeCount (int) Desired count of instances
1109* @param: nodeType (string) Instance type
1110* @return ([]string) List of selected metros
1111*
1112**/
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001113def getEquinixMetrosWithCapacity(nodeCount = 50, nodeType = 'c3.small.x86', version = '0.9.0') {
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001114 def common = new com.mirantis.mk.Common()
1115 def metalUrl = "https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux"
1116 def metros = []
1117 def out = ''
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001118 def retries = 3 // number of retries
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001119 def i = 0
1120 def delay = 60 // 1 minute sleep
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001121 def metal = './metal --config metal.yaml'
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001122 try {
1123 sh "curl -o metal -# ${metalUrl} && chmod +x metal"
1124 withCredentials([string(credentialsId: env.KAAS_EQUINIX_API_TOKEN, variable: 'KAAS_EQUINIX_API_TOKEN')]) {
1125 sh 'echo "project-id: ${KAAS_EQUINIX_PROJECT_ID}\ntoken: ${KAAS_EQUINIX_API_TOKEN}" >metal.yaml'
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001126 }
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001127 while (metros.size() == 0 && i < retries) {
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001128 common.infoMsg("Selecting available Equinix metro with free ${nodeCount} ${nodeType} hosts, try ${i+1}/${retries} ...")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001129 if (i > 0 ) { // skip sleep on first step
1130 sleep(delay)
1131 }
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001132 out = sh(script: "${metal} capacity get -m -P ${nodeType}|awk '/${nodeType}/ {print \$2}'|paste -s -d,|xargs ${metal} capacity check -P ${nodeType} -q ${nodeCount} -m|grep true|awk '{print \$2}'|paste -s -d,", returnStdout: true).trim()
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001133 metros = out.tokenize(',')
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001134 if (metros.size() == 0) {
1135 nodeCount -= 10
1136 }
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001137 i++
1138 }
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001139 if (metros.size() > 0) {
1140 m = metros.size() > 1 ? "${metros[0]},${metros[1]}" : "${metros[0]}"
1141 sh "${metal} capacity check -P ${nodeType} -m ${m} -q ${nodeCount}"
1142 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001143 } catch (Exception e) {
1144 common.errorMsg "Exception: '${e}'"
1145 return []
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001146 } finally {
1147 sh 'rm metal.yaml'
1148 }
1149 if (metros.size() > 0) {
1150 common.infoMsg("Selected metros: ${metros}")
1151 } else {
1152 common.warningMsg('No any metros have been selected !!! :(')
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001153 }
1154 return metros
1155}
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001156
1157
1158/**
1159 * genCommandLine prepares command line for artifactory-replication
1160 * command using legacy environment variables
1161 *
1162 * @return: (string) Prepared command line
1163 */
1164def genCommandLine() {
1165 def envToParam = [
1166 'DESTINATION_USER': '-dst-user',
1167 'ARTIFACT_FILTER': '-artifact-filter',
1168 'ARTIFACT_FILTER_PROD': '-artifact-filter-prod',
1169 'ARTIFACT_TYPE': '-artifact-type',
1170 'BINARY_CLEAN': '-bin-cleanup',
1171 'BINARY_CLEAN_KEEP_DAYS': '-bin-clean-keep-days',
1172 'BINARY_CLEAN_PREFIX': '-bin-clean-prefix',
1173 'BUILD_URL': '-slack-build-url',
1174 'CHECK_REPOS': '-check-repos',
1175 'DESTINATION_REGISTRY': '-dst-repo',
1176 'DESTINATION_REGISTRY_TYPE': '-dst-repo-type',
1177 'DOCKER_CLEAN': '-cleanup',
1178 'DOCKER_REPO_PREFIX': '-docker-repo-prefix',
1179 'DOCKER_TAG': '-docker-tag',
1180 'FORCE': '-force',
1181 'HELM_CDN_DOMAIN': '-helm-cdn-domain',
1182 'SLACK_CHANNEL': '-slack-channel',
1183 'SLACK_USER': '-slack-user',
1184 'SOURCE_REGISTRY': '-src-repo',
1185 'SOURCE_REGISTRY_TYPE': '-src-repo-type',
1186 'SYNC_PATTERN': '-sync-pattern'
1187 ]
1188 def cmdParams = ''
1189 for (e in envToParam) {
1190 if (env[e.key] == null) {
1191 continue
1192 }
1193 if (e.key == 'CHECK_REPOS' || e.key == 'DOCKER_CLEAN') {
1194 if (env[e.key].toBoolean()) {
1195 cmdParams += e.value + ' '
1196 } else {
1197 cmdParams += '-replicate '
1198 }
1199 } else if (e.key == 'FORCE') {
1200 if (env[e.key].toBoolean()) {
1201 cmdParams += e.value + ' '
1202 }
1203 } else {
Sergey Zhemerdeeve2926cd2022-08-29 15:28:47 +03001204 cmdParams += "${e.value} '${env[e.key]}' "
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001205 }
1206 }
1207 return cmdParams
1208}