vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 1 | package com.mirantis.mk |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 2 | |
| 3 | /** |
| 4 | * |
| 5 | * KaaS Component Testing Utilities |
| 6 | * |
| 7 | */ |
| 8 | |
Владислав Наумов | e534581 | 2020-08-12 16:30:20 +0200 | [diff] [blame] | 9 | /** |
| 10 | * Check KaaS Core CICD feature flags |
| 11 | * such triggers can be used in case of switching between pipelines, |
| 12 | * conditions inside pipelines to reduce dependency on jenkins job builder and jenkins job templates itself |
| 13 | * |
| 14 | * @return (map)[ |
| 15 | * ffNameEnabled: (bool) True/False |
| 16 | * ] |
| 17 | */ |
| 18 | def checkCoreCIFeatureFlags() { |
| 19 | def common = new com.mirantis.mk.Common() |
| 20 | def ff = [ |
| 21 | build_artifacts_upgrade: false, |
| 22 | ] |
| 23 | |
| 24 | def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
| 25 | if (commitMsg ==~ /(?s).*\[ci-build-artifacts-upgrade\].*/) { |
| 26 | ff['build_artifacts_upgrade'] = true |
| 27 | } |
| 28 | |
| 29 | common.infoMsg("Core ci feature flags status: ${ff}") |
| 30 | return ff |
| 31 | } |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 32 | |
| 33 | /** |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 34 | * Determine scope of test suite against per-commit KaaS deployment based on keywords |
Владислав Наумов | 5a523ef | 2020-07-29 13:33:38 +0200 | [diff] [blame] | 35 | * Keyword list: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/ |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 36 | * |
| 37 | * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs |
| 38 | * Example scheme: |
Владислав Наумов | e534581 | 2020-08-12 16:30:20 +0200 | [diff] [blame] | 39 | * New CR pushed in kubernetes/lcm-ansible -> parsing it'cs commit body and combine test-suite -> trigger deployment jobs from kaas/core |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 40 | * manage test-suite through Jenkins Job Parameters |
| 41 | * |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 42 | * @return (map)[ |
| 43 | * deployChildEnabled: (bool) True if need to deploy child cluster during demo-run |
| 44 | * runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 45 | * ] |
| 46 | */ |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 47 | def checkDeploymentTestSuite() { |
vnaumov | bdb9022 | 2020-05-04 18:25:50 +0200 | [diff] [blame] | 48 | def common = new com.mirantis.mk.Common() |
| 49 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 50 | // Available triggers and its sane defaults |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 51 | def deployChild = env.DEPLOY_CHILD_CLUSTER ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false |
| 52 | def upgradeChild = env.UPGRADE_CHILD_CLUSTER ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false |
| 53 | def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false |
| 54 | def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false |
| 55 | def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false |
| 56 | def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false |
| 57 | def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 58 | // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider |
| 59 | def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [ |
| 60 | enabled: false, |
| 61 | managementLocation: '', |
| 62 | regionLocation: '', |
| 63 | ] |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 64 | |
| 65 | // optional demo deployment customization |
Владислав Наумов | 905dd36 | 2020-06-08 16:37:01 +0200 | [diff] [blame] | 66 | def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 67 | def enableOSDemo = true |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 68 | def enableBMDemo = true |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 69 | |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 70 | 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] | 71 | if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) { |
| 72 | deployChild = true |
| 73 | } |
| 74 | if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) { |
| 75 | deployChild = true |
| 76 | upgradeChild = true |
| 77 | } |
| 78 | if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) { |
| 79 | upgradeMgmt = true |
| 80 | } |
| 81 | if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) { |
| 82 | runUie2e = true |
| 83 | } |
| 84 | if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) { |
| 85 | runMgmtConformance = true |
| 86 | } |
| 87 | if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) { |
| 88 | runChildConformance = true |
| 89 | deployChild = true |
| 90 | } |
| 91 | if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) { |
| 92 | fetchServiceBinaries = true |
| 93 | } |
| 94 | if (commitMsg ==~ /(?s).*\[aws-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/) { |
| 95 | awsOnDemandDemo = true |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 96 | common.warningMsg('Forced running additional kaas deployment with AWS provider, triggered on patchset using custom keyword: \'[aws-demo]\' ') |
| 97 | } |
| 98 | if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) { |
| 99 | enableOSDemo = false |
| 100 | common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set') |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 101 | } |
| 102 | |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 103 | if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) { |
| 104 | enableBMDemo = false |
| 105 | common.errorMsg('BM demo deployment will be aborted, VF -1 will be set') |
| 106 | } |
| 107 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 108 | // TODO (vnaumov) remove below condition after moving all releases to UCP |
| 109 | def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/) |
| 110 | if (ucpChildMatches.size() > 0) { |
| 111 | deployChild = true |
| 112 | common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ') |
| 113 | |
| 114 | // TODO(vnaumov) delete after ucp upgrades support |
| 115 | common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled') |
| 116 | upgradeChild = false |
| 117 | } |
| 118 | |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 119 | // multiregional tests |
| 120 | def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/) |
| 121 | if (multiRegionalMatches.size() > 0) { |
| 122 | multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches) |
| 123 | } |
| 124 | switch (multiregionalMappings['managementLocation']) { |
| 125 | case 'aws': |
| 126 | awsOnDemandDemo = true |
| 127 | common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request') |
| 128 | case 'os': |
| 129 | if (enableOSDemo == false) { |
| 130 | error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously') |
| 131 | } |
| 132 | } |
| 133 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 134 | common.infoMsg(""" |
| 135 | Child cluster deployment scheduled: ${deployChild} |
| 136 | Child cluster release upgrade scheduled: ${upgradeChild} |
| 137 | Child conformance testing scheduled: ${runChildConformance} |
| 138 | Mgmt cluster release upgrade scheduled: ${upgradeMgmt} |
| 139 | Mgmt conformance testing scheduled: ${runMgmtConformance} |
| 140 | Mgmt UI e2e testing scheduled: ${runUie2e} |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 141 | AWS provider deployment scheduled: ${awsOnDemandDemo} |
| 142 | OS provider deployment scheduled: ${enableOSDemo} |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 143 | BM provider deployment scheduled: ${enableBMDemo} |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame^] | 144 | Multiregional configuration: ${multiregionalMappings} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 145 | Service binaries fetching scheduled: ${fetchServiceBinaries} |
Владислав Наумов | 5a523ef | 2020-07-29 13:33:38 +0200 | [diff] [blame] | 146 | Triggers: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/""") |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 147 | return [ |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 148 | deployChildEnabled : deployChild, |
| 149 | upgradeChildEnabled : upgradeChild, |
| 150 | runChildConformanceEnabled : runChildConformance, |
| 151 | upgradeMgmtEnabled : upgradeMgmt, |
| 152 | runUie2eEnabled : runUie2e, |
| 153 | runMgmtConformanceEnabled : runMgmtConformance, |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 154 | fetchServiceBinariesEnabled: fetchServiceBinaries, |
Владислав Наумов | 4eb1da3 | 2020-08-31 14:45:16 +0200 | [diff] [blame] | 155 | awsOnDemandDemoEnabled : awsOnDemandDemo, |
azvyagintsev | 1761bdc | 2020-09-04 17:24:12 +0300 | [diff] [blame] | 156 | bmDemoEnabled : enableBMDemo, |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame^] | 157 | osDemoEnabled : enableOSDemo, |
| 158 | multiregionalConfiguration : multiregionalMappings] |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Determine management and regional setup for demo workflow scenario |
| 163 | * |
| 164 | * |
| 165 | * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]` |
| 166 | or Jenkins environment string variable in form like 'aws,os' |
| 167 | * @return (map)[ |
| 168 | enabled: (bool), |
| 169 | * managementLocation: (string), //aws,os |
| 170 | * regionLocation: (string), //aws,os |
| 171 | * ] |
| 172 | */ |
| 173 | def multiregionWorkflowParser(keyword) { |
Владислав Наумов | 8c0c39d | 2020-09-11 14:46:48 +0200 | [diff] [blame] | 174 | def common = new com.mirantis.mk.Common() |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 175 | def supportedManagementProviders = ['os', 'aws'] |
| 176 | def supportedRegionalProviders = ['os'] |
| 177 | |
| 178 | def clusterTypes = '' |
Владислав Наумов | 38ed7bf | 2020-09-11 14:43:39 +0200 | [diff] [blame] | 179 | if (keyword.toString().contains('multiregion')) { |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 180 | common.infoMsg('Multiregion definition configured via gerrit keyword trigger') |
| 181 | clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',') |
| 182 | } else { |
| 183 | common.infoMsg('Multiregion definition configured via environment variable') |
| 184 | clusterTypes = keyword.trim().split(',') |
| 185 | } |
| 186 | |
| 187 | if (clusterTypes.size() != 2) { |
| 188 | error('Incorrect regions definiton, valid scheme: [miltiregion ${management}, ${region}]') |
| 189 | } |
| 190 | |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame^] | 191 | def desiredManagementProvider = clusterTypes[0].trim() |
| 192 | def desiredRegionalProvider = clusterTypes[1].trim() |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 193 | if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) { |
| 194 | error("""unsupported management <-> regional bundle, available options: |
Владислав Наумов | f793fe3 | 2020-09-11 15:19:19 +0200 | [diff] [blame^] | 195 | management providers list - ${supportedManagementProviders} |
| 196 | regional providers list - ${supportedRegionalProviders}""") |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | return [ |
| 200 | enabled: true, |
| 201 | managementLocation: desiredManagementProvider, |
| 202 | regionLocation: desiredRegionalProvider, |
| 203 | ] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Determine if custom si tests/pipelines refspec forwarded from gerrit change request |
| 208 | |
Владислав Наумов | 5a523ef | 2020-07-29 13:33:38 +0200 | [diff] [blame] | 209 | * Keyword list: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/ |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 210 | * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs |
| 211 | * Example scheme: |
| 212 | * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core |
| 213 | * manage refspecs through Jenkins Job Parameters |
| 214 | * |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 215 | * @return (map)[* siTests: (string) final refspec for si-tests |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 216 | * siPipelines: (string) final refspec for si-pipelines |
| 217 | * ] |
| 218 | */ |
| 219 | def checkCustomSIRefspec() { |
vnaumov | bdb9022 | 2020-05-04 18:25:50 +0200 | [diff] [blame] | 220 | def common = new com.mirantis.mk.Common() |
| 221 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 222 | // Available triggers and its sane defaults |
Владислав Наумов | 6c2afff | 2020-06-05 12:54:53 +0200 | [diff] [blame] | 223 | def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master' |
| 224 | def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master' |
| 225 | def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test:master' |
| 226 | 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] | 227 | |
| 228 | def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/) |
| 229 | def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/) |
| 230 | |
| 231 | if (siTestMatches.size() > 0) { |
| 232 | siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim() |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 233 | siTestsDockerImage = "docker-dev-local.docker.mirantis.net/review/" + |
| 234 | "kaas-si-test-${siTestsRefspec.split('/')[-2]}:${siTestsRefspec.split('/')[-1]}" |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 235 | } |
| 236 | if (siPipelinesMatches.size() > 0) { |
| 237 | siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 238 | } |
| 239 | |
| 240 | common.infoMsg(""" |
| 241 | kaas/si-pipelines will be fetched from: ${siPipelinesRefspec} |
| 242 | kaas/si-tests will be fetched from: ${siTestsRefspec} |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 243 | kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage} |
Владислав Наумов | 5a523ef | 2020-07-29 13:33:38 +0200 | [diff] [blame] | 244 | Keywords: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/""") |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 245 | return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 246 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 247 | |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 248 | /** |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 249 | * Parse additional configuration for kaas component CICD repo |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 250 | * @param configurationFile (str) path to configuration file in yaml format |
| 251 | * |
| 252 | * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests, |
| 253 | * ] |
| 254 | */ |
| 255 | def parseKaaSComponentCIParameters(configurationFile){ |
| 256 | def common = new com.mirantis.mk.Common() |
| 257 | def ciConfig = readYaml file: configurationFile |
| 258 | def ciSpec = [ |
| 259 | siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '', |
| 260 | ] |
| 261 | |
| 262 | if (ciConfig.containsKey('si-tests-feature-flags')) { |
| 263 | common.infoMsg("""SI tests feature flags customization detected, |
| 264 | results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""") |
| 265 | |
| 266 | def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() } |
| 267 | ffMeta.addAll(ciConfig['si-tests-feature-flags']) |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 268 | |
Владислав Наумов | cb5ffca | 2020-07-14 15:28:36 +0200 | [diff] [blame] | 269 | ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',') |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 270 | common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}") |
| 271 | } |
| 272 | |
| 273 | common.infoMsg("""Additional ci configuration parsed successfully: |
| 274 | siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""") |
| 275 | return ciSpec |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 280 | |
Владислав Наумов | 5a523ef | 2020-07-29 13:33:38 +0200 | [diff] [blame] | 281 | * Keyword list: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/ |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 282 | * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs |
| 283 | * Example scheme: |
| 284 | * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core |
| 285 | * manage refspecs through Jenkins Job Parameters |
| 286 | * |
| 287 | * @return (map)[ core: (string) final refspec for kaas/core |
| 288 | * corePipelines: (string) final refspec for pipelines in kaas/core |
| 289 | * ] |
| 290 | */ |
| 291 | def checkCustomCoreRefspec() { |
| 292 | def common = new com.mirantis.mk.Common() |
| 293 | |
| 294 | // Available triggers and its sane defaults |
| 295 | def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master' |
| 296 | // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs* |
| 297 | def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC' |
| 298 | def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
| 299 | |
| 300 | def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/) |
| 301 | def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/) |
| 302 | |
| 303 | if (coreMatches.size() > 0) { |
| 304 | coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 305 | } |
| 306 | if (corePipelinesMatches.size() > 0) { |
| 307 | corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 308 | } |
| 309 | |
| 310 | common.infoMsg(""" |
| 311 | kaas/core will be fetched from: ${coreRefspec} |
| 312 | kaas/core pipelines will be fetched from: ${corePipelinesRefspec} |
Владислав Наумов | 5a523ef | 2020-07-29 13:33:38 +0200 | [diff] [blame] | 313 | Keywords: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/""") |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 314 | return [core: coreRefspec, corePipelines: corePipelinesRefspec] |
| 315 | } |
| 316 | |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 317 | |
| 318 | /** |
| 319 | * Trigger KaaS demo jobs based on AWS/OS providers with customized test suite, parsed from external sources (gerrit commit/jj vars) |
Владислав Наумов | 5a523ef | 2020-07-29 13:33:38 +0200 | [diff] [blame] | 320 | * Keyword list: https://docs.google.com/document/d/1SSPD8ZdljbqmNl_FEAvTHUTow9Ki8NIMu82IcAVhzXw/ |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 321 | * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs |
| 322 | * |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 323 | * @param: component (string) component name [iam, lcm, stacklight] |
| 324 | * @param: patchSpec (string) Patch for kaas/cluster releases in json format |
| 325 | * @param: configurationFile (string) Additional file for component repo CI config in yaml format |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 326 | */ |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 327 | def triggerPatchedComponentDemo(component, patchSpec, configurationFile = '.ci-parameters.yaml') { |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 328 | def common = new com.mirantis.mk.Common() |
| 329 | // Determine if custom trigger keywords forwarded from gerrit |
| 330 | def triggers = checkDeploymentTestSuite() |
| 331 | // Determine SI refspecs |
| 332 | def siRefspec = checkCustomSIRefspec() |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 333 | // Determine Core refspecs |
| 334 | def coreRefspec = checkCustomCoreRefspec() |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 335 | |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 336 | // Determine component repo ci configuration |
| 337 | def ciSpec = [:] |
| 338 | def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: '' |
| 339 | if (fileExists(configurationFile)) { |
| 340 | common.infoMsg('Component CI configuration file detected, parsing...') |
| 341 | ciSpec = parseKaaSComponentCIParameters(configurationFile) |
| 342 | componentFeatureFlags = ciSpec['siTestsFeatureFlags'] |
| 343 | } else { |
| 344 | common.warningMsg('''Component CI configuration file is not exists, |
Владислав Наумов | c17dd55 | 2020-07-29 17:07:38 +0200 | [diff] [blame] | 345 | several code-management features may be unavailable, |
| 346 | follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Component-CI |
| 347 | to create configuration file''') |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 351 | def jobs = [:] |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 352 | def parameters = [ |
Владислав Наумов | 9080f37 | 2020-06-08 13:57:16 +0200 | [diff] [blame] | 353 | string(name: 'GERRIT_REFSPEC', value: coreRefspec.core), |
| 354 | string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 355 | string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests), |
Владислав Наумов | 418042b | 2020-07-09 18:31:10 +0200 | [diff] [blame] | 356 | string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags), |
Владислав Наумов | 4a5c324 | 2020-06-08 14:36:11 +0200 | [diff] [blame] | 357 | string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 358 | string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 359 | booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 360 | booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled), |
Владислав Наумов | 080d941 | 2020-07-29 13:05:14 +0200 | [diff] [blame] | 361 | booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled), |
| 362 | booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled), |
| 363 | booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled), |
| 364 | booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled), |
Владислав Наумов | 905dd36 | 2020-06-08 16:37:01 +0200 | [diff] [blame] | 365 | booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled), |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 366 | ] |
Владислав Наумов | 765f3bd | 2020-09-07 18:09:24 +0200 | [diff] [blame] | 367 | // customize multiregional demo |
| 368 | if (triggers.multiregionalConfiguration.enabled) { |
| 369 | parameters.add(string(name: 'MULTIREGION_SETUP', |
| 370 | value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}" |
| 371 | )) |
| 372 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 373 | |
Владислав Наумов | aa43061 | 2020-06-08 17:18:31 +0200 | [diff] [blame] | 374 | def jobResults = [] |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 375 | jobs["kaas-core-openstack-patched-${component}"] = { |
Владислав Наумов | f86b111 | 2020-06-09 14:04:48 +0200 | [diff] [blame] | 376 | try { |
| 377 | common.infoMsg('Deploy: patched KaaS demo with Openstack provider') |
Владислав Наумов | 4aa112d | 2020-06-16 18:52:21 +0200 | [diff] [blame] | 378 | os_job_info = build job: "kaas-testing-core-openstack-workflow-${component}", parameters: parameters, wait: true |
| 379 | def build_description = os_job_info.getDescription() |
Владислав Наумов | d044e84 | 2020-06-17 15:33:43 +0200 | [diff] [blame] | 380 | def build_result = os_job_info.getResult() |
| 381 | jobResults.add(build_result) |
| 382 | |
Владислав Наумов | f86b111 | 2020-06-09 14:04:48 +0200 | [diff] [blame] | 383 | if (build_description) { |
| 384 | currentBuild.description += build_description |
| 385 | } |
| 386 | } finally { |
Владислав Наумов | 6d741fa | 2020-06-17 17:35:43 +0200 | [diff] [blame] | 387 | common.infoMsg('Patched KaaS demo with Openstack provider finished') |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 388 | } |
| 389 | } |
| 390 | if (triggers.awsOnDemandDemoEnabled) { |
Владислав Наумов | 5928195 | 2020-07-29 16:43:49 +0200 | [diff] [blame] | 391 | common.infoMsg('AWS demo triggered, need to sync artifacts in the public-ci cdn..') |
| 392 | switch (component) { |
| 393 | case 'iam': |
| 394 | build job: 'cdn-binary-dev-replication-iam', propagate: true, wait: true |
| 395 | break |
| 396 | case 'lcm': |
| 397 | build job: 'cdn-binary-dev-replication-lcm', propagate: true, wait: true |
| 398 | break |
| 399 | } |
| 400 | |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 401 | jobs["kaas-core-aws-patched-${component}"] = { |
Владислав Наумов | f86b111 | 2020-06-09 14:04:48 +0200 | [diff] [blame] | 402 | try { |
| 403 | common.infoMsg('Deploy: patched KaaS demo with AWS provider') |
Владислав Наумов | 4aa112d | 2020-06-16 18:52:21 +0200 | [diff] [blame] | 404 | aws_job_info = build job: "kaas-testing-core-aws-workflow-${component}", parameters: parameters, wait: true |
| 405 | def build_description = aws_job_info.getDescription() |
Владислав Наумов | d044e84 | 2020-06-17 15:33:43 +0200 | [diff] [blame] | 406 | def build_result = aws_job_info.getResult() |
| 407 | jobResults.add(build_result) |
| 408 | |
Владислав Наумов | f86b111 | 2020-06-09 14:04:48 +0200 | [diff] [blame] | 409 | if (build_description) { |
| 410 | currentBuild.description += build_description |
| 411 | } |
| 412 | } finally { |
Владислав Наумов | 6d741fa | 2020-06-17 17:35:43 +0200 | [diff] [blame] | 413 | common.infoMsg('Patched KaaS demo with AWS provider finished') |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 414 | } |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | common.infoMsg('Trigger KaaS demo deployments according to defined provider set') |
| 419 | // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085 |
| 420 | parallel jobs |
Владислав Наумов | aa43061 | 2020-06-08 17:18:31 +0200 | [diff] [blame] | 421 | |
| 422 | if (jobResults.contains('FAILURE')) { |
Владислав Наумов | f86b111 | 2020-06-09 14:04:48 +0200 | [diff] [blame] | 423 | common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed') |
Владислав Наумов | aa43061 | 2020-06-08 17:18:31 +0200 | [diff] [blame] | 424 | currentBuild.result = 'FAILURE' |
| 425 | } |
Владислав Наумов | 2a982ff | 2020-06-02 19:06:46 +0200 | [diff] [blame] | 426 | } |
Владислав Наумов | 30a516c | 2020-07-09 13:15:41 +0200 | [diff] [blame] | 427 | |
| 428 | |