blob: 1710ca6d90c5d30d09b47a6f37fa57b62fcf7c44 [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
Sergey Lalovc1cb49f2022-09-27 01:16:25 +040056 def fullUpgradeChild = env.FULL_UPGRADE_CHILD_CLUSTER ? env.FULL_UPGRADE_CHILD_CLUSTER.toBoolean() : false
Mikhail Ivanov38ee4382022-01-27 16:21:51 +040057 def mosDeployChild = env.DEPLOY_MOS_CHILD_CLUSTER ? env.DEPLOY_MOS_CHILD_CLUSTER.toBoolean() : false
58 def mosUpgradeChild = env.UPGRADE_MOS_CHILD_CLUSTER ? env.UPGRADE_MOS_CHILD_CLUSTER.toBoolean() : false
Mikhail Ivanov74504372021-05-21 17:01:06 +040059 def customChildRelease = env.KAAS_CHILD_CLUSTER_RELEASE_NAME ? env.KAAS_CHILD_CLUSTER_RELEASE_NAME : ''
slalov021171f2022-03-04 14:48:38 +040060 def mosTfDeploy = env.MOS_TF_DEPLOY ? env.MOS_TF_DEPLOY.toBoolean() : false
Владислав Наумов0dc99252020-11-13 13:30:48 +010061 def attachBYO = env.ATTACH_BYO ? env.ATTACH_BYO.toBoolean() : false
Владислав Наумовcdbd84e2020-12-01 16:51:09 +010062 def upgradeBYO = env.UPGRADE_BYO ? env.UPGRADE_BYO.toBoolean() : false
Vladislav Naumov7930ab22021-11-22 18:24:24 +010063 def runBYOMatrix = env.RUN_BYO_MATRIX ? env.RUN_BYO_MATRIX.toBoolean() : false
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +040064 def defaultBYOOs = env.DEFAULT_BYO_OS ? env.DEFAULT_BYO_OS.toString() : 'ubuntu'
Владислав Наумов6c2afff2020-06-05 12:54:53 +020065 def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
slalov1202bba2022-04-20 22:31:07 +040066 def autoUpgradeMgmt = env.AUTO_UPGRADE_MCC ? env.AUTO_UPGRADE_MCC.toBoolean() : false
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +040067 def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false
Sergey Lalovb2f60372022-09-20 23:58:47 +040068 def deployOsOnMos = env.DEPLOY_OS_ON_MOS? env.DEPLOY_OS_ON_MOS.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020069 def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +040070 def runUie2eNew = env.RUN_UI_E2E_NEW ? env.RUN_UI_E2E_NEW.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020071 def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
Владислав Наумов9cec55d2021-08-03 15:00:59 +020072 def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +020073 def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false
Mikhail Ivanov2907e4d2022-04-25 16:41:21 +040074 def runProxyChildTest = env.RUN_PROXY_CHILD_TEST ? env.RUN_PROXY_CHILD_TEST.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020075 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
76 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Vladislav Naumov42b71dc2021-11-22 13:09:42 +010077 def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false
slalov13e579c2022-01-31 21:37:02 +040078 def runMaintenanceTest = env.RUN_MAINTENANCE_TEST ? env.RUN_MAINTENANCE_TEST.toBoolean() : false
slalov0a4947a2022-06-09 15:44:35 +040079 def runContainerregistryTest = env.RUN_CONTAINER_REGISTRY_TEST ? env.RUN_CONTAINER_REGISTRY_TEST.toBoolean() : false
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +030080 def runMgmtDeleteMasterTest = env.RUN_MGMT_DELETE_MASTER_TEST ? env.RUN_MGMT_DELETE_MASTER_TEST.toBoolean() : false
81 def runRgnlDeleteMasterTest = env.RUN_RGNL_DELETE_MASTER_TEST ? env.RUN_RGNL_DELETE_MASTER_TEST.toBoolean() : false
82 def runChildDeleteMasterTest = env.RUN_CHILD_DELETE_MASTER_TEST ? env.RUN_CHILD_DELETE_MASTER_TEST.toBoolean() : false
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +030083 def runGracefulRebootTest = env.RUN_GRACEFUL_REBOOT_TEST ? env.RUN_GRACEFUL_REBOOT_TEST.toBoolean() : false
Sergey Lalovbc68d752022-11-08 13:40:53 +040084 def pauseForDebug = env.PAUSE_FOR_DEBUG ? env.PAUSE_FOR_DEBUG.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020085 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
86 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
87 enabled: false,
88 managementLocation: '',
89 regionLocation: '',
90 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020091
Владислав Наумовb8305e22021-02-10 17:23:12 +010092 // proxy customization
93 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020094 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
95 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020096 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010097 ]
98
Владислав Наумов4eb1da32020-08-31 14:45:16 +020099 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +0200100 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +0200101 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +0200102 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +0200103 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +0200104 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200105 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400106 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200107 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +0300108 def enableBMDemo = true
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400109 def enableArtifactsBuild = true
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400110 def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300111 def enableVsphereUbuntu = env.VSPHERE_DEPLOY_UBUNTU ? env.VSPHERE_DEPLOY_UBUNTU.toBoolean() : false
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300112 def childOsBootFromVolume = env.OPENSTACK_BOOT_FROM_VOLUME ? env.OPENSTACK_BOOT_FROM_VOLUME.toBoolean() : false
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400113 def bootstrapV2Scenario = env.BOOTSTRAP_V2_ENABLED ? env.BOOTSTRAP_V2_ENABLED.toBoolean() : false
Sergey Lalovacec3c12022-07-20 16:00:14 +0400114 def equinixMetalV2Metro = env.EQUINIX_MGMT_METRO ? env.EQUINIX_MGMT_METRO : ''
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400115 def enableFips = env.ENABLE_FIPS ? env.ENABLE_FIPS.toBoolean() : false
vnaumov33747e12020-05-04 17:35:20 +0200116
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200117 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +0100118 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
119 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +0200120 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 +0100121 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100122 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
123 seedMacOs = true
124 }
slalov574123e2022-04-06 17:24:19 +0400125 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance || runProxyChildTest) {
vnaumov33747e12020-05-04 17:35:20 +0200126 deployChild = true
127 }
128 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
129 deployChild = true
130 upgradeChild = true
131 }
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400132 if (commitMsg ==~ /(?s).*\[child-upgrade-full\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade-full.*/) {
133 deployChild = true
134 upgradeChild = true
135 fullUpgradeChild = true
136 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400137 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
138 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400139 // override child version when it set explicitly
140 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400141 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400142 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
143 }
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400144 if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) {
145 mosDeployChild = true
146 }
147 if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) {
148 mosDeployChild = true
149 mosUpgradeChild = true
150 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100151 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
152 attachBYO = true
153 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100154 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
155 attachBYO = true
156 upgradeBYO = true
157 }
Sergey Lalovacec3c12022-07-20 16:00:14 +0400158 if (commitMsg ==~ /(?s).*\[ui-test-on-all-providers\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-test-on-all-providers.*/) {
159 enableVsphereDemo = true
160 enableOSDemo = true
161 awsOnDemandDemo = true
162 azureOnDemandDemo = true
163 equinixOnDemandDemo = true
164 equinixMetalV2OnDemandDemo = true
165 runUie2e = true
Sergey Lalovacec3c12022-07-20 16:00:14 +0400166 // Edit after fix PRODX-3961
167 enableBMDemo = false
168 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400169 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
170 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 +0100171 runBYOMatrix = true
172
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400173 if (byoDeployMatches.size() > 0) {
174 defaultBYOOs = byoDeployMatches[0][2]
175 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
176 }
177
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100178 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
179 attachBYO = false
180 upgradeBYO = false
181 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400182 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200183 upgradeMgmt = true
184 }
slalov1202bba2022-04-20 22:31:07 +0400185 if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) {
186 autoUpgradeMgmt = true
187 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400188 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
189 enableLMALogging = true
190 }
Sergey Lalovb2f60372022-09-20 23:58:47 +0400191 if (commitMsg ==~ /(?s).*\[deploy-os-on-mos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*deploy-os-on-mos.*/) {
192 deployOsOnMos = true
193 mosDeployChild = true
194 openstackIMC = 'eu2'
195 }
vnaumov33747e12020-05-04 17:35:20 +0200196 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
197 runUie2e = true
198 }
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400199 if (commitMsg ==~ /(?s).*\[ui-e2e-new\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-new.*/) {
200 runUie2eNew = true
201 }
vnaumov33747e12020-05-04 17:35:20 +0200202 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
203 runMgmtConformance = true
204 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200205 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
206 runMgmtUserControllerTest = true
207 }
slalov574123e2022-04-06 17:24:19 +0400208 if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) {
209 runProxyChildTest = true
210 deployChild = true
211 common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed')
212 }
vnaumov33747e12020-05-04 17:35:20 +0200213 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
214 runChildConformance = true
215 deployChild = true
216 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200217 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
218 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400219 enableLMALogging = true
220 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400221 }
slalov13e579c2022-01-31 21:37:02 +0400222 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
223 runMaintenanceTest = true
224 }
slalov0a4947a2022-06-09 15:44:35 +0400225 if (commitMsg ==~ /(?s).*\[container-registry-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*container-registry-test.*/) {
226 runContainerregistryTest = true
227 }
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300228 if (commitMsg ==~ /(?s).*\[mgmt-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-delete-master-test.*/) {
229 runMgmtDeleteMasterTest = true
230 }
231 if (commitMsg ==~ /(?s).*\[rgnl-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*rgnl-delete-master-test.*/) {
232 runRgnlDeleteMasterTest = true
233 }
234 if (commitMsg ==~ /(?s).*\[child-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-delete-master-test.*/) {
235 runChildDeleteMasterTest = true
236 }
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300237 if (commitMsg ==~ /(?s).*\[graceful-reboot-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*graceful-reboot-test.*/) {
238 runGracefulRebootTest = true
239 }
Sergey Lalovbc68d752022-11-08 13:40:53 +0400240 if (commitMsg ==~ /(?s).*\[pause-for-debug\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*pause-for-debug.*/) {
241 pauseForDebug = true
242 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200243 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
244 proxyConfig['childOffline'] = true
245 deployChild = true
246 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200247 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
248 proxyConfig['childOffline'] = true
249 proxyConfig['childProxy'] = true
250 deployChild = true
251 }
vnaumov33747e12020-05-04 17:35:20 +0200252 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
253 fetchServiceBinaries = true
254 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200255 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400256 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200257 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 +0400258 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200259 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
260 azureOnAwsDemo = true
261 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
262 }
263 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
264 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
265 attachBYO ||
266 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100267 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200268 seedMacOs ||
269 equinixOnAwsDemo ||
270 azureOnAwsDemo) {
271
vnaumov33747e12020-05-04 17:35:20 +0200272 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200273 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 +0200274 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200275 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200276 equinixOnDemandDemo = true
277 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200278 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200279 equinixMetalV2OnDemandDemo = true
280 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100281 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
282 equinixMetalV2OnDemandDemo = true
283 equinixMetalV2ChildDiffMetro = true
284 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200285 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
286 azureOnDemandDemo = true
287 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200288 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
289 enableOSDemo = false
290 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200291 }
292
azvyagintsev1761bdc2020-09-04 17:24:12 +0300293 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
294 enableBMDemo = false
295 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
296 }
297
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400298 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
299 enableVsphereDemo = false
300 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
301 }
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300302 if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) {
303 enableVsphereUbuntu = true
304 common.warningMsg('Ubuntu will be used to deploy vsphere machines')
305 }
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400306
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400307 if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) {
308 enableArtifactsBuild = false
309 common.errorMsg('artifacts build will be aborted, VF -1 will be set')
310 }
311
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300312 if (commitMsg ==~ /(?s).*\[child-os-boot-from-volume\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-os-boot-from-volume\.*/) {
313 childOsBootFromVolume = true
314 common.warningMsg('OS will be booted from Ceph volumes')
315 }
316
vnaumov33747e12020-05-04 17:35:20 +0200317 // TODO (vnaumov) remove below condition after moving all releases to UCP
318 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
319 if (ucpChildMatches.size() > 0) {
320 deployChild = true
321 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
322
323 // TODO(vnaumov) delete after ucp upgrades support
324 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
325 upgradeChild = false
326 }
327
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200328 // multiregional tests
329 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
330 if (multiRegionalMatches.size() > 0) {
331 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
332 }
333 switch (multiregionalMappings['managementLocation']) {
334 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100335 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200336 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100337
338 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
339 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
340 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200341 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200342 case 'os':
343 if (enableOSDemo == false) {
344 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
345 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200346 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200347 case 'vsphere':
348 if (enableVsphereDemo == false) {
349 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
350 }
351 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200352 case 'equinix':
353 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
354 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400355 break
eromanova8c702ae2021-12-24 17:43:12 +0400356 case 'equinixmetalv2':
357 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
358 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400359 break
slalovfd0b7e62021-07-28 18:05:16 +0400360 case 'azure':
361 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
362 azureOnDemandDemo = true
363 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200364 }
365
Владислав Наумовb8305e22021-02-10 17:23:12 +0100366 // CDN configuration
367 def cdnConfig = [
368 mgmt: [
369 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200370 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100371 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200372 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200373 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200374 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100375 ]
376
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400377 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
378 openstackIMC = 'eu'
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400379 }
slalov021171f2022-03-04 14:48:38 +0400380 if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) {
381 openstackIMC = 'eu2'
Mikhail Ivanovf05b8252022-04-27 18:14:03 +0400382 }
383 if (openstackIMC == 'eu' || openstackIMC == 'eu2') {
slalov021171f2022-03-04 14:48:38 +0400384 // use internal-eu because on internal-ci with eu cloud image pull takes much time
385 def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
386 common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}")
387 cdnConfig['mgmt']['openstack'] = cdnRegion
388 }
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400389
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100390 // calculate weight of current demo run to manage lockable resources
Sergey Lalov46deb442022-08-18 12:11:03 +0400391 def demoWeight = deployChild ? 2 : 1 // management = 1, child += 1
392 if (runUie2e) {
393 demoWeight += 1
394 }
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100395
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400396 if (commitMsg ==~ /(?s).*\[bootstrapv2-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv2-scenario\.*/) {
397 bootstrapV2Scenario = true
398 }
399
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400400 if (commitMsg ==~ /(?s).*\[enable-fips\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*enable-fips\.*/) {
401 enableFips = true
402 }
403
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300404 // parse equinixmetalv2-metro trigger
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300405 def equinixMetalV2MetroMatcher = (commitMsg =~ /\[equinixmetalv2-metro(\s+.*)?\]/)
406 if (equinixMetalV2OnDemandDemo && equinixMetalV2MetroMatcher.size() > 0) {
Sergey Zhemerdeevcc785e42022-07-22 17:15:47 +0300407 equinixMetalV2Metro = equinixMetalV2MetroMatcher[0][1].trim().toLowerCase()
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300408 common.infoMsg("Forced Equnix mgmt deployment using custom metro ${equinixMetalV2Metro}")
409 }
410
vnaumov33747e12020-05-04 17:35:20 +0200411 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400412 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100413 CDN deployment configuration: ${cdnConfig}
414 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100415 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200416 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400417 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200418 Child cluster release upgrade scheduled: ${upgradeChild}
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400419 Full Child cluster release upgrade scheduled: ${fullUpgradeChild}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400420 MOS child deploy scheduled: ${mosDeployChild}
421 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200422 Child conformance testing scheduled: ${runChildConformance}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100423 Single BYO cluster attachment scheduled: ${attachBYO}
424 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
425 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400426 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200427 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
slalov1202bba2022-04-20 22:31:07 +0400428 Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400429 Mgmt LMA logging enabled: ${enableLMALogging}
Sergey Lalovb2f60372022-09-20 23:58:47 +0400430 Deploy Os on child with mos release ${deployOsOnMos}
vnaumov33747e12020-05-04 17:35:20 +0200431 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200432 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200433 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200434 Mgmt UI e2e testing scheduled: ${runUie2e}
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400435 Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew}
slalov13e579c2022-01-31 21:37:02 +0400436 Maintenance test: ${runMaintenanceTest}
slalov0a4947a2022-06-09 15:44:35 +0400437 Container Registry test: ${runContainerregistryTest}
slalov574123e2022-04-06 17:24:19 +0400438 Child proxy test: ${runProxyChildTest}
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300439 Graceful reboot test: ${runGracefulRebootTest}
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300440 Delete mgmt master node test: ${runMgmtDeleteMasterTest}
441 Delete rgnl master node test: ${runRgnlDeleteMasterTest}
442 Delete child master node test: ${runChildDeleteMasterTest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200443 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200444 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200445 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100446 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Sergey Zhemerdeev019c45a2022-08-13 00:09:07 +0300447 EquinixmetalV2 mgmt will be deployed on the metro: ${equinixMetalV2Metro?:'auto'}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200448 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200449 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200450 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400451 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200452 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300453 BM provider deployment scheduled: ${enableBMDemo}
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300454 Ubuntu on vSphere scheduled: ${enableVsphereUbuntu}
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400455 Artifacts build scheduled: ${enableArtifactsBuild}
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300456 Boot OS child from Ceph volumes: ${childOsBootFromVolume}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200457 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200458 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100459 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400460 Bootstrap v2 scenario enabled: ${bootstrapV2Scenario}
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400461 FIPS enabled: ${enableFips}
Sergey Lalovbc68d752022-11-08 13:40:53 +0400462 Pause for debug enabled: ${pauseForDebug}
Владислав Наумов81777472021-03-09 15:14:27 +0400463 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200464 return [
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400465 osCloudLocation : openstackIMC,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100466 cdnConfig : cdnConfig,
467 proxyConfig : proxyConfig,
468 useMacOsSeedNode : seedMacOs,
469 deployChildEnabled : deployChild,
470 childDeployCustomRelease : customChildRelease,
471 upgradeChildEnabled : upgradeChild,
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400472 fullUpgradeChildEnabled : fullUpgradeChild,
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400473 mosDeployChildEnabled : mosDeployChild,
474 mosUpgradeChildEnabled : mosUpgradeChild,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100475 runChildConformanceEnabled : runChildConformance,
476 attachBYOEnabled : attachBYO,
477 upgradeBYOEnabled : upgradeBYO,
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100478 runBYOMatrixEnabled : runBYOMatrix,
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400479 defaultBYOOs : defaultBYOOs,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100480 upgradeMgmtEnabled : upgradeMgmt,
slalov1202bba2022-04-20 22:31:07 +0400481 autoUpgradeMgmtEnabled : autoUpgradeMgmt,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100482 enableLMALoggingEnabled : enableLMALogging,
Sergey Lalovb2f60372022-09-20 23:58:47 +0400483 deployOsOnMosEnabled : deployOsOnMos,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100484 runUie2eEnabled : runUie2e,
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400485 runUie2eNewEnabled : runUie2eNew,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100486 runMgmtConformanceEnabled : runMgmtConformance,
slalov0a4947a2022-06-09 15:44:35 +0400487 runMaintenanceTestEnabled : runMaintenanceTest,
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300488 runContainerregistryTestEnabled : runContainerregistryTest,
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300489 runGracefulRebootTestEnabled : runGracefulRebootTest,
Sergey Lalovbc68d752022-11-08 13:40:53 +0400490 pauseForDebugEnabled : pauseForDebug,
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300491 runMgmtDeleteMasterTestEnabled : runMgmtDeleteMasterTest,
492 runRgnlDeleteMasterTestEnabled : runRgnlDeleteMasterTest,
493 runChildDeleteMasterTestEnabled : runChildDeleteMasterTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100494 runLMATestEnabled : runLMATest,
495 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
slalov574123e2022-04-06 17:24:19 +0400496 runProxyChildTestEnabled : runProxyChildTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100497 fetchServiceBinariesEnabled : fetchServiceBinaries,
498 awsOnDemandDemoEnabled : awsOnDemandDemo,
499 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
500 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
501 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
502 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
503 azureOnDemandDemoEnabled : azureOnDemandDemo,
504 azureOnAwsDemoEnabled : azureOnAwsDemo,
505 vsphereDemoEnabled : enableVsphereDemo,
506 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
507 bmDemoEnabled : enableBMDemo,
508 osDemoEnabled : enableOSDemo,
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300509 vsphereUbuntuEnabled : enableVsphereUbuntu,
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400510 artifactsBuildEnabled : enableArtifactsBuild,
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300511 childOsBootFromVolume : childOsBootFromVolume,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100512 multiregionalConfiguration : multiregionalMappings,
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400513 demoWeight : demoWeight,
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300514 bootstrapV2Scenario : bootstrapV2Scenario,
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400515 equinixMetalV2Metro : equinixMetalV2Metro,
516 enableFips : enableFips]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200517}
518
519/**
520 * Determine management and regional setup for demo workflow scenario
521 *
522 *
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300523 * @param: keyword (string) string , represents keyword trigger, specified in gerrit commit body, like `[multiregion aws,os]`
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200524 or Jenkins environment string variable in form like 'aws,os'
525 * @return (map)[
526 enabled: (bool),
527 * managementLocation: (string), //aws,os
528 * regionLocation: (string), //aws,os
529 * ]
530 */
531def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200532 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400533 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
534 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200535
536 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200537 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200538 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
539 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
540 } else {
541 common.infoMsg('Multiregion definition configured via environment variable')
542 clusterTypes = keyword.trim().split(',')
543 }
544
545 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100546 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200547 }
548
Владислав Наумовf793fe32020-09-11 15:19:19 +0200549 def desiredManagementProvider = clusterTypes[0].trim()
550 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200551 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
552 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200553 management providers list - ${supportedManagementProviders}
554 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200555 }
556
557 return [
558 enabled: true,
559 managementLocation: desiredManagementProvider,
560 regionLocation: desiredRegionalProvider,
561 ]
vnaumov33747e12020-05-04 17:35:20 +0200562}
563
564/**
565 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
566
Владислав Наумов81777472021-03-09 15:14:27 +0400567 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
vnaumov33747e12020-05-04 17:35:20 +0200568 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
569 * Example scheme:
570 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
571 * manage refspecs through Jenkins Job Parameters
572 *
azvyagintseva12230a2020-06-05 13:24:06 +0300573 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200574 * siPipelines: (string) final refspec for si-pipelines
575 * ]
576 */
577def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200578 def common = new com.mirantis.mk.Common()
579
vnaumov33747e12020-05-04 17:35:20 +0200580 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200581 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
582 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200583 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
584 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200585 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200586
587 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
588 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
589
590 if (siTestMatches.size() > 0) {
591 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400592 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200593 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200594 }
595 if (siPipelinesMatches.size() > 0) {
596 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
597 }
598
599 common.infoMsg("""
600 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
601 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200602 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400603 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200604 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200605}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200606
Владислав Наумов9080f372020-06-08 13:57:16 +0200607/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200608 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200609 * @param configurationFile (str) path to configuration file in yaml format
610 *
611 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300612 * siTestsFeatureFlagsStable (string) dedicated feature flags that will be used in SI tests for deploying stable release
Владислав Наумов30a516c2020-07-09 13:15:41 +0200613 * ]
614 */
615def parseKaaSComponentCIParameters(configurationFile){
616 def common = new com.mirantis.mk.Common()
617 def ciConfig = readYaml file: configurationFile
618 def ciSpec = [
619 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300620 siTestsFeatureFlagsStable: env.SI_TESTS_FEATURE_FLAGS_STABLE ?: '',
Владислав Наумов30a516c2020-07-09 13:15:41 +0200621 ]
622
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300623 // If exists and not empty
624 if (ciConfig.getOrDefault('si-tests-feature-flags', [])) {
Владислав Наумов30a516c2020-07-09 13:15:41 +0200625 common.infoMsg("""SI tests feature flags customization detected,
626 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
627
628 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
629 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200630
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200631 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200632 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
633 }
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300634 if (ciConfig.getOrDefault('si-tests-feature-flags-stable', [])) {
635 common.infoMsg("""SI tests feature flags for stable release customization detected,
636 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlagsStable']}] identification...""")
637
638 def ffMeta = ciSpec['siTestsFeatureFlagsStable'].tokenize(',').collect { it.trim() }
639 ffMeta.addAll(ciConfig['si-tests-feature-flags-stable'])
640
641 ciSpec['siTestsFeatureFlagsStable'] = ffMeta.unique().join(',')
642 common.infoMsg("SI tests custom feature flags for stable release: ${ciSpec['siTestsFeatureFlagsStable']}")
643 }
Владислав Наумов30a516c2020-07-09 13:15:41 +0200644
645 common.infoMsg("""Additional ci configuration parsed successfully:
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300646 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}
647 siTestsFeatureFlagsStable: ${ciSpec['siTestsFeatureFlagsStable']}""")
Владислав Наумов30a516c2020-07-09 13:15:41 +0200648 return ciSpec
649}
650
651/**
652 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200653
Владислав Наумов81777472021-03-09 15:14:27 +0400654 * 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 +0200655 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
656 * Example scheme:
657 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
658 * manage refspecs through Jenkins Job Parameters
659 *
660 * @return (map)[ core: (string) final refspec for kaas/core
661 * corePipelines: (string) final refspec for pipelines in kaas/core
662 * ]
663 */
664def checkCustomCoreRefspec() {
665 def common = new com.mirantis.mk.Common()
666
667 // Available triggers and its sane defaults
668 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
669 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
670 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
671 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
672
673 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
674 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
675
676 if (coreMatches.size() > 0) {
677 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
678 }
679 if (corePipelinesMatches.size() > 0) {
680 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
681 }
682
683 common.infoMsg("""
684 kaas/core will be fetched from: ${coreRefspec}
685 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400686 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200687 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
688}
689
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200690
691/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200692 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
693 * needed to forward inside kaas core set of jobs
694 *
695 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
696 * @return (list)[ string(name: '', value: ''),
697 * ]
698 */
699def generateKaaSVarsFromContext(context) {
700 def common = new com.mirantis.mk.Common()
701 def parameters = []
702 def config = readYaml text: context
703
704 config.each { k,v ->
705 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
706 parameters.add(string(name: k, value: v))
707 }
708
709 return parameters
710}
711
712/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200713 * 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 +0400714 * 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 +0200715 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
716 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200717 * @param: component (string) component name [iam, lcm, stacklight]
718 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
719 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200720 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200721def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200722 def common = new com.mirantis.mk.Common()
723 // Determine if custom trigger keywords forwarded from gerrit
724 def triggers = checkDeploymentTestSuite()
725 // Determine SI refspecs
726 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200727 // Determine Core refspecs
728 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200729
Владислав Наумов418042b2020-07-09 18:31:10 +0200730 // Determine component repo ci configuration
731 def ciSpec = [:]
732 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
733 if (fileExists(configurationFile)) {
734 common.infoMsg('Component CI configuration file detected, parsing...')
735 ciSpec = parseKaaSComponentCIParameters(configurationFile)
736 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
737 } else {
738 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200739 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200740 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
741 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200742 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400743
744 def platforms = []
745 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
746 // Currently only vsphere demo is required for IPAM component
747 platforms.add('vsphere')
748 } else {
749 if (triggers.osDemoEnabled) {
750 platforms.add('openstack')
751 }
752 if (triggers.awsOnDemandDemoEnabled) {
753 platforms.add('aws')
754 }
755 if (triggers.equinixOnDemandDemoEnabled) {
756 platforms.add('equinix')
757 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200758 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
759 platforms.add('equinixmetalv2')
760 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200761 if (triggers.azureOnDemandDemoEnabled) {
762 platforms.add('azure')
763 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400764 if (triggers.vsphereDemoEnabled) {
765 platforms.add('vsphere')
766 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400767 }
768
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200769 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200770 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200771 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
772 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200773 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200774 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200775 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
776 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200777 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200778 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400779 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400780 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100781 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200782 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200783 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100784 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200785 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
slalov1202bba2022-04-20 22:31:07 +0400786 booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400787 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Sergey Lalovb2f60372022-09-20 23:58:47 +0400788 booleanParam(name: 'DEPLOY_OS_ON_MOS', value: triggers.deployOsOnMosEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200789 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200790 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
slalov0a4947a2022-06-09 15:44:35 +0400791 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnabled),
792 booleanParam(name: 'RUN_CONTAINER_REGISTRY_TEST', value: triggers.runContainerregistryTestEnabled),
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300793 booleanParam(name: 'RUN_GRACEFUL_REBOOT_TEST', value: triggers.runGracefulRebootTestEnabled),
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300794 booleanParam(name: 'RUN_MGMT_DELETE_MASTER_TEST', value: triggers.runMgmtDeleteMasterTestEnabled),
795 booleanParam(name: 'RUN_RGNL_DELETE_MASTER_TEST', value: triggers.runRgnlDeleteMasterTestEnabled),
796 booleanParam(name: 'RUN_CHILD_DELETE_MASTER_TEST', value: triggers.runChildDeleteMasterTestEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200797 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200798 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200799 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
800 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400801 booleanParam(name: 'FULL_UPGRADE_CHILD_CLUSTER', value: triggers.fullUpgradeChildEnabled),
slalov574123e2022-04-06 17:24:19 +0400802 booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100803 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100804 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100805 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200806 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400807 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200808 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200809 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100810 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400811 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200812 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200813 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Sergey Zhemerdeev9074f6e2022-06-07 12:03:16 +0300814 booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled),
Sergey Lalovbc68d752022-11-08 13:40:53 +0400815 booleanParam(name: 'PAUSE_FOR_DEBUG', value: triggers.pauseForDebugEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200816 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200817
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200818 // customize multiregional demo
819 if (triggers.multiregionalConfiguration.enabled) {
820 parameters.add(string(name: 'MULTIREGION_SETUP',
821 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
822 ))
823 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200824
Владислав Наумов92288d92020-07-13 18:36:21 +0200825 // Determine component team custom context
826 if (coreContext != '') {
827 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
828 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200829 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200830 }
831
Владислав Наумовaa430612020-06-08 17:18:31 +0200832 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400833
834 platforms.each { platform ->
835 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000836 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400837 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
838 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
839 def build_description = job_info.getDescription()
840 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000841 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200842
Vladislav Naumov5313a202021-04-07 17:13:39 +0000843 if (build_description) {
844 currentBuild.description += build_description
845 }
846 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400847 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000848 }
849 }
850 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200851
852 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400853 if (jobs.size() == 0) {
854 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
855 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200856 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
857 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200858
859 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200860 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200861 currentBuild.result = 'FAILURE'
862 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200863}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200864
865
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400866/**
867 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200868 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400869 *
870 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
871 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
872 * @param: multiregionalConfiguration (map) Multiregional configuration
873 * @return (map) Return aggregated map with lockResources and netMap
874 */
875
876
877def generateLockResources(callBackDemo, triggers) {
878 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200879 def netMap = [
880 vsphere: [:],
881 equinix: [:],
882 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400883 // Define vsphere locklabels with initial quantity
884 def lockLabels = [
885 vsphere_networking_core_ci: 0,
886 vsphere_offline_networking_core_ci: 0,
887 ]
888 def deployChild = triggers.deployChildEnabled
slalov27833272022-06-30 02:13:50 +0400889 def testUiVsphere = triggers.runUie2eEnabled
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400890 def multiregionConfig = triggers.multiregionalConfiguration
891 def runMultiregion = multiregionConfig.enabled
892
893 // Generate vsphere netMap and lockLabels based on demo context
894 switch (callBackDemo) {
895 case 'aws':
896 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
897 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +0400898 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400899
900 // Define netMap for Vsphere region
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400901 if (runMultiregion && multiregionConfig.managementLocation == 'aws') {
902 if (multiregionConfig.regionLocation == 'vsphere') {
903 if (deployChild) {
904 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
905 }
906 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400907 }
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400908
909 if (multiregionConfig.regionLocation == 'azure') {
910 lockLabels['azure_core_ci_queue'] = 1
911 if (deployChild) {
912 lockLabels['azure_core_ci_queue'] += 1
913 }
914 }
915 }
916 if (triggers.azureOnAwsDemoEnabled) {
917 lockLabels['azure_core_ci_queue'] = 1
918 }
919
920 if (triggers.equinixOnAwsDemoEnabled) {
921 lockLabels['equinix_core_ci_queue'] = 1
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400922 }
923 break
924 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200925 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
slalov27833272022-06-30 02:13:50 +0400926 if (deployChild || testUiVsphere) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200927 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400928 }
929 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
930 multiregionConfig.regionLocation == 'vsphere') {
931 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200932 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400933 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200934 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400935 }
936 break
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400937 case 'azure':
938 lockLabels['azure_core_ci_queue'] = triggers.demoWeight
939 if (runMultiregion && multiregionConfig.managementLocation == 'azure') {
940 if (multiregionConfig.regionLocation == 'aws') {
941 lockLabels['aws_core_ci_queue'] = 1
942 if (deployChild) {
943 lockLabels['aws_core_ci_queue'] += 1
944 }
945 }
946
947 if (multiregionConfig.regionLocation == 'equinix') {
948 lockLabels['equinix_core_ci_queue'] = 1
949 if (deployChild) {
950 lockLabels['equinix_core_ci_queue'] +=1
951 }
952 }
953 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400954 default:
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400955 error('Supposed to be called from aws, azure or vsphere demos only')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400956 }
957
958 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
959 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200960 netMap['vsphere'].each { clusterType, netConfig ->
961 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
962 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
963 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
964
965 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400966 lockLabels['vsphere_offline_networking_core_ci']++
967 } else {
968 lockLabels['vsphere_networking_core_ci']++
969 }
970 }
971
972 // generate lock metadata
973 def lockResources = []
974 lockLabels.each { label, quantity ->
975 if (quantity > 0) {
976 def res = [
977 label: label,
978 quantity: quantity,
979 ]
980 lockResources.add(res)
981 }
982 }
983
984 common.infoMsg("""Generated vsphere netMap: ${netMap}
985 Generated lockResources: ${lockResources}""")
986
987 return [
988 netMap: netMap,
989 lockResources: lockResources,
990 ]
991}
992
993/**
994 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
995 * and empty rangeConfig to the this map.
996 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200997 * @param: netMap (string) vsphere, equinix netMap or empty map
998 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400999 * @param: clusterType (string) Vsphere cluster type
1000 */
1001
Владислав Наумов33e1e812021-08-17 17:09:25 +02001002def addToProviderNetMap (netMap, provider, clusterType) {
1003 switch (provider) {
1004 case 'equinix':
1005 netMap[provider][clusterType] = [
1006 vlanConfig: '',
1007 ]
1008 break
1009 case 'vsphere':
1010 netMap[provider][clusterType] = [
1011 netName: 'default',
1012 rangeConfig: '',
1013 ]
1014 break
1015 default:
1016 error('Net map locks supported for Equinix/Vsphere providers only')
1017 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001018}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +03001019
1020/**
1021* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
1022* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
1023* If keyword contains only 'key' part then 'value' is boolean True.
1024* This function does not perform keywords validation.
1025* First line of a commit message is ignored.
1026* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
1027* TODO: Remove backslash chars from values if they prepend '[' or ']'.
1028**/
1029
1030List getCIKeywordsFromCommitMsg() {
1031 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
1032 List commitMsgLines = commitMsg.split('\n')
1033 List keywords = []
1034 if (commitMsgLines.size() < 2) {
1035 return keywords
1036 }
1037
1038 String commitMsgBody = commitMsgLines[1..-1].join('\n')
1039
1040 // Split commit message body to chunks using '[' or ']' as delimiter,
1041 // ignoring them if prepended by backslash (regex negative lookbehind).
1042 // Resulting list will have chunks between '[' and ']' at odd indexes.
1043 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
1044
1045 // Iterate chunks by odd indexes only, trim values and split to
1046 // <key> / <value> pair where <key> is the part of a sting before the first
1047 // whitespace delimiter, and <value> is the rest (may include whitespaces).
1048 // If there is no whitespace in the string then this is a 'switch'
1049 // and <value> will be boolean True.
1050 for (i = 1; i < parts.size(); i += 2) {
1051 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
1052 keywords.add(['key': key, 'value': value])
1053 }
1054
1055 return keywords
1056}
1057
1058/**
1059* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
1060* that were specified for given job name. `job-params` keyword has the following structure
1061*
1062* [job-params <job name> <parameter name> <parameter value>]
1063*
1064* Return value is a Map that contains those parameters using the following structure:
1065*
1066* <job name>:
1067* <parameter name>: <parameter value>
1068*
1069**/
1070Map getJobsParamsFromCommitMsg() {
1071 List keywords = getCIKeywordsFromCommitMsg()
1072
1073 List jobsParamsList = []
1074 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
1075 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
1076 def (key, value) = params.split(/\s+/, 2)
1077 ['name': name, 'key': key, 'value': value]
1078 }
1079
1080 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
1081 if (!result.containsKey(it.name)) {
1082 result[it.name] = [:]
1083 }
1084 result[it.name][it.key] = it.value
1085 result
1086 }
1087
1088 return jobsParams
1089}
1090
1091
1092/**
1093* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
1094* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
1095* uses only those parametes that were set to all jobs (with <job name> == '*') or to
1096* a particular job. Parameters set to a particular job have higher precedence.
1097*
1098* Return value is a Map that contains those parameters:
1099*
1100* <parameter name>: <parameter value>
1101*
1102**/
1103Map getJobParamsFromCommitMsg(String jobName) {
1104 jobsParams = getJobsParamsFromCommitMsg()
1105 jobParams = jobsParams.getOrDefault('*', [:])
1106 if (jobName) {
1107 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
1108 }
1109 return jobParams
1110}
azvyagintsevc17d14b2022-06-06 19:06:33 +03001111
1112/** Getting test scheme from text, which should be
1113Imput example:
1114text="""
1115 DATA
1116
1117 kaas_bm_test_schemas:
1118 KAAS_RELEASES_REFSPEC: ''
1119 KEY: VAL
1120
1121 DATA
1122 """
1123
1124 Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas'])
1125
1126 Return:
1127 ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL']
1128 **/
1129def parseTextForTestSchemas(Map opts) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001130 String text = opts.getOrDefault('text', '')
azvyagintsevc17d14b2022-06-06 19:06:33 +03001131 String keyLine = opts.getOrDefault('keyLine', '')
1132 Map testScheme = [:]
1133 if (!text || !keyLine) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001134 return testScheme
azvyagintsevc17d14b2022-06-06 19:06:33 +03001135 }
1136 if (text =~ /\n$keyLine\n.*/) {
1137 def common = new com.mirantis.mk.Common()
1138 try {
1139 String regExp = '\\n' + keyLine + '\\n'
1140 // regexep block must be followed by empty line
1141 testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}"
1142 common.infoMsg("parseTextForTestSchemas result:\n" + testScheme)
1143 common.mergeEnv(env, toJson(testScheme))
1144 }
1145 catch (Exception e) {
1146 common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}")
1147 throw e
1148 }
1149 }
azvyagintsevd96aac22022-06-10 14:23:26 +03001150 return testScheme
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +03001151}
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001152
1153
1154/**
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001155* getEquinixFacilityWithCapacity returns list of Equinix facilities using specified
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001156* instance type (nodeType), desired count of facilities (facilityCount) and
1157* instances (nodeCount) in a facility using specified matal version.
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001158* Function downloads metal CLI from the
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001159* https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux
1160* Empty list is returned in case of no facilities with specified capacity was found or any other errors.
Sergey Zhemerdeev15aa8602022-10-13 11:10:02 +03001161* Non-empty list is shuffled.
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001162*
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001163* @param: facilityCount (int) Desired count of facilities
1164* @param: nodeCount (int) Desired count of instances
1165* @param: nodeType (string) Instance type
1166* @param: version (string) Metal version to use
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001167* @return ([]string) List of selected facilities
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001168*
1169**/
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001170def getEquinixFacilityWithCapacity(facilityCount = 1, nodeCount = 50, nodeType = 'c3.small.x86', version = '0.9.0') {
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001171 def common = new com.mirantis.mk.Common()
1172 def metalUrl = "https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux"
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001173 def metal = './metal --config metal.yaml'
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001174 def facility = []
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001175 def out = ''
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001176 def retries = 3 // number of retries
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001177 def i = 0
1178 def delay = 60 // 1 minute sleep
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001179 def excludeFacility = [] // list of facilities to exclude from selection
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001180 try {
Sergey Zhemerdeevb3575342022-10-04 11:02:19 +03001181 if (excludeFacility.size() > 0) {
1182 common.infoMsg("Excluded facilities: ${excludeFacility}")
1183 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001184 sh "curl -o metal -# ${metalUrl} && chmod +x metal"
1185 withCredentials([string(credentialsId: env.KAAS_EQUINIX_API_TOKEN, variable: 'KAAS_EQUINIX_API_TOKEN')]) {
1186 sh 'echo "project-id: ${KAAS_EQUINIX_PROJECT_ID}\ntoken: ${KAAS_EQUINIX_API_TOKEN}" >metal.yaml'
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001187 }
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001188 while (facility.size() < facilityCount && i < retries) {
1189 common.infoMsg("Selecting ${facilityCount} available Equinix facilities with free ${nodeCount} ${nodeType} hosts, try ${i+1}/${retries} ...")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001190 if (i > 0 ) { // skip sleep on first step
1191 sleep(delay)
1192 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001193 out = sh(script: "${metal} capacity get -f -P ${nodeType}|awk '/${nodeType}/ {print \$2}'|paste -s -d,|xargs ${metal} capacity check -P ${nodeType} -q ${nodeCount} -f|grep true|awk '{print \$2}'|paste -s -d,", returnStdout: true).trim()
1194 facility = out.tokenize(',')
Sergey Zhemerdeevb3575342022-10-04 11:02:19 +03001195 facility -= excludeFacility
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001196 if (facility.size() < facilityCount) {
1197 nodeCount -= 10
1198 // We need different metros for the [equinixmetalv2-child-diff-metro] case, facility[][0, 1] contains a metro name
1199 } else if (facility.size() == 2 && facility[0][0, 1] == facility[1][0, 1]) {
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001200 nodeCount -= 10
1201 }
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001202 i++
1203 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001204 if (facility.size() > 0) {
1205 f = facility.size() > 1 ? "${facility[0]},${facility[1]}" : "${facility[0]}"
1206 sh "${metal} capacity check -P ${nodeType} -f ${f} -q ${nodeCount}"
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001207 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001208 } catch (Exception e) {
1209 common.errorMsg "Exception: '${e}'"
1210 return []
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001211 } finally {
1212 sh 'rm metal.yaml'
1213 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001214 if (facility.size() > 0) {
Sergey Zhemerdeev15aa8602022-10-13 11:10:02 +03001215 Collections.shuffle(facility)
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001216 common.infoMsg("Selected facilities: ${facility}")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001217 } else {
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001218 common.warningMsg('No any facilities have been selected !!! :(')
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001219 }
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001220 return facility
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001221}
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001222
1223
1224/**
1225 * genCommandLine prepares command line for artifactory-replication
1226 * command using legacy environment variables
1227 *
1228 * @return: (string) Prepared command line
1229 */
1230def genCommandLine() {
1231 def envToParam = [
1232 'DESTINATION_USER': '-dst-user',
1233 'ARTIFACT_FILTER': '-artifact-filter',
1234 'ARTIFACT_FILTER_PROD': '-artifact-filter-prod',
1235 'ARTIFACT_TYPE': '-artifact-type',
1236 'BINARY_CLEAN': '-bin-cleanup',
1237 'BINARY_CLEAN_KEEP_DAYS': '-bin-clean-keep-days',
1238 'BINARY_CLEAN_PREFIX': '-bin-clean-prefix',
1239 'BUILD_URL': '-slack-build-url',
1240 'CHECK_REPOS': '-check-repos',
1241 'DESTINATION_REGISTRY': '-dst-repo',
1242 'DESTINATION_REGISTRY_TYPE': '-dst-repo-type',
1243 'DOCKER_CLEAN': '-cleanup',
1244 'DOCKER_REPO_PREFIX': '-docker-repo-prefix',
1245 'DOCKER_TAG': '-docker-tag',
1246 'FORCE': '-force',
1247 'HELM_CDN_DOMAIN': '-helm-cdn-domain',
1248 'SLACK_CHANNEL': '-slack-channel',
1249 'SLACK_USER': '-slack-user',
1250 'SOURCE_REGISTRY': '-src-repo',
1251 'SOURCE_REGISTRY_TYPE': '-src-repo-type',
1252 'SYNC_PATTERN': '-sync-pattern'
1253 ]
1254 def cmdParams = ''
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001255 def isCheckClean = false
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001256 for (e in envToParam) {
1257 if (env[e.key] == null) {
1258 continue
1259 }
1260 if (e.key == 'CHECK_REPOS' || e.key == 'DOCKER_CLEAN') {
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001261 // Avoid CHECK_REPOS=true and DOCKER_CLEAN=true
1262 if (env[e.key].toBoolean() && !isCheckClean) {
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001263 cmdParams += e.value + ' '
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001264 isCheckClean = true
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001265 }
1266 } else if (e.key == 'FORCE') {
1267 if (env[e.key].toBoolean()) {
1268 cmdParams += e.value + ' '
1269 }
1270 } else {
Sergey Zhemerdeeve2926cd2022-08-29 15:28:47 +03001271 cmdParams += "${e.value} '${env[e.key]}' "
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001272 }
1273 }
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001274 // No any check or clean was specified - take a default action
1275 if (!isCheckClean) {
1276 cmdParams += '-replicate'
1277 }
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001278 return cmdParams
1279}
Sergey Kolekonov0e60a942022-09-05 13:02:22 +04001280
1281/**
1282 * custom scheduling algorithm
1283 * it ensures that builds of the same job are distributed as much as possible between different nodes
1284 * @param label (string) desired node label
1285 * @return: (string) node name
1286 */
1287def schedule (label='docker') {
1288 def common = new com.mirantis.mk.Common()
1289 def freeNodes = []
1290 def nodesMap = [:]
1291
1292 // filter nodes with the specified label and at least one free executor
1293 timeout(time: 30, unit: 'MINUTES') {
1294 while (!freeNodes) {
1295 freeNodes = jenkins.model.Jenkins.instance.computers.findAll { node ->
1296 label in node.getAssignedLabels().collect { it.name } &&
1297 node.isPartiallyIdle()
1298 }
1299 if (!freeNodes) {
1300 echo 'No nodes available for scheduling, retrying...'
1301 sleep 30
1302 }
1303 }
1304 }
1305
1306 // generate a map of nodes matching other criteria
1307 for (node in freeNodes) {
1308 // sameJobExecutors is the number of executors running the same job as the calling one
1309 sameJobExecutors = node.getExecutors() // get all executors
1310 .collect { executor -> executor.getCurrentExecutable() } // get running "threads"
1311 .collect { thread -> thread?.displayName } // filter job names from threads
1312 .minus(null) // null = empty executors, remove them from the list
1313 .findAll { it.contains(env.JOB_NAME) } // filter the same jobs as the calling one
1314 .size()
1315
1316 // calculate busy executors, we don't want to count "sameJobExecutors" twice
1317 totalBusyExecutors = node.countBusy() - sameJobExecutors
1318 // generate the final map which contains nodes matching criteria with their load score
1319 // builds of the same jobs have x10 score, all others x1
1320 nodesMap += ["${node.getName()}" : sameJobExecutors * 10 + totalBusyExecutors]
1321 }
1322
1323 // return the least loaded node
1324 return common.SortMapByValueAsc(nodesMap).collect { it.key }[0]
1325}