resiliency tests: send log to erp5 master.

parent 0e5941b7
...@@ -31,6 +31,8 @@ import json ...@@ -31,6 +31,8 @@ import json
import importlib import importlib
import logging import logging
import os import os
import sys
import tempfile
import time import time
import traceback import traceback
from erp5.util import taskdistribution from erp5.util import taskdistribution
...@@ -89,17 +91,23 @@ def parseArguments(): ...@@ -89,17 +91,23 @@ def parseArguments():
def setupLogging(log_path=None, name=__name__): def setupLogging(log_path=None, name=__name__):
logger_format = '%(asctime)s %(name)-13s: %(levelname)-8s %(message)s' logger_format = '%(asctime)s %(name)-13s: %(levelname)-8s %(message)s'
formatter = logging.Formatter(logger_format) formatter = logging.Formatter(logger_format)
logging.basicConfig(level=logging.INFO, logging.basicConfig(level=logging.INFO, format=logger_format)
format=logger_format)
logger = logging.getLogger(name) root_logger = logging.getLogger('')
logger.addHandler(logging.NullHandler()) fd, fname = tempfile.mkstemp()
file_handler = logging.FileHandler(fname)
file_handler.setFormatter(formatter)
root_logger.addHandler(file_handler)
if log_path: if log_path:
file_handler = logging.handlers.RotatingFileHandler( file_handler = logging.handlers.RotatingFileHandler(
filename=log_path, filename=log_path,
maxBytes=20000000, backupCount=4) maxBytes=20000000, backupCount=4)
file_handler.setFormatter(formatter) file_handler.setFormatter(formatter)
logger.addHandler(file_handler) root_logger.addHandler(file_handler)
return logger
logger = logging.getLogger(name)
return logger, fname
def runTestSuite(test_suite_title, test_suite_arguments, log): def runTestSuite(test_suite_title, test_suite_arguments, log):
""" """
...@@ -139,7 +147,7 @@ class ScalabilityLauncher(object): ...@@ -139,7 +147,7 @@ class ScalabilityLauncher(object):
'runScalabilityTestSuite.log') 'runScalabilityTestSuite.log')
else: else:
log_path = None log_path = None
logger = setupLogging('runScalabilityTestSuite', log_path) logger, fname = setupLogging('runScalabilityTestSuite', log_path)
self.log = logger.info self.log = logger.info
# Proxy to erp5 master test_result # Proxy to erp5 master test_result
...@@ -229,36 +237,41 @@ def runUnitTest(): ...@@ -229,36 +237,41 @@ def runUnitTest():
""" """
Function meant to be run by "classical" (a.k.a UnitTest) erp5testnode. Function meant to be run by "classical" (a.k.a UnitTest) erp5testnode.
""" """
logger = setupLogging('runScalabilityTestSuite', None)
args = parseArguments() args = parseArguments()
master = taskdistribution.TaskDistributionTool(args.test_suite_master_url) logger, fname = setupLogging('runScalabilityTestSuite', None)
test_suite_title = args.test_suite_title or args.test_suite try:
revision = args.revision master = taskdistribution.TaskDistributionTool(args.test_suite_master_url)
test_suite_title = args.test_suite_title or args.test_suite
test_result = master.createTestResult(revision, [test_suite_title], revision = args.revision
args.node_title, True, test_suite_title, 'foo')
#args.project_title) test_result = master.createTestResult(revision, [test_suite_title],
test_line = test_result.start() args.node_title, True, test_suite_title, 'foo')
#args.project_title)
start_time = time.time() test_line = test_result.start()
args.additional_arguments.append('type=UnitTest') start_time = time.time()
success = runTestSuite(
args.test_suite, args.additional_arguments.append('type=UnitTest')
args.additional_arguments, success = runTestSuite(
logger.info, args.test_suite,
) args.additional_arguments,
logger.info,
if success: )
error_count = 0
else: if success:
error_count = 1 error_count = 0
else:
error_count = 1
test_duration = time.time() - start_time test_duration = time.time() - start_time
test_line.stop(stdout='Success', test_line.stop(stdout=open(fname).read(),
test_count=1, test_count=1,
error_count=error_count, error_count=error_count,
duration=test_duration) duration=test_duration)
except:
raise
finally:
os.remove(fname)
def runStandaloneResiliencyTest(): def runStandaloneResiliencyTest():
""" """
...@@ -272,5 +285,5 @@ def runStandaloneResiliencyTest(): ...@@ -272,5 +285,5 @@ def runStandaloneResiliencyTest():
runTestSuite( runTestSuite(
arguments.test_suite_title, arguments.test_suite_title,
arguments.additional_arguments, arguments.additional_arguments,
setupLogging().info setupLogging()[0].info
) )
...@@ -142,7 +142,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite): ...@@ -142,7 +142,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
status = getSRStatus() status = getSRStatus()
limit -= 1 limit -= 1
self.logger.info('Software release is still building. Sleeping...') self.logger.info('Software release is still building. Sleeping...')
time.sleep(15) time.sleep(60)
def _buildSoftwareRelease(self): def _buildSoftwareRelease(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment