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