blob: 8c804a1f589e4c6c5f3cf4b7f4cf71c11734e591 [file] [log] [blame]
azvyagintsev4eb89ea2018-08-07 17:48:19 +02001def common = new com.mirantis.mk.Common()
2def 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
azvyagintsev5c0313d2018-08-13 17:13:35 +03007 * SLAVE_NODE:
azvyagintsev4eb89ea2018-08-07 17:48:19 +02008 */
9
azvyagintsev2a4ad372019-02-07 18:43:12 +020010slaveNode = env.SLAVE_NODE ?: 'docker'
azvyagintsev5c0313d2018-08-13 17:13:35 +030011
azvyagintsev4eb89ea2018-08-07 17:48:19 +020012timeout(time: 1, unit: 'HOURS') {
azvyagintseva381cc32018-09-11 15:36:23 +030013 node(slaveNode) {
14 stage("RunTest") {
Denis Egorenko34c4a3b2019-03-12 12:48:15 +040015 extraVars = readYaml text: EXTRA_VARIABLES_YAML
azvyagintseva381cc32018-09-11 15:36:23 +030016 try {
azvyagintseva381cc32018-09-11 15:36:23 +030017 currentBuild.description = extraVars.modelFile
Denis Egorenko032b8ca2018-09-13 17:00:23 +040018 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 Egorenko926bc7d2019-02-19 14:27:34 +040028 'dockerHostname': "cfg01",
29 'domain': "${templateContext.default_context.cluster_domain}",
Denis Egorenko032b8ca2018-09-13 17:00:23 +040030 'clusterName': templateContext.default_context.cluster_name,
31 'reclassEnv': extraVars.testReclassEnv,
azvyagintsev1bcadc42018-10-05 20:13:15 +030032 'distribRevision': extraVars.DISTRIB_REVISION,
Denis Egorenko032b8ca2018-09-13 17:00:23 +040033 'dockerContainerName': extraVars.DockerCName,
Denis Egorenkod87490e2019-02-26 20:00:41 +040034 'testContext': extraVars.modelFile,
35 'dockerExtraOpts': [ '--memory=3g' ]
Denis Egorenko032b8ca2018-09-13 17:00:23 +040036 ]
Denis Egorenkoa79259f2019-03-07 16:13:31 +040037 if (extraVars.DISTRIB_REVISION == 'nightly') {
38 config['nodegenerator'] = true
39 }
Denis Egorenko086aff12018-10-18 17:54:59 +040040 if (extraVars.useExtraRepos) {
41 config['extraRepos'] = extraVars.extraRepos ? extraVars.extraRepos : [:]
42 config['extraRepoMergeStrategy'] = extraVars.extraRepoMergeStrategy ? extraVars.extraRepoMergeStrategy : ''
43 }
Denis Egorenko032b8ca2018-09-13 17:00:23 +040044 saltModelTesting.testNode(config)
azvyagintseva381cc32018-09-11 15:36:23 +030045 } 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 Egorenko34c4a3b2019-03-12 12:48:15 +040050 } 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 }
azvyagintseva381cc32018-09-11 15:36:23 +030061 }
62 }
azvyagintsev4eb89ea2018-08-07 17:48:19 +020063 }
azvyagintsev5c0313d2018-08-13 17:13:35 +030064}