Commit daf3d133 authored by Jérome Perrin's avatar Jérome Perrin

testnode: advertise log URL with log_frontend_url

testnode use to publish the URL of logs so that Nexedi ERP5 can
display link to "view logs". This URL was an IPv6 URL on a certificate
which does not validate.

Now testnode software release request a shared frontend for these
logs and generate a config file with log_frontend_url set.

testnode now advertise the URL of log using the log frontend url
from config.

Also simplify frontend_url key to manage it using the same way.
parent fcbdb89b
Pipeline #12015 passed with stage
in 0 seconds
......@@ -95,6 +95,7 @@ class ERP5TestNode(TestCase):
config["httpd_ip"] = "ff:ff:ff:ff:ff:ff:ff:ff"
config["httpd_software_access_port"] = "9080"
config["frontend_url"] = "http://frontend/"
config["log_frontend_url"] = "http://log-frontend/"
config["software_list"] = ["foo", "bar"]
config["partition_reference"] = "part"
config["ipv4_address"] = "1.2.3.4"
......@@ -1015,7 +1016,7 @@ shared = true
logger, test_result_path, node_title, revision)
def patch_runTestSuite(self,*argv, **kw):
return {'status_code': 0}
def checkTestSuite(test_node):
def checkTestSuite(test_node, reportTaskStatus_mock):
test_node.node_test_suite_dict
rand_part_set = set()
self.assertEqual(2, len(test_node.node_test_suite_dict))
......@@ -1025,6 +1026,14 @@ shared = true
"Incorrect suite log path : %r" % suite.suite_log_path)
m = re.search('-(.*)/suite.log$', suite.suite_log_path)
rand_part = m.groups()[0]
reportTaskStatus_mock.assert_has_calls(
[mock.call(
mock.ANY,
{'command': 'LOG url',
'stdout': "http://log-frontend/{}-{}".format(suite.reference, rand_part),
'stderr': ''},
"Foo-Test-Node")])
self.assertEqual(len(rand_part), 10)
self.assertNotIn(rand_part, rand_part_set)
rand_part_set.add(rand_part)
......@@ -1081,9 +1090,11 @@ shared = true
return {'status_code': 0}
RunnerClass._prepareSlapOS = patch_prepareSlapOS
SlapOSControler.initializeSlapOSControler = doNothing
with mock.patch('erp5.util.taskdistribution.DummyTaskDistributor.reportTaskStatus') as reportTaskStatus:
test_node.run()
self.assertEqual(counter, 3)
checkTestSuite(test_node)
checkTestSuite(test_node, reportTaskStatus)
time.sleep = original_sleep
# Restore old class methods
if my_test_type == "ScalabilityTest":
......
......@@ -74,7 +74,8 @@ def main(*args):
'proxy_port', 'git_binary','zip_binary','node_quantity',
'test_node_title', 'ipv4_address','ipv6_address','test_suite_master_url',
'slapos_binary', 'httpd_ip', 'httpd_port', 'httpd_software_access_port',
'computer_id', 'server_url', 'shared_part_list', 'keep_log_days'):
'computer_id', 'server_url', 'shared_part_list', 'keep_log_days',
'frontend_url', 'log_frontend_url', ):
CONFIG[key] = config.get('testnode',key)
for key in ('slapos_directory', 'working_directory', 'test_suite_directory',
......@@ -87,7 +88,6 @@ def main(*args):
CONFIG['httpd_url'] = 'https://[%s]:%s' % (CONFIG['httpd_ip'],
CONFIG['httpd_port'])
CONFIG['system_temp_folder'] = "/tmp"
CONFIG['frontend_url'] = config.get('testnode', 'frontend_url')
# generate vcs_repository_list
if 'bot_environment' in config.sections():
......
......@@ -28,6 +28,7 @@ import os
import json
import time
import logging
from six.moves.urllib.parse import urljoin
from contextlib import contextmanager
from slapos.slap.slap import ConnectionError
from . import logger, log_formatter
......@@ -341,8 +342,8 @@ shared = true
self.cleanUp() # XXX not a good place to do that
continue
with self.suiteLog(node_test_suite) as suite_log_folder_name:
test_result.reportStatus('LOG url', "%s/%s" % (
config.get('httpd_url'), suite_log_folder_name), '')
test_result.reportStatus(
'LOG url', urljoin(config['log_frontend_url'], suite_log_folder_name), '')
git_gc_auto = self.checkRevision(test_result, node_test_suite)
node_test_suite.edit(test_result=test_result)
# get cluster configuration for this test suite, this is needed to
......
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