Refactor salt-models testing
The tests take too much time to be executed and they often fail due to lack
of resources. The solution to improve salt models testing is to disitribute
the work among Jenkins slave. The previous approach consisted in doing all the
tests on one slave for a given model.
Fix test for system-reclass by testing the good reclass-system version.
Change-Id: I605355bdb66d7195e42454bb87b5cc0663d13929
diff --git a/test-salt-model-node.groovy b/test-salt-model-node.groovy
new file mode 100644
index 0000000..8ec3936
--- /dev/null
+++ b/test-salt-model-node.groovy
@@ -0,0 +1,62 @@
+
+/**
+ * Test salt models pipeline
+ * DEFAULT_GIT_REF
+ * DEFAULT_GIT_URL
+ * CREDENTIALS_ID
+ * EXTRA_FORMULAS
+ * NODE_TARGET
+ * SYSTEM_GIT_URL
+ * SYSTEM_GIT_REF
+ */
+
+def common = new com.mirantis.mk.Common()
+def gerrit = new com.mirantis.mk.Gerrit()
+def saltModelTesting = new com.mirantis.mk.SaltModelTesting()
+
+def defaultGitRef = DEFAULT_GIT_REF
+def defaultGitUrl = DEFAULT_GIT_URL
+
+def checkouted = false
+node("python") {
+ try{
+ stage("checkout") {
+ if(defaultGitRef != "" && defaultGitUrl != "") {
+ checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "HEAD", CREDENTIALS_ID)
+ } else {
+ throw new Exception("Cannot checkout gerrit patchset, DEFAULT_GIT_URL or DEFAULT_GIT_REF is null")
+ }
+ if(checkouted) {
+ if (fileExists('classes/system')) {
+ if (SYSTEM_GIT_URL == "") {
+ ssh.prepareSshAgentKey(CREDENTIALS_ID)
+ dir('classes/system') {
+ remoteUrl = git.getGitRemote()
+ ssh.ensureKnownHosts(remoteUrl)
+ }
+ ssh.agentSh("git submodule init; git submodule sync; git submodule update --recursive")
+ } else {
+ dir('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}")
+ }
+ }
+ }
+ }
+ }
+ }
+
+ stage("test node") {
+ if (checkouted) {
+ def workspace = common.getWorkspace()
+ saltModelTesting.setupAndTestNode(NODE_TARGET, EXTRA_FORMULAS, workspace)
+ }
+ }
+ } catch (Throwable e) {
+ // If there was an error or exception thrown, the build failed
+ currentBuild.result = "FAILURE"
+ throw e
+ } finally {
+ common.sendNotification(currentBuild.result,"",["slack"])
+ }
+}