azvyagintsev | 4eb89ea | 2018-08-07 17:48:19 +0200 | [diff] [blame] | 1 | def common = new com.mirantis.mk.Common() |
| 2 | def saltModelTesting = new com.mirantis.mk.SaltModelTesting() |
| 3 | |
| 4 | /** |
| 5 | * Test CC model wrapper |
| 6 | * EXTRA_VARIABLES_YAML: yaml based string, to be directly passed into testCCModel |
azvyagintsev | 5c0313d | 2018-08-13 17:13:35 +0300 | [diff] [blame] | 7 | * SLAVE_NODE: |
azvyagintsev | 4eb89ea | 2018-08-07 17:48:19 +0200 | [diff] [blame] | 8 | */ |
| 9 | |
azvyagintsev | 2a4ad37 | 2019-02-07 18:43:12 +0200 | [diff] [blame] | 10 | slaveNode = env.SLAVE_NODE ?: 'docker' |
azvyagintsev | 5c0313d | 2018-08-13 17:13:35 +0300 | [diff] [blame] | 11 | |
azvyagintsev | 4eb89ea | 2018-08-07 17:48:19 +0200 | [diff] [blame] | 12 | timeout(time: 1, unit: 'HOURS') { |
azvyagintsev | a381cc3 | 2018-09-11 15:36:23 +0300 | [diff] [blame] | 13 | node(slaveNode) { |
| 14 | stage("RunTest") { |
Denis Egorenko | 34c4a3b | 2019-03-12 12:48:15 +0400 | [diff] [blame] | 15 | extraVars = readYaml text: EXTRA_VARIABLES_YAML |
azvyagintsev | a381cc3 | 2018-09-11 15:36:23 +0300 | [diff] [blame] | 16 | try { |
azvyagintsev | a381cc3 | 2018-09-11 15:36:23 +0300 | [diff] [blame] | 17 | currentBuild.description = extraVars.modelFile |
azvyagintsev | 7d98281 | 2019-04-15 23:21:35 +0300 | [diff] [blame] | 18 | sh(script: 'find . -mindepth 1 -delete || true', returnStatus: true) |
Denis Egorenko | 032b8ca | 2018-09-13 17:00:23 +0400 | [diff] [blame] | 19 | sh(script: """ |
| 20 | wget --progress=dot:mega --auth-no-challenge -O models.tar.gz ${extraVars.MODELS_TARGZ} |
| 21 | tar -xzf models.tar.gz |
| 22 | """) |
| 23 | common.infoMsg("Going to test exactly one context: ${extraVars.modelFile}\n, with params: ${extraVars}") |
| 24 | |
| 25 | def content = readFile(file: extraVars.modelFile) |
| 26 | def templateContext = readYaml text: content |
| 27 | def config = [ |
azvyagintsev | 7d98281 | 2019-04-15 23:21:35 +0300 | [diff] [blame] | 28 | 'dockerHostname' : "cfg01", |
| 29 | 'domain' : "${templateContext.default_context.cluster_domain}", |
| 30 | 'clusterName' : templateContext.default_context.cluster_name, |
| 31 | 'reclassEnv' : extraVars.testReclassEnv, |
| 32 | 'distribRevision' : extraVars.DISTRIB_REVISION, |
Denis Egorenko | 032b8ca | 2018-09-13 17:00:23 +0400 | [diff] [blame] | 33 | 'dockerContainerName': extraVars.DockerCName, |
azvyagintsev | 7d98281 | 2019-04-15 23:21:35 +0300 | [diff] [blame] | 34 | 'testContext' : extraVars.modelFile, |
| 35 | 'dockerExtraOpts' : ['--memory=3g'] |
Denis Egorenko | 032b8ca | 2018-09-13 17:00:23 +0400 | [diff] [blame] | 36 | ] |
Denis Egorenko | a79259f | 2019-03-07 16:13:31 +0400 | [diff] [blame] | 37 | if (extraVars.DISTRIB_REVISION == 'nightly') { |
| 38 | config['nodegenerator'] = true |
| 39 | } |
Denis Egorenko | 19a793d | 2019-11-18 20:50:59 +0400 | [diff] [blame] | 40 | if (extraVars.updatesVersion) { |
| 41 | config['updateSaltFormulasRev'] = extraVars.updatesVersion |
| 42 | } |
Denis Egorenko | 086aff1 | 2018-10-18 17:54:59 +0400 | [diff] [blame] | 43 | if (extraVars.useExtraRepos) { |
| 44 | config['extraRepos'] = extraVars.extraRepos ? extraVars.extraRepos : [:] |
| 45 | config['extraRepoMergeStrategy'] = extraVars.extraRepoMergeStrategy ? extraVars.extraRepoMergeStrategy : '' |
| 46 | } |
Denis Egorenko | 032b8ca | 2018-09-13 17:00:23 +0400 | [diff] [blame] | 47 | saltModelTesting.testNode(config) |
azvyagintsev | a381cc3 | 2018-09-11 15:36:23 +0300 | [diff] [blame] | 48 | } catch (Throwable e) { |
| 49 | // If there was an error or exception thrown, the build failed |
| 50 | currentBuild.result = "FAILURE" |
| 51 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 52 | throw e |
Denis Egorenko | 34c4a3b | 2019-03-12 12:48:15 +0400 | [diff] [blame] | 53 | } finally { |
| 54 | stage('Save artifacts to Artifactory') { |
| 55 | def artifactory = new com.mirantis.mcp.MCPArtifactory() |
azvyagintsev | 7d98281 | 2019-04-15 23:21:35 +0300 | [diff] [blame] | 56 | def envGerritVars = ["GERRIT_PROJECT=${extraVars.get('GERRIT_PROJECT', '')}", "GERRIT_CHANGE_NUMBER=${extraVars.get('GERRIT_CHANGE_NUMBER', '')}", |
| 57 | "GERRIT_PATCHSET_NUMBER=${extraVars.get('GERRIT_PATCHSET_NUMBER', '')}", "GERRIT_CHANGE_ID=${extraVars.get('GERRIT_CHANGE_ID', '')}", |
| 58 | "GERRIT_PATCHSET_REVISION=${extraVars.get('GERRIT_PATCHSET_REVISION', '')}"] |
Denis Egorenko | 34c4a3b | 2019-03-12 12:48:15 +0400 | [diff] [blame] | 59 | withEnv(envGerritVars) { |
Denis Egorenko | 4be215f | 2021-01-20 13:35:22 +0400 | [diff] [blame] | 60 | def artifactoryLink = artifactory.uploadJobArtifactsToArtifactory(['artifactory': 'mcp-ci', 'artifactoryRepo': "artifactory/drivetrain-local/${JOB_NAME}/${BUILD_NUMBER}"]) |
Denis Egorenko | 34c4a3b | 2019-03-12 12:48:15 +0400 | [diff] [blame] | 61 | currentBuild.description += "<br/>${artifactoryLink}" |
| 62 | } |
| 63 | } |
azvyagintsev | a381cc3 | 2018-09-11 15:36:23 +0300 | [diff] [blame] | 64 | } |
| 65 | } |
azvyagintsev | 4eb89ea | 2018-08-07 17:48:19 +0200 | [diff] [blame] | 66 | } |
azvyagintsev | 5c0313d | 2018-08-13 17:13:35 +0300 | [diff] [blame] | 67 | } |