Browse Source

[Test] Save logs and config once a test has been done

tags/1.8.0
Mikhail Galanin 5 years ago
parent
commit
ca8bf2132d
2 changed files with 21 additions and 0 deletions
  1. 20
    0
      test/functional/lib/rspamd.py
  2. 1
    0
      test/functional/lib/rspamd.robot

+ 20
- 0
test/functional/lib/rspamd.py View 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']

+ 1
- 0
test/functional/lib/rspamd.robot View 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

Loading…
Cancel
Save