blob: ab29e547f65034f23380f2b9d559d569aa81cbbb [file] [log] [blame]
vnaumov33747e12020-05-04 17:35:20 +02001package com.mirantis.mk
vnaumov33747e12020-05-04 17:35:20 +02002
3/**
4 *
5 * KaaS Component Testing Utilities
6 *
7 */
8
Владислав Наумовe5345812020-08-12 16:30:20 +02009/**
10 * Check KaaS Core CICD feature flags
11 * such triggers can be used in case of switching between pipelines,
12 * conditions inside pipelines to reduce dependency on jenkins job builder and jenkins job templates itself
13 *
14 * @return (map)[
15 * ffNameEnabled: (bool) True/False
16 * ]
17 */
18def checkCoreCIFeatureFlags() {
19 def common = new com.mirantis.mk.Common()
20 def ff = [
21 build_artifacts_upgrade: false,
22 ]
23
24 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
25 if (commitMsg ==~ /(?s).*\[ci-build-artifacts-upgrade\].*/) {
26 ff['build_artifacts_upgrade'] = true
27 }
28
29 common.infoMsg("Core ci feature flags status: ${ff}")
30 return ff
31}
vnaumov33747e12020-05-04 17:35:20 +020032
33/**
azvyagintseva12230a2020-06-05 13:24:06 +030034 * Determine scope of test suite against per-commit KaaS deployment based on keywords
Владислав Наумов81777472021-03-09 15:14:27 +040035 * 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 +030036 *
37 * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs
38 * Example scheme:
Владислав Наумовe5345812020-08-12 16:30:20 +020039 * 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 +030040 * manage test-suite through Jenkins Job Parameters
41 *
Владислав Наумов6c2afff2020-06-05 12:54:53 +020042 * @return (map)[
43 * deployChildEnabled: (bool) True if need to deploy child cluster during demo-run
44 * runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run
azvyagintseva12230a2020-06-05 13:24:06 +030045 * ]
46 */
vnaumov33747e12020-05-04 17:35:20 +020047def checkDeploymentTestSuite() {
vnaumovbdb90222020-05-04 18:25:50 +020048 def common = new com.mirantis.mk.Common()
49
vnaumov33747e12020-05-04 17:35:20 +020050 // Available triggers and its sane defaults
Владислав Наумов44c64b72020-12-04 20:22:53 +010051 def seedMacOs = env.SEED_MACOS ? env.SEED_MACOS.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020052 def deployChild = env.DEPLOY_CHILD_CLUSTER ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false
53 def upgradeChild = env.UPGRADE_CHILD_CLUSTER ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false
Mikhail Ivanov74504372021-05-21 17:01:06 +040054 def customChildRelease = env.KAAS_CHILD_CLUSTER_RELEASE_NAME ? env.KAAS_CHILD_CLUSTER_RELEASE_NAME : ''
Владислав Наумов0dc99252020-11-13 13:30:48 +010055 def attachBYO = env.ATTACH_BYO ? env.ATTACH_BYO.toBoolean() : false
Владислав Наумовcdbd84e2020-12-01 16:51:09 +010056 def upgradeBYO = env.UPGRADE_BYO ? env.UPGRADE_BYO.toBoolean() : false
Vladislav Naumov7930ab22021-11-22 18:24:24 +010057 def runBYOMatrix = env.RUN_BYO_MATRIX ? env.RUN_BYO_MATRIX.toBoolean() : false
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +040058 def defaultBYOOs = env.DEFAULT_BYO_OS ? env.DEFAULT_BYO_OS.toString() : 'ubuntu'
Владислав Наумов6c2afff2020-06-05 12:54:53 +020059 def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +040060 def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020061 def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
62 def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
Владислав Наумов9cec55d2021-08-03 15:00:59 +020063 def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +020064 def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020065 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
66 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Vladislav Naumov42b71dc2021-11-22 13:09:42 +010067 def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false
slalov13e579c2022-01-31 21:37:02 +040068 def runMaintenanceTest = env.RUN_MAINTENANCE_TEST ? env.RUN_MAINTENANCE_TEST.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020069 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
70 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
71 enabled: false,
72 managementLocation: '',
73 regionLocation: '',
74 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020075
Владислав Наумовb8305e22021-02-10 17:23:12 +010076 // proxy customization
77 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020078 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
79 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020080 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010081 ]
82
Владислав Наумов4eb1da32020-08-31 14:45:16 +020083 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020084 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +020085 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +020086 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +020087 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +020088 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +020089 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +040090 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +020091 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +030092 def enableBMDemo = true
Mikhail Ivanovb6283f72021-11-24 18:34:57 +040093 def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
vnaumov33747e12020-05-04 17:35:20 +020094
Владислав Наумов6c2afff2020-06-05 12:54:53 +020095 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +010096 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
97 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +020098 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 +010099 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100100 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
101 seedMacOs = true
102 }
vnaumov33747e12020-05-04 17:35:20 +0200103 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) {
104 deployChild = true
105 }
106 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
107 deployChild = true
108 upgradeChild = true
109 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400110 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
111 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400112 // override child version when it set explicitly
113 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400114 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400115 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
116 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100117 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
118 attachBYO = true
119 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100120 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
121 attachBYO = true
122 upgradeBYO = true
123 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400124
125 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
126 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 +0100127 runBYOMatrix = true
128
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400129 if (byoDeployMatches.size() > 0) {
130 defaultBYOOs = byoDeployMatches[0][2]
131 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
132 }
133
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100134 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
135 attachBYO = false
136 upgradeBYO = false
137 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400138 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200139 upgradeMgmt = true
140 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400141 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
142 enableLMALogging = true
143 }
vnaumov33747e12020-05-04 17:35:20 +0200144 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
145 runUie2e = true
146 }
147 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
148 runMgmtConformance = true
149 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200150 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
151 runMgmtUserControllerTest = true
152 }
vnaumov33747e12020-05-04 17:35:20 +0200153 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
154 runChildConformance = true
155 deployChild = true
156 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200157 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
158 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400159 enableLMALogging = true
160 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400161 }
slalov13e579c2022-01-31 21:37:02 +0400162 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
163 runMaintenanceTest = true
164 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200165 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
166 proxyConfig['childOffline'] = true
167 deployChild = true
168 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200169 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
170 proxyConfig['childOffline'] = true
171 proxyConfig['childProxy'] = true
172 deployChild = true
173 }
vnaumov33747e12020-05-04 17:35:20 +0200174 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
175 fetchServiceBinaries = true
176 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200177 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400178 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200179 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 +0400180 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200181 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
182 azureOnAwsDemo = true
183 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
184 }
185 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
186 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
187 attachBYO ||
188 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100189 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200190 seedMacOs ||
191 equinixOnAwsDemo ||
192 azureOnAwsDemo) {
193
vnaumov33747e12020-05-04 17:35:20 +0200194 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200195 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 +0200196 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200197 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200198 equinixOnDemandDemo = true
199 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200200 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200201 equinixMetalV2OnDemandDemo = true
202 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100203 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
204 equinixMetalV2OnDemandDemo = true
205 equinixMetalV2ChildDiffMetro = true
206 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200207 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
208 azureOnDemandDemo = true
209 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200210 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
211 enableOSDemo = false
212 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200213 }
214
azvyagintsev1761bdc2020-09-04 17:24:12 +0300215 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
216 enableBMDemo = false
217 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
218 }
219
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400220 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
221 enableVsphereDemo = false
222 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
223 }
224
vnaumov33747e12020-05-04 17:35:20 +0200225 // TODO (vnaumov) remove below condition after moving all releases to UCP
226 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
227 if (ucpChildMatches.size() > 0) {
228 deployChild = true
229 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
230
231 // TODO(vnaumov) delete after ucp upgrades support
232 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
233 upgradeChild = false
234 }
235
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200236 // multiregional tests
237 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
238 if (multiRegionalMatches.size() > 0) {
239 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
240 }
241 switch (multiregionalMappings['managementLocation']) {
242 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100243 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200244 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100245
246 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
247 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
248 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200249 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200250 case 'os':
251 if (enableOSDemo == false) {
252 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
253 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200254 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200255 case 'vsphere':
256 if (enableVsphereDemo == false) {
257 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
258 }
259 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200260 case 'equinix':
261 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
262 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400263 break
eromanova8c702ae2021-12-24 17:43:12 +0400264 case 'equinixmetalv2':
265 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
266 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400267 break
slalovfd0b7e62021-07-28 18:05:16 +0400268 case 'azure':
269 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
270 azureOnDemandDemo = true
271 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200272 }
273
Владислав Наумовb8305e22021-02-10 17:23:12 +0100274 // CDN configuration
275 def cdnConfig = [
276 mgmt: [
277 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200278 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100279 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200280 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200281 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200282 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100283 ]
284
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400285 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
286 openstackIMC = 'eu'
287 // use internal-eu because on internal-ci with eu cloud image pull takes much time
288 def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
289 common.infoMsg("eu-demo was triggered, force switching CDN region to ${cdnRegion}")
290 cdnConfig['mgmt']['openstack'] = cdnRegion
291 }
292
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100293 // calculate weight of current demo run to manage lockable resources
294 def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1
295
vnaumov33747e12020-05-04 17:35:20 +0200296 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400297 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100298 CDN deployment configuration: ${cdnConfig}
299 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100300 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200301 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400302 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200303 Child cluster release upgrade scheduled: ${upgradeChild}
304 Child conformance testing scheduled: ${runChildConformance}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100305 Single BYO cluster attachment scheduled: ${attachBYO}
306 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
307 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400308 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200309 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400310 Mgmt LMA logging enabled: ${enableLMALogging}
vnaumov33747e12020-05-04 17:35:20 +0200311 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200312 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200313 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200314 Mgmt UI e2e testing scheduled: ${runUie2e}
slalov13e579c2022-01-31 21:37:02 +0400315 Maintenance test: ${runMaintenanceTest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200316 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200317 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200318 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100319 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200320 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200321 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200322 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400323 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200324 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300325 BM provider deployment scheduled: ${enableBMDemo}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200326 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200327 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100328 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Владислав Наумов81777472021-03-09 15:14:27 +0400329 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200330 return [
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400331 osCloudLocation : openstackIMC,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100332 cdnConfig : cdnConfig,
333 proxyConfig : proxyConfig,
334 useMacOsSeedNode : seedMacOs,
335 deployChildEnabled : deployChild,
336 childDeployCustomRelease : customChildRelease,
337 upgradeChildEnabled : upgradeChild,
338 runChildConformanceEnabled : runChildConformance,
339 attachBYOEnabled : attachBYO,
340 upgradeBYOEnabled : upgradeBYO,
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100341 runBYOMatrixEnabled : runBYOMatrix,
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400342 defaultBYOOs : defaultBYOOs,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100343 upgradeMgmtEnabled : upgradeMgmt,
344 enableLMALoggingEnabled : enableLMALogging,
345 runUie2eEnabled : runUie2e,
346 runMgmtConformanceEnabled : runMgmtConformance,
slalov13e579c2022-01-31 21:37:02 +0400347 runMaintenanceTestEnable : runMaintenanceTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100348 runLMATestEnabled : runLMATest,
349 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
350 fetchServiceBinariesEnabled : fetchServiceBinaries,
351 awsOnDemandDemoEnabled : awsOnDemandDemo,
352 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
353 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
354 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
355 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
356 azureOnDemandDemoEnabled : azureOnDemandDemo,
357 azureOnAwsDemoEnabled : azureOnAwsDemo,
358 vsphereDemoEnabled : enableVsphereDemo,
359 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
360 bmDemoEnabled : enableBMDemo,
361 osDemoEnabled : enableOSDemo,
362 multiregionalConfiguration : multiregionalMappings,
363 demoWeight : demoWeight]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200364}
365
366/**
367 * Determine management and regional setup for demo workflow scenario
368 *
369 *
370 * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]`
371 or Jenkins environment string variable in form like 'aws,os'
372 * @return (map)[
373 enabled: (bool),
374 * managementLocation: (string), //aws,os
375 * regionLocation: (string), //aws,os
376 * ]
377 */
378def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200379 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400380 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
381 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200382
383 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200384 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200385 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
386 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
387 } else {
388 common.infoMsg('Multiregion definition configured via environment variable')
389 clusterTypes = keyword.trim().split(',')
390 }
391
392 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100393 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200394 }
395
Владислав Наумовf793fe32020-09-11 15:19:19 +0200396 def desiredManagementProvider = clusterTypes[0].trim()
397 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200398 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
399 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200400 management providers list - ${supportedManagementProviders}
401 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200402 }
403
404 return [
405 enabled: true,
406 managementLocation: desiredManagementProvider,
407 regionLocation: desiredRegionalProvider,
408 ]
vnaumov33747e12020-05-04 17:35:20 +0200409}
410
411/**
412 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
413
Владислав Наумов81777472021-03-09 15:14:27 +0400414 * 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 +0200415 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
416 * Example scheme:
417 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
418 * manage refspecs through Jenkins Job Parameters
419 *
azvyagintseva12230a2020-06-05 13:24:06 +0300420 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200421 * siPipelines: (string) final refspec for si-pipelines
422 * ]
423 */
424def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200425 def common = new com.mirantis.mk.Common()
426
vnaumov33747e12020-05-04 17:35:20 +0200427 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200428 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
429 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200430 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
431 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200432 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200433
434 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
435 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
436
437 if (siTestMatches.size() > 0) {
438 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400439 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200440 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200441 }
442 if (siPipelinesMatches.size() > 0) {
443 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
444 }
445
446 common.infoMsg("""
447 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
448 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200449 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400450 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200451 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200452}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200453
Владислав Наумов9080f372020-06-08 13:57:16 +0200454/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200455 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200456 * @param configurationFile (str) path to configuration file in yaml format
457 *
458 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
459 * ]
460 */
461def parseKaaSComponentCIParameters(configurationFile){
462 def common = new com.mirantis.mk.Common()
463 def ciConfig = readYaml file: configurationFile
464 def ciSpec = [
465 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
466 ]
467
468 if (ciConfig.containsKey('si-tests-feature-flags')) {
469 common.infoMsg("""SI tests feature flags customization detected,
470 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
471
472 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
473 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200474
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200475 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200476 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
477 }
478
479 common.infoMsg("""Additional ci configuration parsed successfully:
480 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
481 return ciSpec
482}
483
484/**
485 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200486
Владислав Наумов81777472021-03-09 15:14:27 +0400487 * 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 +0200488 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
489 * Example scheme:
490 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
491 * manage refspecs through Jenkins Job Parameters
492 *
493 * @return (map)[ core: (string) final refspec for kaas/core
494 * corePipelines: (string) final refspec for pipelines in kaas/core
495 * ]
496 */
497def checkCustomCoreRefspec() {
498 def common = new com.mirantis.mk.Common()
499
500 // Available triggers and its sane defaults
501 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
502 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
503 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
504 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
505
506 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
507 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
508
509 if (coreMatches.size() > 0) {
510 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
511 }
512 if (corePipelinesMatches.size() > 0) {
513 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
514 }
515
516 common.infoMsg("""
517 kaas/core will be fetched from: ${coreRefspec}
518 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400519 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200520 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
521}
522
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200523
524/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200525 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
526 * needed to forward inside kaas core set of jobs
527 *
528 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
529 * @return (list)[ string(name: '', value: ''),
530 * ]
531 */
532def generateKaaSVarsFromContext(context) {
533 def common = new com.mirantis.mk.Common()
534 def parameters = []
535 def config = readYaml text: context
536
537 config.each { k,v ->
538 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
539 parameters.add(string(name: k, value: v))
540 }
541
542 return parameters
543}
544
545/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200546 * 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 +0400547 * 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 +0200548 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
549 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200550 * @param: component (string) component name [iam, lcm, stacklight]
551 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
552 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200553 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200554def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200555 def common = new com.mirantis.mk.Common()
556 // Determine if custom trigger keywords forwarded from gerrit
557 def triggers = checkDeploymentTestSuite()
558 // Determine SI refspecs
559 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200560 // Determine Core refspecs
561 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200562
Владислав Наумов418042b2020-07-09 18:31:10 +0200563 // Determine component repo ci configuration
564 def ciSpec = [:]
565 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
566 if (fileExists(configurationFile)) {
567 common.infoMsg('Component CI configuration file detected, parsing...')
568 ciSpec = parseKaaSComponentCIParameters(configurationFile)
569 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
570 } else {
571 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200572 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200573 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
574 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200575 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400576
577 def platforms = []
578 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
579 // Currently only vsphere demo is required for IPAM component
580 platforms.add('vsphere')
581 } else {
582 if (triggers.osDemoEnabled) {
583 platforms.add('openstack')
584 }
585 if (triggers.awsOnDemandDemoEnabled) {
586 platforms.add('aws')
587 }
588 if (triggers.equinixOnDemandDemoEnabled) {
589 platforms.add('equinix')
590 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200591 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
592 platforms.add('equinixmetalv2')
593 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200594 if (triggers.azureOnDemandDemoEnabled) {
595 platforms.add('azure')
596 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400597 if (triggers.vsphereDemoEnabled) {
598 platforms.add('vsphere')
599 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400600 }
601
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200602 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200603 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200604 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
605 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200606 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200607 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200608 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
609 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200610 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200611 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400612 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400613 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100614 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200615 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200616 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100617 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200618 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400619 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200620 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200621 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
slalov13e579c2022-01-31 21:37:02 +0400622 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnable),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200623 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200624 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200625 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
626 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100627 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100628 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100629 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200630 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400631 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200632 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200633 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100634 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400635 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200636 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200637 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200638 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200639
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200640 // customize multiregional demo
641 if (triggers.multiregionalConfiguration.enabled) {
642 parameters.add(string(name: 'MULTIREGION_SETUP',
643 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
644 ))
645 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200646
Владислав Наумов92288d92020-07-13 18:36:21 +0200647 // Determine component team custom context
648 if (coreContext != '') {
649 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
650 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200651 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200652 }
653
Владислав Наумовaa430612020-06-08 17:18:31 +0200654 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400655
656 platforms.each { platform ->
657 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000658 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400659 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
660 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
661 def build_description = job_info.getDescription()
662 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000663 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200664
Vladislav Naumov5313a202021-04-07 17:13:39 +0000665 if (build_description) {
666 currentBuild.description += build_description
667 }
668 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400669 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000670 }
671 }
672 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200673
674 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400675 if (jobs.size() == 0) {
676 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
677 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200678 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
679 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200680
681 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200682 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200683 currentBuild.result = 'FAILURE'
684 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200685}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200686
687
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400688/**
689 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200690 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400691 *
692 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
693 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
694 * @param: multiregionalConfiguration (map) Multiregional configuration
695 * @return (map) Return aggregated map with lockResources and netMap
696 */
697
698
699def generateLockResources(callBackDemo, triggers) {
700 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200701 def netMap = [
702 vsphere: [:],
703 equinix: [:],
704 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400705 // Define vsphere locklabels with initial quantity
706 def lockLabels = [
707 vsphere_networking_core_ci: 0,
708 vsphere_offline_networking_core_ci: 0,
709 ]
710 def deployChild = triggers.deployChildEnabled
711 def multiregionConfig = triggers.multiregionalConfiguration
712 def runMultiregion = multiregionConfig.enabled
713
714 // Generate vsphere netMap and lockLabels based on demo context
715 switch (callBackDemo) {
716 case 'aws':
717 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
718 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
719
720 // Define netMap for Vsphere region
Владислав Наумовf60480d2021-10-15 14:04:01 +0200721 if (runMultiregion && multiregionConfig.managementLocation == 'aws' &&
722 multiregionConfig.regionLocation == 'vsphere') {
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400723 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200724 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400725 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200726 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400727 }
728 break
729 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200730 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400731 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200732 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400733 }
734 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
735 multiregionConfig.regionLocation == 'vsphere') {
736 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200737 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400738 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200739 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400740 }
741 break
742 default:
743 error('Supposed to be called from aws or vsphere demos only')
744 }
745
746 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
747 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200748 netMap['vsphere'].each { clusterType, netConfig ->
749 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
750 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
751 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
752
753 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400754 lockLabels['vsphere_offline_networking_core_ci']++
755 } else {
756 lockLabels['vsphere_networking_core_ci']++
757 }
758 }
759
760 // generate lock metadata
761 def lockResources = []
762 lockLabels.each { label, quantity ->
763 if (quantity > 0) {
764 def res = [
765 label: label,
766 quantity: quantity,
767 ]
768 lockResources.add(res)
769 }
770 }
771
772 common.infoMsg("""Generated vsphere netMap: ${netMap}
773 Generated lockResources: ${lockResources}""")
774
775 return [
776 netMap: netMap,
777 lockResources: lockResources,
778 ]
779}
780
781/**
782 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
783 * and empty rangeConfig to the this map.
784 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200785 * @param: netMap (string) vsphere, equinix netMap or empty map
786 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400787 * @param: clusterType (string) Vsphere cluster type
788 */
789
Владислав Наумов33e1e812021-08-17 17:09:25 +0200790def addToProviderNetMap (netMap, provider, clusterType) {
791 switch (provider) {
792 case 'equinix':
793 netMap[provider][clusterType] = [
794 vlanConfig: '',
795 ]
796 break
797 case 'vsphere':
798 netMap[provider][clusterType] = [
799 netName: 'default',
800 rangeConfig: '',
801 ]
802 break
803 default:
804 error('Net map locks supported for Equinix/Vsphere providers only')
805 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400806}