blob: df5c51b75f2839727bd5b7cfc51a2f722f804cd7 [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
Владислав Наумов6c2afff2020-06-05 12:54:53 +020058 def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +040059 def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020060 def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
61 def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
Владислав Наумов9cec55d2021-08-03 15:00:59 +020062 def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +020063 def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020064 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
65 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Vladislav Naumov42b71dc2021-11-22 13:09:42 +010066 def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020067 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
68 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
69 enabled: false,
70 managementLocation: '',
71 regionLocation: '',
72 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020073
Владислав Наумовb8305e22021-02-10 17:23:12 +010074 // proxy customization
75 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020076 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
77 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020078 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010079 ]
80
Владислав Наумов4eb1da32020-08-31 14:45:16 +020081 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020082 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +020083 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +020084 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +020085 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +020086 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +020087 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +040088 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +020089 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +030090 def enableBMDemo = true
Mikhail Ivanovb6283f72021-11-24 18:34:57 +040091 def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
vnaumov33747e12020-05-04 17:35:20 +020092
Владислав Наумов6c2afff2020-06-05 12:54:53 +020093 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +010094 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
95 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +020096 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 +010097 }
Владислав Наумов44c64b72020-12-04 20:22:53 +010098 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
99 seedMacOs = true
100 }
vnaumov33747e12020-05-04 17:35:20 +0200101 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) {
102 deployChild = true
103 }
104 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
105 deployChild = true
106 upgradeChild = true
107 }
Mikhail Ivanov76d69952021-06-04 16:06:45 +0400108 def deployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
Mikhail Ivanov74504372021-05-21 17:01:06 +0400109 if (deployMatches.size() > 0) {
110 // override child version when it set explicitly
111 deployChild = true
Mikhail Ivanoved543492021-05-24 16:26:55 +0400112 customChildRelease = deployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400113 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
114 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100115 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
116 attachBYO = true
117 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100118 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
119 attachBYO = true
120 upgradeBYO = true
121 }
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100122 if (commitMsg ==~ /(?s).*\[run-byo-matrix\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*run-byo-matrix\.*/) {
123 runBYOMatrix = true
124
125 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
126 attachBYO = false
127 upgradeBYO = false
128 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400129 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200130 upgradeMgmt = true
131 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400132 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
133 enableLMALogging = true
134 }
vnaumov33747e12020-05-04 17:35:20 +0200135 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
136 runUie2e = true
137 }
138 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
139 runMgmtConformance = true
140 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200141 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
142 runMgmtUserControllerTest = true
143 }
vnaumov33747e12020-05-04 17:35:20 +0200144 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
145 runChildConformance = true
146 deployChild = true
147 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200148 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
149 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400150 enableLMALogging = true
151 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400152 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200153 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
154 proxyConfig['childOffline'] = true
155 deployChild = true
156 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200157 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
158 proxyConfig['childOffline'] = true
159 proxyConfig['childProxy'] = true
160 deployChild = true
161 }
vnaumov33747e12020-05-04 17:35:20 +0200162 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
163 fetchServiceBinaries = true
164 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200165 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400166 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200167 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 +0400168 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200169 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
170 azureOnAwsDemo = true
171 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
172 }
173 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
174 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
175 attachBYO ||
176 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100177 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200178 seedMacOs ||
179 equinixOnAwsDemo ||
180 azureOnAwsDemo) {
181
vnaumov33747e12020-05-04 17:35:20 +0200182 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200183 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 +0200184 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200185 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200186 equinixOnDemandDemo = true
187 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200188 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200189 equinixMetalV2OnDemandDemo = true
190 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100191 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
192 equinixMetalV2OnDemandDemo = true
193 equinixMetalV2ChildDiffMetro = true
194 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200195 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
196 azureOnDemandDemo = true
197 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200198 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
199 enableOSDemo = false
200 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200201 }
202
azvyagintsev1761bdc2020-09-04 17:24:12 +0300203 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
204 enableBMDemo = false
205 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
206 }
207
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400208 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
209 enableVsphereDemo = false
210 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
211 }
212
vnaumov33747e12020-05-04 17:35:20 +0200213 // TODO (vnaumov) remove below condition after moving all releases to UCP
214 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
215 if (ucpChildMatches.size() > 0) {
216 deployChild = true
217 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
218
219 // TODO(vnaumov) delete after ucp upgrades support
220 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
221 upgradeChild = false
222 }
223
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200224 // multiregional tests
225 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
226 if (multiRegionalMatches.size() > 0) {
227 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
228 }
229 switch (multiregionalMappings['managementLocation']) {
230 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100231 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200232 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100233
234 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
235 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
236 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200237 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200238 case 'os':
239 if (enableOSDemo == false) {
240 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
241 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200242 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200243 case 'vsphere':
244 if (enableVsphereDemo == false) {
245 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
246 }
247 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200248 case 'equinix':
249 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
250 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400251 break
eromanova8c702ae2021-12-24 17:43:12 +0400252 case 'equinixmetalv2':
253 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
254 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400255 break
slalovfd0b7e62021-07-28 18:05:16 +0400256 case 'azure':
257 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
258 azureOnDemandDemo = true
259 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200260 }
261
Владислав Наумовb8305e22021-02-10 17:23:12 +0100262 // CDN configuration
263 def cdnConfig = [
264 mgmt: [
265 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200266 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100267 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200268 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200269 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200270 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100271 ]
272
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400273 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
274 openstackIMC = 'eu'
275 // use internal-eu because on internal-ci with eu cloud image pull takes much time
276 def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
277 common.infoMsg("eu-demo was triggered, force switching CDN region to ${cdnRegion}")
278 cdnConfig['mgmt']['openstack'] = cdnRegion
279 }
280
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100281 // calculate weight of current demo run to manage lockable resources
282 def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1
283
vnaumov33747e12020-05-04 17:35:20 +0200284 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400285 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100286 CDN deployment configuration: ${cdnConfig}
287 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100288 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200289 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400290 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200291 Child cluster release upgrade scheduled: ${upgradeChild}
292 Child conformance testing scheduled: ${runChildConformance}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100293 Single BYO cluster attachment scheduled: ${attachBYO}
294 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
295 BYO test matrix whole suite scheduled: ${runBYOMatrix}
vnaumov33747e12020-05-04 17:35:20 +0200296 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400297 Mgmt LMA logging enabled: ${enableLMALogging}
vnaumov33747e12020-05-04 17:35:20 +0200298 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200299 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200300 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200301 Mgmt UI e2e testing scheduled: ${runUie2e}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200302 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200303 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200304 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100305 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200306 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200307 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200308 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400309 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200310 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300311 BM provider deployment scheduled: ${enableBMDemo}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200312 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200313 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100314 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Владислав Наумов81777472021-03-09 15:14:27 +0400315 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200316 return [
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400317 osCloudLocation : openstackIMC,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100318 cdnConfig : cdnConfig,
319 proxyConfig : proxyConfig,
320 useMacOsSeedNode : seedMacOs,
321 deployChildEnabled : deployChild,
322 childDeployCustomRelease : customChildRelease,
323 upgradeChildEnabled : upgradeChild,
324 runChildConformanceEnabled : runChildConformance,
325 attachBYOEnabled : attachBYO,
326 upgradeBYOEnabled : upgradeBYO,
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100327 runBYOMatrixEnabled : runBYOMatrix,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100328 upgradeMgmtEnabled : upgradeMgmt,
329 enableLMALoggingEnabled : enableLMALogging,
330 runUie2eEnabled : runUie2e,
331 runMgmtConformanceEnabled : runMgmtConformance,
332 runLMATestEnabled : runLMATest,
333 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
334 fetchServiceBinariesEnabled : fetchServiceBinaries,
335 awsOnDemandDemoEnabled : awsOnDemandDemo,
336 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
337 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
338 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
339 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
340 azureOnDemandDemoEnabled : azureOnDemandDemo,
341 azureOnAwsDemoEnabled : azureOnAwsDemo,
342 vsphereDemoEnabled : enableVsphereDemo,
343 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
344 bmDemoEnabled : enableBMDemo,
345 osDemoEnabled : enableOSDemo,
346 multiregionalConfiguration : multiregionalMappings,
347 demoWeight : demoWeight]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200348}
349
350/**
351 * Determine management and regional setup for demo workflow scenario
352 *
353 *
354 * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]`
355 or Jenkins environment string variable in form like 'aws,os'
356 * @return (map)[
357 enabled: (bool),
358 * managementLocation: (string), //aws,os
359 * regionLocation: (string), //aws,os
360 * ]
361 */
362def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200363 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400364 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
365 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200366
367 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200368 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200369 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
370 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
371 } else {
372 common.infoMsg('Multiregion definition configured via environment variable')
373 clusterTypes = keyword.trim().split(',')
374 }
375
376 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100377 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200378 }
379
Владислав Наумовf793fe32020-09-11 15:19:19 +0200380 def desiredManagementProvider = clusterTypes[0].trim()
381 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200382 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
383 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200384 management providers list - ${supportedManagementProviders}
385 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200386 }
387
388 return [
389 enabled: true,
390 managementLocation: desiredManagementProvider,
391 regionLocation: desiredRegionalProvider,
392 ]
vnaumov33747e12020-05-04 17:35:20 +0200393}
394
395/**
396 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
397
Владислав Наумов81777472021-03-09 15:14:27 +0400398 * 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 +0200399 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
400 * Example scheme:
401 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
402 * manage refspecs through Jenkins Job Parameters
403 *
azvyagintseva12230a2020-06-05 13:24:06 +0300404 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200405 * siPipelines: (string) final refspec for si-pipelines
406 * ]
407 */
408def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200409 def common = new com.mirantis.mk.Common()
410
vnaumov33747e12020-05-04 17:35:20 +0200411 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200412 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
413 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200414 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
415 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200416 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200417
418 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
419 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
420
421 if (siTestMatches.size() > 0) {
422 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400423 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200424 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200425 }
426 if (siPipelinesMatches.size() > 0) {
427 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
428 }
429
430 common.infoMsg("""
431 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
432 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200433 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400434 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200435 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200436}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200437
Владислав Наумов9080f372020-06-08 13:57:16 +0200438/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200439 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200440 * @param configurationFile (str) path to configuration file in yaml format
441 *
442 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
443 * ]
444 */
445def parseKaaSComponentCIParameters(configurationFile){
446 def common = new com.mirantis.mk.Common()
447 def ciConfig = readYaml file: configurationFile
448 def ciSpec = [
449 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
450 ]
451
452 if (ciConfig.containsKey('si-tests-feature-flags')) {
453 common.infoMsg("""SI tests feature flags customization detected,
454 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
455
456 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
457 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200458
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200459 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200460 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
461 }
462
463 common.infoMsg("""Additional ci configuration parsed successfully:
464 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
465 return ciSpec
466}
467
468/**
469 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200470
Владислав Наумов81777472021-03-09 15:14:27 +0400471 * 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 +0200472 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
473 * Example scheme:
474 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
475 * manage refspecs through Jenkins Job Parameters
476 *
477 * @return (map)[ core: (string) final refspec for kaas/core
478 * corePipelines: (string) final refspec for pipelines in kaas/core
479 * ]
480 */
481def checkCustomCoreRefspec() {
482 def common = new com.mirantis.mk.Common()
483
484 // Available triggers and its sane defaults
485 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
486 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
487 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
488 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
489
490 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
491 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
492
493 if (coreMatches.size() > 0) {
494 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
495 }
496 if (corePipelinesMatches.size() > 0) {
497 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
498 }
499
500 common.infoMsg("""
501 kaas/core will be fetched from: ${coreRefspec}
502 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400503 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200504 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
505}
506
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200507
508/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200509 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
510 * needed to forward inside kaas core set of jobs
511 *
512 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
513 * @return (list)[ string(name: '', value: ''),
514 * ]
515 */
516def generateKaaSVarsFromContext(context) {
517 def common = new com.mirantis.mk.Common()
518 def parameters = []
519 def config = readYaml text: context
520
521 config.each { k,v ->
522 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
523 parameters.add(string(name: k, value: v))
524 }
525
526 return parameters
527}
528
529/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200530 * 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 +0400531 * 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 +0200532 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
533 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200534 * @param: component (string) component name [iam, lcm, stacklight]
535 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
536 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200537 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200538def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200539 def common = new com.mirantis.mk.Common()
540 // Determine if custom trigger keywords forwarded from gerrit
541 def triggers = checkDeploymentTestSuite()
542 // Determine SI refspecs
543 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200544 // Determine Core refspecs
545 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200546
Владислав Наумов418042b2020-07-09 18:31:10 +0200547 // Determine component repo ci configuration
548 def ciSpec = [:]
549 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
550 if (fileExists(configurationFile)) {
551 common.infoMsg('Component CI configuration file detected, parsing...')
552 ciSpec = parseKaaSComponentCIParameters(configurationFile)
553 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
554 } else {
555 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200556 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200557 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
558 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200559 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400560
561 def platforms = []
562 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
563 // Currently only vsphere demo is required for IPAM component
564 platforms.add('vsphere')
565 } else {
566 if (triggers.osDemoEnabled) {
567 platforms.add('openstack')
568 }
569 if (triggers.awsOnDemandDemoEnabled) {
570 platforms.add('aws')
571 }
572 if (triggers.equinixOnDemandDemoEnabled) {
573 platforms.add('equinix')
574 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200575 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
576 platforms.add('equinixmetalv2')
577 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200578 if (triggers.azureOnDemandDemoEnabled) {
579 platforms.add('azure')
580 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400581 if (triggers.vsphereDemoEnabled) {
582 platforms.add('vsphere')
583 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400584 }
585
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200586 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200587 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200588 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
589 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200590 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200591 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200592 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
593 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200594 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200595 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400596 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400597 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100598 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200599 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200600 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100601 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200602 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400603 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200604 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200605 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200606 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200607 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200608 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
609 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100610 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100611 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100612 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200613 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400614 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200615 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200616 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100617 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400618 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200619 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200620 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200621 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200622
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200623 // customize multiregional demo
624 if (triggers.multiregionalConfiguration.enabled) {
625 parameters.add(string(name: 'MULTIREGION_SETUP',
626 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
627 ))
628 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200629
Владислав Наумов92288d92020-07-13 18:36:21 +0200630 // Determine component team custom context
631 if (coreContext != '') {
632 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
633 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200634 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200635 }
636
Владислав Наумовaa430612020-06-08 17:18:31 +0200637 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400638
639 platforms.each { platform ->
640 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000641 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400642 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
643 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
644 def build_description = job_info.getDescription()
645 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000646 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200647
Vladislav Naumov5313a202021-04-07 17:13:39 +0000648 if (build_description) {
649 currentBuild.description += build_description
650 }
651 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400652 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000653 }
654 }
655 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200656
657 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400658 if (jobs.size() == 0) {
659 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
660 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200661 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
662 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200663
664 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200665 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200666 currentBuild.result = 'FAILURE'
667 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200668}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200669
670
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400671/**
672 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200673 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400674 *
675 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
676 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
677 * @param: multiregionalConfiguration (map) Multiregional configuration
678 * @return (map) Return aggregated map with lockResources and netMap
679 */
680
681
682def generateLockResources(callBackDemo, triggers) {
683 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200684 def netMap = [
685 vsphere: [:],
686 equinix: [:],
687 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400688 // Define vsphere locklabels with initial quantity
689 def lockLabels = [
690 vsphere_networking_core_ci: 0,
691 vsphere_offline_networking_core_ci: 0,
692 ]
693 def deployChild = triggers.deployChildEnabled
694 def multiregionConfig = triggers.multiregionalConfiguration
695 def runMultiregion = multiregionConfig.enabled
696
697 // Generate vsphere netMap and lockLabels based on demo context
698 switch (callBackDemo) {
699 case 'aws':
700 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
701 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
702
703 // Define netMap for Vsphere region
Владислав Наумовf60480d2021-10-15 14:04:01 +0200704 if (runMultiregion && multiregionConfig.managementLocation == 'aws' &&
705 multiregionConfig.regionLocation == 'vsphere') {
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400706 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200707 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400708 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200709 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400710 }
711 break
712 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200713 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400714 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200715 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400716 }
717 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
718 multiregionConfig.regionLocation == 'vsphere') {
719 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200720 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400721 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200722 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400723 }
724 break
725 default:
726 error('Supposed to be called from aws or vsphere demos only')
727 }
728
729 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
730 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200731 netMap['vsphere'].each { clusterType, netConfig ->
732 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
733 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
734 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
735
736 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400737 lockLabels['vsphere_offline_networking_core_ci']++
738 } else {
739 lockLabels['vsphere_networking_core_ci']++
740 }
741 }
742
743 // generate lock metadata
744 def lockResources = []
745 lockLabels.each { label, quantity ->
746 if (quantity > 0) {
747 def res = [
748 label: label,
749 quantity: quantity,
750 ]
751 lockResources.add(res)
752 }
753 }
754
755 common.infoMsg("""Generated vsphere netMap: ${netMap}
756 Generated lockResources: ${lockResources}""")
757
758 return [
759 netMap: netMap,
760 lockResources: lockResources,
761 ]
762}
763
764/**
765 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
766 * and empty rangeConfig to the this map.
767 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200768 * @param: netMap (string) vsphere, equinix netMap or empty map
769 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400770 * @param: clusterType (string) Vsphere cluster type
771 */
772
Владислав Наумов33e1e812021-08-17 17:09:25 +0200773def addToProviderNetMap (netMap, provider, clusterType) {
774 switch (provider) {
775 case 'equinix':
776 netMap[provider][clusterType] = [
777 vlanConfig: '',
778 ]
779 break
780 case 'vsphere':
781 netMap[provider][clusterType] = [
782 netName: 'default',
783 rangeConfig: '',
784 ]
785 break
786 default:
787 error('Net map locks supported for Equinix/Vsphere providers only')
788 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400789}