Merge "[CVP] Fix cleanup execution for cvp jobs"
diff --git a/src/com/mirantis/mcp/Validate.groovy b/src/com/mirantis/mcp/Validate.groovy
index 9514a27..1947c76 100644
--- a/src/com/mirantis/mcp/Validate.groovy
+++ b/src/com/mirantis/mcp/Validate.groovy
@@ -729,16 +729,17 @@
  * @param tempest_version	        Version of tempest to use. This value will be just passed to configure.sh script (cvp-configuration repo).
  * @param conf_script_path              Path to configuration script.
  * @param ext_variables                 Some custom extra variables to add into container
+ * @param container_name                Name of container to use
  */
 def configureContainer(master, target, proxy, testing_tools_repo, tempest_repo,
                        tempest_endpoint_type="internalURL", tempest_version="",
-                       conf_script_path="", ext_variables = []) {
+                       conf_script_path="", ext_variables = [], container_name="cvp") {
     def salt = new com.mirantis.mk.Salt()
     def common = new com.mirantis.mk.Common()
     if (testing_tools_repo != "" ) {
         workdir = ''
         if (testing_tools_repo.contains('http://') || testing_tools_repo.contains('https://')) {
-            salt.cmdRun(master, target, "docker exec cvp git clone ${testing_tools_repo} cvp-configuration")
+            salt.cmdRun(master, target, "docker exec ${container_name} git clone ${testing_tools_repo} cvp-configuration")
             configure_script = conf_script_path != "" ? conf_script_path : "cvp-configuration/configure.sh"
         }
         else {
@@ -748,7 +749,7 @@
         ext_variables.addAll("PROXY=${proxy}", "TEMPEST_REPO=${tempest_repo}",
                              "TEMPEST_ENDPOINT_TYPE=${tempest_endpoint_type}",
                              "tempest_version=${tempest_version}")
-        salt.cmdRun(master, target, "docker exec -e " + ext_variables.join(' -e ') + " ${workdir} cvp bash -c ${configure_script}")
+        salt.cmdRun(master, target, "docker exec -e " + ext_variables.join(' -e ') + " ${workdir} ${container_name} bash -c ${configure_script}")
     }
     else {
         common.infoMsg("TOOLS_REPO is empty, no configuration is needed for this container")
@@ -787,16 +788,17 @@
  * @param test_pattern                  Test pattern to run
  * @param scenarios_path                Path to Rally scenarios
  * @param output_dir                    Directory on target host for storing results (containers is not a good place)
+ * @param container_name                Name of container to use
  */
-def runCVPrally(master, target, scenarios_path, output_dir, output_filename="docker-rally") {
+def runCVPrally(master, target, scenarios_path, output_dir, output_filename="docker-rally", container_name="cvp") {
     def salt = new com.mirantis.mk.Salt()
     def xml_file = "${output_filename}.xml"
     def html_file = "${output_filename}.html"
-    salt.cmdRun(master, target, "docker exec cvp rally task start ${scenarios_path}")
-    salt.cmdRun(master, target, "docker exec cvp rally task report --out ${html_file}")
-    salt.cmdRun(master, target, "docker exec cvp rally task report --junit --out ${xml_file}")
-    salt.cmdRun(master, target, "docker cp cvp:/home/rally/${xml_file} ${output_dir}")
-    salt.cmdRun(master, target, "docker cp cvp:/home/rally/${html_file} ${output_dir}")
+    salt.cmdRun(master, target, "docker exec ${container_name} rally task start ${scenarios_path}")
+    salt.cmdRun(master, target, "docker exec ${container_name} rally task report --out ${html_file}")
+    salt.cmdRun(master, target, "docker exec ${container_name} rally task report --junit --out ${xml_file}")
+    salt.cmdRun(master, target, "docker cp ${container_name}:/home/rally/${xml_file} ${output_dir}")
+    salt.cmdRun(master, target, "docker cp ${container_name}:/home/rally/${html_file} ${output_dir}")
 }
 
 
diff --git a/src/com/mirantis/mk/Test.groovy b/src/com/mirantis/mk/Test.groovy
index aadeb8a..404c6f8 100644
--- a/src/com/mirantis/mk/Test.groovy
+++ b/src/com/mirantis/mk/Test.groovy
@@ -133,6 +133,7 @@
     def target = config.get('target', 'I@kubernetes:master and ctl01*')
     def status = config.get('status')
     def ctl_target = config.get('ctl_target', 'I@kubernetes:master')
+    def k8s_pool_target = config.get('k8s_pool_target', 'I@kubernetes:pool')
     def results_dir = config.get('results_dir', '/tmp/conformance')
     def artifacts_dir = config.get('artifacts_dir', '_artifacts/')
     def output_file = config.get('output_file', 'conformance.tar')
@@ -142,7 +143,7 @@
     def short_node = locateConformancePod(master, target)
     print("Pod located on $short_node")
 
-    minions = salt.getMinionsSorted(master, ctl_target)
+    minions = salt.getMinionsSorted(master, k8s_pool_target)
     conformance_target = minions.find {it =~ short_node}
 
     if (status == 'NOTEXECUTED') {
@@ -183,12 +184,13 @@
     // Listing defaults
     def master = config.get('master', 'pepperVenv')
     def target = config.get('target', 'I@kubernetes:master and ctl01*')
+    def ctl_target = config.get('ctl_target', 'I@kubernetes:master and ctl01*')
     def pod_path = config.get('pod_path', '/srv/kubernetes/conformance.yml')
     def results_dir = config.get('results_dir', '/tmp/conformance')
     def output_file = config.get('output_file', )
     // End listing defaults
 
-    salt.cmdRun(master, target, "kubectl delete -f ${pod_path}")
+    salt.cmdRun(master, ctl_target, "kubectl delete -f ${pod_path}")
     salt.cmdRun(master, target, "rm -rf ${results_dir}", false)
     salt.cmdRun(master, target, "rm -f ${output_file}", false)
 }