vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 1 | package com.mirantis.mk |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 2 | |
azvyagintsev | c17d14b | 2022-06-06 19:06:33 +0300 | [diff] [blame] | 3 | import static groovy.json.JsonOutput.toJson |
| 4 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 5 | /** |
| 6 | * |
| 7 | * KaaS Component Testing Utilities |
| 8 | * |
| 9 | */ |
| 10 | |
Владислав Наумов | e534581 | 2020-08-12 16:30:20 +0200 | [diff] [blame] | 11 | /** |
| 12 | * Check KaaS Core CICD feature flags |
| 13 | * such triggers can be used in case of switching between pipelines, |
| 14 | * conditions inside pipelines to reduce dependency on jenkins job builder and jenkins job templates itself |
| 15 | * |
| 16 | * @return (map)[ |
| 17 | * ffNameEnabled: (bool) True/False |
| 18 | * ] |
| 19 | */ |
| 20 | def checkCoreCIFeatureFlags() { |
| 21 | def common = new com.mirantis.mk.Common() |
| 22 | def ff = [ |
| 23 | build_artifacts_upgrade: false, |
| 24 | ] |
| 25 | |
| 26 | def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
| 27 | if (commitMsg ==~ /(?s).*\[ci-build-artifacts-upgrade\].*/) { |
| 28 | ff['build_artifacts_upgrade'] = true |
| 29 | } |
| 30 | |
| 31 | common.infoMsg("Core ci feature flags status: ${ff}") |
| 32 | return ff |
| 33 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 34 | |
| 35 | /** |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 36 | * Determine scope of test suite against per-commit KaaS deployment based on keywords |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 37 | * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 38 | * |
| 39 | * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs |
| 40 | * Example scheme: |
Владислав Наумов | e534581 | 2020-08-12 16:30:20 +0200 | [diff] [blame] | 41 | * New CR pushed in kubernetes/lcm-ansible -> parsing it'cs commit body and combine test-suite -> trigger deployment jobs from kaas/core |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 42 | * manage test-suite through Jenkins Job Parameters |
| 43 | * |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 44 | * @return (map)[ |
| 45 | * deployChildEnabled: (bool) True if need to deploy child cluster during demo-run |
| 46 | * runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 47 | * ] |
| 48 | */ |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 49 | def checkDeploymentTestSuite() { |
vnaumov | bdb9022 | 2020-05-04 18:25:50 +0200 | [diff] [blame] | 50 | def common = new com.mirantis.mk.Common() |
| 51 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 52 | // Available triggers and its sane defaults |
Владислав Наумов | 44c64b7 | 2020-12-04 20:22:53 +0100 | [diff] [blame] | 53 | def seedMacOs = env.SEED_MACOS ? env.SEED_MACOS.toBoolean() : false |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 54 | def deployChild = env.DEPLOY_CHILD_CLUSTER ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false |
| 55 | def upgradeChild = env.UPGRADE_CHILD_CLUSTER ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false |
Sergey Lalov | c1cb49f | 2022-09-27 01:16:25 +0400 | [diff] [blame] | 56 | def fullUpgradeChild = env.FULL_UPGRADE_CHILD_CLUSTER ? env.FULL_UPGRADE_CHILD_CLUSTER.toBoolean() : false |
Mikhail Ivanov | 38ee438 | 2022-01-27 16:21:51 +0400 | [diff] [blame] | 57 | def mosDeployChild = env.DEPLOY_MOS_CHILD_CLUSTER ? env.DEPLOY_MOS_CHILD_CLUSTER.toBoolean() : false |
| 58 | def mosUpgradeChild = env.UPGRADE_MOS_CHILD_CLUSTER ? env.UPGRADE_MOS_CHILD_CLUSTER.toBoolean() : false |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 59 | def customChildRelease = env.KAAS_CHILD_CLUSTER_RELEASE_NAME ? env.KAAS_CHILD_CLUSTER_RELEASE_NAME : '' |
slalov | 021171f | 2022-03-04 14:48:38 +0400 | [diff] [blame] | 60 | def mosTfDeploy = env.MOS_TF_DEPLOY ? env.MOS_TF_DEPLOY.toBoolean() : false |
Владислав Наумов | 0dc9925 | 2020-11-13 13:30:48 +0100 | [diff] [blame] | 61 | def attachBYO = env.ATTACH_BYO ? env.ATTACH_BYO.toBoolean() : false |
Владислав Наумов | cdbd84e | 2020-12-01 16:51:09 +0100 | [diff] [blame] | 62 | def upgradeBYO = env.UPGRADE_BYO ? env.UPGRADE_BYO.toBoolean() : false |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 63 | def runBYOMatrix = env.RUN_BYO_MATRIX ? env.RUN_BYO_MATRIX.toBoolean() : false |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 64 | def defaultBYOOs = env.DEFAULT_BYO_OS ? env.DEFAULT_BYO_OS.toString() : 'ubuntu' |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 65 | def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false |
slalov | 1202bba | 2022-04-20 22:31:07 +0400 | [diff] [blame] | 66 | def autoUpgradeMgmt = env.AUTO_UPGRADE_MCC ? env.AUTO_UPGRADE_MCC.toBoolean() : false |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 67 | def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false |
Sergey Lalov | b2f6037 | 2022-09-20 23:58:47 +0400 | [diff] [blame] | 68 | def deployOsOnMos = env.DEPLOY_OS_ON_MOS? env.DEPLOY_OS_ON_MOS.toBoolean() : false |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 69 | def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false |
Mikhail Ivanov | f5e20af | 2022-03-24 15:38:06 +0400 | [diff] [blame] | 70 | def runUie2eNew = env.RUN_UI_E2E_NEW ? env.RUN_UI_E2E_NEW.toBoolean() : false |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 71 | def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false |
Владислав Наумов | 9cec55d | 2021-08-03 15:00:59 +0200 | [diff] [blame] | 72 | def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false |
Vladyslav Drok | c4f9c1b | 2021-07-22 15:34:24 +0200 | [diff] [blame] | 73 | def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false |
Mikhail Ivanov | 2907e4d | 2022-04-25 16:41:21 +0400 | [diff] [blame] | 74 | def runProxyChildTest = env.RUN_PROXY_CHILD_TEST ? env.RUN_PROXY_CHILD_TEST.toBoolean() : false |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 75 | def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false |
| 76 | 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] | 77 | def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false |
slalov | 13e579c | 2022-01-31 21:37:02 +0400 | [diff] [blame] | 78 | def runMaintenanceTest = env.RUN_MAINTENANCE_TEST ? env.RUN_MAINTENANCE_TEST.toBoolean() : false |
slalov | 0a4947a | 2022-06-09 15:44:35 +0400 | [diff] [blame] | 79 | def runContainerregistryTest = env.RUN_CONTAINER_REGISTRY_TEST ? env.RUN_CONTAINER_REGISTRY_TEST.toBoolean() : false |
Dmitriy Kasyanov | 5f910e6 | 2022-02-11 14:57:05 +0300 | [diff] [blame] | 80 | def runMgmtDeleteMasterTest = env.RUN_MGMT_DELETE_MASTER_TEST ? env.RUN_MGMT_DELETE_MASTER_TEST.toBoolean() : false |
| 81 | def runRgnlDeleteMasterTest = env.RUN_RGNL_DELETE_MASTER_TEST ? env.RUN_RGNL_DELETE_MASTER_TEST.toBoolean() : false |
| 82 | def runChildDeleteMasterTest = env.RUN_CHILD_DELETE_MASTER_TEST ? env.RUN_CHILD_DELETE_MASTER_TEST.toBoolean() : false |
Mikhail Nikolaenko | 7e632cd | 2022-10-24 16:20:31 +0300 | [diff] [blame] | 83 | def runGracefulRebootTest = env.RUN_GRACEFUL_REBOOT_TEST ? env.RUN_GRACEFUL_REBOOT_TEST.toBoolean() : false |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 84 | // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider |
| 85 | def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [ |
| 86 | enabled: false, |
| 87 | managementLocation: '', |
| 88 | regionLocation: '', |
| 89 | ] |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 90 | |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 91 | // proxy customization |
| 92 | def proxyConfig = [ |
Владислав Наумов | f8f23fa | 2021-04-01 16:57:52 +0200 | [diff] [blame] | 93 | mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false, |
| 94 | childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false, |
Владислав Наумов | 257ea13 | 2021-04-14 14:44:13 +0200 | [diff] [blame] | 95 | childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false, |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 96 | ] |
| 97 | |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 98 | // optional demo deployment customization |
Владислав Наумов | 905dd36 | 2020-06-08 16:37:01 +0200 | [diff] [blame] | 99 | def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 100 | def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false |
Владислав Наумов | 82305e9 | 2021-10-14 20:45:20 +0200 | [diff] [blame] | 101 | def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false |
Владислав Наумов | f371580 | 2021-05-03 18:06:45 +0200 | [diff] [blame] | 102 | def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 103 | def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 104 | 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] | 105 | def enableVsphereDemo = true |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 106 | def enableOSDemo = true |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 107 | def enableBMDemo = true |
Mikhail Ivanov | bd1a9fd | 2022-03-29 21:36:21 +0400 | [diff] [blame] | 108 | def enableArtifactsBuild = true |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 109 | def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us' |
Alexandr Lovtsov | 36473f3 | 2022-04-28 15:46:09 +0300 | [diff] [blame] | 110 | def enableVsphereUbuntu = env.VSPHERE_DEPLOY_UBUNTU ? env.VSPHERE_DEPLOY_UBUNTU.toBoolean() : false |
Sergey Zhemerdeev | e67fb26 | 2022-06-21 00:49:34 +0300 | [diff] [blame] | 111 | def childOsBootFromVolume = env.OPENSTACK_BOOT_FROM_VOLUME ? env.OPENSTACK_BOOT_FROM_VOLUME.toBoolean() : false |
Ivan Berezovskiy | 29e72b7 | 2022-07-12 21:03:24 +0400 | [diff] [blame] | 112 | def bootstrapV2Scenario = env.BOOTSTRAP_V2_ENABLED ? env.BOOTSTRAP_V2_ENABLED.toBoolean() : false |
Sergey Lalov | acec3c1 | 2022-07-20 16:00:14 +0400 | [diff] [blame] | 113 | def equinixMetalV2Metro = env.EQUINIX_MGMT_METRO ? env.EQUINIX_MGMT_METRO : '' |
Mikhail Ivanov | 3088d3d | 2022-10-24 14:05:46 +0400 | [diff] [blame] | 114 | def enableFips = env.ENABLE_FIPS ? env.ENABLE_FIPS.toBoolean() : false |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 115 | |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 116 | 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] | 117 | if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) { |
| 118 | proxyConfig['mgmtOffline'] = true |
Владислав Наумов | 70c0242 | 2021-04-19 14:29:41 +0200 | [diff] [blame] | 119 | 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] | 120 | } |
Владислав Наумов | 44c64b7 | 2020-12-04 20:22:53 +0100 | [diff] [blame] | 121 | if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) { |
| 122 | seedMacOs = true |
| 123 | } |
slalov | 574123e | 2022-04-06 17:24:19 +0400 | [diff] [blame] | 124 | if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance || runProxyChildTest) { |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 125 | deployChild = true |
| 126 | } |
| 127 | if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) { |
| 128 | deployChild = true |
| 129 | upgradeChild = true |
| 130 | } |
Sergey Lalov | c1cb49f | 2022-09-27 01:16:25 +0400 | [diff] [blame] | 131 | if (commitMsg ==~ /(?s).*\[child-upgrade-full\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade-full.*/) { |
| 132 | deployChild = true |
| 133 | upgradeChild = true |
| 134 | fullUpgradeChild = true |
| 135 | } |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 136 | def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/) |
| 137 | if (childDeployMatches.size() > 0) { |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 138 | // override child version when it set explicitly |
| 139 | deployChild = true |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 140 | customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim() |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 141 | common.warningMsg("Forced child deployment using custom release version ${customChildRelease}") |
| 142 | } |
Mikhail Ivanov | 38ee438 | 2022-01-27 16:21:51 +0400 | [diff] [blame] | 143 | if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) { |
| 144 | mosDeployChild = true |
| 145 | } |
| 146 | if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) { |
| 147 | mosDeployChild = true |
| 148 | mosUpgradeChild = true |
| 149 | } |
Владислав Наумов | 0dc9925 | 2020-11-13 13:30:48 +0100 | [diff] [blame] | 150 | if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) { |
| 151 | attachBYO = true |
| 152 | } |
Владислав Наумов | cdbd84e | 2020-12-01 16:51:09 +0100 | [diff] [blame] | 153 | if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) { |
| 154 | attachBYO = true |
| 155 | upgradeBYO = true |
| 156 | } |
Sergey Lalov | acec3c1 | 2022-07-20 16:00:14 +0400 | [diff] [blame] | 157 | if (commitMsg ==~ /(?s).*\[ui-test-on-all-providers\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-test-on-all-providers.*/) { |
| 158 | enableVsphereDemo = true |
| 159 | enableOSDemo = true |
| 160 | awsOnDemandDemo = true |
| 161 | azureOnDemandDemo = true |
| 162 | equinixOnDemandDemo = true |
| 163 | equinixMetalV2OnDemandDemo = true |
| 164 | runUie2e = true |
Sergey Lalov | acec3c1 | 2022-07-20 16:00:14 +0400 | [diff] [blame] | 165 | // Edit after fix PRODX-3961 |
| 166 | enableBMDemo = false |
| 167 | } |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 168 | def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/) |
| 169 | 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] | 170 | runBYOMatrix = true |
| 171 | |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 172 | if (byoDeployMatches.size() > 0) { |
| 173 | defaultBYOOs = byoDeployMatches[0][2] |
| 174 | common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}") |
| 175 | } |
| 176 | |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 177 | common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped') |
| 178 | attachBYO = false |
| 179 | upgradeBYO = false |
| 180 | } |
Владислав Наумов | 7f8c987 | 2021-03-08 17:33:08 +0400 | [diff] [blame] | 181 | if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) { |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 182 | upgradeMgmt = true |
| 183 | } |
slalov | 1202bba | 2022-04-20 22:31:07 +0400 | [diff] [blame] | 184 | if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) { |
| 185 | autoUpgradeMgmt = true |
| 186 | } |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 187 | if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) { |
| 188 | enableLMALogging = true |
| 189 | } |
Sergey Lalov | b2f6037 | 2022-09-20 23:58:47 +0400 | [diff] [blame] | 190 | if (commitMsg ==~ /(?s).*\[deploy-os-on-mos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*deploy-os-on-mos.*/) { |
| 191 | deployOsOnMos = true |
| 192 | mosDeployChild = true |
| 193 | openstackIMC = 'eu2' |
| 194 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 195 | if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) { |
| 196 | runUie2e = true |
| 197 | } |
Mikhail Ivanov | f5e20af | 2022-03-24 15:38:06 +0400 | [diff] [blame] | 198 | if (commitMsg ==~ /(?s).*\[ui-e2e-new\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-new.*/) { |
| 199 | runUie2eNew = true |
| 200 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 201 | if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) { |
| 202 | runMgmtConformance = true |
| 203 | } |
Vladyslav Drok | c4f9c1b | 2021-07-22 15:34:24 +0200 | [diff] [blame] | 204 | if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) { |
| 205 | runMgmtUserControllerTest = true |
| 206 | } |
slalov | 574123e | 2022-04-06 17:24:19 +0400 | [diff] [blame] | 207 | if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) { |
| 208 | runProxyChildTest = true |
| 209 | deployChild = true |
| 210 | common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed') |
| 211 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 212 | if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) { |
| 213 | runChildConformance = true |
| 214 | deployChild = true |
| 215 | } |
Владислав Наумов | 9cec55d | 2021-08-03 15:00:59 +0200 | [diff] [blame] | 216 | if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) { |
| 217 | runLMATest = true |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 218 | enableLMALogging = true |
| 219 | 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] | 220 | } |
slalov | 13e579c | 2022-01-31 21:37:02 +0400 | [diff] [blame] | 221 | if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) { |
| 222 | runMaintenanceTest = true |
| 223 | } |
slalov | 0a4947a | 2022-06-09 15:44:35 +0400 | [diff] [blame] | 224 | if (commitMsg ==~ /(?s).*\[container-registry-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*container-registry-test.*/) { |
| 225 | runContainerregistryTest = true |
| 226 | } |
Dmitriy Kasyanov | 5f910e6 | 2022-02-11 14:57:05 +0300 | [diff] [blame] | 227 | if (commitMsg ==~ /(?s).*\[mgmt-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-delete-master-test.*/) { |
| 228 | runMgmtDeleteMasterTest = true |
| 229 | } |
| 230 | if (commitMsg ==~ /(?s).*\[rgnl-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*rgnl-delete-master-test.*/) { |
| 231 | runRgnlDeleteMasterTest = true |
| 232 | } |
| 233 | if (commitMsg ==~ /(?s).*\[child-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-delete-master-test.*/) { |
| 234 | runChildDeleteMasterTest = true |
| 235 | } |
Mikhail Nikolaenko | 7e632cd | 2022-10-24 16:20:31 +0300 | [diff] [blame] | 236 | if (commitMsg ==~ /(?s).*\[graceful-reboot-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*graceful-reboot-test.*/) { |
| 237 | runGracefulRebootTest = true |
| 238 | } |
Владислав Наумов | f8f23fa | 2021-04-01 16:57:52 +0200 | [diff] [blame] | 239 | if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) { |
| 240 | proxyConfig['childOffline'] = true |
| 241 | deployChild = true |
| 242 | } |
Владислав Наумов | 257ea13 | 2021-04-14 14:44:13 +0200 | [diff] [blame] | 243 | if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) { |
| 244 | proxyConfig['childOffline'] = true |
| 245 | proxyConfig['childProxy'] = true |
| 246 | deployChild = true |
| 247 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 248 | if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) { |
| 249 | fetchServiceBinaries = true |
| 250 | } |
Владислав Наумов | f1665b5 | 2021-05-13 10:51:17 +0200 | [diff] [blame] | 251 | 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] | 252 | equinixOnAwsDemo = true |
Владислав Наумов | f1665b5 | 2021-05-13 10:51:17 +0200 | [diff] [blame] | 253 | 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] | 254 | } |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 255 | if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) { |
| 256 | azureOnAwsDemo = true |
| 257 | common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ') |
| 258 | } |
| 259 | if (commitMsg ==~ /(?s).*\[aws-demo\].*/ || |
| 260 | env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ || |
| 261 | attachBYO || |
| 262 | upgradeBYO || |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 263 | runBYOMatrix || |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 264 | seedMacOs || |
| 265 | equinixOnAwsDemo || |
| 266 | azureOnAwsDemo) { |
| 267 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 268 | awsOnDemandDemo = true |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 269 | 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] | 270 | } |
Владислав Наумов | f1665b5 | 2021-05-13 10:51:17 +0200 | [diff] [blame] | 271 | if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) { |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 272 | equinixOnDemandDemo = true |
| 273 | } |
Владислав Наумов | 82305e9 | 2021-10-14 20:45:20 +0200 | [diff] [blame] | 274 | if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) { |
Владислав Наумов | 144956f | 2021-10-14 17:49:19 +0200 | [diff] [blame] | 275 | equinixMetalV2OnDemandDemo = true |
| 276 | } |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 277 | if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) { |
| 278 | equinixMetalV2OnDemandDemo = true |
| 279 | equinixMetalV2ChildDiffMetro = true |
| 280 | } |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 281 | if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) { |
| 282 | azureOnDemandDemo = true |
| 283 | } |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 284 | if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) { |
| 285 | enableOSDemo = false |
| 286 | common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set') |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 287 | } |
| 288 | |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 289 | if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) { |
| 290 | enableBMDemo = false |
| 291 | common.errorMsg('BM demo deployment will be aborted, VF -1 will be set') |
| 292 | } |
| 293 | |
Ivan Berezovskiy | f9bcfd6 | 2021-03-18 18:41:38 +0400 | [diff] [blame] | 294 | if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) { |
| 295 | enableVsphereDemo = false |
| 296 | common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set') |
| 297 | } |
Alexandr Lovtsov | 36473f3 | 2022-04-28 15:46:09 +0300 | [diff] [blame] | 298 | if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) { |
| 299 | enableVsphereUbuntu = true |
| 300 | common.warningMsg('Ubuntu will be used to deploy vsphere machines') |
| 301 | } |
Ivan Berezovskiy | f9bcfd6 | 2021-03-18 18:41:38 +0400 | [diff] [blame] | 302 | |
Mikhail Ivanov | bd1a9fd | 2022-03-29 21:36:21 +0400 | [diff] [blame] | 303 | if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) { |
| 304 | enableArtifactsBuild = false |
| 305 | common.errorMsg('artifacts build will be aborted, VF -1 will be set') |
| 306 | } |
| 307 | |
Sergey Zhemerdeev | e67fb26 | 2022-06-21 00:49:34 +0300 | [diff] [blame] | 308 | if (commitMsg ==~ /(?s).*\[child-os-boot-from-volume\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-os-boot-from-volume\.*/) { |
| 309 | childOsBootFromVolume = true |
| 310 | common.warningMsg('OS will be booted from Ceph volumes') |
| 311 | } |
| 312 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 313 | // TODO (vnaumov) remove below condition after moving all releases to UCP |
| 314 | def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/) |
| 315 | if (ucpChildMatches.size() > 0) { |
| 316 | deployChild = true |
| 317 | common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ') |
| 318 | |
| 319 | // TODO(vnaumov) delete after ucp upgrades support |
| 320 | common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled') |
| 321 | upgradeChild = false |
| 322 | } |
| 323 | |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 324 | // multiregional tests |
| 325 | def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/) |
| 326 | if (multiRegionalMatches.size() > 0) { |
| 327 | multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches) |
| 328 | } |
| 329 | switch (multiregionalMappings['managementLocation']) { |
| 330 | case 'aws': |
Владислав Наумов | 53b07e5 | 2021-01-07 15:08:27 +0100 | [diff] [blame] | 331 | common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request') |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 332 | awsOnDemandDemo = true |
Владислав Наумов | 53b07e5 | 2021-01-07 15:08:27 +0100 | [diff] [blame] | 333 | |
| 334 | if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers |
| 335 | error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously') |
| 336 | } |
Владислав Наумов | 3e4b5a3 | 2020-09-11 17:05:34 +0200 | [diff] [blame] | 337 | break |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 338 | case 'os': |
| 339 | if (enableOSDemo == false) { |
| 340 | error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously') |
| 341 | } |
Владислав Наумов | 3e4b5a3 | 2020-09-11 17:05:34 +0200 | [diff] [blame] | 342 | break |
Владислав Наумов | 865ba6c | 2021-05-13 13:05:45 +0200 | [diff] [blame] | 343 | case 'vsphere': |
| 344 | if (enableVsphereDemo == false) { |
| 345 | error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously') |
| 346 | } |
| 347 | break |
Владислав Наумов | 5be0294 | 2021-05-13 12:34:37 +0200 | [diff] [blame] | 348 | case 'equinix': |
| 349 | common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request') |
| 350 | equinixOnDemandDemo = true |
eromanova | 3535916 | 2021-12-30 14:13:13 +0400 | [diff] [blame] | 351 | break |
eromanova | 8c702ae | 2021-12-24 17:43:12 +0400 | [diff] [blame] | 352 | case 'equinixmetalv2': |
| 353 | common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request') |
| 354 | equinixMetalV2OnDemandDemo = true |
eromanova | 3535916 | 2021-12-30 14:13:13 +0400 | [diff] [blame] | 355 | break |
slalov | fd0b7e6 | 2021-07-28 18:05:16 +0400 | [diff] [blame] | 356 | case 'azure': |
| 357 | common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request') |
| 358 | azureOnDemandDemo = true |
| 359 | break |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 360 | } |
| 361 | |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 362 | // CDN configuration |
| 363 | def cdnConfig = [ |
| 364 | mgmt: [ |
| 365 | openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci', |
Владислав Наумов | 70c0242 | 2021-04-19 14:29:41 +0200 | [diff] [blame] | 366 | vsphere: 'internal-ci', |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 367 | aws: 'public-ci', |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 368 | equinix: 'public-ci', |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 369 | azure: 'public-ci', |
Владислав Наумов | f8f23fa | 2021-04-01 16:57:52 +0200 | [diff] [blame] | 370 | ], |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 371 | ] |
| 372 | |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 373 | if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) { |
| 374 | openstackIMC = 'eu' |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 375 | } |
slalov | 021171f | 2022-03-04 14:48:38 +0400 | [diff] [blame] | 376 | if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) { |
| 377 | openstackIMC = 'eu2' |
Mikhail Ivanov | f05b825 | 2022-04-27 18:14:03 +0400 | [diff] [blame] | 378 | } |
| 379 | if (openstackIMC == 'eu' || openstackIMC == 'eu2') { |
slalov | 021171f | 2022-03-04 14:48:38 +0400 | [diff] [blame] | 380 | // use internal-eu because on internal-ci with eu cloud image pull takes much time |
| 381 | def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu' |
| 382 | common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}") |
| 383 | cdnConfig['mgmt']['openstack'] = cdnRegion |
| 384 | } |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 385 | |
Владислав Наумов | 74e2d6e | 2020-12-30 17:05:40 +0100 | [diff] [blame] | 386 | // calculate weight of current demo run to manage lockable resources |
Sergey Lalov | 46deb44 | 2022-08-18 12:11:03 +0400 | [diff] [blame] | 387 | def demoWeight = deployChild ? 2 : 1 // management = 1, child += 1 |
| 388 | if (runUie2e) { |
| 389 | demoWeight += 1 |
| 390 | } |
Владислав Наумов | 74e2d6e | 2020-12-30 17:05:40 +0100 | [diff] [blame] | 391 | |
Ivan Berezovskiy | 29e72b7 | 2022-07-12 21:03:24 +0400 | [diff] [blame] | 392 | if (commitMsg ==~ /(?s).*\[bootstrapv2-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv2-scenario\.*/) { |
| 393 | bootstrapV2Scenario = true |
| 394 | } |
| 395 | |
Mikhail Ivanov | 3088d3d | 2022-10-24 14:05:46 +0400 | [diff] [blame] | 396 | if (commitMsg ==~ /(?s).*\[enable-fips\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*enable-fips\.*/) { |
| 397 | enableFips = true |
| 398 | } |
| 399 | |
Sergey Zhemerdeev | dd31ce9 | 2022-07-19 14:15:22 +0300 | [diff] [blame] | 400 | // parse equinixmetalv2-metro trigger |
Sergey Zhemerdeev | dd31ce9 | 2022-07-19 14:15:22 +0300 | [diff] [blame] | 401 | def equinixMetalV2MetroMatcher = (commitMsg =~ /\[equinixmetalv2-metro(\s+.*)?\]/) |
| 402 | if (equinixMetalV2OnDemandDemo && equinixMetalV2MetroMatcher.size() > 0) { |
Sergey Zhemerdeev | cc785e4 | 2022-07-22 17:15:47 +0300 | [diff] [blame] | 403 | equinixMetalV2Metro = equinixMetalV2MetroMatcher[0][1].trim().toLowerCase() |
Sergey Zhemerdeev | dd31ce9 | 2022-07-19 14:15:22 +0300 | [diff] [blame] | 404 | common.infoMsg("Forced Equnix mgmt deployment using custom metro ${equinixMetalV2Metro}") |
| 405 | } |
| 406 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 407 | common.infoMsg(""" |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 408 | OpenStack Cloud location: ${openstackIMC} |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 409 | CDN deployment configuration: ${cdnConfig} |
| 410 | MCC offline deployment configuration: ${proxyConfig} |
Владислав Наумов | 44c64b7 | 2020-12-04 20:22:53 +0100 | [diff] [blame] | 411 | Use MacOS node as seed: ${seedMacOs} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 412 | Child cluster deployment scheduled: ${deployChild} |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 413 | Custom child cluster release: ${customChildRelease} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 414 | Child cluster release upgrade scheduled: ${upgradeChild} |
Sergey Lalov | c1cb49f | 2022-09-27 01:16:25 +0400 | [diff] [blame] | 415 | Full Child cluster release upgrade scheduled: ${fullUpgradeChild} |
Mikhail Ivanov | 38ee438 | 2022-01-27 16:21:51 +0400 | [diff] [blame] | 416 | MOS child deploy scheduled: ${mosDeployChild} |
| 417 | MOS child upgrade scheduled: ${mosUpgradeChild} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 418 | Child conformance testing scheduled: ${runChildConformance} |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 419 | Single BYO cluster attachment scheduled: ${attachBYO} |
| 420 | Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO} |
| 421 | BYO test matrix whole suite scheduled: ${runBYOMatrix} |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 422 | Default BYO OS: ${defaultBYOOs} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 423 | Mgmt cluster release upgrade scheduled: ${upgradeMgmt} |
slalov | 1202bba | 2022-04-20 22:31:07 +0400 | [diff] [blame] | 424 | Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt} |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 425 | Mgmt LMA logging enabled: ${enableLMALogging} |
Sergey Lalov | b2f6037 | 2022-09-20 23:58:47 +0400 | [diff] [blame] | 426 | Deploy Os on child with mos release ${deployOsOnMos} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 427 | Mgmt conformance testing scheduled: ${runMgmtConformance} |
Владислав Наумов | 9cec55d | 2021-08-03 15:00:59 +0200 | [diff] [blame] | 428 | LMA testing scheduled: ${runLMATest} |
Vladyslav Drok | c4f9c1b | 2021-07-22 15:34:24 +0200 | [diff] [blame] | 429 | Mgmt user controller testing scheduled: ${runMgmtUserControllerTest} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 430 | Mgmt UI e2e testing scheduled: ${runUie2e} |
Mikhail Ivanov | f5e20af | 2022-03-24 15:38:06 +0400 | [diff] [blame] | 431 | Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew} |
slalov | 13e579c | 2022-01-31 21:37:02 +0400 | [diff] [blame] | 432 | Maintenance test: ${runMaintenanceTest} |
slalov | 0a4947a | 2022-06-09 15:44:35 +0400 | [diff] [blame] | 433 | Container Registry test: ${runContainerregistryTest} |
slalov | 574123e | 2022-04-06 17:24:19 +0400 | [diff] [blame] | 434 | Child proxy test: ${runProxyChildTest} |
Mikhail Nikolaenko | 7e632cd | 2022-10-24 16:20:31 +0300 | [diff] [blame] | 435 | Graceful reboot test: ${runGracefulRebootTest} |
Dmitriy Kasyanov | 5f910e6 | 2022-02-11 14:57:05 +0300 | [diff] [blame] | 436 | Delete mgmt master node test: ${runMgmtDeleteMasterTest} |
| 437 | Delete rgnl master node test: ${runRgnlDeleteMasterTest} |
| 438 | Delete child master node test: ${runChildDeleteMasterTest} |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 439 | AWS provider deployment scheduled: ${awsOnDemandDemo} |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 440 | Equinix provider deployment scheduled: ${equinixOnDemandDemo} |
Владислав Наумов | 144956f | 2021-10-14 17:49:19 +0200 | [diff] [blame] | 441 | EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo} |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 442 | EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro} |
Sergey Zhemerdeev | 019c45a | 2022-08-13 00:09:07 +0300 | [diff] [blame] | 443 | EquinixmetalV2 mgmt will be deployed on the metro: ${equinixMetalV2Metro?:'auto'} |
Владислав Наумов | f1665b5 | 2021-05-13 10:51:17 +0200 | [diff] [blame] | 444 | Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo} |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 445 | Azure provider deployment scheduled: ${azureOnDemandDemo} |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 446 | Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo} |
Ivan Berezovskiy | f9bcfd6 | 2021-03-18 18:41:38 +0400 | [diff] [blame] | 447 | VSPHERE provider deployment scheduled: ${enableVsphereDemo} |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 448 | OS provider deployment scheduled: ${enableOSDemo} |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 449 | BM provider deployment scheduled: ${enableBMDemo} |
Alexandr Lovtsov | 36473f3 | 2022-04-28 15:46:09 +0300 | [diff] [blame] | 450 | Ubuntu on vSphere scheduled: ${enableVsphereUbuntu} |
Mikhail Ivanov | bd1a9fd | 2022-03-29 21:36:21 +0400 | [diff] [blame] | 451 | Artifacts build scheduled: ${enableArtifactsBuild} |
Sergey Zhemerdeev | e67fb26 | 2022-06-21 00:49:34 +0300 | [diff] [blame] | 452 | Boot OS child from Ceph volumes: ${childOsBootFromVolume} |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame] | 453 | Multiregional configuration: ${multiregionalMappings} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 454 | Service binaries fetching scheduled: ${fetchServiceBinaries} |
Владислав Наумов | 74e2d6e | 2020-12-30 17:05:40 +0100 | [diff] [blame] | 455 | Current weight of the demo run: ${demoWeight} (Used to manage lockable resources) |
Ivan Berezovskiy | 29e72b7 | 2022-07-12 21:03:24 +0400 | [diff] [blame] | 456 | Bootstrap v2 scenario enabled: ${bootstrapV2Scenario} |
Mikhail Ivanov | 3088d3d | 2022-10-24 14:05:46 +0400 | [diff] [blame] | 457 | FIPS enabled: ${enableFips} |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 458 | 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] | 459 | return [ |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 460 | osCloudLocation : openstackIMC, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 461 | cdnConfig : cdnConfig, |
| 462 | proxyConfig : proxyConfig, |
| 463 | useMacOsSeedNode : seedMacOs, |
| 464 | deployChildEnabled : deployChild, |
| 465 | childDeployCustomRelease : customChildRelease, |
| 466 | upgradeChildEnabled : upgradeChild, |
Sergey Lalov | c1cb49f | 2022-09-27 01:16:25 +0400 | [diff] [blame] | 467 | fullUpgradeChildEnabled : fullUpgradeChild, |
Mikhail Ivanov | 38ee438 | 2022-01-27 16:21:51 +0400 | [diff] [blame] | 468 | mosDeployChildEnabled : mosDeployChild, |
| 469 | mosUpgradeChildEnabled : mosUpgradeChild, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 470 | runChildConformanceEnabled : runChildConformance, |
| 471 | attachBYOEnabled : attachBYO, |
| 472 | upgradeBYOEnabled : upgradeBYO, |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 473 | runBYOMatrixEnabled : runBYOMatrix, |
Mikhail Ivanov | eabc9d9 | 2021-12-30 16:40:14 +0400 | [diff] [blame] | 474 | defaultBYOOs : defaultBYOOs, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 475 | upgradeMgmtEnabled : upgradeMgmt, |
slalov | 1202bba | 2022-04-20 22:31:07 +0400 | [diff] [blame] | 476 | autoUpgradeMgmtEnabled : autoUpgradeMgmt, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 477 | enableLMALoggingEnabled : enableLMALogging, |
Sergey Lalov | b2f6037 | 2022-09-20 23:58:47 +0400 | [diff] [blame] | 478 | deployOsOnMosEnabled : deployOsOnMos, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 479 | runUie2eEnabled : runUie2e, |
Mikhail Ivanov | f5e20af | 2022-03-24 15:38:06 +0400 | [diff] [blame] | 480 | runUie2eNewEnabled : runUie2eNew, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 481 | runMgmtConformanceEnabled : runMgmtConformance, |
slalov | 0a4947a | 2022-06-09 15:44:35 +0400 | [diff] [blame] | 482 | runMaintenanceTestEnabled : runMaintenanceTest, |
Dmitriy Kasyanov | 5f910e6 | 2022-02-11 14:57:05 +0300 | [diff] [blame] | 483 | runContainerregistryTestEnabled : runContainerregistryTest, |
Mikhail Nikolaenko | 7e632cd | 2022-10-24 16:20:31 +0300 | [diff] [blame] | 484 | runGracefulRebootTestEnabled : runGracefulRebootTest, |
Dmitriy Kasyanov | 5f910e6 | 2022-02-11 14:57:05 +0300 | [diff] [blame] | 485 | runMgmtDeleteMasterTestEnabled : runMgmtDeleteMasterTest, |
| 486 | runRgnlDeleteMasterTestEnabled : runRgnlDeleteMasterTest, |
| 487 | runChildDeleteMasterTestEnabled : runChildDeleteMasterTest, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 488 | runLMATestEnabled : runLMATest, |
| 489 | runMgmtUserControllerTestEnabled : runMgmtUserControllerTest, |
slalov | 574123e | 2022-04-06 17:24:19 +0400 | [diff] [blame] | 490 | runProxyChildTestEnabled : runProxyChildTest, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 491 | fetchServiceBinariesEnabled : fetchServiceBinaries, |
| 492 | awsOnDemandDemoEnabled : awsOnDemandDemo, |
| 493 | equinixOnDemandDemoEnabled : equinixOnDemandDemo, |
| 494 | equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo, |
| 495 | equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro, |
| 496 | equinixOnAwsDemoEnabled : equinixOnAwsDemo, |
| 497 | azureOnDemandDemoEnabled : azureOnDemandDemo, |
| 498 | azureOnAwsDemoEnabled : azureOnAwsDemo, |
| 499 | vsphereDemoEnabled : enableVsphereDemo, |
| 500 | vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out |
| 501 | bmDemoEnabled : enableBMDemo, |
| 502 | osDemoEnabled : enableOSDemo, |
Alexandr Lovtsov | 36473f3 | 2022-04-28 15:46:09 +0300 | [diff] [blame] | 503 | vsphereUbuntuEnabled : enableVsphereUbuntu, |
Mikhail Ivanov | bd1a9fd | 2022-03-29 21:36:21 +0400 | [diff] [blame] | 504 | artifactsBuildEnabled : enableArtifactsBuild, |
Sergey Zhemerdeev | e67fb26 | 2022-06-21 00:49:34 +0300 | [diff] [blame] | 505 | childOsBootFromVolume : childOsBootFromVolume, |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 506 | multiregionalConfiguration : multiregionalMappings, |
Ivan Berezovskiy | 29e72b7 | 2022-07-12 21:03:24 +0400 | [diff] [blame] | 507 | demoWeight : demoWeight, |
Sergey Zhemerdeev | dd31ce9 | 2022-07-19 14:15:22 +0300 | [diff] [blame] | 508 | bootstrapV2Scenario : bootstrapV2Scenario, |
Mikhail Ivanov | 3088d3d | 2022-10-24 14:05:46 +0400 | [diff] [blame] | 509 | equinixMetalV2Metro : equinixMetalV2Metro, |
| 510 | enableFips : enableFips] |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | /** |
| 514 | * Determine management and regional setup for demo workflow scenario |
| 515 | * |
| 516 | * |
Sergey Zhemerdeev | dd31ce9 | 2022-07-19 14:15:22 +0300 | [diff] [blame] | 517 | * @param: keyword (string) string , represents keyword trigger, specified in gerrit commit body, like `[multiregion aws,os]` |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 518 | or Jenkins environment string variable in form like 'aws,os' |
| 519 | * @return (map)[ |
| 520 | enabled: (bool), |
| 521 | * managementLocation: (string), //aws,os |
| 522 | * regionLocation: (string), //aws,os |
| 523 | * ] |
| 524 | */ |
| 525 | def multiregionWorkflowParser(keyword) { |
Владислав Наумов | 8c0c39d | 2020-09-11 14:46:48 +0200 | [diff] [blame] | 526 | def common = new com.mirantis.mk.Common() |
eromanova | 8c702ae | 2021-12-24 17:43:12 +0400 | [diff] [blame] | 527 | def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure'] |
| 528 | def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws'] |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 529 | |
| 530 | def clusterTypes = '' |
Владислав Наумов | 38ed7bf | 2020-09-11 14:43:39 +0200 | [diff] [blame] | 531 | if (keyword.toString().contains('multiregion')) { |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 532 | common.infoMsg('Multiregion definition configured via gerrit keyword trigger') |
| 533 | clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',') |
| 534 | } else { |
| 535 | common.infoMsg('Multiregion definition configured via environment variable') |
| 536 | clusterTypes = keyword.trim().split(',') |
| 537 | } |
| 538 | |
| 539 | if (clusterTypes.size() != 2) { |
Владислав Наумов | 482fb50 | 2020-10-30 17:59:27 +0100 | [diff] [blame] | 540 | error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}") |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 541 | } |
| 542 | |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame] | 543 | def desiredManagementProvider = clusterTypes[0].trim() |
| 544 | def desiredRegionalProvider = clusterTypes[1].trim() |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 545 | if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) { |
| 546 | error("""unsupported management <-> regional bundle, available options: |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame] | 547 | management providers list - ${supportedManagementProviders} |
| 548 | regional providers list - ${supportedRegionalProviders}""") |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | return [ |
| 552 | enabled: true, |
| 553 | managementLocation: desiredManagementProvider, |
| 554 | regionLocation: desiredRegionalProvider, |
| 555 | ] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | /** |
| 559 | * Determine if custom si tests/pipelines refspec forwarded from gerrit change request |
| 560 | |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 561 | * 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] | 562 | * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs |
| 563 | * Example scheme: |
| 564 | * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core |
| 565 | * manage refspecs through Jenkins Job Parameters |
| 566 | * |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 567 | * @return (map)[* siTests: (string) final refspec for si-tests |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 568 | * siPipelines: (string) final refspec for si-pipelines |
| 569 | * ] |
| 570 | */ |
| 571 | def checkCustomSIRefspec() { |
vnaumov | bdb9022 | 2020-05-04 18:25:50 +0200 | [diff] [blame] | 572 | def common = new com.mirantis.mk.Common() |
| 573 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 574 | // Available triggers and its sane defaults |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 575 | def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master' |
| 576 | def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master' |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 577 | def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test' |
| 578 | def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master' |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 579 | 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] | 580 | |
| 581 | def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/) |
| 582 | def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/) |
| 583 | |
| 584 | if (siTestMatches.size() > 0) { |
| 585 | siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim() |
Владислав Наумов | 7f6c088 | 2021-03-23 19:10:57 +0400 | [diff] [blame] | 586 | siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}" |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 587 | siTestsDockerImageTag = siTestsRefspec.split('/')[-1] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 588 | } |
| 589 | if (siPipelinesMatches.size() > 0) { |
| 590 | siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 591 | } |
| 592 | |
| 593 | common.infoMsg(""" |
| 594 | kaas/si-pipelines will be fetched from: ${siPipelinesRefspec} |
| 595 | kaas/si-tests will be fetched from: ${siTestsRefspec} |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 596 | kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag} |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 597 | 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] | 598 | return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 599 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 600 | |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 601 | /** |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 602 | * Parse additional configuration for kaas component CICD repo |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 603 | * @param configurationFile (str) path to configuration file in yaml format |
| 604 | * |
| 605 | * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests, |
Alexandr Lovtsov | 1c78e45 | 2022-08-29 20:57:51 +0300 | [diff] [blame] | 606 | * siTestsFeatureFlagsStable (string) dedicated feature flags that will be used in SI tests for deploying stable release |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 607 | * ] |
| 608 | */ |
| 609 | def parseKaaSComponentCIParameters(configurationFile){ |
| 610 | def common = new com.mirantis.mk.Common() |
| 611 | def ciConfig = readYaml file: configurationFile |
| 612 | def ciSpec = [ |
| 613 | siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '', |
Alexandr Lovtsov | 1c78e45 | 2022-08-29 20:57:51 +0300 | [diff] [blame] | 614 | siTestsFeatureFlagsStable: env.SI_TESTS_FEATURE_FLAGS_STABLE ?: '', |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 615 | ] |
| 616 | |
Alexandr Lovtsov | 1c78e45 | 2022-08-29 20:57:51 +0300 | [diff] [blame] | 617 | // If exists and not empty |
| 618 | if (ciConfig.getOrDefault('si-tests-feature-flags', [])) { |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 619 | common.infoMsg("""SI tests feature flags customization detected, |
| 620 | results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""") |
| 621 | |
| 622 | def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() } |
| 623 | ffMeta.addAll(ciConfig['si-tests-feature-flags']) |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 624 | |
Владислав Наумов | cb5ffca | 2020-07-14 15:28:36 +0200 | [diff] [blame] | 625 | ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',') |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 626 | common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}") |
| 627 | } |
Alexandr Lovtsov | 1c78e45 | 2022-08-29 20:57:51 +0300 | [diff] [blame] | 628 | if (ciConfig.getOrDefault('si-tests-feature-flags-stable', [])) { |
| 629 | common.infoMsg("""SI tests feature flags for stable release customization detected, |
| 630 | results will be merged with existing flags: [${ciSpec['siTestsFeatureFlagsStable']}] identification...""") |
| 631 | |
| 632 | def ffMeta = ciSpec['siTestsFeatureFlagsStable'].tokenize(',').collect { it.trim() } |
| 633 | ffMeta.addAll(ciConfig['si-tests-feature-flags-stable']) |
| 634 | |
| 635 | ciSpec['siTestsFeatureFlagsStable'] = ffMeta.unique().join(',') |
| 636 | common.infoMsg("SI tests custom feature flags for stable release: ${ciSpec['siTestsFeatureFlagsStable']}") |
| 637 | } |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 638 | |
| 639 | common.infoMsg("""Additional ci configuration parsed successfully: |
Alexandr Lovtsov | 1c78e45 | 2022-08-29 20:57:51 +0300 | [diff] [blame] | 640 | siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']} |
| 641 | siTestsFeatureFlagsStable: ${ciSpec['siTestsFeatureFlagsStable']}""") |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 642 | return ciSpec |
| 643 | } |
| 644 | |
| 645 | /** |
| 646 | * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 647 | |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 648 | * 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] | 649 | * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs |
| 650 | * Example scheme: |
| 651 | * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core |
| 652 | * manage refspecs through Jenkins Job Parameters |
| 653 | * |
| 654 | * @return (map)[ core: (string) final refspec for kaas/core |
| 655 | * corePipelines: (string) final refspec for pipelines in kaas/core |
| 656 | * ] |
| 657 | */ |
| 658 | def checkCustomCoreRefspec() { |
| 659 | def common = new com.mirantis.mk.Common() |
| 660 | |
| 661 | // Available triggers and its sane defaults |
| 662 | def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master' |
| 663 | // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs* |
| 664 | def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC' |
| 665 | def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
| 666 | |
| 667 | def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/) |
| 668 | def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/) |
| 669 | |
| 670 | if (coreMatches.size() > 0) { |
| 671 | coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 672 | } |
| 673 | if (corePipelinesMatches.size() > 0) { |
| 674 | corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 675 | } |
| 676 | |
| 677 | common.infoMsg(""" |
| 678 | kaas/core will be fetched from: ${coreRefspec} |
| 679 | kaas/core pipelines will be fetched from: ${corePipelinesRefspec} |
Владислав Наумов | 8177747 | 2021-03-09 15:14:27 +0400 | [diff] [blame] | 680 | 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] | 681 | return [core: coreRefspec, corePipelines: corePipelinesRefspec] |
| 682 | } |
| 683 | |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 684 | |
| 685 | /** |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 686 | * generate Jenkins Parameter objects from from text parameter with additonal kaas core context |
| 687 | * needed to forward inside kaas core set of jobs |
| 688 | * |
| 689 | * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format |
| 690 | * @return (list)[ string(name: '', value: ''), |
| 691 | * ] |
| 692 | */ |
| 693 | def generateKaaSVarsFromContext(context) { |
| 694 | def common = new com.mirantis.mk.Common() |
| 695 | def parameters = [] |
| 696 | def config = readYaml text: context |
| 697 | |
| 698 | config.each { k,v -> |
| 699 | common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}") |
| 700 | parameters.add(string(name: k, value: v)) |
| 701 | } |
| 702 | |
| 703 | return parameters |
| 704 | } |
| 705 | |
| 706 | /** |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 707 | * 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] | 708 | * 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] | 709 | * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs |
| 710 | * |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 711 | * @param: component (string) component name [iam, lcm, stacklight] |
| 712 | * @param: patchSpec (string) Patch for kaas/cluster releases in json format |
| 713 | * @param: configurationFile (string) Additional file for component repo CI config in yaml format |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 714 | */ |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 715 | def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') { |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 716 | def common = new com.mirantis.mk.Common() |
| 717 | // Determine if custom trigger keywords forwarded from gerrit |
| 718 | def triggers = checkDeploymentTestSuite() |
| 719 | // Determine SI refspecs |
| 720 | def siRefspec = checkCustomSIRefspec() |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 721 | // Determine Core refspecs |
| 722 | def coreRefspec = checkCustomCoreRefspec() |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 723 | |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 724 | // Determine component repo ci configuration |
| 725 | def ciSpec = [:] |
| 726 | def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: '' |
| 727 | if (fileExists(configurationFile)) { |
| 728 | common.infoMsg('Component CI configuration file detected, parsing...') |
| 729 | ciSpec = parseKaaSComponentCIParameters(configurationFile) |
| 730 | componentFeatureFlags = ciSpec['siTestsFeatureFlags'] |
| 731 | } else { |
| 732 | common.warningMsg('''Component CI configuration file is not exists, |
Владислав Наумов | c17dd55 | 2020-07-29 17:07:38 +0200 | [diff] [blame] | 733 | several code-management features may be unavailable, |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 734 | follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag |
| 735 | to create the configuration file''') |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 736 | } |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 737 | |
| 738 | def platforms = [] |
| 739 | if (component == 'ipam' && triggers.vsphereDemoEnabled) { |
| 740 | // Currently only vsphere demo is required for IPAM component |
| 741 | platforms.add('vsphere') |
| 742 | } else { |
| 743 | if (triggers.osDemoEnabled) { |
| 744 | platforms.add('openstack') |
| 745 | } |
| 746 | if (triggers.awsOnDemandDemoEnabled) { |
| 747 | platforms.add('aws') |
| 748 | } |
| 749 | if (triggers.equinixOnDemandDemoEnabled) { |
| 750 | platforms.add('equinix') |
| 751 | } |
Владислав Наумов | 144956f | 2021-10-14 17:49:19 +0200 | [diff] [blame] | 752 | if (triggers.equinixMetalV2OnDemandDemoEnabled) { |
| 753 | platforms.add('equinixmetalv2') |
| 754 | } |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 755 | if (triggers.azureOnDemandDemoEnabled) { |
| 756 | platforms.add('azure') |
| 757 | } |
Ivan Berezovskiy | b0229d0 | 2021-05-17 16:55:18 +0400 | [diff] [blame] | 758 | if (triggers.vsphereDemoEnabled) { |
| 759 | platforms.add('vsphere') |
| 760 | } |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 761 | } |
| 762 | |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 763 | def jobs = [:] |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 764 | def parameters = [ |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 765 | string(name: 'GERRIT_REFSPEC', value: coreRefspec.core), |
| 766 | string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 767 | string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests), |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 768 | string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags), |
Владислав Наумов | 2db15e2 | 2020-07-14 12:29:22 +0200 | [diff] [blame] | 769 | string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage), |
| 770 | string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag), |
Владислав Наумов | 4a5c324 | 2020-06-08 14:36:11 +0200 | [diff] [blame] | 771 | string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 772 | string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec), |
Mikhail Ivanov | 7450437 | 2021-05-21 17:01:06 +0400 | [diff] [blame] | 773 | string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease), |
Mikhail Ivanov | b6283f7 | 2021-11-24 18:34:57 +0400 | [diff] [blame] | 774 | string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation), |
Владислав Наумов | b8305e2 | 2021-02-10 17:23:12 +0100 | [diff] [blame] | 775 | booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']), |
Владислав Наумов | f8f23fa | 2021-04-01 16:57:52 +0200 | [diff] [blame] | 776 | booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']), |
Владислав Наумов | 257ea13 | 2021-04-14 14:44:13 +0200 | [diff] [blame] | 777 | booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']), |
Владислав Наумов | 44c64b7 | 2020-12-04 20:22:53 +0100 | [diff] [blame] | 778 | booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 779 | booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled), |
slalov | 1202bba | 2022-04-20 22:31:07 +0400 | [diff] [blame] | 780 | booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled), |
Victor Ryzhenkin | d2b7b66 | 2021-08-23 14:18:38 +0400 | [diff] [blame] | 781 | booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled), |
Sergey Lalov | b2f6037 | 2022-09-20 23:58:47 +0400 | [diff] [blame] | 782 | booleanParam(name: 'DEPLOY_OS_ON_MOS', value: triggers.deployOsOnMosEnabled), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 783 | booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 784 | booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled), |
slalov | 0a4947a | 2022-06-09 15:44:35 +0400 | [diff] [blame] | 785 | booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnabled), |
| 786 | booleanParam(name: 'RUN_CONTAINER_REGISTRY_TEST', value: triggers.runContainerregistryTestEnabled), |
Mikhail Nikolaenko | 7e632cd | 2022-10-24 16:20:31 +0300 | [diff] [blame] | 787 | booleanParam(name: 'RUN_GRACEFUL_REBOOT_TEST', value: triggers.runGracefulRebootTestEnabled), |
Dmitriy Kasyanov | 5f910e6 | 2022-02-11 14:57:05 +0300 | [diff] [blame] | 788 | booleanParam(name: 'RUN_MGMT_DELETE_MASTER_TEST', value: triggers.runMgmtDeleteMasterTestEnabled), |
| 789 | booleanParam(name: 'RUN_RGNL_DELETE_MASTER_TEST', value: triggers.runRgnlDeleteMasterTestEnabled), |
| 790 | booleanParam(name: 'RUN_CHILD_DELETE_MASTER_TEST', value: triggers.runChildDeleteMasterTestEnabled), |
Владислав Наумов | 9cec55d | 2021-08-03 15:00:59 +0200 | [diff] [blame] | 791 | booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled), |
Vladyslav Drok | c4f9c1b | 2021-07-22 15:34:24 +0200 | [diff] [blame] | 792 | booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 793 | booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled), |
| 794 | booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled), |
Sergey Lalov | c1cb49f | 2022-09-27 01:16:25 +0400 | [diff] [blame] | 795 | booleanParam(name: 'FULL_UPGRADE_CHILD_CLUSTER', value: triggers.fullUpgradeChildEnabled), |
slalov | 574123e | 2022-04-06 17:24:19 +0400 | [diff] [blame] | 796 | booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled), |
Владислав Наумов | 0dc9925 | 2020-11-13 13:30:48 +0100 | [diff] [blame] | 797 | booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled), |
Владислав Наумов | cdbd84e | 2020-12-01 16:51:09 +0100 | [diff] [blame] | 798 | booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled), |
Vladislav Naumov | 7930ab2 | 2021-11-22 18:24:24 +0100 | [diff] [blame] | 799 | booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 800 | booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled), |
Ivan Berezovskiy | cbf9eeb | 2021-03-22 15:57:32 +0400 | [diff] [blame] | 801 | booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled), |
Владислав Наумов | e021b02 | 2021-05-06 11:26:38 +0200 | [diff] [blame] | 802 | booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled), |
Владислав Наумов | 82305e9 | 2021-10-14 20:45:20 +0200 | [diff] [blame] | 803 | booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled), |
Vladislav Naumov | 42b71dc | 2021-11-22 13:09:42 +0100 | [diff] [blame] | 804 | booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled), |
eromanova | d339751 | 2021-04-01 20:19:19 +0400 | [diff] [blame] | 805 | booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled), |
Владислав Наумов | c52dd9d | 2021-06-28 16:27:29 +0200 | [diff] [blame] | 806 | booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled), |
Владислав Наумов | 2d3db33 | 2021-06-15 15:19:19 +0200 | [diff] [blame] | 807 | booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled), |
Sergey Zhemerdeev | 9074f6e | 2022-06-07 12:03:16 +0300 | [diff] [blame] | 808 | booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 809 | ] |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 810 | |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 811 | // customize multiregional demo |
| 812 | if (triggers.multiregionalConfiguration.enabled) { |
| 813 | parameters.add(string(name: 'MULTIREGION_SETUP', |
| 814 | value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}" |
| 815 | )) |
| 816 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 817 | |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 818 | // Determine component team custom context |
| 819 | if (coreContext != '') { |
| 820 | common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...') |
| 821 | def additionalParameters = generateKaaSVarsFromContext(coreContext) |
Владислав Наумов | bef51a9 | 2020-10-01 17:36:51 +0200 | [diff] [blame] | 822 | parameters.addAll(additionalParameters) |
Владислав Наумов | 92288d9 | 2020-07-13 18:36:21 +0200 | [diff] [blame] | 823 | } |
| 824 | |
Владислав Наумов | aa43061 | 2020-06-08 17:18:31 +0200 | [diff] [blame] | 825 | def jobResults = [] |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 826 | |
| 827 | platforms.each { platform -> |
| 828 | jobs["kaas-core-${platform}-patched-${component}"] = { |
Vladislav Naumov | 5313a20 | 2021-04-07 17:13:39 +0000 | [diff] [blame] | 829 | try { |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 830 | common.infoMsg("Deploy: patched KaaS demo with ${platform} provider") |
| 831 | def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true |
| 832 | def build_description = job_info.getDescription() |
| 833 | def build_result = job_info.getResult() |
Vladislav Naumov | 5313a20 | 2021-04-07 17:13:39 +0000 | [diff] [blame] | 834 | jobResults.add(build_result) |
Владислав Наумов | d044e84 | 2020-06-17 15:33:43 +0200 | [diff] [blame] | 835 | |
Vladislav Naumov | 5313a20 | 2021-04-07 17:13:39 +0000 | [diff] [blame] | 836 | if (build_description) { |
| 837 | currentBuild.description += build_description |
| 838 | } |
| 839 | } finally { |
Ivan Berezovskiy | 91ede50 | 2021-05-13 21:05:36 +0400 | [diff] [blame] | 840 | common.infoMsg("Patched KaaS demo with ${platform} provider finished") |
Vladislav Naumov | 5313a20 | 2021-04-07 17:13:39 +0000 | [diff] [blame] | 841 | } |
| 842 | } |
| 843 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 844 | |
| 845 | common.infoMsg('Trigger KaaS demo deployments according to defined provider set') |
Владислав Наумов | 37f7f84 | 2021-03-09 16:08:39 +0400 | [diff] [blame] | 846 | if (jobs.size() == 0) { |
| 847 | error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled') |
| 848 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 849 | // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085 |
| 850 | parallel jobs |
Владислав Наумов | aa43061 | 2020-06-08 17:18:31 +0200 | [diff] [blame] | 851 | |
| 852 | if (jobResults.contains('FAILURE')) { |
Владислав Наумов | f86b111 | 2020-06-09 14:04:48 +0200 | [diff] [blame] | 853 | common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed') |
Владислав Наумов | aa43061 | 2020-06-08 17:18:31 +0200 | [diff] [blame] | 854 | currentBuild.result = 'FAILURE' |
| 855 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 856 | } |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 857 | |
| 858 | |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 859 | /** |
| 860 | * 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] | 861 | * 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] | 862 | * |
| 863 | * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere] |
| 864 | * @param: triggers (map) Custom trigger keywords forwarded from gerrit |
| 865 | * @param: multiregionalConfiguration (map) Multiregional configuration |
| 866 | * @return (map) Return aggregated map with lockResources and netMap |
| 867 | */ |
| 868 | |
| 869 | |
| 870 | def generateLockResources(callBackDemo, triggers) { |
| 871 | def common = new com.mirantis.mk.Common() |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 872 | def netMap = [ |
| 873 | vsphere: [:], |
| 874 | equinix: [:], |
| 875 | ] |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 876 | // Define vsphere locklabels with initial quantity |
| 877 | def lockLabels = [ |
| 878 | vsphere_networking_core_ci: 0, |
| 879 | vsphere_offline_networking_core_ci: 0, |
| 880 | ] |
| 881 | def deployChild = triggers.deployChildEnabled |
slalov | 2783327 | 2022-06-30 02:13:50 +0400 | [diff] [blame] | 882 | def testUiVsphere = triggers.runUie2eEnabled |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 883 | def multiregionConfig = triggers.multiregionalConfiguration |
| 884 | def runMultiregion = multiregionConfig.enabled |
| 885 | |
| 886 | // Generate vsphere netMap and lockLabels based on demo context |
| 887 | switch (callBackDemo) { |
| 888 | case 'aws': |
| 889 | // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child |
| 890 | lockLabels['aws_core_ci_queue'] = triggers.demoWeight |
Sergey Kolekonov | f4c1f49 | 2022-02-03 14:44:45 +0400 | [diff] [blame] | 891 | if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 } |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 892 | |
| 893 | // Define netMap for Vsphere region |
Mikhail Ivanov | 90a27fa | 2022-05-30 15:18:24 +0400 | [diff] [blame] | 894 | if (runMultiregion && multiregionConfig.managementLocation == 'aws') { |
| 895 | if (multiregionConfig.regionLocation == 'vsphere') { |
| 896 | if (deployChild) { |
| 897 | addToProviderNetMap(netMap, 'vsphere', 'regional-child') |
| 898 | } |
| 899 | addToProviderNetMap(netMap, 'vsphere', 'region') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 900 | } |
Mikhail Ivanov | 90a27fa | 2022-05-30 15:18:24 +0400 | [diff] [blame] | 901 | |
| 902 | if (multiregionConfig.regionLocation == 'azure') { |
| 903 | lockLabels['azure_core_ci_queue'] = 1 |
| 904 | if (deployChild) { |
| 905 | lockLabels['azure_core_ci_queue'] += 1 |
| 906 | } |
| 907 | } |
| 908 | } |
| 909 | if (triggers.azureOnAwsDemoEnabled) { |
| 910 | lockLabels['azure_core_ci_queue'] = 1 |
| 911 | } |
| 912 | |
| 913 | if (triggers.equinixOnAwsDemoEnabled) { |
| 914 | lockLabels['equinix_core_ci_queue'] = 1 |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 915 | } |
| 916 | break |
| 917 | case 'vsphere': |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 918 | addToProviderNetMap(netMap, 'vsphere', 'mgmt') |
slalov | 2783327 | 2022-06-30 02:13:50 +0400 | [diff] [blame] | 919 | if (deployChild || testUiVsphere) { |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 920 | addToProviderNetMap(netMap, 'vsphere', 'child') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 921 | } |
| 922 | if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' && |
| 923 | multiregionConfig.regionLocation == 'vsphere') { |
| 924 | if (deployChild) { |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 925 | addToProviderNetMap(netMap, 'vsphere', 'regional-child') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 926 | } |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 927 | addToProviderNetMap(netMap, 'vsphere', 'region') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 928 | } |
| 929 | break |
Mikhail Ivanov | 90a27fa | 2022-05-30 15:18:24 +0400 | [diff] [blame] | 930 | case 'azure': |
| 931 | lockLabels['azure_core_ci_queue'] = triggers.demoWeight |
| 932 | if (runMultiregion && multiregionConfig.managementLocation == 'azure') { |
| 933 | if (multiregionConfig.regionLocation == 'aws') { |
| 934 | lockLabels['aws_core_ci_queue'] = 1 |
| 935 | if (deployChild) { |
| 936 | lockLabels['aws_core_ci_queue'] += 1 |
| 937 | } |
| 938 | } |
| 939 | |
| 940 | if (multiregionConfig.regionLocation == 'equinix') { |
| 941 | lockLabels['equinix_core_ci_queue'] = 1 |
| 942 | if (deployChild) { |
| 943 | lockLabels['equinix_core_ci_queue'] +=1 |
| 944 | } |
| 945 | } |
| 946 | } |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 947 | default: |
Mikhail Ivanov | 90a27fa | 2022-05-30 15:18:24 +0400 | [diff] [blame] | 948 | error('Supposed to be called from aws, azure or vsphere demos only') |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment |
| 952 | // Vsphere labels only |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 953 | netMap['vsphere'].each { clusterType, netConfig -> |
| 954 | if (triggers.proxyConfig["${clusterType}Offline"] == true || |
| 955 | (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) || |
| 956 | (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) { |
| 957 | |
| 958 | netMap['vsphere'][clusterType]['netName'] = 'offline' |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 959 | lockLabels['vsphere_offline_networking_core_ci']++ |
| 960 | } else { |
| 961 | lockLabels['vsphere_networking_core_ci']++ |
| 962 | } |
| 963 | } |
| 964 | |
| 965 | // generate lock metadata |
| 966 | def lockResources = [] |
| 967 | lockLabels.each { label, quantity -> |
| 968 | if (quantity > 0) { |
| 969 | def res = [ |
| 970 | label: label, |
| 971 | quantity: quantity, |
| 972 | ] |
| 973 | lockResources.add(res) |
| 974 | } |
| 975 | } |
| 976 | |
| 977 | common.infoMsg("""Generated vsphere netMap: ${netMap} |
| 978 | Generated lockResources: ${lockResources}""") |
| 979 | |
| 980 | return [ |
| 981 | netMap: netMap, |
| 982 | lockResources: lockResources, |
| 983 | ] |
| 984 | } |
| 985 | |
| 986 | /** |
| 987 | * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName |
| 988 | * and empty rangeConfig to the this map. |
| 989 | * |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 990 | * @param: netMap (string) vsphere, equinix netMap or empty map |
| 991 | * @param: provider (string) provider type |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 992 | * @param: clusterType (string) Vsphere cluster type |
| 993 | */ |
| 994 | |
Владислав Наумов | 33e1e81 | 2021-08-17 17:09:25 +0200 | [diff] [blame] | 995 | def addToProviderNetMap (netMap, provider, clusterType) { |
| 996 | switch (provider) { |
| 997 | case 'equinix': |
| 998 | netMap[provider][clusterType] = [ |
| 999 | vlanConfig: '', |
| 1000 | ] |
| 1001 | break |
| 1002 | case 'vsphere': |
| 1003 | netMap[provider][clusterType] = [ |
| 1004 | netName: 'default', |
| 1005 | rangeConfig: '', |
| 1006 | ] |
| 1007 | break |
| 1008 | default: |
| 1009 | error('Net map locks supported for Equinix/Vsphere providers only') |
| 1010 | } |
Stanislav Riazanov | 78fa7df | 2021-05-28 20:28:59 +0400 | [diff] [blame] | 1011 | } |
Dmitry Teselkin | fce71aa | 2022-03-05 19:36:52 +0300 | [diff] [blame] | 1012 | |
| 1013 | /** |
| 1014 | * getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps. |
| 1015 | * Each element (map) contains keys 'key' for keyword name and 'value' for its value. |
| 1016 | * If keyword contains only 'key' part then 'value' is boolean True. |
| 1017 | * This function does not perform keywords validation. |
| 1018 | * First line of a commit message is ignored. |
| 1019 | * To use '[' or ']' characters inside keyword prepend it with backslash '\'. |
| 1020 | * TODO: Remove backslash chars from values if they prepend '[' or ']'. |
| 1021 | **/ |
| 1022 | |
| 1023 | List getCIKeywordsFromCommitMsg() { |
| 1024 | String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
| 1025 | List commitMsgLines = commitMsg.split('\n') |
| 1026 | List keywords = [] |
| 1027 | if (commitMsgLines.size() < 2) { |
| 1028 | return keywords |
| 1029 | } |
| 1030 | |
| 1031 | String commitMsgBody = commitMsgLines[1..-1].join('\n') |
| 1032 | |
| 1033 | // Split commit message body to chunks using '[' or ']' as delimiter, |
| 1034 | // ignoring them if prepended by backslash (regex negative lookbehind). |
| 1035 | // Resulting list will have chunks between '[' and ']' at odd indexes. |
| 1036 | List parts = commitMsgBody.split(/(?<!\\)[\[\]]/) |
| 1037 | |
| 1038 | // Iterate chunks by odd indexes only, trim values and split to |
| 1039 | // <key> / <value> pair where <key> is the part of a sting before the first |
| 1040 | // whitespace delimiter, and <value> is the rest (may include whitespaces). |
| 1041 | // If there is no whitespace in the string then this is a 'switch' |
| 1042 | // and <value> will be boolean True. |
| 1043 | for (i = 1; i < parts.size(); i += 2) { |
| 1044 | def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1] |
| 1045 | keywords.add(['key': key, 'value': value]) |
| 1046 | } |
| 1047 | |
| 1048 | return keywords |
| 1049 | } |
| 1050 | |
| 1051 | /** |
| 1052 | * getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword |
| 1053 | * that were specified for given job name. `job-params` keyword has the following structure |
| 1054 | * |
| 1055 | * [job-params <job name> <parameter name> <parameter value>] |
| 1056 | * |
| 1057 | * Return value is a Map that contains those parameters using the following structure: |
| 1058 | * |
| 1059 | * <job name>: |
| 1060 | * <parameter name>: <parameter value> |
| 1061 | * |
| 1062 | **/ |
| 1063 | Map getJobsParamsFromCommitMsg() { |
| 1064 | List keywords = getCIKeywordsFromCommitMsg() |
| 1065 | |
| 1066 | List jobsParamsList = [] |
| 1067 | keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) { |
| 1068 | def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1] |
| 1069 | def (key, value) = params.split(/\s+/, 2) |
| 1070 | ['name': name, 'key': key, 'value': value] |
| 1071 | } |
| 1072 | |
| 1073 | Map jobsParams = jobsParamsList.inject([:]) { result, it -> |
| 1074 | if (!result.containsKey(it.name)) { |
| 1075 | result[it.name] = [:] |
| 1076 | } |
| 1077 | result[it.name][it.key] = it.value |
| 1078 | result |
| 1079 | } |
| 1080 | |
| 1081 | return jobsParams |
| 1082 | } |
| 1083 | |
| 1084 | |
| 1085 | /** |
| 1086 | * getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message. |
| 1087 | * It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then |
| 1088 | * uses only those parametes that were set to all jobs (with <job name> == '*') or to |
| 1089 | * a particular job. Parameters set to a particular job have higher precedence. |
| 1090 | * |
| 1091 | * Return value is a Map that contains those parameters: |
| 1092 | * |
| 1093 | * <parameter name>: <parameter value> |
| 1094 | * |
| 1095 | **/ |
| 1096 | Map getJobParamsFromCommitMsg(String jobName) { |
| 1097 | jobsParams = getJobsParamsFromCommitMsg() |
| 1098 | jobParams = jobsParams.getOrDefault('*', [:]) |
| 1099 | if (jobName) { |
| 1100 | jobParams.putAll(jobsParams.getOrDefault(jobName, [:])) |
| 1101 | } |
| 1102 | return jobParams |
| 1103 | } |
azvyagintsev | c17d14b | 2022-06-06 19:06:33 +0300 | [diff] [blame] | 1104 | |
| 1105 | /** Getting test scheme from text, which should be |
| 1106 | Imput example: |
| 1107 | text=""" |
| 1108 | DATA |
| 1109 | |
| 1110 | kaas_bm_test_schemas: |
| 1111 | KAAS_RELEASES_REFSPEC: '' |
| 1112 | KEY: VAL |
| 1113 | |
| 1114 | DATA |
| 1115 | """ |
| 1116 | |
| 1117 | Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas']) |
| 1118 | |
| 1119 | Return: |
| 1120 | ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL'] |
| 1121 | **/ |
| 1122 | def parseTextForTestSchemas(Map opts) { |
azvyagintsev | d96aac2 | 2022-06-10 14:23:26 +0300 | [diff] [blame] | 1123 | String text = opts.getOrDefault('text', '') |
azvyagintsev | c17d14b | 2022-06-06 19:06:33 +0300 | [diff] [blame] | 1124 | String keyLine = opts.getOrDefault('keyLine', '') |
| 1125 | Map testScheme = [:] |
| 1126 | if (!text || !keyLine) { |
azvyagintsev | d96aac2 | 2022-06-10 14:23:26 +0300 | [diff] [blame] | 1127 | return testScheme |
azvyagintsev | c17d14b | 2022-06-06 19:06:33 +0300 | [diff] [blame] | 1128 | } |
| 1129 | if (text =~ /\n$keyLine\n.*/) { |
| 1130 | def common = new com.mirantis.mk.Common() |
| 1131 | try { |
| 1132 | String regExp = '\\n' + keyLine + '\\n' |
| 1133 | // regexep block must be followed by empty line |
| 1134 | testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}" |
| 1135 | common.infoMsg("parseTextForTestSchemas result:\n" + testScheme) |
| 1136 | common.mergeEnv(env, toJson(testScheme)) |
| 1137 | } |
| 1138 | catch (Exception e) { |
| 1139 | common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}") |
| 1140 | throw e |
| 1141 | } |
| 1142 | } |
azvyagintsev | d96aac2 | 2022-06-10 14:23:26 +0300 | [diff] [blame] | 1143 | return testScheme |
Dmitriy Kasyanov | 5f910e6 | 2022-02-11 14:57:05 +0300 | [diff] [blame] | 1144 | } |
Sergey Zhemerdeev | 3156908 | 2022-08-10 10:13:19 +0300 | [diff] [blame] | 1145 | |
| 1146 | |
| 1147 | /** |
Sergey Zhemerdeev | de949bf | 2022-09-14 15:44:33 +0300 | [diff] [blame] | 1148 | * getEquinixFacilityWithCapacity returns list of Equinix facilities using specified |
Sergey Zhemerdeev | 46080fa | 2022-10-06 12:34:12 +0300 | [diff] [blame] | 1149 | * instance type (nodeType), desired count of facilities (facilityCount) and |
| 1150 | * instances (nodeCount) in a facility using specified matal version. |
Sergey Zhemerdeev | 3156908 | 2022-08-10 10:13:19 +0300 | [diff] [blame] | 1151 | * Function downloads metal CLI from the |
Sergey Zhemerdeev | de949bf | 2022-09-14 15:44:33 +0300 | [diff] [blame] | 1152 | * https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux |
| 1153 | * Empty list is returned in case of no facilities with specified capacity was found or any other errors. |
Sergey Zhemerdeev | 15aa860 | 2022-10-13 11:10:02 +0300 | [diff] [blame] | 1154 | * Non-empty list is shuffled. |
Sergey Zhemerdeev | 3156908 | 2022-08-10 10:13:19 +0300 | [diff] [blame] | 1155 | * |
Sergey Zhemerdeev | 46080fa | 2022-10-06 12:34:12 +0300 | [diff] [blame] | 1156 | * @param: facilityCount (int) Desired count of facilities |
| 1157 | * @param: nodeCount (int) Desired count of instances |
| 1158 | * @param: nodeType (string) Instance type |
| 1159 | * @param: version (string) Metal version to use |
Sergey Zhemerdeev | de949bf | 2022-09-14 15:44:33 +0300 | [diff] [blame] | 1160 | * @return ([]string) List of selected facilities |
Sergey Zhemerdeev | 3156908 | 2022-08-10 10:13:19 +0300 | [diff] [blame] | 1161 | * |
| 1162 | **/ |
Sergey Zhemerdeev | 46080fa | 2022-10-06 12:34:12 +0300 | [diff] [blame] | 1163 | def getEquinixFacilityWithCapacity(facilityCount = 1, nodeCount = 50, nodeType = 'c3.small.x86', version = '0.9.0') { |
Sergey Zhemerdeev | 3156908 | 2022-08-10 10:13:19 +0300 | [diff] [blame] | 1164 | def common = new com.mirantis.mk.Common() |
| 1165 | def metalUrl = "https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux" |
Sergey Zhemerdeev | b68bf61 | 2022-09-12 13:12:32 +0300 | [diff] [blame] | 1166 | def metal = './metal --config metal.yaml' |
Sergey Zhemerdeev | b68bf61 | 2022-09-12 13:12:32 +0300 | [diff] [blame] | 1167 | def facility = [] |
Sergey Zhemerdeev | 3156908 | 2022-08-10 10:13:19 +0300 | [diff] [blame] | 1168 | def out = '' |
Sergey Zhemerdeev | bcccb91 | 2022-08-25 14:26:52 +0300 | [diff] [blame] | 1169 | def retries = 3 // number of retries |
Sergey Zhemerdeev | 495ba58 | 2022-08-16 16:31:43 +0300 | [diff] [blame] | 1170 | def i = 0 |
| 1171 | def delay = 60 // 1 minute sleep |
Sergey Zhemerdeev | 46080fa | 2022-10-06 12:34:12 +0300 | [diff] [blame] | 1172 | def excludeFacility = [] // list of facilities to exclude from selection |
Sergey Zhemerdeev | 3156908 | 2022-08-10 10:13:19 +0300 | [diff] [blame] | 1173 | try { |
Sergey Zhemerdeev | b357534 | 2022-10-04 11:02:19 +0300 | [diff] [blame] | 1174 | if (excludeFacility.size() > 0) { |
| 1175 | common.infoMsg("Excluded facilities: ${excludeFacility}") |
| 1176 | } |
Sergey Zhemerdeev | 3156908 | 2022-08-10 10:13:19 +0300 | [diff] [blame] | 1177 | sh "curl -o metal -# ${metalUrl} && chmod +x metal" |
| 1178 | withCredentials([string(credentialsId: env.KAAS_EQUINIX_API_TOKEN, variable: 'KAAS_EQUINIX_API_TOKEN')]) { |
| 1179 | sh 'echo "project-id: ${KAAS_EQUINIX_PROJECT_ID}\ntoken: ${KAAS_EQUINIX_API_TOKEN}" >metal.yaml' |
Sergey Zhemerdeev | 3156908 | 2022-08-10 10:13:19 +0300 | [diff] [blame] | 1180 | } |
Sergey Zhemerdeev | 46080fa | 2022-10-06 12:34:12 +0300 | [diff] [blame] | 1181 | while (facility.size() < facilityCount && i < retries) { |
| 1182 | common.infoMsg("Selecting ${facilityCount} available Equinix facilities with free ${nodeCount} ${nodeType} hosts, try ${i+1}/${retries} ...") |
Sergey Zhemerdeev | 495ba58 | 2022-08-16 16:31:43 +0300 | [diff] [blame] | 1183 | if (i > 0 ) { // skip sleep on first step |
| 1184 | sleep(delay) |
| 1185 | } |
Sergey Zhemerdeev | b68bf61 | 2022-09-12 13:12:32 +0300 | [diff] [blame] | 1186 | out = sh(script: "${metal} capacity get -f -P ${nodeType}|awk '/${nodeType}/ {print \$2}'|paste -s -d,|xargs ${metal} capacity check -P ${nodeType} -q ${nodeCount} -f|grep true|awk '{print \$2}'|paste -s -d,", returnStdout: true).trim() |
| 1187 | facility = out.tokenize(',') |
Sergey Zhemerdeev | b357534 | 2022-10-04 11:02:19 +0300 | [diff] [blame] | 1188 | facility -= excludeFacility |
Sergey Zhemerdeev | 46080fa | 2022-10-06 12:34:12 +0300 | [diff] [blame] | 1189 | if (facility.size() < facilityCount) { |
| 1190 | nodeCount -= 10 |
| 1191 | // We need different metros for the [equinixmetalv2-child-diff-metro] case, facility[][0, 1] contains a metro name |
| 1192 | } else if (facility.size() == 2 && facility[0][0, 1] == facility[1][0, 1]) { |
Sergey Zhemerdeev | bcccb91 | 2022-08-25 14:26:52 +0300 | [diff] [blame] | 1193 | nodeCount -= 10 |
| 1194 | } |
Sergey Zhemerdeev | 495ba58 | 2022-08-16 16:31:43 +0300 | [diff] [blame] | 1195 | i++ |
| 1196 | } |
Sergey Zhemerdeev | b68bf61 | 2022-09-12 13:12:32 +0300 | [diff] [blame] | 1197 | if (facility.size() > 0) { |
| 1198 | f = facility.size() > 1 ? "${facility[0]},${facility[1]}" : "${facility[0]}" |
| 1199 | sh "${metal} capacity check -P ${nodeType} -f ${f} -q ${nodeCount}" |
Sergey Zhemerdeev | bcccb91 | 2022-08-25 14:26:52 +0300 | [diff] [blame] | 1200 | } |
Sergey Zhemerdeev | 3156908 | 2022-08-10 10:13:19 +0300 | [diff] [blame] | 1201 | } catch (Exception e) { |
| 1202 | common.errorMsg "Exception: '${e}'" |
| 1203 | return [] |
Sergey Zhemerdeev | 495ba58 | 2022-08-16 16:31:43 +0300 | [diff] [blame] | 1204 | } finally { |
| 1205 | sh 'rm metal.yaml' |
| 1206 | } |
Sergey Zhemerdeev | b68bf61 | 2022-09-12 13:12:32 +0300 | [diff] [blame] | 1207 | if (facility.size() > 0) { |
Sergey Zhemerdeev | 15aa860 | 2022-10-13 11:10:02 +0300 | [diff] [blame] | 1208 | Collections.shuffle(facility) |
Sergey Zhemerdeev | b68bf61 | 2022-09-12 13:12:32 +0300 | [diff] [blame] | 1209 | common.infoMsg("Selected facilities: ${facility}") |
Sergey Zhemerdeev | 495ba58 | 2022-08-16 16:31:43 +0300 | [diff] [blame] | 1210 | } else { |
Sergey Zhemerdeev | de949bf | 2022-09-14 15:44:33 +0300 | [diff] [blame] | 1211 | common.warningMsg('No any facilities have been selected !!! :(') |
Sergey Zhemerdeev | 3156908 | 2022-08-10 10:13:19 +0300 | [diff] [blame] | 1212 | } |
Sergey Zhemerdeev | de949bf | 2022-09-14 15:44:33 +0300 | [diff] [blame] | 1213 | return facility |
Sergey Zhemerdeev | 3156908 | 2022-08-10 10:13:19 +0300 | [diff] [blame] | 1214 | } |
Sergey Zhemerdeev | 2a27334 | 2022-08-18 12:06:11 +0300 | [diff] [blame] | 1215 | |
| 1216 | |
| 1217 | /** |
| 1218 | * genCommandLine prepares command line for artifactory-replication |
| 1219 | * command using legacy environment variables |
| 1220 | * |
| 1221 | * @return: (string) Prepared command line |
| 1222 | */ |
| 1223 | def genCommandLine() { |
| 1224 | def envToParam = [ |
| 1225 | 'DESTINATION_USER': '-dst-user', |
| 1226 | 'ARTIFACT_FILTER': '-artifact-filter', |
| 1227 | 'ARTIFACT_FILTER_PROD': '-artifact-filter-prod', |
| 1228 | 'ARTIFACT_TYPE': '-artifact-type', |
| 1229 | 'BINARY_CLEAN': '-bin-cleanup', |
| 1230 | 'BINARY_CLEAN_KEEP_DAYS': '-bin-clean-keep-days', |
| 1231 | 'BINARY_CLEAN_PREFIX': '-bin-clean-prefix', |
| 1232 | 'BUILD_URL': '-slack-build-url', |
| 1233 | 'CHECK_REPOS': '-check-repos', |
| 1234 | 'DESTINATION_REGISTRY': '-dst-repo', |
| 1235 | 'DESTINATION_REGISTRY_TYPE': '-dst-repo-type', |
| 1236 | 'DOCKER_CLEAN': '-cleanup', |
| 1237 | 'DOCKER_REPO_PREFIX': '-docker-repo-prefix', |
| 1238 | 'DOCKER_TAG': '-docker-tag', |
| 1239 | 'FORCE': '-force', |
| 1240 | 'HELM_CDN_DOMAIN': '-helm-cdn-domain', |
| 1241 | 'SLACK_CHANNEL': '-slack-channel', |
| 1242 | 'SLACK_USER': '-slack-user', |
| 1243 | 'SOURCE_REGISTRY': '-src-repo', |
| 1244 | 'SOURCE_REGISTRY_TYPE': '-src-repo-type', |
| 1245 | 'SYNC_PATTERN': '-sync-pattern' |
| 1246 | ] |
| 1247 | def cmdParams = '' |
Sergey Zhemerdeev | 88d1c3d | 2022-08-31 16:37:48 +0300 | [diff] [blame] | 1248 | def isCheckClean = false |
Sergey Zhemerdeev | 2a27334 | 2022-08-18 12:06:11 +0300 | [diff] [blame] | 1249 | for (e in envToParam) { |
| 1250 | if (env[e.key] == null) { |
| 1251 | continue |
| 1252 | } |
| 1253 | if (e.key == 'CHECK_REPOS' || e.key == 'DOCKER_CLEAN') { |
Sergey Zhemerdeev | 88d1c3d | 2022-08-31 16:37:48 +0300 | [diff] [blame] | 1254 | // Avoid CHECK_REPOS=true and DOCKER_CLEAN=true |
| 1255 | if (env[e.key].toBoolean() && !isCheckClean) { |
Sergey Zhemerdeev | 2a27334 | 2022-08-18 12:06:11 +0300 | [diff] [blame] | 1256 | cmdParams += e.value + ' ' |
Sergey Zhemerdeev | 88d1c3d | 2022-08-31 16:37:48 +0300 | [diff] [blame] | 1257 | isCheckClean = true |
Sergey Zhemerdeev | 2a27334 | 2022-08-18 12:06:11 +0300 | [diff] [blame] | 1258 | } |
| 1259 | } else if (e.key == 'FORCE') { |
| 1260 | if (env[e.key].toBoolean()) { |
| 1261 | cmdParams += e.value + ' ' |
| 1262 | } |
| 1263 | } else { |
Sergey Zhemerdeev | e2926cd | 2022-08-29 15:28:47 +0300 | [diff] [blame] | 1264 | cmdParams += "${e.value} '${env[e.key]}' " |
Sergey Zhemerdeev | 2a27334 | 2022-08-18 12:06:11 +0300 | [diff] [blame] | 1265 | } |
| 1266 | } |
Sergey Zhemerdeev | 88d1c3d | 2022-08-31 16:37:48 +0300 | [diff] [blame] | 1267 | // No any check or clean was specified - take a default action |
| 1268 | if (!isCheckClean) { |
| 1269 | cmdParams += '-replicate' |
| 1270 | } |
Sergey Zhemerdeev | 2a27334 | 2022-08-18 12:06:11 +0300 | [diff] [blame] | 1271 | return cmdParams |
| 1272 | } |
Sergey Kolekonov | 0e60a94 | 2022-09-05 13:02:22 +0400 | [diff] [blame] | 1273 | |
| 1274 | /** |
| 1275 | * custom scheduling algorithm |
| 1276 | * it ensures that builds of the same job are distributed as much as possible between different nodes |
| 1277 | * @param label (string) desired node label |
| 1278 | * @return: (string) node name |
| 1279 | */ |
| 1280 | def schedule (label='docker') { |
| 1281 | def common = new com.mirantis.mk.Common() |
| 1282 | def freeNodes = [] |
| 1283 | def nodesMap = [:] |
| 1284 | |
| 1285 | // filter nodes with the specified label and at least one free executor |
| 1286 | timeout(time: 30, unit: 'MINUTES') { |
| 1287 | while (!freeNodes) { |
| 1288 | freeNodes = jenkins.model.Jenkins.instance.computers.findAll { node -> |
| 1289 | label in node.getAssignedLabels().collect { it.name } && |
| 1290 | node.isPartiallyIdle() |
| 1291 | } |
| 1292 | if (!freeNodes) { |
| 1293 | echo 'No nodes available for scheduling, retrying...' |
| 1294 | sleep 30 |
| 1295 | } |
| 1296 | } |
| 1297 | } |
| 1298 | |
| 1299 | // generate a map of nodes matching other criteria |
| 1300 | for (node in freeNodes) { |
| 1301 | // sameJobExecutors is the number of executors running the same job as the calling one |
| 1302 | sameJobExecutors = node.getExecutors() // get all executors |
| 1303 | .collect { executor -> executor.getCurrentExecutable() } // get running "threads" |
| 1304 | .collect { thread -> thread?.displayName } // filter job names from threads |
| 1305 | .minus(null) // null = empty executors, remove them from the list |
| 1306 | .findAll { it.contains(env.JOB_NAME) } // filter the same jobs as the calling one |
| 1307 | .size() |
| 1308 | |
| 1309 | // calculate busy executors, we don't want to count "sameJobExecutors" twice |
| 1310 | totalBusyExecutors = node.countBusy() - sameJobExecutors |
| 1311 | // generate the final map which contains nodes matching criteria with their load score |
| 1312 | // builds of the same jobs have x10 score, all others x1 |
| 1313 | nodesMap += ["${node.getName()}" : sameJobExecutors * 10 + totalBusyExecutors] |
| 1314 | } |
| 1315 | |
| 1316 | // return the least loaded node |
| 1317 | return common.SortMapByValueAsc(nodesMap).collect { it.key }[0] |
| 1318 | } |