azvyagintsev | 4eb89ea | 2018-08-07 17:48:19 +0200 | [diff] [blame] | 1 | package com.mirantis.mk |
azvyagintsev | 5c0313d | 2018-08-13 17:13:35 +0300 | [diff] [blame] | 2 | |
azvyagintsev | 4eb89ea | 2018-08-07 17:48:19 +0200 | [diff] [blame] | 3 | def common = new com.mirantis.mk.Common() |
| 4 | def saltModelTesting = new com.mirantis.mk.SaltModelTesting() |
| 5 | |
| 6 | /** |
| 7 | * Test CC model wrapper |
| 8 | * EXTRA_VARIABLES_YAML: yaml based string, to be directly passed into testCCModel |
azvyagintsev | 5c0313d | 2018-08-13 17:13:35 +0300 | [diff] [blame] | 9 | * SLAVE_NODE: |
azvyagintsev | 4eb89ea | 2018-08-07 17:48:19 +0200 | [diff] [blame] | 10 | */ |
| 11 | |
azvyagintsev | 2a4ad37 | 2019-02-07 18:43:12 +0200 | [diff] [blame^] | 12 | slaveNode = env.SLAVE_NODE ?: 'docker' |
azvyagintsev | 5c0313d | 2018-08-13 17:13:35 +0300 | [diff] [blame] | 13 | |
azvyagintsev | 4eb89ea | 2018-08-07 17:48:19 +0200 | [diff] [blame] | 14 | timeout(time: 1, unit: 'HOURS') { |
azvyagintsev | a381cc3 | 2018-09-11 15:36:23 +0300 | [diff] [blame] | 15 | node(slaveNode) { |
| 16 | stage("RunTest") { |
| 17 | try { |
| 18 | extraVars = readYaml text: EXTRA_VARIABLES_YAML |
| 19 | currentBuild.description = extraVars.modelFile |
Denis Egorenko | 032b8ca | 2018-09-13 17:00:23 +0400 | [diff] [blame] | 20 | sh(script: 'find . -mindepth 1 -delete || true', returnStatus: true) |
| 21 | sh(script: """ |
| 22 | wget --progress=dot:mega --auth-no-challenge -O models.tar.gz ${extraVars.MODELS_TARGZ} |
| 23 | tar -xzf models.tar.gz |
| 24 | """) |
| 25 | common.infoMsg("Going to test exactly one context: ${extraVars.modelFile}\n, with params: ${extraVars}") |
| 26 | |
| 27 | def content = readFile(file: extraVars.modelFile) |
| 28 | def templateContext = readYaml text: content |
| 29 | def config = [ |
| 30 | 'dockerHostname': "cfg01.${templateContext.default_context.cluster_domain}", |
| 31 | 'clusterName': templateContext.default_context.cluster_name, |
| 32 | 'reclassEnv': extraVars.testReclassEnv, |
azvyagintsev | 1bcadc4 | 2018-10-05 20:13:15 +0300 | [diff] [blame] | 33 | 'distribRevision': extraVars.DISTRIB_REVISION, |
Denis Egorenko | 032b8ca | 2018-09-13 17:00:23 +0400 | [diff] [blame] | 34 | 'dockerContainerName': extraVars.DockerCName, |
| 35 | 'testContext': extraVars.modelFile |
| 36 | ] |
Denis Egorenko | 086aff1 | 2018-10-18 17:54:59 +0400 | [diff] [blame] | 37 | if (extraVars.useExtraRepos) { |
| 38 | config['extraRepos'] = extraVars.extraRepos ? extraVars.extraRepos : [:] |
| 39 | config['extraRepoMergeStrategy'] = extraVars.extraRepoMergeStrategy ? extraVars.extraRepoMergeStrategy : '' |
| 40 | } |
Denis Egorenko | 032b8ca | 2018-09-13 17:00:23 +0400 | [diff] [blame] | 41 | saltModelTesting.testNode(config) |
azvyagintsev | a381cc3 | 2018-09-11 15:36:23 +0300 | [diff] [blame] | 42 | } catch (Throwable e) { |
| 43 | // If there was an error or exception thrown, the build failed |
| 44 | currentBuild.result = "FAILURE" |
| 45 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 46 | throw e |
| 47 | } |
| 48 | } |
azvyagintsev | 4eb89ea | 2018-08-07 17:48:19 +0200 | [diff] [blame] | 49 | } |
azvyagintsev | 5c0313d | 2018-08-13 17:13:35 +0300 | [diff] [blame] | 50 | } |