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 | |
| 3 | /** |
| 4 | * |
| 5 | * KaaS Component Testing Utilities |
| 6 | * |
| 7 | */ |
| 8 | |
Владислав Наумов | e534581 | 2020-08-12 16:30:20 +0200 | [diff] [blame] | 9 | /** |
| 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 | */ |
| 18 | def 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 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 32 | |
| 33 | /** |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 34 | * Determine scope of test suite against per-commit KaaS deployment based on keywords |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 35 | * 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] | 36 | * |
| 37 | * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs |
| 38 | * Example scheme: |
Владислав Наумов | e534581 | 2020-08-12 16:30:20 +0200 | [diff] [blame] | 39 | * 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] | 40 | * manage test-suite through Jenkins Job Parameters |
| 41 | * |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 42 | * @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 |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 45 | * ] |
| 46 | */ |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 47 | def checkDeploymentTestSuite() { |
vnaumov | bdb9022 | 2020-05-04 18:25:50 +0200 | [diff] [blame] | 48 | def common = new com.mirantis.mk.Common() |
| 49 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 50 | // Available triggers and its sane defaults |
Владислав Наумов | 44c64b7 | 2020-12-04 20:22:53 +0100 | [diff] [blame] | 51 | def seedMacOs = env.SEED_MACOS ? env.SEED_MACOS.toBoolean() : false |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 52 | 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 Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 54 | def customChildRelease = env.KAAS_CHILD_CLUSTER_RELEASE_NAME ? env.KAAS_CHILD_CLUSTER_RELEASE_NAME : '' |
Владислав Наумов | 0dc9925 | 2020-11-13 13:30:48 +0100 | [diff] [blame] | 55 | def attachBYO = env.ATTACH_BYO ? env.ATTACH_BYO.toBoolean() : false |
Владислав Наумов | cdbd84e | 2020-12-01 16:51:09 +0100 | [diff] [blame] | 56 | def upgradeBYO = env.UPGRADE_BYO ? env.UPGRADE_BYO.toBoolean() : false |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame^] | 57 | def runBYOMatrix = env.RUN_BYO_MATRIX ? env.RUN_BYO_MATRIX.toBoolean() : false |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 58 | def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 59 | def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 60 | 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 |
Владислав Наумов | 9cec55d | 2021-08-03 15:00:59 +0200 | [diff] [blame] | 62 | def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false |
Vladyslav Drok | c4f9c1b | 2021-07-22 15:34:24 +0200 | [diff] [blame] | 63 | def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 64 | 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 Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 66 | def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 67 | // 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 | ] |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 73 | |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 74 | // proxy customization |
| 75 | def proxyConfig = [ |
Владислав Наумов | f8f23fa | 2021-04-01 16:57:52 +0200 | [diff] [blame] | 76 | mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false, |
| 77 | childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false, |
Владислав Наумов | 257ea13 | 2021-04-14 14:44:13 +0200 | [diff] [blame] | 78 | childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false, |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 79 | ] |
| 80 | |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 81 | // optional demo deployment customization |
Владислав Наумов | 905dd36 | 2020-06-08 16:37:01 +0200 | [diff] [blame] | 82 | def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 83 | def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false |
Владислав Наумов | 82305e9 | 2021-10-14 20:45:20 +0200 | [diff] [blame] | 84 | def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false |
Владислав Наумов | f371580 | 2021-05-03 18:06:45 +0200 | [diff] [blame] | 85 | def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 86 | def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 87 | 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] | 88 | def enableVsphereDemo = true |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 89 | def enableOSDemo = true |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 90 | def enableBMDemo = true |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 91 | |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 92 | 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] | 93 | if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) { |
| 94 | proxyConfig['mgmtOffline'] = true |
Владислав Наумов | 70c0242 | 2021-04-19 14:29:41 +0200 | [diff] [blame] | 95 | 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] | 96 | } |
Владислав Наумов | 44c64b7 | 2020-12-04 20:22:53 +0100 | [diff] [blame] | 97 | if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) { |
| 98 | seedMacOs = true |
| 99 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 100 | if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) { |
| 101 | deployChild = true |
| 102 | } |
| 103 | if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) { |
| 104 | deployChild = true |
| 105 | upgradeChild = true |
| 106 | } |
Mikhail Ivanov | 76d6995 | 2021-06-04 16:06:45 +0400 | [diff] [blame] | 107 | def deployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/) |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 108 | if (deployMatches.size() > 0) { |
| 109 | // override child version when it set explicitly |
| 110 | deployChild = true |
Mikhail Ivanov | ed54349 | 2021-05-24 16:26:55 +0400 | [diff] [blame] | 111 | customChildRelease = deployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim() |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 112 | common.warningMsg("Forced child deployment using custom release version ${customChildRelease}") |
| 113 | } |
Владислав Наумов | 0dc9925 | 2020-11-13 13:30:48 +0100 | [diff] [blame] | 114 | if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) { |
| 115 | attachBYO = true |
| 116 | } |
Владислав Наумов | cdbd84e | 2020-12-01 16:51:09 +0100 | [diff] [blame] | 117 | if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) { |
| 118 | attachBYO = true |
| 119 | upgradeBYO = true |
| 120 | } |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame^] | 121 | if (commitMsg ==~ /(?s).*\[run-byo-matrix\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*run-byo-matrix\.*/) { |
| 122 | runBYOMatrix = true |
| 123 | |
| 124 | common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped') |
| 125 | attachBYO = false |
| 126 | upgradeBYO = false |
| 127 | } |
Владислав Наумов | 7f8c987 | 2021-03-08 17:33:08 +0400 | [diff] [blame] | 128 | if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) { |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 129 | upgradeMgmt = true |
| 130 | } |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 131 | if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) { |
| 132 | enableLMALogging = true |
| 133 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 134 | if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) { |
| 135 | runUie2e = true |
| 136 | } |
| 137 | if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) { |
| 138 | runMgmtConformance = true |
| 139 | } |
Vladyslav Drok | c4f9c1b | 2021-07-22 15:34:24 +0200 | [diff] [blame] | 140 | if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) { |
| 141 | runMgmtUserControllerTest = true |
| 142 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 143 | if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) { |
| 144 | runChildConformance = true |
| 145 | deployChild = true |
| 146 | } |
Владислав Наумов | 9cec55d | 2021-08-03 15:00:59 +0200 | [diff] [blame] | 147 | if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) { |
| 148 | runLMATest = true |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 149 | enableLMALogging = true |
| 150 | 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] | 151 | } |
Владислав Наумов | f8f23fa | 2021-04-01 16:57:52 +0200 | [diff] [blame] | 152 | if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) { |
| 153 | proxyConfig['childOffline'] = true |
| 154 | deployChild = true |
| 155 | } |
Владислав Наумов | 257ea13 | 2021-04-14 14:44:13 +0200 | [diff] [blame] | 156 | if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) { |
| 157 | proxyConfig['childOffline'] = true |
| 158 | proxyConfig['childProxy'] = true |
| 159 | deployChild = true |
| 160 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 161 | if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) { |
| 162 | fetchServiceBinaries = true |
| 163 | } |
Владислав Наумов | f1665b5 | 2021-05-13 10:51:17 +0200 | [diff] [blame] | 164 | 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] | 165 | equinixOnAwsDemo = true |
Владислав Наумов | f1665b5 | 2021-05-13 10:51:17 +0200 | [diff] [blame] | 166 | 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] | 167 | } |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 168 | if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) { |
| 169 | azureOnAwsDemo = true |
| 170 | common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ') |
| 171 | } |
| 172 | if (commitMsg ==~ /(?s).*\[aws-demo\].*/ || |
| 173 | env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ || |
| 174 | attachBYO || |
| 175 | upgradeBYO || |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame^] | 176 | runBYOMatrix || |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 177 | seedMacOs || |
| 178 | equinixOnAwsDemo || |
| 179 | azureOnAwsDemo) { |
| 180 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 181 | awsOnDemandDemo = true |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 182 | 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] | 183 | } |
Владислав Наумов | f1665b5 | 2021-05-13 10:51:17 +0200 | [diff] [blame] | 184 | if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) { |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 185 | equinixOnDemandDemo = true |
| 186 | } |
Владислав Наумов | 82305e9 | 2021-10-14 20:45:20 +0200 | [diff] [blame] | 187 | if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) { |
Владислав Наумов | 144956f | 2021-10-14 17:49:19 +0200 | [diff] [blame] | 188 | equinixMetalV2OnDemandDemo = true |
| 189 | } |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 190 | if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) { |
| 191 | equinixMetalV2OnDemandDemo = true |
| 192 | equinixMetalV2ChildDiffMetro = true |
| 193 | } |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 194 | if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) { |
| 195 | azureOnDemandDemo = true |
| 196 | } |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 197 | if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) { |
| 198 | enableOSDemo = false |
| 199 | common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set') |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 200 | } |
| 201 | |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 202 | if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) { |
| 203 | enableBMDemo = false |
| 204 | common.errorMsg('BM demo deployment will be aborted, VF -1 will be set') |
| 205 | } |
| 206 | |
Ivan Berezovskiy | f9bcfd6 | 2021-03-18 18:41:38 +0400 | [diff] [blame] | 207 | if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) { |
| 208 | enableVsphereDemo = false |
| 209 | common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set') |
| 210 | } |
| 211 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 212 | // TODO (vnaumov) remove below condition after moving all releases to UCP |
| 213 | def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/) |
| 214 | if (ucpChildMatches.size() > 0) { |
| 215 | deployChild = true |
| 216 | common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ') |
| 217 | |
| 218 | // TODO(vnaumov) delete after ucp upgrades support |
| 219 | common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled') |
| 220 | upgradeChild = false |
| 221 | } |
| 222 | |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 223 | // multiregional tests |
| 224 | def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/) |
| 225 | if (multiRegionalMatches.size() > 0) { |
| 226 | multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches) |
| 227 | } |
| 228 | switch (multiregionalMappings['managementLocation']) { |
| 229 | case 'aws': |
Владислав Наумов | 53b07e5 | 2021-01-07 15:08:27 +0100 | [diff] [blame] | 230 | common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request') |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 231 | awsOnDemandDemo = true |
Владислав Наумов | 53b07e5 | 2021-01-07 15:08:27 +0100 | [diff] [blame] | 232 | |
| 233 | if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers |
| 234 | error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously') |
| 235 | } |
Владислав Наумов | 3e4b5a3 | 2020-09-11 17:05:34 +0200 | [diff] [blame] | 236 | break |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 237 | case 'os': |
| 238 | if (enableOSDemo == false) { |
| 239 | error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously') |
| 240 | } |
Владислав Наумов | 3e4b5a3 | 2020-09-11 17:05:34 +0200 | [diff] [blame] | 241 | break |
Владислав Наумов | 865ba6c | 2021-05-13 13:05:45 +0200 | [diff] [blame] | 242 | case 'vsphere': |
| 243 | if (enableVsphereDemo == false) { |
| 244 | error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously') |
| 245 | } |
| 246 | break |
Владислав Наумов | 5be0294 | 2021-05-13 12:34:37 +0200 | [diff] [blame] | 247 | case 'equinix': |
| 248 | common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request') |
| 249 | equinixOnDemandDemo = true |
| 250 | break |
slalov | fd0b7e6 | 2021-07-28 18:05:16 +0400 | [diff] [blame] | 251 | case 'azure': |
| 252 | common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request') |
| 253 | azureOnDemandDemo = true |
| 254 | break |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 255 | } |
| 256 | |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 257 | // CDN configuration |
| 258 | def cdnConfig = [ |
| 259 | mgmt: [ |
| 260 | openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci', |
Владислав Наумов | 70c0242 | 2021-04-19 14:29:41 +0200 | [diff] [blame] | 261 | vsphere: 'internal-ci', |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 262 | aws: 'public-ci', |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 263 | equinix: 'public-ci', |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 264 | azure: 'public-ci', |
Владислав Наумов | f8f23fa | 2021-04-01 16:57:52 +0200 | [diff] [blame] | 265 | ], |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 266 | ] |
| 267 | |
Владислав Наумов | 74e2d6e | 2020-12-30 17:05:40 +0100 | [diff] [blame] | 268 | // calculate weight of current demo run to manage lockable resources |
| 269 | def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1 |
| 270 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 271 | common.infoMsg(""" |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 272 | CDN deployment configuration: ${cdnConfig} |
| 273 | MCC offline deployment configuration: ${proxyConfig} |
Владислав Наумов | 44c64b7 | 2020-12-04 20:22:53 +0100 | [diff] [blame] | 274 | Use MacOS node as seed: ${seedMacOs} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 275 | Child cluster deployment scheduled: ${deployChild} |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 276 | Custom child cluster release: ${customChildRelease} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 277 | Child cluster release upgrade scheduled: ${upgradeChild} |
| 278 | Child conformance testing scheduled: ${runChildConformance} |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame^] | 279 | Single BYO cluster attachment scheduled: ${attachBYO} |
| 280 | Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO} |
| 281 | BYO test matrix whole suite scheduled: ${runBYOMatrix} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 282 | Mgmt cluster release upgrade scheduled: ${upgradeMgmt} |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 283 | Mgmt LMA logging enabled: ${enableLMALogging} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 284 | Mgmt conformance testing scheduled: ${runMgmtConformance} |
Владислав Наумов | 9cec55d | 2021-08-03 15:00:59 +0200 | [diff] [blame] | 285 | LMA testing scheduled: ${runLMATest} |
Vladyslav Drok | c4f9c1b | 2021-07-22 15:34:24 +0200 | [diff] [blame] | 286 | Mgmt user controller testing scheduled: ${runMgmtUserControllerTest} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 287 | Mgmt UI e2e testing scheduled: ${runUie2e} |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 288 | AWS provider deployment scheduled: ${awsOnDemandDemo} |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 289 | Equinix provider deployment scheduled: ${equinixOnDemandDemo} |
Владислав Наумов | 144956f | 2021-10-14 17:49:19 +0200 | [diff] [blame] | 290 | EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo} |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 291 | EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro} |
Владислав Наумов | f1665b5 | 2021-05-13 10:51:17 +0200 | [diff] [blame] | 292 | Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo} |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 293 | Azure provider deployment scheduled: ${azureOnDemandDemo} |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 294 | Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo} |
Ivan Berezovskiy | f9bcfd6 | 2021-03-18 18:41:38 +0400 | [diff] [blame] | 295 | VSPHERE provider deployment scheduled: ${enableVsphereDemo} |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 296 | OS provider deployment scheduled: ${enableOSDemo} |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 297 | BM provider deployment scheduled: ${enableBMDemo} |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame] | 298 | Multiregional configuration: ${multiregionalMappings} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 299 | Service binaries fetching scheduled: ${fetchServiceBinaries} |
Владислав Наумов | 74e2d6e | 2020-12-30 17:05:40 +0100 | [diff] [blame] | 300 | Current weight of the demo run: ${demoWeight} (Used to manage lockable resources) |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 301 | 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] | 302 | return [ |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 303 | cdnConfig : cdnConfig, |
| 304 | proxyConfig : proxyConfig, |
| 305 | useMacOsSeedNode : seedMacOs, |
| 306 | deployChildEnabled : deployChild, |
| 307 | childDeployCustomRelease : customChildRelease, |
| 308 | upgradeChildEnabled : upgradeChild, |
| 309 | runChildConformanceEnabled : runChildConformance, |
| 310 | attachBYOEnabled : attachBYO, |
| 311 | upgradeBYOEnabled : upgradeBYO, |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame^] | 312 | runBYOMatrixEnabled : runBYOMatrix, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 313 | upgradeMgmtEnabled : upgradeMgmt, |
| 314 | enableLMALoggingEnabled : enableLMALogging, |
| 315 | runUie2eEnabled : runUie2e, |
| 316 | runMgmtConformanceEnabled : runMgmtConformance, |
| 317 | runLMATestEnabled : runLMATest, |
| 318 | runMgmtUserControllerTestEnabled : runMgmtUserControllerTest, |
| 319 | fetchServiceBinariesEnabled : fetchServiceBinaries, |
| 320 | awsOnDemandDemoEnabled : awsOnDemandDemo, |
| 321 | equinixOnDemandDemoEnabled : equinixOnDemandDemo, |
| 322 | equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo, |
| 323 | equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro, |
| 324 | equinixOnAwsDemoEnabled : equinixOnAwsDemo, |
| 325 | azureOnDemandDemoEnabled : azureOnDemandDemo, |
| 326 | azureOnAwsDemoEnabled : azureOnAwsDemo, |
| 327 | vsphereDemoEnabled : enableVsphereDemo, |
| 328 | vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out |
| 329 | bmDemoEnabled : enableBMDemo, |
| 330 | osDemoEnabled : enableOSDemo, |
| 331 | multiregionalConfiguration : multiregionalMappings, |
| 332 | demoWeight : demoWeight] |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | /** |
| 336 | * Determine management and regional setup for demo workflow scenario |
| 337 | * |
| 338 | * |
| 339 | * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]` |
| 340 | or Jenkins environment string variable in form like 'aws,os' |
| 341 | * @return (map)[ |
| 342 | enabled: (bool), |
| 343 | * managementLocation: (string), //aws,os |
| 344 | * regionLocation: (string), //aws,os |
| 345 | * ] |
| 346 | */ |
| 347 | def multiregionWorkflowParser(keyword) { |
Владислав Наумов | 8c0c39d | 2020-09-11 14:46:48 +0200 | [diff] [blame] | 348 | def common = new com.mirantis.mk.Common() |
slalov | de59e31 | 2021-07-27 16:25:16 +0400 | [diff] [blame] | 349 | def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'azure'] |
slalov | 19d6e77 | 2021-08-09 15:29:04 +0400 | [diff] [blame] | 350 | def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'bm', 'azure', 'aws'] |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 351 | |
| 352 | def clusterTypes = '' |
Владислав Наумов | 38ed7bf | 2020-09-11 14:43:39 +0200 | [diff] [blame] | 353 | if (keyword.toString().contains('multiregion')) { |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 354 | common.infoMsg('Multiregion definition configured via gerrit keyword trigger') |
| 355 | clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',') |
| 356 | } else { |
| 357 | common.infoMsg('Multiregion definition configured via environment variable') |
| 358 | clusterTypes = keyword.trim().split(',') |
| 359 | } |
| 360 | |
| 361 | if (clusterTypes.size() != 2) { |
Владислав Наумов | 482fb50 | 2020-10-30 17:59:27 +0100 | [diff] [blame] | 362 | error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}") |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 363 | } |
| 364 | |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame] | 365 | def desiredManagementProvider = clusterTypes[0].trim() |
| 366 | def desiredRegionalProvider = clusterTypes[1].trim() |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 367 | if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) { |
| 368 | error("""unsupported management <-> regional bundle, available options: |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame] | 369 | management providers list - ${supportedManagementProviders} |
| 370 | regional providers list - ${supportedRegionalProviders}""") |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | return [ |
| 374 | enabled: true, |
| 375 | managementLocation: desiredManagementProvider, |
| 376 | regionLocation: desiredRegionalProvider, |
| 377 | ] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | /** |
| 381 | * Determine if custom si tests/pipelines refspec forwarded from gerrit change request |
| 382 | |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 383 | * 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] | 384 | * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs |
| 385 | * Example scheme: |
| 386 | * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core |
| 387 | * manage refspecs through Jenkins Job Parameters |
| 388 | * |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 389 | * @return (map)[* siTests: (string) final refspec for si-tests |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 390 | * siPipelines: (string) final refspec for si-pipelines |
| 391 | * ] |
| 392 | */ |
| 393 | def checkCustomSIRefspec() { |
vnaumov | bdb9022 | 2020-05-04 18:25:50 +0200 | [diff] [blame] | 394 | def common = new com.mirantis.mk.Common() |
| 395 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 396 | // Available triggers and its sane defaults |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 397 | def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master' |
| 398 | def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master' |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 399 | def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test' |
| 400 | def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master' |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 401 | 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] | 402 | |
| 403 | def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/) |
| 404 | def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/) |
| 405 | |
| 406 | if (siTestMatches.size() > 0) { |
| 407 | siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim() |
Владислав Наумов | 7f6c088 | 2021-03-23 19:10:57 +0400 | [diff] [blame] | 408 | siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}" |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 409 | siTestsDockerImageTag = siTestsRefspec.split('/')[-1] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 410 | } |
| 411 | if (siPipelinesMatches.size() > 0) { |
| 412 | siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 413 | } |
| 414 | |
| 415 | common.infoMsg(""" |
| 416 | kaas/si-pipelines will be fetched from: ${siPipelinesRefspec} |
| 417 | kaas/si-tests will be fetched from: ${siTestsRefspec} |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 418 | kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag} |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 419 | 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] | 420 | return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 421 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 422 | |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 423 | /** |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 424 | * Parse additional configuration for kaas component CICD repo |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 425 | * @param configurationFile (str) path to configuration file in yaml format |
| 426 | * |
| 427 | * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests, |
| 428 | * ] |
| 429 | */ |
| 430 | def parseKaaSComponentCIParameters(configurationFile){ |
| 431 | def common = new com.mirantis.mk.Common() |
| 432 | def ciConfig = readYaml file: configurationFile |
| 433 | def ciSpec = [ |
| 434 | siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '', |
| 435 | ] |
| 436 | |
| 437 | if (ciConfig.containsKey('si-tests-feature-flags')) { |
| 438 | common.infoMsg("""SI tests feature flags customization detected, |
| 439 | results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""") |
| 440 | |
| 441 | def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() } |
| 442 | ffMeta.addAll(ciConfig['si-tests-feature-flags']) |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 443 | |
Владислав Наумов | cb5ffca | 2020-07-14 15:28:36 +0200 | [diff] [blame] | 444 | ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',') |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 445 | common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}") |
| 446 | } |
| 447 | |
| 448 | common.infoMsg("""Additional ci configuration parsed successfully: |
| 449 | siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""") |
| 450 | return ciSpec |
| 451 | } |
| 452 | |
| 453 | /** |
| 454 | * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 455 | |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 456 | * 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] | 457 | * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs |
| 458 | * Example scheme: |
| 459 | * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core |
| 460 | * manage refspecs through Jenkins Job Parameters |
| 461 | * |
| 462 | * @return (map)[ core: (string) final refspec for kaas/core |
| 463 | * corePipelines: (string) final refspec for pipelines in kaas/core |
| 464 | * ] |
| 465 | */ |
| 466 | def checkCustomCoreRefspec() { |
| 467 | def common = new com.mirantis.mk.Common() |
| 468 | |
| 469 | // Available triggers and its sane defaults |
| 470 | def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master' |
| 471 | // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs* |
| 472 | def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC' |
| 473 | def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
| 474 | |
| 475 | def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/) |
| 476 | def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/) |
| 477 | |
| 478 | if (coreMatches.size() > 0) { |
| 479 | coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 480 | } |
| 481 | if (corePipelinesMatches.size() > 0) { |
| 482 | corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 483 | } |
| 484 | |
| 485 | common.infoMsg(""" |
| 486 | kaas/core will be fetched from: ${coreRefspec} |
| 487 | kaas/core pipelines will be fetched from: ${corePipelinesRefspec} |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 488 | 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] | 489 | return [core: coreRefspec, corePipelines: corePipelinesRefspec] |
| 490 | } |
| 491 | |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 492 | |
| 493 | /** |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 494 | * generate Jenkins Parameter objects from from text parameter with additonal kaas core context |
| 495 | * needed to forward inside kaas core set of jobs |
| 496 | * |
| 497 | * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format |
| 498 | * @return (list)[ string(name: '', value: ''), |
| 499 | * ] |
| 500 | */ |
| 501 | def generateKaaSVarsFromContext(context) { |
| 502 | def common = new com.mirantis.mk.Common() |
| 503 | def parameters = [] |
| 504 | def config = readYaml text: context |
| 505 | |
| 506 | config.each { k,v -> |
| 507 | common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}") |
| 508 | parameters.add(string(name: k, value: v)) |
| 509 | } |
| 510 | |
| 511 | return parameters |
| 512 | } |
| 513 | |
| 514 | /** |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 515 | * 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] | 516 | * 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] | 517 | * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs |
| 518 | * |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 519 | * @param: component (string) component name [iam, lcm, stacklight] |
| 520 | * @param: patchSpec (string) Patch for kaas/cluster releases in json format |
| 521 | * @param: configurationFile (string) Additional file for component repo CI config in yaml format |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 522 | */ |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 523 | def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') { |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 524 | def common = new com.mirantis.mk.Common() |
| 525 | // Determine if custom trigger keywords forwarded from gerrit |
| 526 | def triggers = checkDeploymentTestSuite() |
| 527 | // Determine SI refspecs |
| 528 | def siRefspec = checkCustomSIRefspec() |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 529 | // Determine Core refspecs |
| 530 | def coreRefspec = checkCustomCoreRefspec() |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 531 | |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 532 | // Determine component repo ci configuration |
| 533 | def ciSpec = [:] |
| 534 | def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: '' |
| 535 | if (fileExists(configurationFile)) { |
| 536 | common.infoMsg('Component CI configuration file detected, parsing...') |
| 537 | ciSpec = parseKaaSComponentCIParameters(configurationFile) |
| 538 | componentFeatureFlags = ciSpec['siTestsFeatureFlags'] |
| 539 | } else { |
| 540 | common.warningMsg('''Component CI configuration file is not exists, |
Владислав Наумов | c17dd55 | 2020-07-29 17:07:38 +0200 | [diff] [blame] | 541 | several code-management features may be unavailable, |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 542 | follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag |
| 543 | to create the configuration file''') |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 544 | } |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 545 | |
| 546 | def platforms = [] |
| 547 | if (component == 'ipam' && triggers.vsphereDemoEnabled) { |
| 548 | // Currently only vsphere demo is required for IPAM component |
| 549 | platforms.add('vsphere') |
| 550 | } else { |
| 551 | if (triggers.osDemoEnabled) { |
| 552 | platforms.add('openstack') |
| 553 | } |
| 554 | if (triggers.awsOnDemandDemoEnabled) { |
| 555 | platforms.add('aws') |
| 556 | } |
| 557 | if (triggers.equinixOnDemandDemoEnabled) { |
| 558 | platforms.add('equinix') |
| 559 | } |
Владислав Наумов | 144956f | 2021-10-14 17:49:19 +0200 | [diff] [blame] | 560 | if (triggers.equinixMetalV2OnDemandDemoEnabled) { |
| 561 | platforms.add('equinixmetalv2') |
| 562 | } |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 563 | if (triggers.azureOnDemandDemoEnabled) { |
| 564 | platforms.add('azure') |
| 565 | } |
Ivan Berezovskiy | b0229d0 | 2021-05-17 16:55:18 +0400 | [diff] [blame] | 566 | if (triggers.vsphereDemoEnabled) { |
| 567 | platforms.add('vsphere') |
| 568 | } |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 569 | } |
| 570 | |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 571 | def jobs = [:] |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 572 | def parameters = [ |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 573 | string(name: 'GERRIT_REFSPEC', value: coreRefspec.core), |
| 574 | string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 575 | string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests), |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 576 | string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags), |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 577 | string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage), |
| 578 | string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag), |
Владислав Наумов | 4a5c324 | 2020-06-08 14:36:11 +0200 | [diff] [blame] | 579 | string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 580 | string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec), |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 581 | string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease), |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 582 | booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']), |
Владислав Наумов | f8f23fa | 2021-04-01 16:57:52 +0200 | [diff] [blame] | 583 | booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']), |
Владислав Наумов | 257ea13 | 2021-04-14 14:44:13 +0200 | [diff] [blame] | 584 | booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']), |
Владислав Наумов | 44c64b7 | 2020-12-04 20:22:53 +0100 | [diff] [blame] | 585 | booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 586 | booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled), |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 587 | booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 588 | booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 589 | booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled), |
Владислав Наумов | 9cec55d | 2021-08-03 15:00:59 +0200 | [diff] [blame] | 590 | booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled), |
Vladyslav Drok | c4f9c1b | 2021-07-22 15:34:24 +0200 | [diff] [blame] | 591 | booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 592 | booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled), |
| 593 | booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled), |
Владислав Наумов | 0dc9925 | 2020-11-13 13:30:48 +0100 | [diff] [blame] | 594 | booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled), |
Владислав Наумов | cdbd84e | 2020-12-01 16:51:09 +0100 | [diff] [blame] | 595 | booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled), |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame^] | 596 | booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 597 | booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled), |
Ivan Berezovskiy | cbf9eeb | 2021-03-22 15:57:32 +0400 | [diff] [blame] | 598 | booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled), |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 599 | booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled), |
Владислав Наумов | 82305e9 | 2021-10-14 20:45:20 +0200 | [diff] [blame] | 600 | booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled), |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 601 | booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled), |
eromanova | d339751 | 2021-04-01 20:19:19 +0400 | [diff] [blame] | 602 | booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled), |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 603 | booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled), |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 604 | booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 605 | ] |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 606 | |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 607 | // customize multiregional demo |
| 608 | if (triggers.multiregionalConfiguration.enabled) { |
| 609 | parameters.add(string(name: 'MULTIREGION_SETUP', |
| 610 | value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}" |
| 611 | )) |
| 612 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 613 | |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 614 | // Determine component team custom context |
| 615 | if (coreContext != '') { |
| 616 | common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...') |
| 617 | def additionalParameters = generateKaaSVarsFromContext(coreContext) |
Владислав Наумов | bef51a9 | 2020-10-01 17:36:51 +0200 | [diff] [blame] | 618 | parameters.addAll(additionalParameters) |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 619 | } |
| 620 | |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 621 | if (triggers.awsOnDemandDemoEnabled || |
| 622 | triggers.equinixOnDemandDemoEnabled || |
| 623 | triggers.azureOnDemandDemoEnabled) { |
| 624 | |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 625 | common.infoMsg('Public provider demo triggered, need to sync artifacts in the public-ci cdn..') |
| 626 | switch (component) { |
| 627 | case 'iam': |
| 628 | build job: 'cdn-binary-dev-replication-iam', propagate: true, wait: true |
| 629 | break |
| 630 | case 'lcm': |
| 631 | build job: 'cdn-binary-dev-replication-lcm', propagate: true, wait: true |
| 632 | break |
| 633 | } |
| 634 | } |
| 635 | |
Владислав Наумов | aa43061 | 2020-06-08 17:18:31 +0200 | [diff] [blame] | 636 | def jobResults = [] |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 637 | |
| 638 | platforms.each { platform -> |
| 639 | jobs["kaas-core-${platform}-patched-${component}"] = { |
Vladislav Naumov | 5313a20 | 2021-04-07 17:13:39 +0000 | [diff] [blame] | 640 | try { |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 641 | common.infoMsg("Deploy: patched KaaS demo with ${platform} provider") |
| 642 | def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true |
| 643 | def build_description = job_info.getDescription() |
| 644 | def build_result = job_info.getResult() |
Vladislav Naumov | 5313a20 | 2021-04-07 17:13:39 +0000 | [diff] [blame] | 645 | jobResults.add(build_result) |
Владислав Наумов | d044e84 | 2020-06-17 15:33:43 +0200 | [diff] [blame] | 646 | |
Vladislav Naumov | 5313a20 | 2021-04-07 17:13:39 +0000 | [diff] [blame] | 647 | if (build_description) { |
| 648 | currentBuild.description += build_description |
| 649 | } |
| 650 | } finally { |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 651 | common.infoMsg("Patched KaaS demo with ${platform} provider finished") |
Vladislav Naumov | 5313a20 | 2021-04-07 17:13:39 +0000 | [diff] [blame] | 652 | } |
| 653 | } |
| 654 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 655 | |
| 656 | common.infoMsg('Trigger KaaS demo deployments according to defined provider set') |
Владислав Наумов | 37f7f84 | 2021-03-09 16:08:39 +0400 | [diff] [blame] | 657 | if (jobs.size() == 0) { |
| 658 | error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled') |
| 659 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 660 | // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085 |
| 661 | parallel jobs |
Владислав Наумов | aa43061 | 2020-06-08 17:18:31 +0200 | [diff] [blame] | 662 | |
| 663 | if (jobResults.contains('FAILURE')) { |
Владислав Наумов | f86b111 | 2020-06-09 14:04:48 +0200 | [diff] [blame] | 664 | common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed') |
Владислав Наумов | aa43061 | 2020-06-08 17:18:31 +0200 | [diff] [blame] | 665 | currentBuild.result = 'FAILURE' |
| 666 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 667 | } |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 668 | |
| 669 | |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 670 | /** |
| 671 | * 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] | 672 | * 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] | 673 | * |
| 674 | * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere] |
| 675 | * @param: triggers (map) Custom trigger keywords forwarded from gerrit |
| 676 | * @param: multiregionalConfiguration (map) Multiregional configuration |
| 677 | * @return (map) Return aggregated map with lockResources and netMap |
| 678 | */ |
| 679 | |
| 680 | |
| 681 | def generateLockResources(callBackDemo, triggers) { |
| 682 | def common = new com.mirantis.mk.Common() |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 683 | def netMap = [ |
| 684 | vsphere: [:], |
| 685 | equinix: [:], |
| 686 | ] |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 687 | // Define vsphere locklabels with initial quantity |
| 688 | def lockLabels = [ |
| 689 | vsphere_networking_core_ci: 0, |
| 690 | vsphere_offline_networking_core_ci: 0, |
| 691 | ] |
| 692 | def deployChild = triggers.deployChildEnabled |
| 693 | def multiregionConfig = triggers.multiregionalConfiguration |
| 694 | def runMultiregion = multiregionConfig.enabled |
| 695 | |
| 696 | // Generate vsphere netMap and lockLabels based on demo context |
| 697 | switch (callBackDemo) { |
| 698 | case 'aws': |
| 699 | // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child |
| 700 | lockLabels['aws_core_ci_queue'] = triggers.demoWeight |
| 701 | |
| 702 | // Define netMap for Vsphere region |
Владислав Наумов | f60480d | 2021-10-15 14:04:01 +0200 | [diff] [blame] | 703 | if (runMultiregion && multiregionConfig.managementLocation == 'aws' && |
| 704 | multiregionConfig.regionLocation == 'vsphere') { |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 705 | if (deployChild) { |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 706 | addToProviderNetMap(netMap, 'vsphere', 'regional-child') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 707 | } |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 708 | addToProviderNetMap(netMap, 'vsphere', 'region') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 709 | } |
| 710 | break |
| 711 | case 'vsphere': |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 712 | addToProviderNetMap(netMap, 'vsphere', 'mgmt') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 713 | if (deployChild) { |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 714 | addToProviderNetMap(netMap, 'vsphere', 'child') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 715 | } |
| 716 | if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' && |
| 717 | multiregionConfig.regionLocation == 'vsphere') { |
| 718 | if (deployChild) { |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 719 | addToProviderNetMap(netMap, 'vsphere', 'regional-child') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 720 | } |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 721 | addToProviderNetMap(netMap, 'vsphere', 'region') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 722 | } |
| 723 | break |
| 724 | default: |
| 725 | error('Supposed to be called from aws or vsphere demos only') |
| 726 | } |
| 727 | |
| 728 | // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment |
| 729 | // Vsphere labels only |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 730 | netMap['vsphere'].each { clusterType, netConfig -> |
| 731 | if (triggers.proxyConfig["${clusterType}Offline"] == true || |
| 732 | (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) || |
| 733 | (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) { |
| 734 | |
| 735 | netMap['vsphere'][clusterType]['netName'] = 'offline' |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 736 | lockLabels['vsphere_offline_networking_core_ci']++ |
| 737 | } else { |
| 738 | lockLabels['vsphere_networking_core_ci']++ |
| 739 | } |
| 740 | } |
| 741 | |
| 742 | // generate lock metadata |
| 743 | def lockResources = [] |
| 744 | lockLabels.each { label, quantity -> |
| 745 | if (quantity > 0) { |
| 746 | def res = [ |
| 747 | label: label, |
| 748 | quantity: quantity, |
| 749 | ] |
| 750 | lockResources.add(res) |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | common.infoMsg("""Generated vsphere netMap: ${netMap} |
| 755 | Generated lockResources: ${lockResources}""") |
| 756 | |
| 757 | return [ |
| 758 | netMap: netMap, |
| 759 | lockResources: lockResources, |
| 760 | ] |
| 761 | } |
| 762 | |
| 763 | /** |
| 764 | * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName |
| 765 | * and empty rangeConfig to the this map. |
| 766 | * |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 767 | * @param: netMap (string) vsphere, equinix netMap or empty map |
| 768 | * @param: provider (string) provider type |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 769 | * @param: clusterType (string) Vsphere cluster type |
| 770 | */ |
| 771 | |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 772 | def addToProviderNetMap (netMap, provider, clusterType) { |
| 773 | switch (provider) { |
| 774 | case 'equinix': |
| 775 | netMap[provider][clusterType] = [ |
| 776 | vlanConfig: '', |
| 777 | ] |
| 778 | break |
| 779 | case 'vsphere': |
| 780 | netMap[provider][clusterType] = [ |
| 781 | netName: 'default', |
| 782 | rangeConfig: '', |
| 783 | ] |
| 784 | break |
| 785 | default: |
| 786 | error('Net map locks supported for Equinix/Vsphere providers only') |
| 787 | } |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 788 | } |