Fix saltModelTesting.setupAndTestNode call's
* setupAndTestNode function has been refectored, and now return
true\false result. Otherwise, function result has not been checked.
* Since setupAndTestNode now return answer, no sence to use retry on it-
it's never throw expected exception.
Change-Id: I84ee45964151ebf3bae0f52fb25d5b7f60428d75
diff --git a/test-cookiecutter-reclass.groovy b/test-cookiecutter-reclass.groovy
index fedbd14..eb74b22 100644
--- a/test-cookiecutter-reclass.groovy
+++ b/test-cookiecutter-reclass.groovy
@@ -77,49 +77,43 @@
}
def testModel(modelFile, testEnv) {
- def templateEnv = "${env.WORKSPACE}"
- def content = readFile(file: "${templateEnv}/contexts/${modelFile}.yml")
- def templateContext = readYaml text: content
- def clusterName = templateContext.default_context.cluster_name
- def clusterDomain = templateContext.default_context.cluster_domain
- if (SYSTEM_GIT_URL == "") {
- git.checkoutGitRepository("${testEnv}/classes/system", RECLASS_MODEL_URL, RECLASS_MODEL_BRANCH, CREDENTIALS_ID)
- } else {
- dir("${testEnv}/classes/system") {
- if (!gerrit.gerritPatchsetCheckout(SYSTEM_GIT_URL, SYSTEM_GIT_REF, "HEAD", CREDENTIALS_ID)) {
- common.errorMsg("Failed to obtain system reclass with url: ${SYSTEM_GIT_URL} and ${SYSTEM_GIT_REF}")
- }
- }
+ def templateEnv = "${env.WORKSPACE}"
+ def content = readFile(file: "${templateEnv}/contexts/${modelFile}.yml")
+ def templateContext = readYaml text: content
+ def clusterName = templateContext.default_context.cluster_name
+ def clusterDomain = templateContext.default_context.cluster_domain
+ if (SYSTEM_GIT_URL == "") {
+ git.checkoutGitRepository("${testEnv}/classes/system", RECLASS_MODEL_URL, RECLASS_MODEL_BRANCH, CREDENTIALS_ID)
+ } else {
+ dir("${testEnv}/classes/system") {
+ if (!gerrit.gerritPatchsetCheckout(SYSTEM_GIT_URL, SYSTEM_GIT_REF, "HEAD", CREDENTIALS_ID)) {
+ common.errorMsg("Failed to obtain system reclass with url: ${SYSTEM_GIT_URL} and ${SYSTEM_GIT_REF}")
+ }
}
+ }
- def nbTry = 0
- while (nbTry < 5) {
- nbTry++
- try {
- def DockerCName = "${env.JOB_NAME.toLowerCase()}_${env.BUILD_TAG.toLowerCase()}"
- saltModelTesting.setupAndTestNode(
- "cfg01.${clusterDomain}",
- clusterName,
- EXTRA_FORMULAS,
- testEnv,
- 'pkg',
- DISTRIB_REVISION,
- 'master',
- 0,
- false,
- false,
- '',
- '',
- DockerCName)
- break
- } catch (Exception e) {
- if (e.getMessage() == "script returned exit code 124") {
- common.errorMsg("Impossible to test node due to timeout of salt-master, retriggering")
- } else {
- throw e
- }
- }
- }
+ def testResult = false
+ def DockerCName = "${env.JOB_NAME.toLowerCase()}_${env.BUILD_TAG.toLowerCase()}"
+ testResult = saltModelTesting.setupAndTestNode(
+ "cfg01.${clusterDomain}",
+ clusterName,
+ EXTRA_FORMULAS,
+ testEnv,
+ 'pkg',
+ DISTRIB_REVISION,
+ 'master',
+ 0,
+ false,
+ false,
+ '',
+ '',
+ DockerCName)
+ if (testResult) {
+ common.infoMsg("testModel finished: SUCCESS")
+ } else {
+ error('testModel finished: FAILURE')
+ currentBuild.result = "FAILURE"
+ }
}