Commit 40a3804e authored by Julien Muchembled's avatar Julien Muchembled

erp5.util: update unit tests and fix recent regressions

parent cc5792d6
...@@ -2,7 +2,7 @@ import unittest ...@@ -2,7 +2,7 @@ import unittest
from unittest import TestCase from unittest import TestCase
from erp5.util.testnode.testnode import TestNode from erp5.util.testnode.testnode import TestNode
from erp5.util.testnode.NodeTestSuite import SlapOSInstance from erp5.util.testnode.NodeTestSuite import SlapOSInstance, NodeTestSuite
from erp5.util.testnode.ProcessManager import ProcessManager, SubprocessError from erp5.util.testnode.ProcessManager import ProcessManager, SubprocessError
from erp5.util.testnode.Updater import Updater from erp5.util.testnode.Updater import Updater
...@@ -87,6 +87,7 @@ class ERP5TestNode(TestCase): ...@@ -87,6 +87,7 @@ class ERP5TestNode(TestCase):
config["server_url"] = "http://foo.bar" config["server_url"] = "http://foo.bar"
config["httpd_ip"] = "ff:ff:ff:ff:ff:ff:ff:ff" config["httpd_ip"] = "ff:ff:ff:ff:ff:ff:ff:ff"
config["httpd_software_access_port"] = "9080" config["httpd_software_access_port"] = "9080"
config["frontend_url"] = "http://frontend/"
return TestNode(self.log, config) return TestNode(self.log, config)
...@@ -228,7 +229,8 @@ class ERP5TestNode(TestCase): ...@@ -228,7 +229,8 @@ class ERP5TestNode(TestCase):
test_node.test_suite_portal.getTestNode = TaskDistributor.getTestType test_node.test_suite_portal.getTestNode = TaskDistributor.getTestType
node_test_suite = test_node.getNodeTestSuite('foo') node_test_suite = test_node.getNodeTestSuite('foo')
self.updateNodeTestSuiteData(node_test_suite, add_third_repository=True) self.updateNodeTestSuiteData(node_test_suite, add_third_repository=True)
node_test_suite.revision = 'rep1=1234-azerty,rep2=3456-qwerty' node_test_suite.revision_list = (('rep1', (1234, 'azerty')),
('rep2', (3456, 'qwerty')))
test_node.constructProfile(node_test_suite,my_test_type) test_node.constructProfile(node_test_suite,my_test_type)
self.assertEquals("%s/software.cfg" % (node_test_suite.working_directory,), self.assertEquals("%s/software.cfg" % (node_test_suite.working_directory,),
node_test_suite.custom_profile_path) node_test_suite.custom_profile_path)
...@@ -243,12 +245,14 @@ repository = %(temp_dir)s/testnode/foo/rep1 ...@@ -243,12 +245,14 @@ repository = %(temp_dir)s/testnode/foo/rep1
branch = master branch = master
revision = revision =
develop = false develop = false
shared = true
[rep2] [rep2]
repository = %(temp_dir)s/testnode/foo/rep2 repository = %(temp_dir)s/testnode/foo/rep2
branch = foo branch = foo
revision = revision =
develop = false develop = false
shared = true
""" % {'temp_dir': self._temp_dir} """ % {'temp_dir': self._temp_dir}
else: else:
revision1 = "azerty" revision1 = "azerty"
...@@ -262,12 +266,14 @@ repository = <obfuscated_url>/rep1/rep1.git ...@@ -262,12 +266,14 @@ repository = <obfuscated_url>/rep1/rep1.git
revision = %(revision1)s revision = %(revision1)s
ignore-ssl-certificate = true ignore-ssl-certificate = true
develop = false develop = false
shared = true
[rep2] [rep2]
repository = <obfuscated_url>/rep2/rep2.git repository = <obfuscated_url>/rep2/rep2.git
revision = %(revision2)s revision = %(revision2)s
ignore-ssl-certificate = true ignore-ssl-certificate = true
develop = false develop = false
shared = true
""" % {'temp_dir': self._temp_dir, 'revision1': revision1, 'revision2': revision2} """ % {'temp_dir': self._temp_dir, 'revision1': revision1, 'revision2': revision2}
self.assertEquals(expected_profile, profile.read()) self.assertEquals(expected_profile, profile.read())
profile.close() profile.close()
...@@ -440,14 +446,13 @@ develop = false ...@@ -440,14 +446,13 @@ develop = false
self.assertEquals([commit_dict['rep0'][0][0],commit_dict['rep1'][0][0]], self.assertEquals([commit_dict['rep0'][0][0],commit_dict['rep1'][0][0]],
getRepInfo(hash=1)) getRepInfo(hash=1))
class TestResult(object): class TestResult(object):
pass revision = NodeTestSuite.revision
test_result = TestResult() test_result = TestResult()
# for test result to be one commit late for rep1 to force testnode to # for test result to be one commit late for rep1 to force testnode to
# reset tree to older version # reset tree to older version
test_result.revision = 'rep0=2-%s,rep1=1-%s' % (commit_dict['rep0'][0][0], test_result.revision_list = (('rep0', (2, commit_dict['rep0'][0][0])),
commit_dict['rep1'][1][0]) ('rep1', (1, commit_dict['rep1'][1][0])))
test_node.checkRevision(test_result, node_test_suite) test_node.checkRevision(test_result, node_test_suite)
expected_count_list = ['2', '1']
self.assertEquals(['2', '1'], getRepInfo(count=1)) self.assertEquals(['2', '1'], getRepInfo(count=1))
self.assertEquals([commit_dict['rep0'][0][0],commit_dict['rep1'][1][0]], self.assertEquals([commit_dict['rep0'][0][0],commit_dict['rep1'][1][0]],
getRepInfo(hash=1)) getRepInfo(hash=1))
...@@ -515,7 +520,7 @@ develop = false ...@@ -515,7 +520,7 @@ develop = false
# Create and initialise/regenerate a nodetestsuite # Create and initialise/regenerate a nodetestsuite
node_test_suite = test_node.getNodeTestSuite('foo') node_test_suite = test_node.getNodeTestSuite('foo')
self.updateNodeTestSuiteData(node_test_suite) self.updateNodeTestSuiteData(node_test_suite)
node_test_suite.revision = 'dummy' node_test_suite.revision_list = ('dummy', (0, '')),
# Path to the dummy runable # Path to the dummy runable
run_test_suite_path = _createPath( run_test_suite_path = _createPath(
os.path.join(slapos_controler.instance_root,'a/bin'),'runTestSuite') os.path.join(slapos_controler.instance_root,'a/bin'),'runTestSuite')
...@@ -527,9 +532,10 @@ develop = false ...@@ -527,9 +532,10 @@ develop = false
runner = RunnerClass(test_node) runner = RunnerClass(test_node)
runner.runTestSuite(node_test_suite,"http://foo.bar") runner.runTestSuite(node_test_suite,"http://foo.bar")
expected_parameter_list = ['%s/a/bin/runTestSuite' expected_parameter_list = ['%s/a/bin/runTestSuite'
%(slapos_controler.instance_root), '--test_suite', 'Foo', '--revision', %(slapos_controler.instance_root), '--test_suite', 'Foo',
'dummy', '--test_suite_title', 'Foo-Test', '--node_quantity', 3, '--master_url', '--revision', 'dummy=0-', '--test_suite_title', 'Foo-Test',
'http://foo.bar'] '--node_quantity', 3, '--master_url', 'http://foo.bar',
'--frontend_url', 'http://frontend/']
if additional_parameter_list: if additional_parameter_list:
expected_parameter_list.extend(additional_parameter_list) expected_parameter_list.extend(additional_parameter_list)
self.assertEqual(call_parameter_list[0]['args'], expected_parameter_list) self.assertEqual(call_parameter_list[0]['args'], expected_parameter_list)
......
...@@ -148,7 +148,7 @@ class UnitTestRunner(): ...@@ -148,7 +148,7 @@ class UnitTestRunner():
'--test_suite_title', node_test_suite.test_suite_title, '--test_suite_title', node_test_suite.test_suite_title,
'--node_quantity', config['node_quantity'], '--node_quantity', config['node_quantity'],
'--master_url', portal_url, '--master_url', portal_url,
'--frontend_url', slapos_controler.config['frontend_url']]) '--frontend_url', config['frontend_url']])
firefox_bin_list = glob.glob("%s/soft/*/parts/firefox/firefox-slapos" % \ firefox_bin_list = glob.glob("%s/soft/*/parts/firefox/firefox-slapos" % \
config["slapos_directory"]) config["slapos_directory"])
if len(firefox_bin_list): if len(firefox_bin_list):
......
...@@ -234,27 +234,27 @@ shared = true ...@@ -234,27 +234,27 @@ shared = true
self.suite_log = logger.info self.suite_log = logger.info
def checkRevision(self, test_result, node_test_suite): def checkRevision(self, test_result, node_test_suite):
config = self.config if node_test_suite.revision == test_result.revision:
return
log = self.log log = self.log
if log is None: log('Disagreement on tested revision, checking out: %r != %r',
log = self.log node_test_suite.revision, test_result.revision)
if node_test_suite.revision != test_result.revision: updater_kw = dict(git_binary=self.config['git_binary'], log=log,
log('Disagreement on tested revision, checking out: %r' % ( process_manager=self.process_manager)
(node_test_suite.revision,test_result.revision),)) revision_list = []
for i, repository_revision in enumerate(test_result.revision.split(',')): for i, revision in enumerate(test_result.revision.split(',')):
vcs_repository = node_test_suite.vcs_repository_list[i] vcs_repository = node_test_suite.vcs_repository_list[i]
repository_path = vcs_repository['repository_path'] repository_path = vcs_repository['repository_path']
revision = repository_revision.rsplit('-', 1)[1] count, revision = revision.split('=')[1].split('-')
revision_list.append((vcs_repository['repository_id'],
(int(count), revision)))
# other testnodes on other boxes are already ready to test another # other testnodes on other boxes are already ready to test another
# revision # revision
log(' %s at %s' % (repository_path, node_test_suite.revision)) updater = Updater(repository_path, revision=revision, **updater_kw)
updater = Updater(repository_path, git_binary=config['git_binary'],
revision=revision, log=log,
process_manager=self.process_manager)
updater.checkout() updater.checkout()
updater.git_update_server_info() updater.git_update_server_info()
updater.git_create_repository_link() updater.git_create_repository_link()
node_test_suite.revision = test_result.revision node_test_suite.revision_list = revision_list
def _cleanupLog(self): def _cleanupLog(self):
config = self.config config = self.config
...@@ -460,12 +460,12 @@ shared = true ...@@ -460,12 +460,12 @@ shared = true
sleep_time = 120 - (now-begin) sleep_time = 120 - (now-begin)
log("End of processing, going to sleep %s", sleep_time) log("End of processing, going to sleep %s", sleep_time)
time.sleep(sleep_time) time.sleep(sleep_time)
except Exception:
log("", exc_info=1)
except: except:
log("", exc_info=1) log("", exc_info=1)
raise raise
finally: finally:
if 'tb' in locals():
del tb
# Nice way to kill *everything* generated by run process -- process # Nice way to kill *everything* generated by run process -- process
# groups working only in POSIX compilant systems # groups working only in POSIX compilant systems
# Exceptions are swallowed during cleanup phase # Exceptions are swallowed during cleanup phase
......
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