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 |
Denis Egorenko | 032b8ca | 2018-09-13 17:00:23 +0400 | [diff] [blame] | 18 | sh(script: 'find . -mindepth 1 -delete || true', returnStatus: true) |
| 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 = [ |
Denis Egorenko | 926bc7d | 2019-02-19 14:27:34 +0400 | [diff] [blame] | 28 | 'dockerHostname': "cfg01", |
| 29 | 'domain': "${templateContext.default_context.cluster_domain}", |
Denis Egorenko | 032b8ca | 2018-09-13 17:00:23 +0400 | [diff] [blame] | 30 | 'clusterName': templateContext.default_context.cluster_name, |
| 31 | 'reclassEnv': extraVars.testReclassEnv, |
azvyagintsev | 1bcadc4 | 2018-10-05 20:13:15 +0300 | [diff] [blame] | 32 | 'distribRevision': extraVars.DISTRIB_REVISION, |
Denis Egorenko | 032b8ca | 2018-09-13 17:00:23 +0400 | [diff] [blame] | 33 | 'dockerContainerName': extraVars.DockerCName, |
Denis Egorenko | d87490e | 2019-02-26 20:00:41 +0400 | [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 | 086aff1 | 2018-10-18 17:54:59 +0400 | [diff] [blame] | 40 | if (extraVars.useExtraRepos) { |
| 41 | config['extraRepos'] = extraVars.extraRepos ? extraVars.extraRepos : [:] |
| 42 | config['extraRepoMergeStrategy'] = extraVars.extraRepoMergeStrategy ? extraVars.extraRepoMergeStrategy : '' |
| 43 | } |
Denis Egorenko | 032b8ca | 2018-09-13 17:00:23 +0400 | [diff] [blame] | 44 | saltModelTesting.testNode(config) |
azvyagintsev | a381cc3 | 2018-09-11 15:36:23 +0300 | [diff] [blame] | 45 | } catch (Throwable e) { |
| 46 | // If there was an error or exception thrown, the build failed |
| 47 | currentBuild.result = "FAILURE" |
| 48 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 49 | throw e |
Denis Egorenko | 34c4a3b | 2019-03-12 12:48:15 +0400 | [diff] [blame] | 50 | } finally { |
| 51 | stage('Save artifacts to Artifactory') { |
| 52 | def artifactory = new com.mirantis.mcp.MCPArtifactory() |
| 53 | def envGerritVars = [ "GERRIT_PROJECT=${extraVars.get('GERRIT_PROJECT', '')}", "GERRIT_CHANGE_NUMBER=${extraVars.get('GERRIT_CHANGE_NUMBER', '')}", |
| 54 | "GERRIT_PATCHSET_NUMBER=${extraVars.get('GERRIT_PATCHSET_NUMBER', '')}", "GERRIT_CHANGE_ID=${extraVars.get('GERRIT_CHANGE_ID', '')}", |
| 55 | "GERRIT_PATCHSET_REVISION=${extraVars.get('GERRIT_PATCHSET_REVISION', '')}" ] |
| 56 | withEnv(envGerritVars) { |
| 57 | def artifactoryLink = artifactory.uploadJobArtifactsToArtifactory(['artifactory': 'mcp-ci', 'artifactoryRepo': "drivetrain-local/${JOB_NAME}/${BUILD_NUMBER}"]) |
| 58 | currentBuild.description += "<br/>${artifactoryLink}" |
| 59 | } |
| 60 | } |
azvyagintsev | a381cc3 | 2018-09-11 15:36:23 +0300 | [diff] [blame] | 61 | } |
| 62 | } |
azvyagintsev | 4eb89ea | 2018-08-07 17:48:19 +0200 | [diff] [blame] | 63 | } |
azvyagintsev | 5c0313d | 2018-08-13 17:13:35 +0300 | [diff] [blame] | 64 | } |