Commit 120de5b7 authored by Sebastien Robin's avatar Sebastien Robin

finish to make testnode logging in a file accessible by httpd

parent 6a4cbf5e
......@@ -26,7 +26,7 @@ class ERP5TestNode(TestCase):
self.slapos_directory = os.path.join(self._temp_dir, 'slapos')
self.test_suite_directory = os.path.join(self._temp_dir,'test_suite')
self.environment = os.path.join(self._temp_dir,'environment')
self.log_directory = os.path.join(self._temp_dir,'var/log')
self.log_directory = os.path.join(self._temp_dir,'var/log/testnode')
self.log_file = os.path.join(self.log_directory,'test.log')
self.remote_repository0 = os.path.join(self._temp_dir, 'rep0')
self.remote_repository1 = os.path.join(self._temp_dir, 'rep1')
......@@ -530,9 +530,11 @@ branch = foo
for ref, suite in test_node.node_test_suite_dict.items():
assert(suite.suite_log is not None)
assert(isinstance(suite.suite_log, types.MethodType))
assert('var/log/suite/%s' % suite.reference in suite.suite_log_path)
self.assertTrue('var/log/testnode/%s' % suite.reference in \
suite.suite_log_path,
"Incorrect suite log path : %r" % suite.suite_log_path)
assert(suite.suite_log_path.endswith('suite.log'))
m = re.match('.*\/(.*)\/suite.log', suite.suite_log_path)
m = re.match('.*\-(.*)\/suite.log', suite.suite_log_path)
rand_part = m.groups()[0]
assert(len(rand_part) == 32)
assert(rand_part not in rand_part_set)
......
......@@ -75,7 +75,7 @@ def main(*args):
'git_binary','zip_binary','node_quantity','test_node_title',
'ipv4_address','ipv6_address','test_suite_master_url',
'slapgrid_partition_binary','slapgrid_software_binary',
'slapproxy_binary'):
'slapproxy_binary', 'httpd_ip', 'httpd_port'):
CONFIG[key] = config.get('testnode',key)
for key in ('slapos_directory', 'working_directory', 'test_suite_directory',
......@@ -85,6 +85,8 @@ def main(*args):
raise ValueError('Directory %r does not exists.' % d)
CONFIG['master_url'] = 'http://%s:%s' % (CONFIG['proxy_host'],
CONFIG['proxy_port'])
CONFIG['httpd_url'] = 'https://[%s]:%s' % (CONFIG['httpd_ip'],
CONFIG['httpd_port'])
# generate vcs_repository_list
if 'bot_environment' in config.sections():
......
......@@ -110,20 +110,17 @@ class NodeTestSuite(SlapOSInstance):
vcs_repository['repository_path'] = repository_path
def createSuiteLog(self):
# /srv/slapgrid/slappartXX/srv/var/log/suite/az/mlksjfmlk234Sljssdflkj23KSdfslj/suite.log
if getattr(self, "log_directory", None) is not None:
if getattr(self, "suite_log_path", None) is None:
# /srv/slapgrid/slappartXX/srv/var/log/testnode/az-mlksjfmlk234Sljssdflkj23KSdfslj/suite.log
alphabets = string.digits + string.letters
rand_part = ''.join(random.choice(alphabets) for i in xrange(32))
random_suite_folder_id = '%s-%s' % (self.reference, rand_part)
suite_log_directory = os.path.join(self.log_directory,
'suite',
self.reference,
rand_part)
random_suite_folder_id)
SlapOSControler.createFolders(suite_log_directory)
self.suite_log_path = os.path.join(suite_log_directory,
'suite.log')
self._initializeSuiteLog()
return self.getSuiteLogPath()
return self.getSuiteLogPath(), random_suite_folder_id
def getSuiteLogPath(self):
return getattr(self,"suite_log_path", None)
......@@ -145,6 +142,7 @@ class NodeTestSuite(SlapOSInstance):
class TestNode(object):
def __init__(self, log, config):
self.testnode_log = log
self.log = log
self.config = config or {}
self.process_manager = ProcessManager(log)
......@@ -247,11 +245,15 @@ branch = %(branch)s
Create a log dedicated for the test suite,
and register the url to master node.
"""
log_file_name = node_test_suite.createSuiteLog()
log_file_name, folder_id = node_test_suite.createSuiteLog()
if log_file_name is None and config.get('log_file'):
log_file_name = config['log_file']
# TODO make the path into url
test_result.reportStatus('registerSuiteLog', log_file_name, '')
test_result.reportStatus('LOG url', "%s/%s" % (self.config.get('httpd_url'),
folder_id), '')
self.log("going to switch to log %r" % log_file_name)
log = node_test_suite.getSuiteLog()
self.process_manager.log = self.log = log
return log_file_name
def checkRevision(self, test_result, node_test_suite):
......@@ -393,6 +395,7 @@ branch = %(branch)s
try:
while True:
try:
self.log = self.process_manager.log = self.testnode_log
self.cleanUp(None)
remote_test_result_needs_cleanup = False
begin = time.time()
......
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