CSIT-1288: Prepare data to be sent by Jenkins 69/14869/3
authorTibor Frank <tifrank@cisco.com>
Tue, 18 Sep 2018 10:50:16 +0000 (12:50 +0200)
committerTibor Frank <tifrank@cisco.com>
Tue, 18 Sep 2018 12:13:47 +0000 (14:13 +0200)
 - Add creation of tar.gz file

Change-Id: I525c713bb3e157cd94337222781066252c3fa517
Signed-off-by: Tibor Frank <tifrank@cisco.com>
resources/tools/presentation/generator_alerts.py
resources/tools/presentation/specification_CPTA.yaml
resources/tools/presentation/utils.py

index 71913eb..77302b6 100644 (file)
@@ -18,6 +18,7 @@ from email.mime.text import MIMEText
 from email.mime.multipart import MIMEMultipart
 from os.path import isdir
 
+from utils import execute_command
 from errors import PresentationError
 
 
@@ -262,6 +263,15 @@ class Alerting(object):
             except IOError:
                 logging.error("Not possible to write the file '{0}.html'.".
                               format(file_name))
+
+            zip_file = config.get("zip-output", None)
+            if zip_file:
+                logging.info("Writing the file '{0}/{1}' ...".
+                             format(config["output-dir"], zip_file))
+                execute_command("tar czvf {dir}/{zip} {dir}/{input}.*".format(
+                    dir=config["output-dir"],
+                    zip=zip_file,
+                    input=config["output-file"]))
         else:
             raise AlertingError("Alert of type '{0}' is not implemented.".
                                 format(alert["type"]))
index 8c5217b..8dfd941 100644 (file)
         output-dir: "_build/_static/vpp"
         # The name of the output files. ASCII text and HTML formats are
         # generated.
-        output-file: "jenkins-alert-failed-tests"
+        output-file: "trending-failed-tests"
+        # If defined, all output files are zipped into this file.
+        zip-output: "failed-tests.tar.gz"
 
   data-sets:
 
index 2cc85c2..51bb1d0 100644 (file)
@@ -120,8 +120,8 @@ def execute_command(cmd):
 
     :param cmd: Command to execute.
     :type cmd: str
-    :returns: Return code of the executed command.
-    :rtype: int
+    :returns: Return code of the executed command, stdout and stderr.
+    :rtype: tuple(int, str, str)
     """
 
     env = environ.copy()