Merge "Added user check for aptly promote pipeline if using stable"
diff --git a/cloud-deploy-pipeline.groovy b/cloud-deploy-pipeline.groovy
index 13031c0..16f2e97 100644
--- a/cloud-deploy-pipeline.groovy
+++ b/cloud-deploy-pipeline.groovy
@@ -380,6 +380,11 @@
                     orchestrate.installOpenstackControl(venvPepper)
                 }
 
+                // Workaround for PROD-17765 issue to prevent crashes of keystone.role_present state.
+                // More details: https://mirantis.jira.com/browse/PROD-17765
+                salt.runSaltProcessStep(venvPepper, 'I@keystone:client', 'service.restart', ['salt-minion'])
+                salt.minionsReachable(venvPepper, 'I@salt:master and *01*', 'I@keystone:client', null, 10, 6)
+
                 stage('Install OpenStack network') {
 
                     if (common.checkContains('STACK_INSTALL', 'contrail')) {
@@ -388,8 +393,7 @@
                         orchestrate.installOpenstackNetwork(venvPepper)
                     }
 
-                    salt.cmdRun(venvPepper, 'I@keystone:server', '. /root/keystonerc; neutron net-list')
-                    salt.cmdRun(venvPepper, 'I@keystone:server', '. /root/keystonerc; nova net-list')
+                    salt.cmdRun(venvPepper, 'I@keystone:server', '. /root/keystonercv3; openstack network list')
                 }
 
                 if (salt.testTarget(venvPepper, 'I@ironic:conductor')){
diff --git a/cvp-perf.groovy b/cvp-perf.groovy
new file mode 100644
index 0000000..0fb9085
--- /dev/null
+++ b/cvp-perf.groovy
@@ -0,0 +1,57 @@
+/**
+ *
+ * Launch validation of the cloud
+ *
+ * Expected parameters:
+ *   SALT_MASTER_URL             URL of Salt master
+ *   SALT_MASTER_CREDENTIALS     Credentials that are used in this Jenkins for accessing Salt master (usually "salt")
+ *   PROXY                       Proxy address (if any) for accessing the Internet. It will be used for cloning repos and installing pip dependencies
+ *   TEST_IMAGE                  Docker image link to use for running container with testing tools.
+ *   TOOLS_REPO                  URL of repo where testing tools, scenarios, configs are located
+ *
+ *   TARGET_NODE                 Node to run container with Rally
+ *   DEBUG_MODE                  If you need to debug (keep container after test), please enabled this
+ *   RALLY_SCENARIO_FILE         Path to Rally scenario file in container
+ *
+ */
+
+common = new com.mirantis.mk.Common()
+salt = new com.mirantis.mk.Salt()
+validate = new com.mirantis.mcp.Validate()
+
+def artifacts_dir = 'validation_artifacts/'
+def remote_artifacts_dir = '/root/qa_results/'
+def saltMaster
+
+node() {
+    try{
+        stage('Initialization') {
+            saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
+            sh "rm -rf ${artifacts_dir}"
+            salt.cmdRun(saltMaster, TARGET_NODE, "mkdir -p ${remote_artifacts_dir}")
+            validate.runBasicContainer(saltMaster, TARGET_NODE, TEST_IMAGE)
+            validate.configureContainer(saltMaster, TARGET_NODE, PROXY, TOOLS_REPO, "")
+        }
+
+        stage('Run Rally tests') {
+            sh "mkdir -p ${artifacts_dir}"
+            validate.runCVPrally(saltMaster, TARGET_NODE, RALLY_SCENARIO_FILE, remote_artifacts_dir)
+        }
+
+        stage('Collect results') {
+            validate.addFiles(saltMaster, TARGET_NODE, remote_artifacts_dir, artifacts_dir)
+            archiveArtifacts artifacts: "${artifacts_dir}/*"
+            junit "${artifacts_dir}/*.xml"
+        }
+    } catch (Throwable e) {
+        // If there was an error or exception thrown, the build failed
+        currentBuild.result = "FAILURE"
+        throw e
+    } finally {
+        if (DEBUG_MODE == 'false') {
+            validate.runCleanup(saltMaster, TARGET_NODE)
+            salt.cmdRun(saltMaster, TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
+        }
+    }
+}
+
diff --git a/validate-cloud.groovy b/validate-cloud.groovy
index eecef42..5dd8008 100644
--- a/validate-cloud.groovy
+++ b/validate-cloud.groovy
@@ -29,6 +29,7 @@
  *   RALLY_CONFIG_BRANCH         Git branch which will be used during the checkout
  *   RALLY_SCENARIOS             Path to file or directory with rally scenarios
  *   RALLY_TASK_ARGS_FILE        Path to file with rally tests arguments
+ *   REPORT_DIR                  Path for reports outside docker image
  *   TEST_K8S_API_SERVER         Kubernetes API address
  *   TEST_K8S_CONFORMANCE_IMAGE  Path to docker image with conformance e2e tests
  *   TEST_K8S_NODE               Kubernetes node to run tests from
@@ -69,11 +70,18 @@
 
             stage('Run Rally tests') {
                 if (RUN_RALLY_TESTS.toBoolean() == true) {
+                    def report_dir = '/root/qa_results'
+                    try {
+                         if(REPORT_DIR != ""){
+                             report_dir = REPORT_DIR
+                         }
+                    } catch (MissingPropertyException e) {
+                    }
                     def rally_variables = ["floating_network=${FLOATING_NETWORK}",
                                            "rally_image=${RALLY_IMAGE}",
                                            "rally_flavor=${RALLY_FLAVOR}",
                                            "availability_zone=${AVAILABILITY_ZONE}"]
-                    validate.runRallyTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, RALLY_CONFIG_REPO, RALLY_CONFIG_BRANCH, RALLY_SCENARIOS, RALLY_TASK_ARGS_FILE, rally_variables)
+                    validate.runRallyTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, RALLY_CONFIG_REPO, RALLY_CONFIG_BRANCH, RALLY_SCENARIOS, RALLY_TASK_ARGS_FILE, rally_variables, report_dir)
                 } else {
                     common.infoMsg("Skipping Rally tests")
                 }