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