blob: 90a6aa7e3ad3bde8594501851e0814a477691997 [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
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +030085 def runChildMachineDeletionPolicyTest = env.RUN_CHILD_MACHINE_DELETION_POLICY_TEST ? env.RUN_CHILD_MACHINE_DELETION_POLICY_TEST.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020086 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
87 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
88 enabled: false,
89 managementLocation: '',
90 regionLocation: '',
91 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020092
Владислав Наумовb8305e22021-02-10 17:23:12 +010093 // proxy customization
94 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020095 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
96 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020097 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010098 ]
99
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200100 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +0200101 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +0200102 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +0200103 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +0200104 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +0200105 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200106 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400107 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200108 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +0300109 def enableBMDemo = true
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400110 def enableArtifactsBuild = true
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400111 def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300112 def enableVsphereUbuntu = env.VSPHERE_DEPLOY_UBUNTU ? env.VSPHERE_DEPLOY_UBUNTU.toBoolean() : false
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300113 def childOsBootFromVolume = env.OPENSTACK_BOOT_FROM_VOLUME ? env.OPENSTACK_BOOT_FROM_VOLUME.toBoolean() : false
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400114 def bootstrapV2Scenario = env.BOOTSTRAP_V2_ENABLED ? env.BOOTSTRAP_V2_ENABLED.toBoolean() : false
Sergey Lalovacec3c12022-07-20 16:00:14 +0400115 def equinixMetalV2Metro = env.EQUINIX_MGMT_METRO ? env.EQUINIX_MGMT_METRO : ''
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400116 def enableFips = env.ENABLE_FIPS ? env.ENABLE_FIPS.toBoolean() : false
vnaumov33747e12020-05-04 17:35:20 +0200117
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200118 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +0100119 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
120 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +0200121 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 +0100122 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100123 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
124 seedMacOs = true
125 }
slalov574123e2022-04-06 17:24:19 +0400126 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance || runProxyChildTest) {
vnaumov33747e12020-05-04 17:35:20 +0200127 deployChild = true
128 }
129 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
130 deployChild = true
131 upgradeChild = true
132 }
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400133 if (commitMsg ==~ /(?s).*\[child-upgrade-full\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade-full.*/) {
134 deployChild = true
135 upgradeChild = true
136 fullUpgradeChild = true
137 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400138 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
139 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400140 // override child version when it set explicitly
141 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400142 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400143 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
144 }
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400145 if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) {
146 mosDeployChild = true
147 }
148 if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) {
149 mosDeployChild = true
150 mosUpgradeChild = true
151 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100152 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
153 attachBYO = true
154 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100155 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
156 attachBYO = true
157 upgradeBYO = true
158 }
Sergey Lalovacec3c12022-07-20 16:00:14 +0400159 if (commitMsg ==~ /(?s).*\[ui-test-on-all-providers\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-test-on-all-providers.*/) {
160 enableVsphereDemo = true
161 enableOSDemo = true
162 awsOnDemandDemo = true
163 azureOnDemandDemo = true
164 equinixOnDemandDemo = true
165 equinixMetalV2OnDemandDemo = true
166 runUie2e = true
Sergey Lalovacec3c12022-07-20 16:00:14 +0400167 // Edit after fix PRODX-3961
168 enableBMDemo = false
169 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400170 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
171 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 +0100172 runBYOMatrix = true
173
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400174 if (byoDeployMatches.size() > 0) {
175 defaultBYOOs = byoDeployMatches[0][2]
176 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
177 }
178
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100179 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
180 attachBYO = false
181 upgradeBYO = false
182 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400183 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200184 upgradeMgmt = true
185 }
slalov1202bba2022-04-20 22:31:07 +0400186 if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) {
187 autoUpgradeMgmt = true
188 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400189 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
190 enableLMALogging = true
191 }
Sergey Lalovb2f60372022-09-20 23:58:47 +0400192 if (commitMsg ==~ /(?s).*\[deploy-os-on-mos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*deploy-os-on-mos.*/) {
193 deployOsOnMos = true
194 mosDeployChild = true
195 openstackIMC = 'eu2'
196 }
vnaumov33747e12020-05-04 17:35:20 +0200197 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
198 runUie2e = true
199 }
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400200 if (commitMsg ==~ /(?s).*\[ui-e2e-new\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-new.*/) {
201 runUie2eNew = true
202 }
vnaumov33747e12020-05-04 17:35:20 +0200203 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
204 runMgmtConformance = true
205 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200206 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
207 runMgmtUserControllerTest = true
208 }
slalov574123e2022-04-06 17:24:19 +0400209 if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) {
210 runProxyChildTest = true
211 deployChild = true
212 common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed')
213 }
vnaumov33747e12020-05-04 17:35:20 +0200214 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
215 runChildConformance = true
216 deployChild = true
217 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200218 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
219 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400220 enableLMALogging = true
221 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400222 }
slalov13e579c2022-01-31 21:37:02 +0400223 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
224 runMaintenanceTest = true
225 }
slalov0a4947a2022-06-09 15:44:35 +0400226 if (commitMsg ==~ /(?s).*\[container-registry-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*container-registry-test.*/) {
227 runContainerregistryTest = true
228 }
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300229 if (commitMsg ==~ /(?s).*\[mgmt-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-delete-master-test.*/) {
230 runMgmtDeleteMasterTest = true
231 }
232 if (commitMsg ==~ /(?s).*\[rgnl-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*rgnl-delete-master-test.*/) {
233 runRgnlDeleteMasterTest = true
234 }
235 if (commitMsg ==~ /(?s).*\[child-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-delete-master-test.*/) {
236 runChildDeleteMasterTest = true
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300237 deployChild = true
238 common.infoMsg('Child cluster deployment will be enabled since delete child master node test suite will be executed')
239 }
240 if (commitMsg ==~ /(?s).*\[child-machine-deletion-policy-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-machine-deletion-policy-test.*/) {
241 runChildMachineDeletionPolicyTest = true
242 deployChild = true
243 common.infoMsg('Child cluster deployment will be enabled since machine deletion child policy test suite will be executed')
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300244 }
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300245 if (commitMsg ==~ /(?s).*\[graceful-reboot-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*graceful-reboot-test.*/) {
246 runGracefulRebootTest = true
247 }
Sergey Lalovbc68d752022-11-08 13:40:53 +0400248 if (commitMsg ==~ /(?s).*\[pause-for-debug\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*pause-for-debug.*/) {
249 pauseForDebug = true
250 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200251 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
252 proxyConfig['childOffline'] = true
253 deployChild = true
254 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200255 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
256 proxyConfig['childOffline'] = true
257 proxyConfig['childProxy'] = true
258 deployChild = true
259 }
vnaumov33747e12020-05-04 17:35:20 +0200260 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
261 fetchServiceBinaries = true
262 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200263 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400264 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200265 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 +0400266 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200267 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
268 azureOnAwsDemo = true
269 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
270 }
271 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
272 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
273 attachBYO ||
274 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100275 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200276 seedMacOs ||
277 equinixOnAwsDemo ||
278 azureOnAwsDemo) {
279
vnaumov33747e12020-05-04 17:35:20 +0200280 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200281 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 +0200282 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200283 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200284 equinixOnDemandDemo = true
285 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200286 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200287 equinixMetalV2OnDemandDemo = true
288 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100289 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
290 equinixMetalV2OnDemandDemo = true
291 equinixMetalV2ChildDiffMetro = true
292 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200293 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
294 azureOnDemandDemo = true
295 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200296 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
297 enableOSDemo = false
298 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200299 }
300
azvyagintsev1761bdc2020-09-04 17:24:12 +0300301 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
302 enableBMDemo = false
303 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
304 }
305
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400306 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
307 enableVsphereDemo = false
308 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
309 }
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300310 if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) {
311 enableVsphereUbuntu = true
312 common.warningMsg('Ubuntu will be used to deploy vsphere machines')
313 }
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400314
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400315 if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) {
316 enableArtifactsBuild = false
317 common.errorMsg('artifacts build will be aborted, VF -1 will be set')
318 }
319
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300320 if (commitMsg ==~ /(?s).*\[child-os-boot-from-volume\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-os-boot-from-volume\.*/) {
321 childOsBootFromVolume = true
322 common.warningMsg('OS will be booted from Ceph volumes')
323 }
324
vnaumov33747e12020-05-04 17:35:20 +0200325 // TODO (vnaumov) remove below condition after moving all releases to UCP
326 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
327 if (ucpChildMatches.size() > 0) {
328 deployChild = true
329 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
330
331 // TODO(vnaumov) delete after ucp upgrades support
332 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
333 upgradeChild = false
334 }
335
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200336 // multiregional tests
337 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
338 if (multiRegionalMatches.size() > 0) {
339 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
340 }
341 switch (multiregionalMappings['managementLocation']) {
342 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100343 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200344 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100345
346 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
347 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
348 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200349 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200350 case 'os':
351 if (enableOSDemo == false) {
352 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
353 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200354 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200355 case 'vsphere':
356 if (enableVsphereDemo == false) {
357 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
358 }
359 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200360 case 'equinix':
361 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
362 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400363 break
eromanova8c702ae2021-12-24 17:43:12 +0400364 case 'equinixmetalv2':
365 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
366 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400367 break
slalovfd0b7e62021-07-28 18:05:16 +0400368 case 'azure':
369 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
370 azureOnDemandDemo = true
371 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200372 }
373
Владислав Наумовb8305e22021-02-10 17:23:12 +0100374 // CDN configuration
375 def cdnConfig = [
376 mgmt: [
377 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200378 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100379 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200380 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200381 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200382 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100383 ]
384
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400385 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
386 openstackIMC = 'eu'
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400387 }
slalov021171f2022-03-04 14:48:38 +0400388 if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) {
389 openstackIMC = 'eu2'
Mikhail Ivanovf05b8252022-04-27 18:14:03 +0400390 }
391 if (openstackIMC == 'eu' || openstackIMC == 'eu2') {
slalov021171f2022-03-04 14:48:38 +0400392 // use internal-eu because on internal-ci with eu cloud image pull takes much time
393 def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
394 common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}")
395 cdnConfig['mgmt']['openstack'] = cdnRegion
396 }
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400397
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100398 // calculate weight of current demo run to manage lockable resources
Sergey Lalov46deb442022-08-18 12:11:03 +0400399 def demoWeight = deployChild ? 2 : 1 // management = 1, child += 1
400 if (runUie2e) {
401 demoWeight += 1
402 }
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100403
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400404 if (commitMsg ==~ /(?s).*\[bootstrapv2-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv2-scenario\.*/) {
405 bootstrapV2Scenario = true
406 }
407
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400408 if (commitMsg ==~ /(?s).*\[enable-fips\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*enable-fips\.*/) {
409 enableFips = true
410 }
411
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300412 // parse equinixmetalv2-metro trigger
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300413 def equinixMetalV2MetroMatcher = (commitMsg =~ /\[equinixmetalv2-metro(\s+.*)?\]/)
414 if (equinixMetalV2OnDemandDemo && equinixMetalV2MetroMatcher.size() > 0) {
Sergey Zhemerdeevcc785e42022-07-22 17:15:47 +0300415 equinixMetalV2Metro = equinixMetalV2MetroMatcher[0][1].trim().toLowerCase()
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300416 common.infoMsg("Forced Equnix mgmt deployment using custom metro ${equinixMetalV2Metro}")
417 }
418
vnaumov33747e12020-05-04 17:35:20 +0200419 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400420 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100421 CDN deployment configuration: ${cdnConfig}
422 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100423 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200424 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400425 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200426 Child cluster release upgrade scheduled: ${upgradeChild}
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400427 Full Child cluster release upgrade scheduled: ${fullUpgradeChild}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400428 MOS child deploy scheduled: ${mosDeployChild}
429 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200430 Child conformance testing scheduled: ${runChildConformance}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100431 Single BYO cluster attachment scheduled: ${attachBYO}
432 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
433 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400434 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200435 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
slalov1202bba2022-04-20 22:31:07 +0400436 Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400437 Mgmt LMA logging enabled: ${enableLMALogging}
Sergey Lalovb2f60372022-09-20 23:58:47 +0400438 Deploy Os on child with mos release ${deployOsOnMos}
vnaumov33747e12020-05-04 17:35:20 +0200439 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200440 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200441 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200442 Mgmt UI e2e testing scheduled: ${runUie2e}
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400443 Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew}
slalov13e579c2022-01-31 21:37:02 +0400444 Maintenance test: ${runMaintenanceTest}
slalov0a4947a2022-06-09 15:44:35 +0400445 Container Registry test: ${runContainerregistryTest}
slalov574123e2022-04-06 17:24:19 +0400446 Child proxy test: ${runProxyChildTest}
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300447 Graceful reboot test: ${runGracefulRebootTest}
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300448 Delete mgmt master node test: ${runMgmtDeleteMasterTest}
449 Delete rgnl master node test: ${runRgnlDeleteMasterTest}
450 Delete child master node test: ${runChildDeleteMasterTest}
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300451 Child machine deletion policy test: ${runChildMachineDeletionPolicyTest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200452 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200453 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200454 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100455 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Sergey Zhemerdeev019c45a2022-08-13 00:09:07 +0300456 EquinixmetalV2 mgmt will be deployed on the metro: ${equinixMetalV2Metro?:'auto'}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200457 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200458 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200459 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400460 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200461 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300462 BM provider deployment scheduled: ${enableBMDemo}
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300463 Ubuntu on vSphere scheduled: ${enableVsphereUbuntu}
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400464 Artifacts build scheduled: ${enableArtifactsBuild}
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300465 Boot OS child from Ceph volumes: ${childOsBootFromVolume}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200466 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200467 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100468 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400469 Bootstrap v2 scenario enabled: ${bootstrapV2Scenario}
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400470 FIPS enabled: ${enableFips}
Sergey Lalovbc68d752022-11-08 13:40:53 +0400471 Pause for debug enabled: ${pauseForDebug}
Владислав Наумов81777472021-03-09 15:14:27 +0400472 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200473 return [
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300474 osCloudLocation : openstackIMC,
475 cdnConfig : cdnConfig,
476 proxyConfig : proxyConfig,
477 useMacOsSeedNode : seedMacOs,
478 deployChildEnabled : deployChild,
479 childDeployCustomRelease : customChildRelease,
480 upgradeChildEnabled : upgradeChild,
481 fullUpgradeChildEnabled : fullUpgradeChild,
482 mosDeployChildEnabled : mosDeployChild,
483 mosUpgradeChildEnabled : mosUpgradeChild,
484 runChildConformanceEnabled : runChildConformance,
485 attachBYOEnabled : attachBYO,
486 upgradeBYOEnabled : upgradeBYO,
487 runBYOMatrixEnabled : runBYOMatrix,
488 defaultBYOOs : defaultBYOOs,
489 upgradeMgmtEnabled : upgradeMgmt,
490 autoUpgradeMgmtEnabled : autoUpgradeMgmt,
491 enableLMALoggingEnabled : enableLMALogging,
492 deployOsOnMosEnabled : deployOsOnMos,
493 runUie2eEnabled : runUie2e,
494 runUie2eNewEnabled : runUie2eNew,
495 runMgmtConformanceEnabled : runMgmtConformance,
496 runMaintenanceTestEnabled : runMaintenanceTest,
497 runContainerregistryTestEnabled : runContainerregistryTest,
498 runGracefulRebootTestEnabled : runGracefulRebootTest,
499 pauseForDebugEnabled : pauseForDebug,
500 runMgmtDeleteMasterTestEnabled : runMgmtDeleteMasterTest,
501 runRgnlDeleteMasterTestEnabled : runRgnlDeleteMasterTest,
502 runChildDeleteMasterTestEnabled : runChildDeleteMasterTest,
503 runChildMachineDeletionPolicyTestEnabled : runChildMachineDeletionPolicyTest,
504 runLMATestEnabled : runLMATest,
505 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
506 runProxyChildTestEnabled : runProxyChildTest,
507 fetchServiceBinariesEnabled : fetchServiceBinaries,
508 awsOnDemandDemoEnabled : awsOnDemandDemo,
509 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
510 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
511 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
512 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
513 azureOnDemandDemoEnabled : azureOnDemandDemo,
514 azureOnAwsDemoEnabled : azureOnAwsDemo,
515 vsphereDemoEnabled : enableVsphereDemo,
516 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
517 bmDemoEnabled : enableBMDemo,
518 osDemoEnabled : enableOSDemo,
519 vsphereUbuntuEnabled : enableVsphereUbuntu,
520 artifactsBuildEnabled : enableArtifactsBuild,
521 childOsBootFromVolume : childOsBootFromVolume,
522 multiregionalConfiguration : multiregionalMappings,
523 demoWeight : demoWeight,
524 bootstrapV2Scenario : bootstrapV2Scenario,
525 equinixMetalV2Metro : equinixMetalV2Metro,
526 enableFips : enableFips]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200527}
528
529/**
530 * Determine management and regional setup for demo workflow scenario
531 *
532 *
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300533 * @param: keyword (string) string , represents keyword trigger, specified in gerrit commit body, like `[multiregion aws,os]`
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200534 or Jenkins environment string variable in form like 'aws,os'
535 * @return (map)[
536 enabled: (bool),
537 * managementLocation: (string), //aws,os
538 * regionLocation: (string), //aws,os
539 * ]
540 */
541def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200542 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400543 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
544 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200545
546 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200547 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200548 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
549 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
550 } else {
551 common.infoMsg('Multiregion definition configured via environment variable')
552 clusterTypes = keyword.trim().split(',')
553 }
554
555 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100556 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200557 }
558
Владислав Наумовf793fe32020-09-11 15:19:19 +0200559 def desiredManagementProvider = clusterTypes[0].trim()
560 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200561 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
562 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200563 management providers list - ${supportedManagementProviders}
564 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200565 }
566
567 return [
568 enabled: true,
569 managementLocation: desiredManagementProvider,
570 regionLocation: desiredRegionalProvider,
571 ]
vnaumov33747e12020-05-04 17:35:20 +0200572}
573
574/**
575 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
576
Владислав Наумов81777472021-03-09 15:14:27 +0400577 * 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 +0200578 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
579 * Example scheme:
580 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
581 * manage refspecs through Jenkins Job Parameters
582 *
azvyagintseva12230a2020-06-05 13:24:06 +0300583 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200584 * siPipelines: (string) final refspec for si-pipelines
585 * ]
586 */
587def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200588 def common = new com.mirantis.mk.Common()
589
vnaumov33747e12020-05-04 17:35:20 +0200590 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200591 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
592 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200593 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
594 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200595 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200596
597 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
598 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
599
600 if (siTestMatches.size() > 0) {
601 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400602 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200603 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200604 }
605 if (siPipelinesMatches.size() > 0) {
606 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
607 }
608
609 common.infoMsg("""
610 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
611 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200612 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400613 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200614 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200615}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200616
Владислав Наумов9080f372020-06-08 13:57:16 +0200617/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200618 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200619 * @param configurationFile (str) path to configuration file in yaml format
620 *
621 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300622 * siTestsFeatureFlagsStable (string) dedicated feature flags that will be used in SI tests for deploying stable release
Владислав Наумов30a516c2020-07-09 13:15:41 +0200623 * ]
624 */
625def parseKaaSComponentCIParameters(configurationFile){
626 def common = new com.mirantis.mk.Common()
627 def ciConfig = readYaml file: configurationFile
628 def ciSpec = [
629 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300630 siTestsFeatureFlagsStable: env.SI_TESTS_FEATURE_FLAGS_STABLE ?: '',
Владислав Наумов30a516c2020-07-09 13:15:41 +0200631 ]
632
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300633 // If exists and not empty
634 if (ciConfig.getOrDefault('si-tests-feature-flags', [])) {
Владислав Наумов30a516c2020-07-09 13:15:41 +0200635 common.infoMsg("""SI tests feature flags customization detected,
636 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
637
638 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
639 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200640
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200641 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200642 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
643 }
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300644 if (ciConfig.getOrDefault('si-tests-feature-flags-stable', [])) {
645 common.infoMsg("""SI tests feature flags for stable release customization detected,
646 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlagsStable']}] identification...""")
647
648 def ffMeta = ciSpec['siTestsFeatureFlagsStable'].tokenize(',').collect { it.trim() }
649 ffMeta.addAll(ciConfig['si-tests-feature-flags-stable'])
650
651 ciSpec['siTestsFeatureFlagsStable'] = ffMeta.unique().join(',')
652 common.infoMsg("SI tests custom feature flags for stable release: ${ciSpec['siTestsFeatureFlagsStable']}")
653 }
Владислав Наумов30a516c2020-07-09 13:15:41 +0200654
655 common.infoMsg("""Additional ci configuration parsed successfully:
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300656 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}
657 siTestsFeatureFlagsStable: ${ciSpec['siTestsFeatureFlagsStable']}""")
Владислав Наумов30a516c2020-07-09 13:15:41 +0200658 return ciSpec
659}
660
661/**
662 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200663
Владислав Наумов81777472021-03-09 15:14:27 +0400664 * 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 +0200665 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
666 * Example scheme:
667 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
668 * manage refspecs through Jenkins Job Parameters
669 *
670 * @return (map)[ core: (string) final refspec for kaas/core
671 * corePipelines: (string) final refspec for pipelines in kaas/core
672 * ]
673 */
674def checkCustomCoreRefspec() {
675 def common = new com.mirantis.mk.Common()
676
677 // Available triggers and its sane defaults
678 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
679 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
680 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
681 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
682
683 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
684 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
685
686 if (coreMatches.size() > 0) {
687 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
688 }
689 if (corePipelinesMatches.size() > 0) {
690 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
691 }
692
693 common.infoMsg("""
694 kaas/core will be fetched from: ${coreRefspec}
695 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400696 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200697 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
698}
699
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200700
701/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200702 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
703 * needed to forward inside kaas core set of jobs
704 *
705 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
706 * @return (list)[ string(name: '', value: ''),
707 * ]
708 */
709def generateKaaSVarsFromContext(context) {
710 def common = new com.mirantis.mk.Common()
711 def parameters = []
712 def config = readYaml text: context
713
714 config.each { k,v ->
715 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
716 parameters.add(string(name: k, value: v))
717 }
718
719 return parameters
720}
721
722/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200723 * 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 +0400724 * 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 +0200725 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
726 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200727 * @param: component (string) component name [iam, lcm, stacklight]
728 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
729 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200730 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200731def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200732 def common = new com.mirantis.mk.Common()
733 // Determine if custom trigger keywords forwarded from gerrit
734 def triggers = checkDeploymentTestSuite()
735 // Determine SI refspecs
736 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200737 // Determine Core refspecs
738 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200739
Владислав Наумов418042b2020-07-09 18:31:10 +0200740 // Determine component repo ci configuration
741 def ciSpec = [:]
742 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
743 if (fileExists(configurationFile)) {
744 common.infoMsg('Component CI configuration file detected, parsing...')
745 ciSpec = parseKaaSComponentCIParameters(configurationFile)
746 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
747 } else {
748 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200749 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200750 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
751 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200752 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400753
754 def platforms = []
755 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
756 // Currently only vsphere demo is required for IPAM component
757 platforms.add('vsphere')
758 } else {
759 if (triggers.osDemoEnabled) {
760 platforms.add('openstack')
761 }
762 if (triggers.awsOnDemandDemoEnabled) {
763 platforms.add('aws')
764 }
765 if (triggers.equinixOnDemandDemoEnabled) {
766 platforms.add('equinix')
767 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200768 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
769 platforms.add('equinixmetalv2')
770 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200771 if (triggers.azureOnDemandDemoEnabled) {
772 platforms.add('azure')
773 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400774 if (triggers.vsphereDemoEnabled) {
775 platforms.add('vsphere')
776 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400777 }
778
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200779 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200780 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200781 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
782 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200783 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200784 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200785 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
786 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200787 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200788 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400789 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400790 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100791 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200792 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200793 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100794 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200795 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
slalov1202bba2022-04-20 22:31:07 +0400796 booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400797 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Sergey Lalovb2f60372022-09-20 23:58:47 +0400798 booleanParam(name: 'DEPLOY_OS_ON_MOS', value: triggers.deployOsOnMosEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200799 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200800 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
slalov0a4947a2022-06-09 15:44:35 +0400801 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnabled),
802 booleanParam(name: 'RUN_CONTAINER_REGISTRY_TEST', value: triggers.runContainerregistryTestEnabled),
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300803 booleanParam(name: 'RUN_GRACEFUL_REBOOT_TEST', value: triggers.runGracefulRebootTestEnabled),
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300804 booleanParam(name: 'RUN_MGMT_DELETE_MASTER_TEST', value: triggers.runMgmtDeleteMasterTestEnabled),
805 booleanParam(name: 'RUN_RGNL_DELETE_MASTER_TEST', value: triggers.runRgnlDeleteMasterTestEnabled),
806 booleanParam(name: 'RUN_CHILD_DELETE_MASTER_TEST', value: triggers.runChildDeleteMasterTestEnabled),
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300807 booleanParam(name: 'RUN_CHILD_MACHINE_DELETION_POLICY_TEST', value: triggers.runChildMachineDeletionPolicyTestEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200808 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200809 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200810 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
811 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400812 booleanParam(name: 'FULL_UPGRADE_CHILD_CLUSTER', value: triggers.fullUpgradeChildEnabled),
slalov574123e2022-04-06 17:24:19 +0400813 booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100814 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100815 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100816 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200817 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400818 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200819 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200820 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100821 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400822 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200823 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200824 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Sergey Zhemerdeev9074f6e2022-06-07 12:03:16 +0300825 booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled),
Sergey Lalovbc68d752022-11-08 13:40:53 +0400826 booleanParam(name: 'PAUSE_FOR_DEBUG', value: triggers.pauseForDebugEnabled),
Sergey Lalovb5863ee2022-11-18 17:11:18 +0400827 booleanParam(name: 'ENABLE_FIPS', value: triggers.enableFips)
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200828 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200829
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200830 // customize multiregional demo
831 if (triggers.multiregionalConfiguration.enabled) {
832 parameters.add(string(name: 'MULTIREGION_SETUP',
833 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
834 ))
835 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200836
Владислав Наумов92288d92020-07-13 18:36:21 +0200837 // Determine component team custom context
838 if (coreContext != '') {
839 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
840 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200841 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200842 }
843
Владислав Наумовaa430612020-06-08 17:18:31 +0200844 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400845
846 platforms.each { platform ->
847 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000848 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400849 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
850 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
851 def build_description = job_info.getDescription()
852 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000853 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200854
Vladislav Naumov5313a202021-04-07 17:13:39 +0000855 if (build_description) {
856 currentBuild.description += build_description
857 }
858 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400859 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000860 }
861 }
862 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200863
864 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400865 if (jobs.size() == 0) {
866 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
867 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200868 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
869 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200870
871 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200872 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200873 currentBuild.result = 'FAILURE'
874 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200875}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200876
877
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400878/**
879 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200880 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400881 *
882 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
883 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
884 * @param: multiregionalConfiguration (map) Multiregional configuration
885 * @return (map) Return aggregated map with lockResources and netMap
886 */
887
888
889def generateLockResources(callBackDemo, triggers) {
890 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200891 def netMap = [
892 vsphere: [:],
893 equinix: [:],
894 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400895 // Define vsphere locklabels with initial quantity
896 def lockLabels = [
897 vsphere_networking_core_ci: 0,
898 vsphere_offline_networking_core_ci: 0,
899 ]
900 def deployChild = triggers.deployChildEnabled
slalov27833272022-06-30 02:13:50 +0400901 def testUiVsphere = triggers.runUie2eEnabled
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400902 def multiregionConfig = triggers.multiregionalConfiguration
903 def runMultiregion = multiregionConfig.enabled
904
905 // Generate vsphere netMap and lockLabels based on demo context
906 switch (callBackDemo) {
907 case 'aws':
908 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
909 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +0400910 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400911
912 // Define netMap for Vsphere region
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400913 if (runMultiregion && multiregionConfig.managementLocation == 'aws') {
914 if (multiregionConfig.regionLocation == 'vsphere') {
915 if (deployChild) {
916 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
917 }
918 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400919 }
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400920
921 if (multiregionConfig.regionLocation == 'azure') {
922 lockLabels['azure_core_ci_queue'] = 1
923 if (deployChild) {
924 lockLabels['azure_core_ci_queue'] += 1
925 }
926 }
927 }
928 if (triggers.azureOnAwsDemoEnabled) {
929 lockLabels['azure_core_ci_queue'] = 1
930 }
931
932 if (triggers.equinixOnAwsDemoEnabled) {
933 lockLabels['equinix_core_ci_queue'] = 1
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400934 }
935 break
936 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200937 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
slalov27833272022-06-30 02:13:50 +0400938 if (deployChild || testUiVsphere) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200939 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400940 }
941 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
942 multiregionConfig.regionLocation == 'vsphere') {
943 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200944 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400945 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200946 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400947 }
948 break
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400949 case 'azure':
950 lockLabels['azure_core_ci_queue'] = triggers.demoWeight
951 if (runMultiregion && multiregionConfig.managementLocation == 'azure') {
952 if (multiregionConfig.regionLocation == 'aws') {
953 lockLabels['aws_core_ci_queue'] = 1
954 if (deployChild) {
955 lockLabels['aws_core_ci_queue'] += 1
956 }
957 }
958
959 if (multiregionConfig.regionLocation == 'equinix') {
960 lockLabels['equinix_core_ci_queue'] = 1
961 if (deployChild) {
962 lockLabels['equinix_core_ci_queue'] +=1
963 }
964 }
965 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400966 default:
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400967 error('Supposed to be called from aws, azure or vsphere demos only')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400968 }
969
970 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
971 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200972 netMap['vsphere'].each { clusterType, netConfig ->
973 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
974 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
975 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
976
977 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400978 lockLabels['vsphere_offline_networking_core_ci']++
979 } else {
980 lockLabels['vsphere_networking_core_ci']++
981 }
982 }
983
984 // generate lock metadata
985 def lockResources = []
986 lockLabels.each { label, quantity ->
987 if (quantity > 0) {
988 def res = [
989 label: label,
990 quantity: quantity,
991 ]
992 lockResources.add(res)
993 }
994 }
995
996 common.infoMsg("""Generated vsphere netMap: ${netMap}
997 Generated lockResources: ${lockResources}""")
998
999 return [
1000 netMap: netMap,
1001 lockResources: lockResources,
1002 ]
1003}
1004
1005/**
1006 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
1007 * and empty rangeConfig to the this map.
1008 *
Владислав Наумов33e1e812021-08-17 17:09:25 +02001009 * @param: netMap (string) vsphere, equinix netMap or empty map
1010 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001011 * @param: clusterType (string) Vsphere cluster type
1012 */
1013
Владислав Наумов33e1e812021-08-17 17:09:25 +02001014def addToProviderNetMap (netMap, provider, clusterType) {
1015 switch (provider) {
1016 case 'equinix':
1017 netMap[provider][clusterType] = [
1018 vlanConfig: '',
1019 ]
1020 break
1021 case 'vsphere':
1022 netMap[provider][clusterType] = [
1023 netName: 'default',
1024 rangeConfig: '',
1025 ]
1026 break
1027 default:
1028 error('Net map locks supported for Equinix/Vsphere providers only')
1029 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001030}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +03001031
1032/**
1033* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
1034* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
1035* If keyword contains only 'key' part then 'value' is boolean True.
1036* This function does not perform keywords validation.
1037* First line of a commit message is ignored.
1038* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
1039* TODO: Remove backslash chars from values if they prepend '[' or ']'.
1040**/
1041
1042List getCIKeywordsFromCommitMsg() {
1043 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
1044 List commitMsgLines = commitMsg.split('\n')
1045 List keywords = []
1046 if (commitMsgLines.size() < 2) {
1047 return keywords
1048 }
1049
1050 String commitMsgBody = commitMsgLines[1..-1].join('\n')
1051
1052 // Split commit message body to chunks using '[' or ']' as delimiter,
1053 // ignoring them if prepended by backslash (regex negative lookbehind).
1054 // Resulting list will have chunks between '[' and ']' at odd indexes.
1055 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
1056
1057 // Iterate chunks by odd indexes only, trim values and split to
1058 // <key> / <value> pair where <key> is the part of a sting before the first
1059 // whitespace delimiter, and <value> is the rest (may include whitespaces).
1060 // If there is no whitespace in the string then this is a 'switch'
1061 // and <value> will be boolean True.
1062 for (i = 1; i < parts.size(); i += 2) {
1063 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
1064 keywords.add(['key': key, 'value': value])
1065 }
1066
1067 return keywords
1068}
1069
1070/**
1071* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
1072* that were specified for given job name. `job-params` keyword has the following structure
1073*
1074* [job-params <job name> <parameter name> <parameter value>]
1075*
1076* Return value is a Map that contains those parameters using the following structure:
1077*
1078* <job name>:
1079* <parameter name>: <parameter value>
1080*
1081**/
1082Map getJobsParamsFromCommitMsg() {
1083 List keywords = getCIKeywordsFromCommitMsg()
1084
1085 List jobsParamsList = []
1086 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
1087 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
1088 def (key, value) = params.split(/\s+/, 2)
1089 ['name': name, 'key': key, 'value': value]
1090 }
1091
1092 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
1093 if (!result.containsKey(it.name)) {
1094 result[it.name] = [:]
1095 }
1096 result[it.name][it.key] = it.value
1097 result
1098 }
1099
1100 return jobsParams
1101}
1102
1103
1104/**
1105* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
1106* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
1107* uses only those parametes that were set to all jobs (with <job name> == '*') or to
1108* a particular job. Parameters set to a particular job have higher precedence.
1109*
1110* Return value is a Map that contains those parameters:
1111*
1112* <parameter name>: <parameter value>
1113*
1114**/
1115Map getJobParamsFromCommitMsg(String jobName) {
1116 jobsParams = getJobsParamsFromCommitMsg()
1117 jobParams = jobsParams.getOrDefault('*', [:])
1118 if (jobName) {
1119 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
1120 }
1121 return jobParams
1122}
azvyagintsevc17d14b2022-06-06 19:06:33 +03001123
1124/** Getting test scheme from text, which should be
1125Imput example:
1126text="""
1127 DATA
1128
1129 kaas_bm_test_schemas:
1130 KAAS_RELEASES_REFSPEC: ''
1131 KEY: VAL
1132
1133 DATA
1134 """
1135
1136 Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas'])
1137
1138 Return:
1139 ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL']
1140 **/
1141def parseTextForTestSchemas(Map opts) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001142 String text = opts.getOrDefault('text', '')
azvyagintsevc17d14b2022-06-06 19:06:33 +03001143 String keyLine = opts.getOrDefault('keyLine', '')
1144 Map testScheme = [:]
1145 if (!text || !keyLine) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001146 return testScheme
azvyagintsevc17d14b2022-06-06 19:06:33 +03001147 }
1148 if (text =~ /\n$keyLine\n.*/) {
1149 def common = new com.mirantis.mk.Common()
1150 try {
1151 String regExp = '\\n' + keyLine + '\\n'
1152 // regexep block must be followed by empty line
1153 testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}"
1154 common.infoMsg("parseTextForTestSchemas result:\n" + testScheme)
1155 common.mergeEnv(env, toJson(testScheme))
1156 }
1157 catch (Exception e) {
1158 common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}")
1159 throw e
1160 }
1161 }
azvyagintsevd96aac22022-06-10 14:23:26 +03001162 return testScheme
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +03001163}
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001164
1165
1166/**
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001167* getEquinixFacilityWithCapacity returns list of Equinix facilities using specified
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001168* instance type (nodeType), desired count of facilities (facilityCount) and
1169* instances (nodeCount) in a facility using specified matal version.
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001170* Function downloads metal CLI from the
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001171* https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux
1172* 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 +03001173* Non-empty list is shuffled.
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001174*
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001175* @param: facilityCount (int) Desired count of facilities
1176* @param: nodeCount (int) Desired count of instances
1177* @param: nodeType (string) Instance type
1178* @param: version (string) Metal version to use
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001179* @return ([]string) List of selected facilities
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001180*
1181**/
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001182def getEquinixFacilityWithCapacity(facilityCount = 1, nodeCount = 50, nodeType = 'c3.small.x86', version = '0.9.0') {
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001183 def common = new com.mirantis.mk.Common()
1184 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 +03001185 def metal = './metal --config metal.yaml'
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001186 def facility = []
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001187 def out = ''
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001188 def retries = 3 // number of retries
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001189 def i = 0
1190 def delay = 60 // 1 minute sleep
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001191 def excludeFacility = [] // list of facilities to exclude from selection
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001192 try {
Sergey Zhemerdeevb3575342022-10-04 11:02:19 +03001193 if (excludeFacility.size() > 0) {
1194 common.infoMsg("Excluded facilities: ${excludeFacility}")
1195 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001196 sh "curl -o metal -# ${metalUrl} && chmod +x metal"
1197 withCredentials([string(credentialsId: env.KAAS_EQUINIX_API_TOKEN, variable: 'KAAS_EQUINIX_API_TOKEN')]) {
1198 sh 'echo "project-id: ${KAAS_EQUINIX_PROJECT_ID}\ntoken: ${KAAS_EQUINIX_API_TOKEN}" >metal.yaml'
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001199 }
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001200 while (facility.size() < facilityCount && i < retries) {
1201 common.infoMsg("Selecting ${facilityCount} available Equinix facilities with free ${nodeCount} ${nodeType} hosts, try ${i+1}/${retries} ...")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001202 if (i > 0 ) { // skip sleep on first step
1203 sleep(delay)
1204 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001205 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()
1206 facility = out.tokenize(',')
Sergey Zhemerdeevb3575342022-10-04 11:02:19 +03001207 facility -= excludeFacility
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001208 if (facility.size() < facilityCount) {
1209 nodeCount -= 10
1210 // We need different metros for the [equinixmetalv2-child-diff-metro] case, facility[][0, 1] contains a metro name
1211 } else if (facility.size() == 2 && facility[0][0, 1] == facility[1][0, 1]) {
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001212 nodeCount -= 10
1213 }
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001214 i++
1215 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001216 if (facility.size() > 0) {
1217 f = facility.size() > 1 ? "${facility[0]},${facility[1]}" : "${facility[0]}"
1218 sh "${metal} capacity check -P ${nodeType} -f ${f} -q ${nodeCount}"
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001219 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001220 } catch (Exception e) {
1221 common.errorMsg "Exception: '${e}'"
1222 return []
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001223 } finally {
1224 sh 'rm metal.yaml'
1225 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001226 if (facility.size() > 0) {
Sergey Zhemerdeev15aa8602022-10-13 11:10:02 +03001227 Collections.shuffle(facility)
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001228 common.infoMsg("Selected facilities: ${facility}")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001229 } else {
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001230 common.warningMsg('No any facilities have been selected !!! :(')
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001231 }
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001232 return facility
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001233}
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001234
1235
1236/**
1237 * genCommandLine prepares command line for artifactory-replication
1238 * command using legacy environment variables
1239 *
1240 * @return: (string) Prepared command line
1241 */
1242def genCommandLine() {
1243 def envToParam = [
1244 'DESTINATION_USER': '-dst-user',
1245 'ARTIFACT_FILTER': '-artifact-filter',
1246 'ARTIFACT_FILTER_PROD': '-artifact-filter-prod',
1247 'ARTIFACT_TYPE': '-artifact-type',
1248 'BINARY_CLEAN': '-bin-cleanup',
1249 'BINARY_CLEAN_KEEP_DAYS': '-bin-clean-keep-days',
1250 'BINARY_CLEAN_PREFIX': '-bin-clean-prefix',
1251 'BUILD_URL': '-slack-build-url',
1252 'CHECK_REPOS': '-check-repos',
1253 'DESTINATION_REGISTRY': '-dst-repo',
1254 'DESTINATION_REGISTRY_TYPE': '-dst-repo-type',
1255 'DOCKER_CLEAN': '-cleanup',
1256 'DOCKER_REPO_PREFIX': '-docker-repo-prefix',
1257 'DOCKER_TAG': '-docker-tag',
1258 'FORCE': '-force',
1259 'HELM_CDN_DOMAIN': '-helm-cdn-domain',
1260 'SLACK_CHANNEL': '-slack-channel',
1261 'SLACK_USER': '-slack-user',
1262 'SOURCE_REGISTRY': '-src-repo',
1263 'SOURCE_REGISTRY_TYPE': '-src-repo-type',
1264 'SYNC_PATTERN': '-sync-pattern'
1265 ]
1266 def cmdParams = ''
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001267 def isCheckClean = false
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001268 for (e in envToParam) {
1269 if (env[e.key] == null) {
1270 continue
1271 }
1272 if (e.key == 'CHECK_REPOS' || e.key == 'DOCKER_CLEAN') {
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001273 // Avoid CHECK_REPOS=true and DOCKER_CLEAN=true
1274 if (env[e.key].toBoolean() && !isCheckClean) {
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001275 cmdParams += e.value + ' '
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001276 isCheckClean = true
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001277 }
1278 } else if (e.key == 'FORCE') {
1279 if (env[e.key].toBoolean()) {
1280 cmdParams += e.value + ' '
1281 }
1282 } else {
Sergey Zhemerdeeve2926cd2022-08-29 15:28:47 +03001283 cmdParams += "${e.value} '${env[e.key]}' "
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001284 }
1285 }
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001286 // No any check or clean was specified - take a default action
1287 if (!isCheckClean) {
1288 cmdParams += '-replicate'
1289 }
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001290 return cmdParams
1291}
Sergey Kolekonov0e60a942022-09-05 13:02:22 +04001292
1293/**
1294 * custom scheduling algorithm
1295 * it ensures that builds of the same job are distributed as much as possible between different nodes
1296 * @param label (string) desired node label
1297 * @return: (string) node name
1298 */
1299def schedule (label='docker') {
1300 def common = new com.mirantis.mk.Common()
1301 def freeNodes = []
1302 def nodesMap = [:]
1303
1304 // filter nodes with the specified label and at least one free executor
1305 timeout(time: 30, unit: 'MINUTES') {
1306 while (!freeNodes) {
1307 freeNodes = jenkins.model.Jenkins.instance.computers.findAll { node ->
1308 label in node.getAssignedLabels().collect { it.name } &&
Sergey Kolekonovd5887172022-11-10 12:13:22 +06001309 node.isPartiallyIdle() &&
1310 node.isOnline()
Sergey Kolekonov0e60a942022-09-05 13:02:22 +04001311 }
1312 if (!freeNodes) {
1313 echo 'No nodes available for scheduling, retrying...'
1314 sleep 30
1315 }
1316 }
1317 }
1318
1319 // generate a map of nodes matching other criteria
1320 for (node in freeNodes) {
1321 // sameJobExecutors is the number of executors running the same job as the calling one
1322 sameJobExecutors = node.getExecutors() // get all executors
1323 .collect { executor -> executor.getCurrentExecutable() } // get running "threads"
1324 .collect { thread -> thread?.displayName } // filter job names from threads
1325 .minus(null) // null = empty executors, remove them from the list
1326 .findAll { it.contains(env.JOB_NAME) } // filter the same jobs as the calling one
1327 .size()
1328
1329 // calculate busy executors, we don't want to count "sameJobExecutors" twice
1330 totalBusyExecutors = node.countBusy() - sameJobExecutors
1331 // generate the final map which contains nodes matching criteria with their load score
1332 // builds of the same jobs have x10 score, all others x1
1333 nodesMap += ["${node.getName()}" : sameJobExecutors * 10 + totalBusyExecutors]
1334 }
1335
1336 // return the least loaded node
1337 return common.SortMapByValueAsc(nodesMap).collect { it.key }[0]
1338}