]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Save logs and config once a test has been done 2418/head
authorMikhail Galanin <mgalanin@mimecast.com>
Mon, 13 Aug 2018 07:52:35 +0000 (08:52 +0100)
committerMikhail Galanin <mgalanin@mimecast.com>
Mon, 13 Aug 2018 07:52:35 +0000 (08:52 +0100)
test/functional/lib/rspamd.py
test/functional/lib/rspamd.robot

index 3db57a87e0def855c7760b3c7950bfd84c703406..2010f41273f7adaa26e9eaabfa484f52aaaf6cc3 100644 (file)
@@ -12,6 +12,7 @@ import string
 import sys
 import tempfile
 import time
+from robot.libraries.BuiltIn import BuiltIn
 
 if sys.version_info > (3,):
     long = int
@@ -33,6 +34,23 @@ def Check_JSON(j):
 def cleanup_temporary_directory(directory):
     shutil.rmtree(directory)
 
+def save_run_results(directory, filenames):
+    current_directory = os.getcwd()
+    suite_name = BuiltIn().get_variable_value("${SUITE_NAME}")
+    test_name = BuiltIn().get_variable_value("${TEST NAME}")
+    if test_name is None:
+        # this is suite-level tear down 
+        destination_directory = "%s/robot-save/%s" % (current_directory, suite_name)
+    else:
+        destination_directory = "%s/robot-save/%s/%s" % (current_directory, suite_name, test_name)
+    if not os.path.isdir(destination_directory):
+        os.makedirs(destination_directory)
+    for file in filenames.split(' '):
+        source_file = "%s/%s" % (directory, file)
+        if os.path.isfile(source_file):
+            shutil.copy(source_file, "%s/%s" % (destination_directory, file))
+            shutil.copy(source_file, "%s/robot-save/%s.last" % (current_directory, file))
+
 def encode_filename(filename):
     return "".join(['%%%0X' % ord(b) for b in filename])
 
@@ -58,6 +76,7 @@ def get_rspamd():
         return os.environ['RSPAMD_INSTALLROOT'] + "/bin/rspamd"
     dname = get_top_dir()
     return dname + "/src/rspamd"
+
 def get_rspamc():
     if os.environ.get('RSPAMC'):
         return os.environ['RSPAMC']
@@ -65,6 +84,7 @@ def get_rspamc():
         return os.environ['RSPAMD_INSTALLROOT'] + "/bin/rspamc"
     dname = get_top_dir()
     return dname + "/src/client/rspamc"
+
 def get_rspamadm():
     if os.environ.get('RSPAMADM'):
         return os.environ['RSPAMADM']
index 7b355f85b745c3c1a48961daac52fb3b69b5000d..ec2fc5e84cbd7e231af9b18c924308e0458fd80a 100644 (file)
@@ -70,6 +70,7 @@ Generic Teardown
   [Arguments]  @{ports}
   Run Keyword If  '${CONTROLLER_ERRORS}' == 'True'  Check Controller Errors
   Shutdown Process With Children  ${RSPAMD_PID}
+  Save Run Results  ${TMPDIR}  rspamd.log redis.log rspamd.conf
   Cleanup Temporary Directory  ${TMPDIR}
 
 Log Logs