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