Option to redirect stderr output to a file for Tempest test 51/8151/4
authorjose.lausuch <jose.lausuch@ericsson.com>
Wed, 27 Jan 2016 13:56:39 +0000 (14:56 +0100)
committerjose.lausuch <jose.lausuch@ericsson.com>
Wed, 27 Jan 2016 14:08:15 +0000 (15:08 +0100)
The output when we run Tempest from CI is too long
if there are many tests failing. This patch intends to
show only the test cases that passed/failed within a table.
If troubleshooting is needed, it will be a log file with all
the stderr in it.

Change-Id: If5b0f35463a3dae06a0c177de4dc473bfc4687c5
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
testcases/VIM/OpenStack/CI/libraries/run_tempest.py

index ee0a4be..0097a56 100644 (file)
@@ -73,6 +73,8 @@ USER_NAME = functest_yaml.get("tempest").get("identity").get("user_name")
 USER_PASSWORD = functest_yaml.get("tempest").get("identity").get("user_password")
 DEPLOYMENT_MAME = functest_yaml.get("rally").get("deployment_name")
 RALLY_INSTALLATION_DIR = functest_yaml.get("general").get("directories").get("dir_rally_inst")
+RESULTS_DIR = functest_yaml.get("general").get("directories").get("dir_results")
+TEMPEST_RESULTS_DIR = RESULTS_DIR + '/tempest'
 
 
 def get_info(file_result):
@@ -211,7 +213,23 @@ def run_tempest(OPTION):
     logger.info("Starting Tempest test suite: '%s'." % OPTION)
     cmd_line = "rally verify start "+OPTION
     logger.debug('Executing command : {}'.format(cmd_line))
-    subprocess.call(cmd_line, shell=True, stderr=subprocess.STDOUT)
+
+    CI_DEBUG = os.environ.get("CI_DEBUG")
+    if CI_DEBUG == "true" or CI_DEBUG == "True":
+        subprocess.call(cmd_line, shell=True, stderr=subprocess.STDOUT)
+    else:
+        if not os.path.exists(TEMPEST_RESULTS_DIR):
+            os.makedirs(TEMPEST_RESULTS_DIR)
+
+        f = open(TEMPEST_RESULTS_DIR+"/tempest.log", 'w+')
+        FNULL = open(os.devnull, 'w')
+
+        subprocess.call(cmd_line, shell=True, stdout=FNULL, stderr=f)
+        f.close()
+        FNULL.close()
+
+        cmd_line = "rally verify show"
+        subprocess.call(cmd_line, shell=True)
 
     cmd_line = "rally verify list"
     logger.debug('Executing command : {}'.format(cmd_line))