blob: 9a697cfc3975c86686575cafe54359663373fd6b [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
azvyagintsev7d982812019-04-15 23:21:35 +030018 sh(script: 'find . -mindepth 1 -delete || true', returnStatus: true)
Denis Egorenko032b8ca2018-09-13 17:00:23 +040019 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 = [
azvyagintsev7d982812019-04-15 23:21:35 +030028 '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 Egorenko032b8ca2018-09-13 17:00:23 +040033 'dockerContainerName': extraVars.DockerCName,
azvyagintsev7d982812019-04-15 23:21:35 +030034 '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 Egorenko19a793d2019-11-18 20:50:59 +040040 if (extraVars.updatesVersion) {
41 config['updateSaltFormulasRev'] = extraVars.updatesVersion
42 }
Denis Egorenko086aff12018-10-18 17:54:59 +040043 if (extraVars.useExtraRepos) {
44 config['extraRepos'] = extraVars.extraRepos ? extraVars.extraRepos : [:]
45 config['extraRepoMergeStrategy'] = extraVars.extraRepoMergeStrategy ? extraVars.extraRepoMergeStrategy : ''
46 }
Denis Egorenko032b8ca2018-09-13 17:00:23 +040047 saltModelTesting.testNode(config)
azvyagintseva381cc32018-09-11 15:36:23 +030048 } 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 Egorenko34c4a3b2019-03-12 12:48:15 +040053 } finally {
54 stage('Save artifacts to Artifactory') {
55 def artifactory = new com.mirantis.mcp.MCPArtifactory()
azvyagintsev7d982812019-04-15 23:21:35 +030056 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 Egorenko34c4a3b2019-03-12 12:48:15 +040059 withEnv(envGerritVars) {
Denis Egorenko4be215f2021-01-20 13:35:22 +040060 def artifactoryLink = artifactory.uploadJobArtifactsToArtifactory(['artifactory': 'mcp-ci', 'artifactoryRepo': "artifactory/drivetrain-local/${JOB_NAME}/${BUILD_NUMBER}"])
Denis Egorenko34c4a3b2019-03-12 12:48:15 +040061 currentBuild.description += "<br/>${artifactoryLink}"
62 }
63 }
azvyagintseva381cc32018-09-11 15:36:23 +030064 }
65 }
azvyagintsev4eb89ea2018-08-07 17:48:19 +020066 }
azvyagintsev5c0313d2018-08-13 17:13:35 +030067}