Add vars to Test

To be possible set target host to
run tests and group of tests to run,
introduce target and pattern vars

Change-Id: Iff95cf4edef6673c5fe72d35ceaf638b377e55b7
diff --git a/src/com/mirantis/mk/Test.groovy b/src/com/mirantis/mk/Test.groovy
index 4ef8b10..95a432e 100644
--- a/src/com/mirantis/mk/Test.groovy
+++ b/src/com/mirantis/mk/Test.groovy
@@ -32,25 +32,37 @@
 /**
  * Execute tempest tests
  *
- * @param tempestLink   Docker image link with rally and tempest
+ * @param dockerImageLink   Docker image link with rally and tempest
+ * @param target            Host to run tests
+ * @param pattern            If not false, will run only tests matched the pattern
  */
-def runTempestTests(master, tempestLink) {
+def runTempestTests(master, dockerImageLink, target, pattern = "false") {
     def salt = new com.mirantis.mk.Salt()
-    salt.runSaltProcessStep(master, 'ctl01*', 'cmd.run', ["docker run --rm --net=host " +
-                                                          "-e TEMPEST_CONF=mcp.conf " +
-                                                          "-e SKIP_LIST=mcp_skip.list " +
-                                                          "-e SOURCE_FILE=keystonercv3 " +
-                                                          "-v /root/:/home/rally ${tempestLink} >> docker-tempest.log"])
+    if (pattern == "false") {
+        salt.runSaltProcessStep(master, "${target}", 'cmd.run', ["docker run --rm --net=host " +
+                                                                  "-e TEMPEST_CONF=mcp.conf " +
+                                                                  "-e SKIP_LIST=mcp_skip.list " +
+                                                                  "-e SOURCE_FILE=keystonercv3 " +
+                                                                  "-v /root/:/home/rally ${dockerImageLink} >> docker-tempest.log"])
+        }
+    else {
+        salt.runSaltProcessStep(master, "${target}", 'cmd.run', ["docker run --rm --net=host " +
+                                                                  "-e TEMPEST_CONF=mcp.conf " +
+                                                                  "-e SKIP_LIST=mcp_skip.list " +
+                                                                  "-e SOURCE_FILE=keystonercv3 " +
+                                                                  "-e CUSTOM='--pattern ${pattern}' " +
+                                                                  "-v /root/:/home/rally ${dockerImageLink} >> docker-tempest.log"])
+         }
 }
 
 /**
  * Upload results to worker
  *
  */
-def copyTempestResults(master) {
+def copyTempestResults(master, target) {
     def salt = new com.mirantis.mk.Salt()
-    salt.runSaltProcessStep(master, 'ctl01*', 'cmd.run', ["scp /root/docker-tempest.log cfg01:/home/ubuntu/ && " +
-                                                          "find /root -name result.xml -exec scp {} cfg01:/home/ubuntu \\;"])
+    salt.runSaltProcessStep(master, "${target}", 'cmd.run', ["scp /root/docker-tempest.log cfg01:/home/ubuntu/ && " +
+                                                             "find /root -name result.xml -exec scp {} cfg01:/home/ubuntu \\;"])
 }
 
 
@@ -62,3 +74,13 @@
     def salt = new com.mirantis.mk.Salt()
     salt.runSaltProcessStep(master, 'cfg01*', 'cmd.run', ["cat /home/ubuntu/${image}.output"])
 }
+
+
+/** Install docker if needed
+ *
+ * @param target              Target node to install docker pkg
+ */
+def install_docker(master, target) {
+    def salt = new com.mirantis.mk.Salt()
+    salt.runSaltProcessStep(master, "${target}", 'pkg.install', ["docker.io"])
+}