Update pipelines to use new saltModelTesting function

Change-Id: Ie556d4e2c9c341e64f1f3f8f9ee32b0cc8724c26
Related-bug: PROD-22115 (PROD:22115)
diff --git a/generate-cookiecutter-products.groovy b/generate-cookiecutter-products.groovy
index e734734..549a4d3 100644
--- a/generate-cookiecutter-products.groovy
+++ b/generate-cookiecutter-products.groovy
@@ -177,24 +177,20 @@
                     sh("cp -r ${modelEnv} ${testEnv}")
                     def DockerCName = "${env.JOB_NAME.toLowerCase()}_${env.BUILD_TAG.toLowerCase()}"
                     common.infoMsg("Attempt to run test against formula-version: ${mcpVersion}")
-                    testResult = saltModelTesting.setupAndTestNode(
-                        "${saltMaster}.${clusterDomain}",
-                        "",
-                        "",
-                        testEnv,
-                        'pkg',
-                        mcpVersion,
-                        reclassVersion,
-                        0,
-                        false,
-                        false,
-                        '',
-                        '',
-                        DockerCName)
-                    if (testResult) {
+                    try {
+                        def config = [
+                            'dockerHostname': "${saltMaster}.${clusterDomain}",
+                            'reclassEnv': testEnv,
+                            'formulasRevision': mcpVersion,
+                            'reclassVersion': reclassVersion,
+                            'dockerContainerName': DockerCName,
+                            'testContext': 'salt-model-node'
+                        ]
+                        testResult = saltModelTesting.testNode(config)
                         common.infoMsg("Test finished: SUCCESS")
-                    } else {
-                        common.warningMsg('Test finished: FAILURE')
+                    } catch (Exception ex) {
+                        common.warningMsg("Test finished: FAILED")
+                        testResult = false
                     }
                 } else {
                     common.warningMsg("Test stage has been skipped!")
diff --git a/test-cookiecutter-reclass-chunk.groovy b/test-cookiecutter-reclass-chunk.groovy
index 58355c1..ebc4f9a 100644
--- a/test-cookiecutter-reclass-chunk.groovy
+++ b/test-cookiecutter-reclass-chunk.groovy
@@ -17,7 +17,25 @@
             try {
                 extraVars = readYaml text: EXTRA_VARIABLES_YAML
                 currentBuild.description = extraVars.modelFile
-                saltModelTesting.testCCModel(extraVars)
+                sh(script:  'find . -mindepth 1 -delete || true', returnStatus: true)
+                sh(script: """
+                    wget --progress=dot:mega --auth-no-challenge -O models.tar.gz ${extraVars.MODELS_TARGZ}
+                    tar -xzf models.tar.gz
+                """)
+                common.infoMsg("Going to test exactly one context: ${extraVars.modelFile}\n, with params: ${extraVars}")
+
+                def content = readFile(file: extraVars.modelFile)
+                def templateContext = readYaml text: content
+                def config = [
+                    'dockerHostname': "cfg01.${templateContext.default_context.cluster_domain}",
+                    'clusterName': templateContext.default_context.cluster_name,
+                    'reclassEnv': extraVars.testReclassEnv,
+                    'formulasRevision': extraVars.DISTRIB_REVISION,
+                    'reclassVersion': extraVars.reclassVersion,
+                    'dockerContainerName': extraVars.DockerCName,
+                    'testContext': extraVars.modelFile
+                ]
+                saltModelTesting.testNode(config)
             } catch (Throwable e) {
                 // If there was an error or exception thrown, the build failed
                 currentBuild.result = "FAILURE"
diff --git a/test-salt-model-node.groovy b/test-salt-model-node.groovy
index 60477ee..9bbd782 100644
--- a/test-salt-model-node.groovy
+++ b/test-salt-model-node.groovy
@@ -8,7 +8,6 @@
  *  NODE_TARGET
  *  SYSTEM_GIT_URL
  *  SYSTEM_GIT_REF
- *  FORMULAS_SOURCE
  *  RECLASS_VERSION
  *  MAX_CPU_PER_JOB
  *  LEGACY_TEST_MODE
@@ -66,38 +65,23 @@
         stage("test node") {
           if (checkouted) {
             def workspace = common.getWorkspace()
-            def testResult = false
             common.infoMsg("Running salt model test for node ${NODE_TARGET} in cluster ${CLUSTER_NAME}")
-            try {
-              def DockerCName = "${env.JOB_NAME.toLowerCase()}_${env.BUILD_TAG.toLowerCase()}"
-              testResult = saltModelTesting.setupAndTestNode(
-                  NODE_TARGET,
-                  CLUSTER_NAME,
-                  '',
-                  workspace,
-                  FORMULAS_SOURCE,
-                  FORMULAS_REVISION,
-                  reclassVersion,
-                  MAX_CPU_PER_JOB.toInteger(),
-                  RECLASS_IGNORE_CLASS_NOTFOUND,
-                  LEGACY_TEST_MODE,
-                  APT_REPOSITORY,
-                  APT_REPOSITORY_GPG,
-                  DockerCName)
-            } catch (Exception e) {
-              if (e.getMessage() == "script returned exit code 124") {
-                common.errorMsg("Impossible to test node due to timeout of salt-master, ABORTING BUILD")
-                currentBuild.result = "ABORTED"
-              } else {
-                throw e
-              }
-            }
-            if (testResult) {
-              common.infoMsg("Test finished: SUCCESS")
-            } else {
-              error('Test node finished: FAILURE')
-              throw new RuntimeException('Test node stage finished: FAILURE')
-            }
+
+            def DockerCName = "${env.JOB_NAME.toLowerCase()}_${env.BUILD_TAG.toLowerCase()}"
+            def config = [
+              'dockerHostname': NODE_TARGET,
+              'clusterName': CLUSTER_NAME,
+              'reclassEnv': workspace,
+              'formulasRevision': FORMULAS_REVISION,
+              'reclassVersion': reclassVersion,
+              'dockerMaxCpus': MAX_CPU_PER_JOB.toInteger(),
+              'ignoreClassNotfound': RECLASS_IGNORE_CLASS_NOTFOUND,
+              'aptRepoUrl': APT_REPOSITORY,
+              'aptRepoGPG': APT_REPOSITORY_GPG,
+              'dockerContainerName': DockerCName,
+              'testContext': 'salt-model-node'
+            ]
+            saltModelTesting.testNode(config)
           }
         }
       } catch (Throwable e) {