aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-08-13 08:52:35 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-08-13 08:52:35 +0100
commitca8bf2132dd8bbdf3e97d93ab375d70c2b33b1ef (patch)
tree9d3098e495fd97427d2d3d0db46175fc3fa39d6b /test/functional
parentcf2ada2755c4c71f89b43c9206f18632ff3ba984 (diff)
downloadrspamd-ca8bf2132dd8bbdf3e97d93ab375d70c2b33b1ef.tar.gz
rspamd-ca8bf2132dd8bbdf3e97d93ab375d70c2b33b1ef.zip
[Test] Save logs and config once a test has been done
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/lib/rspamd.py20
-rw-r--r--test/functional/lib/rspamd.robot1
2 files changed, 21 insertions, 0 deletions
diff --git a/test/functional/lib/rspamd.py b/test/functional/lib/rspamd.py
index 3db57a87e..2010f4127 100644
--- a/test/functional/lib/rspamd.py
+++ b/test/functional/lib/rspamd.py
@@ -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']
diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot
index 7b355f85b..ec2fc5e84 100644
--- a/test/functional/lib/rspamd.robot
+++ b/test/functional/lib/rspamd.robot
@@ -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