vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 1 | package com.mirantis.mk |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 2 | |
azvyagintsev | c17d14b | 2022-06-06 19:06:33 +0300 | [diff] [blame^] | 3 | import static groovy.json.JsonOutput.toJson |
| 4 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 5 | /** |
| 6 | * |
| 7 | * KaaS Component Testing Utilities |
| 8 | * |
| 9 | */ |
| 10 | |
Владислав Наумов | e534581 | 2020-08-12 16:30:20 +0200 | [diff] [blame] | 11 | /** |
| 12 | * Check KaaS Core CICD feature flags |
| 13 | * such triggers can be used in case of switching between pipelines, |
| 14 | * conditions inside pipelines to reduce dependency on jenkins job builder and jenkins job templates itself |
| 15 | * |
| 16 | * @return (map)[ |
| 17 | * ffNameEnabled: (bool) True/False |
| 18 | * ] |
| 19 | */ |
| 20 | def checkCoreCIFeatureFlags() { |
| 21 | def common = new com.mirantis.mk.Common() |
| 22 | def ff = [ |
| 23 | build_artifacts_upgrade: false, |
| 24 | ] |
| 25 | |
| 26 | def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
| 27 | if (commitMsg ==~ /(?s).*\[ci-build-artifacts-upgrade\].*/) { |
| 28 | ff['build_artifacts_upgrade'] = true |
| 29 | } |
| 30 | |
| 31 | common.infoMsg("Core ci feature flags status: ${ff}") |
| 32 | return ff |
| 33 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 34 | |
| 35 | /** |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 36 | * Determine scope of test suite against per-commit KaaS deployment based on keywords |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 37 | * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 38 | * |
| 39 | * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs |
| 40 | * Example scheme: |
Владислав Наумов | e534581 | 2020-08-12 16:30:20 +0200 | [diff] [blame] | 41 | * New CR pushed in kubernetes/lcm-ansible -> parsing it'cs commit body and combine test-suite -> trigger deployment jobs from kaas/core |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 42 | * manage test-suite through Jenkins Job Parameters |
| 43 | * |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 44 | * @return (map)[ |
| 45 | * deployChildEnabled: (bool) True if need to deploy child cluster during demo-run |
| 46 | * runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 47 | * ] |
| 48 | */ |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 49 | def checkDeploymentTestSuite() { |
vnaumov | bdb9022 | 2020-05-04 18:25:50 +0200 | [diff] [blame] | 50 | def common = new com.mirantis.mk.Common() |
| 51 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 52 | // Available triggers and its sane defaults |
Владислав Наумов | 44c64b7 | 2020-12-04 20:22:53 +0100 | [diff] [blame] | 53 | def seedMacOs = env.SEED_MACOS ? env.SEED_MACOS.toBoolean() : false |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 54 | def deployChild = env.DEPLOY_CHILD_CLUSTER ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false |
| 55 | def upgradeChild = env.UPGRADE_CHILD_CLUSTER ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false |
Mikhail Ivanov | 38ee438 | 2022-01-27 16:21:51 +0400 | [diff] [blame] | 56 | def mosDeployChild = env.DEPLOY_MOS_CHILD_CLUSTER ? env.DEPLOY_MOS_CHILD_CLUSTER.toBoolean() : false |
| 57 | def mosUpgradeChild = env.UPGRADE_MOS_CHILD_CLUSTER ? env.UPGRADE_MOS_CHILD_CLUSTER.toBoolean() : false |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 58 | def customChildRelease = env.KAAS_CHILD_CLUSTER_RELEASE_NAME ? env.KAAS_CHILD_CLUSTER_RELEASE_NAME : '' |
slalov | 021171f | 2022-03-04 14:48:38 +0400 | [diff] [blame] | 59 | def mosTfDeploy = env.MOS_TF_DEPLOY ? env.MOS_TF_DEPLOY.toBoolean() : false |
Владислав Наумов | 0dc9925 | 2020-11-13 13:30:48 +0100 | [diff] [blame] | 60 | def attachBYO = env.ATTACH_BYO ? env.ATTACH_BYO.toBoolean() : false |
Владислав Наумов | cdbd84e | 2020-12-01 16:51:09 +0100 | [diff] [blame] | 61 | def upgradeBYO = env.UPGRADE_BYO ? env.UPGRADE_BYO.toBoolean() : false |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 62 | def runBYOMatrix = env.RUN_BYO_MATRIX ? env.RUN_BYO_MATRIX.toBoolean() : false |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 63 | def defaultBYOOs = env.DEFAULT_BYO_OS ? env.DEFAULT_BYO_OS.toString() : 'ubuntu' |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 64 | def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false |
slalov | 1202bba | 2022-04-20 22:31:07 +0400 | [diff] [blame] | 65 | def autoUpgradeMgmt = env.AUTO_UPGRADE_MCC ? env.AUTO_UPGRADE_MCC.toBoolean() : false |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 66 | def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 67 | def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false |
Mikhail Ivanov | f5e20af | 2022-03-24 15:38:06 +0400 | [diff] [blame] | 68 | def runUie2eNew = env.RUN_UI_E2E_NEW ? env.RUN_UI_E2E_NEW.toBoolean() : false |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 69 | def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false |
Владислав Наумов | 9cec55d | 2021-08-03 15:00:59 +0200 | [diff] [blame] | 70 | def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false |
Vladyslav Drok | c4f9c1b | 2021-07-22 15:34:24 +0200 | [diff] [blame] | 71 | def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false |
Mikhail Ivanov | 2907e4d | 2022-04-25 16:41:21 +0400 | [diff] [blame] | 72 | def runProxyChildTest = env.RUN_PROXY_CHILD_TEST ? env.RUN_PROXY_CHILD_TEST.toBoolean() : false |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 73 | def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false |
| 74 | def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 75 | def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false |
slalov | 13e579c | 2022-01-31 21:37:02 +0400 | [diff] [blame] | 76 | def runMaintenanceTest = env.RUN_MAINTENANCE_TEST ? env.RUN_MAINTENANCE_TEST.toBoolean() : false |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 77 | // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider |
| 78 | def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [ |
| 79 | enabled: false, |
| 80 | managementLocation: '', |
| 81 | regionLocation: '', |
| 82 | ] |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 83 | |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 84 | // proxy customization |
| 85 | def proxyConfig = [ |
Владислав Наумов | f8f23fa | 2021-04-01 16:57:52 +0200 | [diff] [blame] | 86 | mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false, |
| 87 | childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false, |
Владислав Наумов | 257ea13 | 2021-04-14 14:44:13 +0200 | [diff] [blame] | 88 | childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false, |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 89 | ] |
| 90 | |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 91 | // optional demo deployment customization |
Владислав Наумов | 905dd36 | 2020-06-08 16:37:01 +0200 | [diff] [blame] | 92 | def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 93 | def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false |
Владислав Наумов | 82305e9 | 2021-10-14 20:45:20 +0200 | [diff] [blame] | 94 | def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false |
Владислав Наумов | f371580 | 2021-05-03 18:06:45 +0200 | [diff] [blame] | 95 | def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 96 | def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 97 | def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false |
Ivan Berezovskiy | f9bcfd6 | 2021-03-18 18:41:38 +0400 | [diff] [blame] | 98 | def enableVsphereDemo = true |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 99 | def enableOSDemo = true |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 100 | def enableBMDemo = true |
Mikhail Ivanov | bd1a9fd | 2022-03-29 21:36:21 +0400 | [diff] [blame] | 101 | def enableArtifactsBuild = true |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 102 | def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us' |
Alexandr Lovtsov | 36473f3 | 2022-04-28 15:46:09 +0300 | [diff] [blame] | 103 | def enableVsphereUbuntu = env.VSPHERE_DEPLOY_UBUNTU ? env.VSPHERE_DEPLOY_UBUNTU.toBoolean() : false |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 104 | |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 105 | def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 106 | if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) { |
| 107 | proxyConfig['mgmtOffline'] = true |
Владислав Наумов | 70c0242 | 2021-04-19 14:29:41 +0200 | [diff] [blame] | 108 | common.warningMsg('Forced running offline mgmt deployment, some provider CDN regions for mgmt deployment may be set to *public-ci* to verify proxy configuration') |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 109 | } |
Владислав Наумов | 44c64b7 | 2020-12-04 20:22:53 +0100 | [diff] [blame] | 110 | if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) { |
| 111 | seedMacOs = true |
| 112 | } |
slalov | 574123e | 2022-04-06 17:24:19 +0400 | [diff] [blame] | 113 | if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance || runProxyChildTest) { |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 114 | deployChild = true |
| 115 | } |
| 116 | if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) { |
| 117 | deployChild = true |
| 118 | upgradeChild = true |
| 119 | } |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 120 | def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/) |
| 121 | if (childDeployMatches.size() > 0) { |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 122 | // override child version when it set explicitly |
| 123 | deployChild = true |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 124 | customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim() |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 125 | common.warningMsg("Forced child deployment using custom release version ${customChildRelease}") |
| 126 | } |
Mikhail Ivanov | 38ee438 | 2022-01-27 16:21:51 +0400 | [diff] [blame] | 127 | if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) { |
| 128 | mosDeployChild = true |
| 129 | } |
| 130 | if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) { |
| 131 | mosDeployChild = true |
| 132 | mosUpgradeChild = true |
| 133 | } |
Владислав Наумов | 0dc9925 | 2020-11-13 13:30:48 +0100 | [diff] [blame] | 134 | if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) { |
| 135 | attachBYO = true |
| 136 | } |
Владислав Наумов | cdbd84e | 2020-12-01 16:51:09 +0100 | [diff] [blame] | 137 | if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) { |
| 138 | attachBYO = true |
| 139 | upgradeBYO = true |
| 140 | } |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 141 | |
| 142 | def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/) |
| 143 | if (commitMsg ==~ /(?s).*\[run-byo-matrix\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*run-byo-matrix\.*/ || byoDeployMatches.size() > 0) { |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 144 | runBYOMatrix = true |
| 145 | |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 146 | if (byoDeployMatches.size() > 0) { |
| 147 | defaultBYOOs = byoDeployMatches[0][2] |
| 148 | common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}") |
| 149 | } |
| 150 | |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 151 | common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped') |
| 152 | attachBYO = false |
| 153 | upgradeBYO = false |
| 154 | } |
Владислав Наумов | 7f8c987 | 2021-03-08 17:33:08 +0400 | [diff] [blame] | 155 | if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) { |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 156 | upgradeMgmt = true |
| 157 | } |
slalov | 1202bba | 2022-04-20 22:31:07 +0400 | [diff] [blame] | 158 | if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) { |
| 159 | autoUpgradeMgmt = true |
| 160 | } |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 161 | if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) { |
| 162 | enableLMALogging = true |
| 163 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 164 | if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) { |
| 165 | runUie2e = true |
| 166 | } |
Mikhail Ivanov | f5e20af | 2022-03-24 15:38:06 +0400 | [diff] [blame] | 167 | if (commitMsg ==~ /(?s).*\[ui-e2e-new\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-new.*/) { |
| 168 | runUie2eNew = true |
| 169 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 170 | if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) { |
| 171 | runMgmtConformance = true |
| 172 | } |
Vladyslav Drok | c4f9c1b | 2021-07-22 15:34:24 +0200 | [diff] [blame] | 173 | if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) { |
| 174 | runMgmtUserControllerTest = true |
| 175 | } |
slalov | 574123e | 2022-04-06 17:24:19 +0400 | [diff] [blame] | 176 | if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) { |
| 177 | runProxyChildTest = true |
| 178 | deployChild = true |
| 179 | common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed') |
| 180 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 181 | if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) { |
| 182 | runChildConformance = true |
| 183 | deployChild = true |
| 184 | } |
Владислав Наумов | 9cec55d | 2021-08-03 15:00:59 +0200 | [diff] [blame] | 185 | if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) { |
| 186 | runLMATest = true |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 187 | enableLMALogging = true |
| 188 | common.infoMsg('LMA logging will be enabled since LMA test suite will be executed') |
Victor Ryzhenkin | 1520659 | 2021-06-21 17:38:23 +0400 | [diff] [blame] | 189 | } |
slalov | 13e579c | 2022-01-31 21:37:02 +0400 | [diff] [blame] | 190 | if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) { |
| 191 | runMaintenanceTest = true |
| 192 | } |
Владислав Наумов | f8f23fa | 2021-04-01 16:57:52 +0200 | [diff] [blame] | 193 | if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) { |
| 194 | proxyConfig['childOffline'] = true |
| 195 | deployChild = true |
| 196 | } |
Владислав Наумов | 257ea13 | 2021-04-14 14:44:13 +0200 | [diff] [blame] | 197 | if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) { |
| 198 | proxyConfig['childOffline'] = true |
| 199 | proxyConfig['childProxy'] = true |
| 200 | deployChild = true |
| 201 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 202 | if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) { |
| 203 | fetchServiceBinaries = true |
| 204 | } |
Владислав Наумов | f1665b5 | 2021-05-13 10:51:17 +0200 | [diff] [blame] | 205 | if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) { |
eromanova | df247c3 | 2020-12-25 15:44:13 +0400 | [diff] [blame] | 206 | equinixOnAwsDemo = true |
Владислав Наумов | f1665b5 | 2021-05-13 10:51:17 +0200 | [diff] [blame] | 207 | 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]\' ') |
eromanova | df247c3 | 2020-12-25 15:44:13 +0400 | [diff] [blame] | 208 | } |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 209 | if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) { |
| 210 | azureOnAwsDemo = true |
| 211 | common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ') |
| 212 | } |
| 213 | if (commitMsg ==~ /(?s).*\[aws-demo\].*/ || |
| 214 | env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ || |
| 215 | attachBYO || |
| 216 | upgradeBYO || |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 217 | runBYOMatrix || |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 218 | seedMacOs || |
| 219 | equinixOnAwsDemo || |
| 220 | azureOnAwsDemo) { |
| 221 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 222 | awsOnDemandDemo = true |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 223 | common.warningMsg('Running additional kaas deployment with AWS provider, may be forced due applied trigger cross dependencies, follow docs to clarify info') |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 224 | } |
Владислав Наумов | f1665b5 | 2021-05-13 10:51:17 +0200 | [diff] [blame] | 225 | if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) { |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 226 | equinixOnDemandDemo = true |
| 227 | } |
Владислав Наумов | 82305e9 | 2021-10-14 20:45:20 +0200 | [diff] [blame] | 228 | if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) { |
Владислав Наумов | 144956f | 2021-10-14 17:49:19 +0200 | [diff] [blame] | 229 | equinixMetalV2OnDemandDemo = true |
| 230 | } |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 231 | if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) { |
| 232 | equinixMetalV2OnDemandDemo = true |
| 233 | equinixMetalV2ChildDiffMetro = true |
| 234 | } |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 235 | if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) { |
| 236 | azureOnDemandDemo = true |
| 237 | } |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 238 | if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) { |
| 239 | enableOSDemo = false |
| 240 | common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set') |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 241 | } |
| 242 | |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 243 | if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) { |
| 244 | enableBMDemo = false |
| 245 | common.errorMsg('BM demo deployment will be aborted, VF -1 will be set') |
| 246 | } |
| 247 | |
Ivan Berezovskiy | f9bcfd6 | 2021-03-18 18:41:38 +0400 | [diff] [blame] | 248 | if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) { |
| 249 | enableVsphereDemo = false |
| 250 | common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set') |
| 251 | } |
Alexandr Lovtsov | 36473f3 | 2022-04-28 15:46:09 +0300 | [diff] [blame] | 252 | if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) { |
| 253 | enableVsphereUbuntu = true |
| 254 | common.warningMsg('Ubuntu will be used to deploy vsphere machines') |
| 255 | } |
Ivan Berezovskiy | f9bcfd6 | 2021-03-18 18:41:38 +0400 | [diff] [blame] | 256 | |
Mikhail Ivanov | bd1a9fd | 2022-03-29 21:36:21 +0400 | [diff] [blame] | 257 | if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) { |
| 258 | enableArtifactsBuild = false |
| 259 | common.errorMsg('artifacts build will be aborted, VF -1 will be set') |
| 260 | } |
| 261 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 262 | // TODO (vnaumov) remove below condition after moving all releases to UCP |
| 263 | def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/) |
| 264 | if (ucpChildMatches.size() > 0) { |
| 265 | deployChild = true |
| 266 | common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ') |
| 267 | |
| 268 | // TODO(vnaumov) delete after ucp upgrades support |
| 269 | common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled') |
| 270 | upgradeChild = false |
| 271 | } |
| 272 | |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 273 | // multiregional tests |
| 274 | def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/) |
| 275 | if (multiRegionalMatches.size() > 0) { |
| 276 | multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches) |
| 277 | } |
| 278 | switch (multiregionalMappings['managementLocation']) { |
| 279 | case 'aws': |
Владислав Наумов | 53b07e5 | 2021-01-07 15:08:27 +0100 | [diff] [blame] | 280 | common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request') |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 281 | awsOnDemandDemo = true |
Владислав Наумов | 53b07e5 | 2021-01-07 15:08:27 +0100 | [diff] [blame] | 282 | |
| 283 | if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers |
| 284 | error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously') |
| 285 | } |
Владислав Наумов | 3e4b5a3 | 2020-09-11 17:05:34 +0200 | [diff] [blame] | 286 | break |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 287 | case 'os': |
| 288 | if (enableOSDemo == false) { |
| 289 | error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously') |
| 290 | } |
Владислав Наумов | 3e4b5a3 | 2020-09-11 17:05:34 +0200 | [diff] [blame] | 291 | break |
Владислав Наумов | 865ba6c | 2021-05-13 13:05:45 +0200 | [diff] [blame] | 292 | case 'vsphere': |
| 293 | if (enableVsphereDemo == false) { |
| 294 | error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously') |
| 295 | } |
| 296 | break |
Владислав Наумов | 5be0294 | 2021-05-13 12:34:37 +0200 | [diff] [blame] | 297 | case 'equinix': |
| 298 | common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request') |
| 299 | equinixOnDemandDemo = true |
eromanova | 3535916 | 2021-12-30 14:13:13 +0400 | [diff] [blame] | 300 | break |
eromanova | 8c702ae | 2021-12-24 17:43:12 +0400 | [diff] [blame] | 301 | case 'equinixmetalv2': |
| 302 | common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request') |
| 303 | equinixMetalV2OnDemandDemo = true |
eromanova | 3535916 | 2021-12-30 14:13:13 +0400 | [diff] [blame] | 304 | break |
slalov | fd0b7e6 | 2021-07-28 18:05:16 +0400 | [diff] [blame] | 305 | case 'azure': |
| 306 | common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request') |
| 307 | azureOnDemandDemo = true |
| 308 | break |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 309 | } |
| 310 | |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 311 | // CDN configuration |
| 312 | def cdnConfig = [ |
| 313 | mgmt: [ |
| 314 | openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci', |
Владислав Наумов | 70c0242 | 2021-04-19 14:29:41 +0200 | [diff] [blame] | 315 | vsphere: 'internal-ci', |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 316 | aws: 'public-ci', |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 317 | equinix: 'public-ci', |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 318 | azure: 'public-ci', |
Владислав Наумов | f8f23fa | 2021-04-01 16:57:52 +0200 | [diff] [blame] | 319 | ], |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 320 | ] |
| 321 | |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 322 | if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) { |
| 323 | openstackIMC = 'eu' |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 324 | } |
slalov | 021171f | 2022-03-04 14:48:38 +0400 | [diff] [blame] | 325 | if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) { |
| 326 | openstackIMC = 'eu2' |
Mikhail Ivanov | f05b825 | 2022-04-27 18:14:03 +0400 | [diff] [blame] | 327 | } |
| 328 | if (openstackIMC == 'eu' || openstackIMC == 'eu2') { |
slalov | 021171f | 2022-03-04 14:48:38 +0400 | [diff] [blame] | 329 | // use internal-eu because on internal-ci with eu cloud image pull takes much time |
| 330 | def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu' |
| 331 | common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}") |
| 332 | cdnConfig['mgmt']['openstack'] = cdnRegion |
| 333 | } |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 334 | |
Владислав Наумов | 74e2d6e | 2020-12-30 17:05:40 +0100 | [diff] [blame] | 335 | // calculate weight of current demo run to manage lockable resources |
| 336 | def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1 |
| 337 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 338 | common.infoMsg(""" |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 339 | OpenStack Cloud location: ${openstackIMC} |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 340 | CDN deployment configuration: ${cdnConfig} |
| 341 | MCC offline deployment configuration: ${proxyConfig} |
Владислав Наумов | 44c64b7 | 2020-12-04 20:22:53 +0100 | [diff] [blame] | 342 | Use MacOS node as seed: ${seedMacOs} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 343 | Child cluster deployment scheduled: ${deployChild} |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 344 | Custom child cluster release: ${customChildRelease} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 345 | Child cluster release upgrade scheduled: ${upgradeChild} |
Mikhail Ivanov | 38ee438 | 2022-01-27 16:21:51 +0400 | [diff] [blame] | 346 | MOS child deploy scheduled: ${mosDeployChild} |
| 347 | MOS child upgrade scheduled: ${mosUpgradeChild} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 348 | Child conformance testing scheduled: ${runChildConformance} |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 349 | Single BYO cluster attachment scheduled: ${attachBYO} |
| 350 | Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO} |
| 351 | BYO test matrix whole suite scheduled: ${runBYOMatrix} |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 352 | Default BYO OS: ${defaultBYOOs} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 353 | Mgmt cluster release upgrade scheduled: ${upgradeMgmt} |
slalov | 1202bba | 2022-04-20 22:31:07 +0400 | [diff] [blame] | 354 | Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt} |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 355 | Mgmt LMA logging enabled: ${enableLMALogging} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 356 | Mgmt conformance testing scheduled: ${runMgmtConformance} |
Владислав Наумов | 9cec55d | 2021-08-03 15:00:59 +0200 | [diff] [blame] | 357 | LMA testing scheduled: ${runLMATest} |
Vladyslav Drok | c4f9c1b | 2021-07-22 15:34:24 +0200 | [diff] [blame] | 358 | Mgmt user controller testing scheduled: ${runMgmtUserControllerTest} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 359 | Mgmt UI e2e testing scheduled: ${runUie2e} |
Mikhail Ivanov | f5e20af | 2022-03-24 15:38:06 +0400 | [diff] [blame] | 360 | Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew} |
slalov | 13e579c | 2022-01-31 21:37:02 +0400 | [diff] [blame] | 361 | Maintenance test: ${runMaintenanceTest} |
slalov | 574123e | 2022-04-06 17:24:19 +0400 | [diff] [blame] | 362 | Child proxy test: ${runProxyChildTest} |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 363 | AWS provider deployment scheduled: ${awsOnDemandDemo} |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 364 | Equinix provider deployment scheduled: ${equinixOnDemandDemo} |
Владислав Наумов | 144956f | 2021-10-14 17:49:19 +0200 | [diff] [blame] | 365 | EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo} |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 366 | EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro} |
Владислав Наумов | f1665b5 | 2021-05-13 10:51:17 +0200 | [diff] [blame] | 367 | Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo} |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 368 | Azure provider deployment scheduled: ${azureOnDemandDemo} |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 369 | Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo} |
Ivan Berezovskiy | f9bcfd6 | 2021-03-18 18:41:38 +0400 | [diff] [blame] | 370 | VSPHERE provider deployment scheduled: ${enableVsphereDemo} |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 371 | OS provider deployment scheduled: ${enableOSDemo} |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 372 | BM provider deployment scheduled: ${enableBMDemo} |
Alexandr Lovtsov | 36473f3 | 2022-04-28 15:46:09 +0300 | [diff] [blame] | 373 | Ubuntu on vSphere scheduled: ${enableVsphereUbuntu} |
Mikhail Ivanov | bd1a9fd | 2022-03-29 21:36:21 +0400 | [diff] [blame] | 374 | Artifacts build scheduled: ${enableArtifactsBuild} |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame] | 375 | Multiregional configuration: ${multiregionalMappings} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 376 | Service binaries fetching scheduled: ${fetchServiceBinaries} |
Владислав Наумов | 74e2d6e | 2020-12-30 17:05:40 +0100 | [diff] [blame] | 377 | Current weight of the demo run: ${demoWeight} (Used to manage lockable resources) |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 378 | Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""") |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 379 | return [ |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 380 | osCloudLocation : openstackIMC, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 381 | cdnConfig : cdnConfig, |
| 382 | proxyConfig : proxyConfig, |
| 383 | useMacOsSeedNode : seedMacOs, |
| 384 | deployChildEnabled : deployChild, |
| 385 | childDeployCustomRelease : customChildRelease, |
| 386 | upgradeChildEnabled : upgradeChild, |
Mikhail Ivanov | 38ee438 | 2022-01-27 16:21:51 +0400 | [diff] [blame] | 387 | mosDeployChildEnabled : mosDeployChild, |
| 388 | mosUpgradeChildEnabled : mosUpgradeChild, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 389 | runChildConformanceEnabled : runChildConformance, |
| 390 | attachBYOEnabled : attachBYO, |
| 391 | upgradeBYOEnabled : upgradeBYO, |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 392 | runBYOMatrixEnabled : runBYOMatrix, |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 393 | defaultBYOOs : defaultBYOOs, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 394 | upgradeMgmtEnabled : upgradeMgmt, |
slalov | 1202bba | 2022-04-20 22:31:07 +0400 | [diff] [blame] | 395 | autoUpgradeMgmtEnabled : autoUpgradeMgmt, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 396 | enableLMALoggingEnabled : enableLMALogging, |
| 397 | runUie2eEnabled : runUie2e, |
Mikhail Ivanov | f5e20af | 2022-03-24 15:38:06 +0400 | [diff] [blame] | 398 | runUie2eNewEnabled : runUie2eNew, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 399 | runMgmtConformanceEnabled : runMgmtConformance, |
slalov | 13e579c | 2022-01-31 21:37:02 +0400 | [diff] [blame] | 400 | runMaintenanceTestEnable : runMaintenanceTest, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 401 | runLMATestEnabled : runLMATest, |
| 402 | runMgmtUserControllerTestEnabled : runMgmtUserControllerTest, |
slalov | 574123e | 2022-04-06 17:24:19 +0400 | [diff] [blame] | 403 | runProxyChildTestEnabled : runProxyChildTest, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 404 | fetchServiceBinariesEnabled : fetchServiceBinaries, |
| 405 | awsOnDemandDemoEnabled : awsOnDemandDemo, |
| 406 | equinixOnDemandDemoEnabled : equinixOnDemandDemo, |
| 407 | equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo, |
| 408 | equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro, |
| 409 | equinixOnAwsDemoEnabled : equinixOnAwsDemo, |
| 410 | azureOnDemandDemoEnabled : azureOnDemandDemo, |
| 411 | azureOnAwsDemoEnabled : azureOnAwsDemo, |
| 412 | vsphereDemoEnabled : enableVsphereDemo, |
| 413 | vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out |
| 414 | bmDemoEnabled : enableBMDemo, |
| 415 | osDemoEnabled : enableOSDemo, |
Alexandr Lovtsov | 36473f3 | 2022-04-28 15:46:09 +0300 | [diff] [blame] | 416 | vsphereUbuntuEnabled : enableVsphereUbuntu, |
Mikhail Ivanov | bd1a9fd | 2022-03-29 21:36:21 +0400 | [diff] [blame] | 417 | artifactsBuildEnabled : enableArtifactsBuild, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 418 | multiregionalConfiguration : multiregionalMappings, |
| 419 | demoWeight : demoWeight] |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | /** |
| 423 | * Determine management and regional setup for demo workflow scenario |
| 424 | * |
| 425 | * |
| 426 | * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]` |
| 427 | or Jenkins environment string variable in form like 'aws,os' |
| 428 | * @return (map)[ |
| 429 | enabled: (bool), |
| 430 | * managementLocation: (string), //aws,os |
| 431 | * regionLocation: (string), //aws,os |
| 432 | * ] |
| 433 | */ |
| 434 | def multiregionWorkflowParser(keyword) { |
Владислав Наумов | 8c0c39d | 2020-09-11 14:46:48 +0200 | [diff] [blame] | 435 | def common = new com.mirantis.mk.Common() |
eromanova | 8c702ae | 2021-12-24 17:43:12 +0400 | [diff] [blame] | 436 | def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure'] |
| 437 | def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws'] |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 438 | |
| 439 | def clusterTypes = '' |
Владислав Наумов | 38ed7bf | 2020-09-11 14:43:39 +0200 | [diff] [blame] | 440 | if (keyword.toString().contains('multiregion')) { |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 441 | common.infoMsg('Multiregion definition configured via gerrit keyword trigger') |
| 442 | clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',') |
| 443 | } else { |
| 444 | common.infoMsg('Multiregion definition configured via environment variable') |
| 445 | clusterTypes = keyword.trim().split(',') |
| 446 | } |
| 447 | |
| 448 | if (clusterTypes.size() != 2) { |
Владислав Наумов | 482fb50 | 2020-10-30 17:59:27 +0100 | [diff] [blame] | 449 | error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}") |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 450 | } |
| 451 | |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame] | 452 | def desiredManagementProvider = clusterTypes[0].trim() |
| 453 | def desiredRegionalProvider = clusterTypes[1].trim() |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 454 | if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) { |
| 455 | error("""unsupported management <-> regional bundle, available options: |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame] | 456 | management providers list - ${supportedManagementProviders} |
| 457 | regional providers list - ${supportedRegionalProviders}""") |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | return [ |
| 461 | enabled: true, |
| 462 | managementLocation: desiredManagementProvider, |
| 463 | regionLocation: desiredRegionalProvider, |
| 464 | ] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | /** |
| 468 | * Determine if custom si tests/pipelines refspec forwarded from gerrit change request |
| 469 | |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 470 | * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 471 | * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs |
| 472 | * Example scheme: |
| 473 | * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core |
| 474 | * manage refspecs through Jenkins Job Parameters |
| 475 | * |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 476 | * @return (map)[* siTests: (string) final refspec for si-tests |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 477 | * siPipelines: (string) final refspec for si-pipelines |
| 478 | * ] |
| 479 | */ |
| 480 | def checkCustomSIRefspec() { |
vnaumov | bdb9022 | 2020-05-04 18:25:50 +0200 | [diff] [blame] | 481 | def common = new com.mirantis.mk.Common() |
| 482 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 483 | // Available triggers and its sane defaults |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 484 | def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master' |
| 485 | def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master' |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 486 | def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test' |
| 487 | def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master' |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 488 | def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 489 | |
| 490 | def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/) |
| 491 | def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/) |
| 492 | |
| 493 | if (siTestMatches.size() > 0) { |
| 494 | siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim() |
Владислав Наумов | 7f6c088 | 2021-03-23 19:10:57 +0400 | [diff] [blame] | 495 | siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}" |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 496 | siTestsDockerImageTag = siTestsRefspec.split('/')[-1] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 497 | } |
| 498 | if (siPipelinesMatches.size() > 0) { |
| 499 | siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 500 | } |
| 501 | |
| 502 | common.infoMsg(""" |
| 503 | kaas/si-pipelines will be fetched from: ${siPipelinesRefspec} |
| 504 | kaas/si-tests will be fetched from: ${siTestsRefspec} |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 505 | kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag} |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 506 | Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""") |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 507 | return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 508 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 509 | |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 510 | /** |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 511 | * Parse additional configuration for kaas component CICD repo |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 512 | * @param configurationFile (str) path to configuration file in yaml format |
| 513 | * |
| 514 | * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests, |
| 515 | * ] |
| 516 | */ |
| 517 | def parseKaaSComponentCIParameters(configurationFile){ |
| 518 | def common = new com.mirantis.mk.Common() |
| 519 | def ciConfig = readYaml file: configurationFile |
| 520 | def ciSpec = [ |
| 521 | siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '', |
| 522 | ] |
| 523 | |
| 524 | if (ciConfig.containsKey('si-tests-feature-flags')) { |
| 525 | common.infoMsg("""SI tests feature flags customization detected, |
| 526 | results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""") |
| 527 | |
| 528 | def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() } |
| 529 | ffMeta.addAll(ciConfig['si-tests-feature-flags']) |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 530 | |
Владислав Наумов | cb5ffca | 2020-07-14 15:28:36 +0200 | [diff] [blame] | 531 | ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',') |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 532 | common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}") |
| 533 | } |
| 534 | |
| 535 | common.infoMsg("""Additional ci configuration parsed successfully: |
| 536 | siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""") |
| 537 | return ciSpec |
| 538 | } |
| 539 | |
| 540 | /** |
| 541 | * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 542 | |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 543 | * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 544 | * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs |
| 545 | * Example scheme: |
| 546 | * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core |
| 547 | * manage refspecs through Jenkins Job Parameters |
| 548 | * |
| 549 | * @return (map)[ core: (string) final refspec for kaas/core |
| 550 | * corePipelines: (string) final refspec for pipelines in kaas/core |
| 551 | * ] |
| 552 | */ |
| 553 | def checkCustomCoreRefspec() { |
| 554 | def common = new com.mirantis.mk.Common() |
| 555 | |
| 556 | // Available triggers and its sane defaults |
| 557 | def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master' |
| 558 | // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs* |
| 559 | def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC' |
| 560 | def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
| 561 | |
| 562 | def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/) |
| 563 | def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/) |
| 564 | |
| 565 | if (coreMatches.size() > 0) { |
| 566 | coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 567 | } |
| 568 | if (corePipelinesMatches.size() > 0) { |
| 569 | corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 570 | } |
| 571 | |
| 572 | common.infoMsg(""" |
| 573 | kaas/core will be fetched from: ${coreRefspec} |
| 574 | kaas/core pipelines will be fetched from: ${corePipelinesRefspec} |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 575 | Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""") |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 576 | return [core: coreRefspec, corePipelines: corePipelinesRefspec] |
| 577 | } |
| 578 | |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 579 | |
| 580 | /** |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 581 | * generate Jenkins Parameter objects from from text parameter with additonal kaas core context |
| 582 | * needed to forward inside kaas core set of jobs |
| 583 | * |
| 584 | * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format |
| 585 | * @return (list)[ string(name: '', value: ''), |
| 586 | * ] |
| 587 | */ |
| 588 | def generateKaaSVarsFromContext(context) { |
| 589 | def common = new com.mirantis.mk.Common() |
| 590 | def parameters = [] |
| 591 | def config = readYaml text: context |
| 592 | |
| 593 | config.each { k,v -> |
| 594 | common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}") |
| 595 | parameters.add(string(name: k, value: v)) |
| 596 | } |
| 597 | |
| 598 | return parameters |
| 599 | } |
| 600 | |
| 601 | /** |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 602 | * Trigger KaaS demo jobs based on AWS/OS providers with customized test suite, parsed from external sources (gerrit commit/jj vars) |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 603 | * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 604 | * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs |
| 605 | * |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 606 | * @param: component (string) component name [iam, lcm, stacklight] |
| 607 | * @param: patchSpec (string) Patch for kaas/cluster releases in json format |
| 608 | * @param: configurationFile (string) Additional file for component repo CI config in yaml format |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 609 | */ |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 610 | def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') { |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 611 | def common = new com.mirantis.mk.Common() |
| 612 | // Determine if custom trigger keywords forwarded from gerrit |
| 613 | def triggers = checkDeploymentTestSuite() |
| 614 | // Determine SI refspecs |
| 615 | def siRefspec = checkCustomSIRefspec() |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 616 | // Determine Core refspecs |
| 617 | def coreRefspec = checkCustomCoreRefspec() |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 618 | |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 619 | // Determine component repo ci configuration |
| 620 | def ciSpec = [:] |
| 621 | def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: '' |
| 622 | if (fileExists(configurationFile)) { |
| 623 | common.infoMsg('Component CI configuration file detected, parsing...') |
| 624 | ciSpec = parseKaaSComponentCIParameters(configurationFile) |
| 625 | componentFeatureFlags = ciSpec['siTestsFeatureFlags'] |
| 626 | } else { |
| 627 | common.warningMsg('''Component CI configuration file is not exists, |
Владислав Наумов | c17dd55 | 2020-07-29 17:07:38 +0200 | [diff] [blame] | 628 | several code-management features may be unavailable, |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 629 | follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag |
| 630 | to create the configuration file''') |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 631 | } |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 632 | |
| 633 | def platforms = [] |
| 634 | if (component == 'ipam' && triggers.vsphereDemoEnabled) { |
| 635 | // Currently only vsphere demo is required for IPAM component |
| 636 | platforms.add('vsphere') |
| 637 | } else { |
| 638 | if (triggers.osDemoEnabled) { |
| 639 | platforms.add('openstack') |
| 640 | } |
| 641 | if (triggers.awsOnDemandDemoEnabled) { |
| 642 | platforms.add('aws') |
| 643 | } |
| 644 | if (triggers.equinixOnDemandDemoEnabled) { |
| 645 | platforms.add('equinix') |
| 646 | } |
Владислав Наумов | 144956f | 2021-10-14 17:49:19 +0200 | [diff] [blame] | 647 | if (triggers.equinixMetalV2OnDemandDemoEnabled) { |
| 648 | platforms.add('equinixmetalv2') |
| 649 | } |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 650 | if (triggers.azureOnDemandDemoEnabled) { |
| 651 | platforms.add('azure') |
| 652 | } |
Ivan Berezovskiy | b0229d0 | 2021-05-17 16:55:18 +0400 | [diff] [blame] | 653 | if (triggers.vsphereDemoEnabled) { |
| 654 | platforms.add('vsphere') |
| 655 | } |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 656 | } |
| 657 | |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 658 | def jobs = [:] |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 659 | def parameters = [ |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 660 | string(name: 'GERRIT_REFSPEC', value: coreRefspec.core), |
| 661 | string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 662 | string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests), |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 663 | string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags), |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 664 | string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage), |
| 665 | string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag), |
Владислав Наумов | 4a5c324 | 2020-06-08 14:36:11 +0200 | [diff] [blame] | 666 | string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 667 | string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec), |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 668 | string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease), |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 669 | string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation), |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 670 | booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']), |
Владислав Наумов | f8f23fa | 2021-04-01 16:57:52 +0200 | [diff] [blame] | 671 | booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']), |
Владислав Наумов | 257ea13 | 2021-04-14 14:44:13 +0200 | [diff] [blame] | 672 | booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']), |
Владислав Наумов | 44c64b7 | 2020-12-04 20:22:53 +0100 | [diff] [blame] | 673 | booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 674 | booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled), |
slalov | 1202bba | 2022-04-20 22:31:07 +0400 | [diff] [blame] | 675 | booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled), |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 676 | booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 677 | booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 678 | booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled), |
slalov | 13e579c | 2022-01-31 21:37:02 +0400 | [diff] [blame] | 679 | booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnable), |
Владислав Наумов | 9cec55d | 2021-08-03 15:00:59 +0200 | [diff] [blame] | 680 | booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled), |
Vladyslav Drok | c4f9c1b | 2021-07-22 15:34:24 +0200 | [diff] [blame] | 681 | booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 682 | booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled), |
| 683 | booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled), |
slalov | 574123e | 2022-04-06 17:24:19 +0400 | [diff] [blame] | 684 | booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled), |
Владислав Наумов | 0dc9925 | 2020-11-13 13:30:48 +0100 | [diff] [blame] | 685 | booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled), |
Владислав Наумов | cdbd84e | 2020-12-01 16:51:09 +0100 | [diff] [blame] | 686 | booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled), |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 687 | booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 688 | booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled), |
Ivan Berezovskiy | cbf9eeb | 2021-03-22 15:57:32 +0400 | [diff] [blame] | 689 | booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled), |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 690 | booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled), |
Владислав Наумов | 82305e9 | 2021-10-14 20:45:20 +0200 | [diff] [blame] | 691 | booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled), |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 692 | booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled), |
eromanova | d339751 | 2021-04-01 20:19:19 +0400 | [diff] [blame] | 693 | booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled), |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 694 | booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled), |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 695 | booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled), |
Sergey Zhemerdeev | 9074f6e | 2022-06-07 12:03:16 +0300 | [diff] [blame] | 696 | booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 697 | ] |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 698 | |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 699 | // customize multiregional demo |
| 700 | if (triggers.multiregionalConfiguration.enabled) { |
| 701 | parameters.add(string(name: 'MULTIREGION_SETUP', |
| 702 | value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}" |
| 703 | )) |
| 704 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 705 | |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 706 | // Determine component team custom context |
| 707 | if (coreContext != '') { |
| 708 | common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...') |
| 709 | def additionalParameters = generateKaaSVarsFromContext(coreContext) |
Владислав Наумов | bef51a9 | 2020-10-01 17:36:51 +0200 | [diff] [blame] | 710 | parameters.addAll(additionalParameters) |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 711 | } |
| 712 | |
Владислав Наумов | aa43061 | 2020-06-08 17:18:31 +0200 | [diff] [blame] | 713 | def jobResults = [] |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 714 | |
| 715 | platforms.each { platform -> |
| 716 | jobs["kaas-core-${platform}-patched-${component}"] = { |
Vladislav Naumov | 5313a20 | 2021-04-07 17:13:39 +0000 | [diff] [blame] | 717 | try { |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 718 | common.infoMsg("Deploy: patched KaaS demo with ${platform} provider") |
| 719 | def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true |
| 720 | def build_description = job_info.getDescription() |
| 721 | def build_result = job_info.getResult() |
Vladislav Naumov | 5313a20 | 2021-04-07 17:13:39 +0000 | [diff] [blame] | 722 | jobResults.add(build_result) |
Владислав Наумов | d044e84 | 2020-06-17 15:33:43 +0200 | [diff] [blame] | 723 | |
Vladislav Naumov | 5313a20 | 2021-04-07 17:13:39 +0000 | [diff] [blame] | 724 | if (build_description) { |
| 725 | currentBuild.description += build_description |
| 726 | } |
| 727 | } finally { |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 728 | common.infoMsg("Patched KaaS demo with ${platform} provider finished") |
Vladislav Naumov | 5313a20 | 2021-04-07 17:13:39 +0000 | [diff] [blame] | 729 | } |
| 730 | } |
| 731 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 732 | |
| 733 | common.infoMsg('Trigger KaaS demo deployments according to defined provider set') |
Владислав Наумов | 37f7f84 | 2021-03-09 16:08:39 +0400 | [diff] [blame] | 734 | if (jobs.size() == 0) { |
| 735 | error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled') |
| 736 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 737 | // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085 |
| 738 | parallel jobs |
Владислав Наумов | aa43061 | 2020-06-08 17:18:31 +0200 | [diff] [blame] | 739 | |
| 740 | if (jobResults.contains('FAILURE')) { |
Владислав Наумов | f86b111 | 2020-06-09 14:04:48 +0200 | [diff] [blame] | 741 | common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed') |
Владислав Наумов | aa43061 | 2020-06-08 17:18:31 +0200 | [diff] [blame] | 742 | currentBuild.result = 'FAILURE' |
| 743 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 744 | } |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 745 | |
| 746 | |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 747 | /** |
| 748 | * Function currently supported to be called from aws or vsphere demos. It gets particular demo context |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 749 | * and generate proper lockResources data and netMap data for vsphere,equinix related clusters. |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 750 | * |
| 751 | * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere] |
| 752 | * @param: triggers (map) Custom trigger keywords forwarded from gerrit |
| 753 | * @param: multiregionalConfiguration (map) Multiregional configuration |
| 754 | * @return (map) Return aggregated map with lockResources and netMap |
| 755 | */ |
| 756 | |
| 757 | |
| 758 | def generateLockResources(callBackDemo, triggers) { |
| 759 | def common = new com.mirantis.mk.Common() |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 760 | def netMap = [ |
| 761 | vsphere: [:], |
| 762 | equinix: [:], |
| 763 | ] |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 764 | // Define vsphere locklabels with initial quantity |
| 765 | def lockLabels = [ |
| 766 | vsphere_networking_core_ci: 0, |
| 767 | vsphere_offline_networking_core_ci: 0, |
| 768 | ] |
| 769 | def deployChild = triggers.deployChildEnabled |
| 770 | def multiregionConfig = triggers.multiregionalConfiguration |
| 771 | def runMultiregion = multiregionConfig.enabled |
| 772 | |
| 773 | // Generate vsphere netMap and lockLabels based on demo context |
| 774 | switch (callBackDemo) { |
| 775 | case 'aws': |
| 776 | // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child |
| 777 | lockLabels['aws_core_ci_queue'] = triggers.demoWeight |
Sergey Kolekonov | f4c1f49 | 2022-02-03 14:44:45 +0400 | [diff] [blame] | 778 | if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 } |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 779 | |
| 780 | // Define netMap for Vsphere region |
Mikhail Ivanov | 90a27fa | 2022-05-30 15:18:24 +0400 | [diff] [blame] | 781 | if (runMultiregion && multiregionConfig.managementLocation == 'aws') { |
| 782 | if (multiregionConfig.regionLocation == 'vsphere') { |
| 783 | if (deployChild) { |
| 784 | addToProviderNetMap(netMap, 'vsphere', 'regional-child') |
| 785 | } |
| 786 | addToProviderNetMap(netMap, 'vsphere', 'region') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 787 | } |
Mikhail Ivanov | 90a27fa | 2022-05-30 15:18:24 +0400 | [diff] [blame] | 788 | |
| 789 | if (multiregionConfig.regionLocation == 'azure') { |
| 790 | lockLabels['azure_core_ci_queue'] = 1 |
| 791 | if (deployChild) { |
| 792 | lockLabels['azure_core_ci_queue'] += 1 |
| 793 | } |
| 794 | } |
| 795 | } |
| 796 | if (triggers.azureOnAwsDemoEnabled) { |
| 797 | lockLabels['azure_core_ci_queue'] = 1 |
| 798 | } |
| 799 | |
| 800 | if (triggers.equinixOnAwsDemoEnabled) { |
| 801 | lockLabels['equinix_core_ci_queue'] = 1 |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 802 | } |
| 803 | break |
| 804 | case 'vsphere': |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 805 | addToProviderNetMap(netMap, 'vsphere', 'mgmt') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 806 | if (deployChild) { |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 807 | addToProviderNetMap(netMap, 'vsphere', 'child') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 808 | } |
| 809 | if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' && |
| 810 | multiregionConfig.regionLocation == 'vsphere') { |
| 811 | if (deployChild) { |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 812 | addToProviderNetMap(netMap, 'vsphere', 'regional-child') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 813 | } |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 814 | addToProviderNetMap(netMap, 'vsphere', 'region') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 815 | } |
| 816 | break |
Mikhail Ivanov | 90a27fa | 2022-05-30 15:18:24 +0400 | [diff] [blame] | 817 | case 'azure': |
| 818 | lockLabels['azure_core_ci_queue'] = triggers.demoWeight |
| 819 | if (runMultiregion && multiregionConfig.managementLocation == 'azure') { |
| 820 | if (multiregionConfig.regionLocation == 'aws') { |
| 821 | lockLabels['aws_core_ci_queue'] = 1 |
| 822 | if (deployChild) { |
| 823 | lockLabels['aws_core_ci_queue'] += 1 |
| 824 | } |
| 825 | } |
| 826 | |
| 827 | if (multiregionConfig.regionLocation == 'equinix') { |
| 828 | lockLabels['equinix_core_ci_queue'] = 1 |
| 829 | if (deployChild) { |
| 830 | lockLabels['equinix_core_ci_queue'] +=1 |
| 831 | } |
| 832 | } |
| 833 | } |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 834 | default: |
Mikhail Ivanov | 90a27fa | 2022-05-30 15:18:24 +0400 | [diff] [blame] | 835 | error('Supposed to be called from aws, azure or vsphere demos only') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 836 | } |
| 837 | |
| 838 | // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment |
| 839 | // Vsphere labels only |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 840 | netMap['vsphere'].each { clusterType, netConfig -> |
| 841 | if (triggers.proxyConfig["${clusterType}Offline"] == true || |
| 842 | (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) || |
| 843 | (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) { |
| 844 | |
| 845 | netMap['vsphere'][clusterType]['netName'] = 'offline' |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 846 | lockLabels['vsphere_offline_networking_core_ci']++ |
| 847 | } else { |
| 848 | lockLabels['vsphere_networking_core_ci']++ |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | // generate lock metadata |
| 853 | def lockResources = [] |
| 854 | lockLabels.each { label, quantity -> |
| 855 | if (quantity > 0) { |
| 856 | def res = [ |
| 857 | label: label, |
| 858 | quantity: quantity, |
| 859 | ] |
| 860 | lockResources.add(res) |
| 861 | } |
| 862 | } |
| 863 | |
| 864 | common.infoMsg("""Generated vsphere netMap: ${netMap} |
| 865 | Generated lockResources: ${lockResources}""") |
| 866 | |
| 867 | return [ |
| 868 | netMap: netMap, |
| 869 | lockResources: lockResources, |
| 870 | ] |
| 871 | } |
| 872 | |
| 873 | /** |
| 874 | * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName |
| 875 | * and empty rangeConfig to the this map. |
| 876 | * |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 877 | * @param: netMap (string) vsphere, equinix netMap or empty map |
| 878 | * @param: provider (string) provider type |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 879 | * @param: clusterType (string) Vsphere cluster type |
| 880 | */ |
| 881 | |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 882 | def addToProviderNetMap (netMap, provider, clusterType) { |
| 883 | switch (provider) { |
| 884 | case 'equinix': |
| 885 | netMap[provider][clusterType] = [ |
| 886 | vlanConfig: '', |
| 887 | ] |
| 888 | break |
| 889 | case 'vsphere': |
| 890 | netMap[provider][clusterType] = [ |
| 891 | netName: 'default', |
| 892 | rangeConfig: '', |
| 893 | ] |
| 894 | break |
| 895 | default: |
| 896 | error('Net map locks supported for Equinix/Vsphere providers only') |
| 897 | } |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 898 | } |
Dmitry Teselkin | fce71aa | 2022-03-05 19:36:52 +0300 | [diff] [blame] | 899 | |
| 900 | /** |
| 901 | * getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps. |
| 902 | * Each element (map) contains keys 'key' for keyword name and 'value' for its value. |
| 903 | * If keyword contains only 'key' part then 'value' is boolean True. |
| 904 | * This function does not perform keywords validation. |
| 905 | * First line of a commit message is ignored. |
| 906 | * To use '[' or ']' characters inside keyword prepend it with backslash '\'. |
| 907 | * TODO: Remove backslash chars from values if they prepend '[' or ']'. |
| 908 | **/ |
| 909 | |
| 910 | List getCIKeywordsFromCommitMsg() { |
| 911 | String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
| 912 | List commitMsgLines = commitMsg.split('\n') |
| 913 | List keywords = [] |
| 914 | if (commitMsgLines.size() < 2) { |
| 915 | return keywords |
| 916 | } |
| 917 | |
| 918 | String commitMsgBody = commitMsgLines[1..-1].join('\n') |
| 919 | |
| 920 | // Split commit message body to chunks using '[' or ']' as delimiter, |
| 921 | // ignoring them if prepended by backslash (regex negative lookbehind). |
| 922 | // Resulting list will have chunks between '[' and ']' at odd indexes. |
| 923 | List parts = commitMsgBody.split(/(?<!\\)[\[\]]/) |
| 924 | |
| 925 | // Iterate chunks by odd indexes only, trim values and split to |
| 926 | // <key> / <value> pair where <key> is the part of a sting before the first |
| 927 | // whitespace delimiter, and <value> is the rest (may include whitespaces). |
| 928 | // If there is no whitespace in the string then this is a 'switch' |
| 929 | // and <value> will be boolean True. |
| 930 | for (i = 1; i < parts.size(); i += 2) { |
| 931 | def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1] |
| 932 | keywords.add(['key': key, 'value': value]) |
| 933 | } |
| 934 | |
| 935 | return keywords |
| 936 | } |
| 937 | |
| 938 | /** |
| 939 | * getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword |
| 940 | * that were specified for given job name. `job-params` keyword has the following structure |
| 941 | * |
| 942 | * [job-params <job name> <parameter name> <parameter value>] |
| 943 | * |
| 944 | * Return value is a Map that contains those parameters using the following structure: |
| 945 | * |
| 946 | * <job name>: |
| 947 | * <parameter name>: <parameter value> |
| 948 | * |
| 949 | **/ |
| 950 | Map getJobsParamsFromCommitMsg() { |
| 951 | List keywords = getCIKeywordsFromCommitMsg() |
| 952 | |
| 953 | List jobsParamsList = [] |
| 954 | keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) { |
| 955 | def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1] |
| 956 | def (key, value) = params.split(/\s+/, 2) |
| 957 | ['name': name, 'key': key, 'value': value] |
| 958 | } |
| 959 | |
| 960 | Map jobsParams = jobsParamsList.inject([:]) { result, it -> |
| 961 | if (!result.containsKey(it.name)) { |
| 962 | result[it.name] = [:] |
| 963 | } |
| 964 | result[it.name][it.key] = it.value |
| 965 | result |
| 966 | } |
| 967 | |
| 968 | return jobsParams |
| 969 | } |
| 970 | |
| 971 | |
| 972 | /** |
| 973 | * getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message. |
| 974 | * It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then |
| 975 | * uses only those parametes that were set to all jobs (with <job name> == '*') or to |
| 976 | * a particular job. Parameters set to a particular job have higher precedence. |
| 977 | * |
| 978 | * Return value is a Map that contains those parameters: |
| 979 | * |
| 980 | * <parameter name>: <parameter value> |
| 981 | * |
| 982 | **/ |
| 983 | Map getJobParamsFromCommitMsg(String jobName) { |
| 984 | jobsParams = getJobsParamsFromCommitMsg() |
| 985 | jobParams = jobsParams.getOrDefault('*', [:]) |
| 986 | if (jobName) { |
| 987 | jobParams.putAll(jobsParams.getOrDefault(jobName, [:])) |
| 988 | } |
| 989 | return jobParams |
| 990 | } |
azvyagintsev | c17d14b | 2022-06-06 19:06:33 +0300 | [diff] [blame^] | 991 | |
| 992 | /** Getting test scheme from text, which should be |
| 993 | Imput example: |
| 994 | text=""" |
| 995 | DATA |
| 996 | |
| 997 | kaas_bm_test_schemas: |
| 998 | KAAS_RELEASES_REFSPEC: '' |
| 999 | KEY: VAL |
| 1000 | |
| 1001 | DATA |
| 1002 | """ |
| 1003 | |
| 1004 | Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas']) |
| 1005 | |
| 1006 | Return: |
| 1007 | ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL'] |
| 1008 | **/ |
| 1009 | def parseTextForTestSchemas(Map opts) { |
| 1010 | String text = opts.get('text', '') |
| 1011 | String keyLine = opts.getOrDefault('keyLine', '') |
| 1012 | Map testScheme = [:] |
| 1013 | if (!text || !keyLine) { |
| 1014 | return [:] |
| 1015 | } |
| 1016 | if (text =~ /\n$keyLine\n.*/) { |
| 1017 | def common = new com.mirantis.mk.Common() |
| 1018 | try { |
| 1019 | String regExp = '\\n' + keyLine + '\\n' |
| 1020 | // regexep block must be followed by empty line |
| 1021 | testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}" |
| 1022 | common.infoMsg("parseTextForTestSchemas result:\n" + testScheme) |
| 1023 | common.mergeEnv(env, toJson(testScheme)) |
| 1024 | } |
| 1025 | catch (Exception e) { |
| 1026 | common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}") |
| 1027 | throw e |
| 1028 | } |
| 1029 | } |
| 1030 | } |