Commit b527abd1 authored by Xavier Thompson's avatar Xavier Thompson

software/end-to-end-testing: Limit racy testnodes

Multiple testnode can concurrently run the same test, so create test
results only at the end to reduce the risk of race conditions on test
completion leading to tests never reported as completed.

This shows a limit of the current approach; switching to nxdtest
appears desirable.
parent 2446782a
...@@ -4,4 +4,4 @@ md5sum = 562e123cefa9e39cbc78300e4643f7b3 ...@@ -4,4 +4,4 @@ md5sum = 562e123cefa9e39cbc78300e4643f7b3
[runTestSuite.in] [runTestSuite.in]
filename = runTestSuite.in filename = runTestSuite.in
md5sum = 69a9c2ab0279d7152baddf96e46c93d4 md5sum = 3fab881b3baba3c398b4d89b5ce26542
...@@ -43,17 +43,6 @@ def main(): ...@@ -43,17 +43,6 @@ def main():
suite = unittest.defaultTestLoader.loadTestsFromModule(module) suite = unittest.defaultTestLoader.loadTestsFromModule(module)
all_tests = [t for s in suite for t in s] all_tests = [t for s in suite for t in s]
task_distributor = erp5.util.taskdistribution.TaskDistributor(
portal_url=args.master_url
)
test_result = task_distributor.createTestResult(
revision = args.revision,
test_name_list = [t.id() for t in all_tests],
node_title = args.test_node_title,
test_title = args.test_suite_title,
project_title = args.project_title,
)
runner = unittest.TextTestRunner(resultclass=EndToEndResult) runner = unittest.TextTestRunner(resultclass=EndToEndResult)
result = runner.run(suite) result = runner.run(suite)
...@@ -68,6 +57,23 @@ def main(): ...@@ -68,6 +57,23 @@ def main():
print(skipped) print(skipped)
print(durations) print(durations)
# Create test lines at the end to reduce race conditions on multiple testnodes
task_distributor = erp5.util.taskdistribution.TaskDistributor(
portal_url=args.master_url
)
test_result = task_distributor.createTestResult(
revision = args.revision,
test_name_list = [t.id() for t in all_tests],
node_title = args.test_node_title,
test_title = args.test_suite_title,
project_title = args.project_title,
)
if test_result is None:
print("A test result has already been completed")
print("Nothing to do")
return
for t in all_tests: for t in all_tests:
kind = [errors, failures, skipped] kind = [errors, failures, skipped]
count = [0, 0, 0] count = [0, 0, 0]
...@@ -82,7 +88,13 @@ def main(): ...@@ -82,7 +88,13 @@ def main():
print(t.id()) print(t.id())
print(count) print(count)
print(output) print(output)
test_result_line = test_result.start() test_result_line = test_result.start()
if test_result_line is None:
print("A test result line has already been completed")
print("Nothing to do")
break
test_result_line.stop( test_result_line.stop(
test_count = 1, test_count = 1,
error_count = count[0], error_count = count[0],
...@@ -185,6 +197,14 @@ class EndToEndTestCase(unittest.TestCase): ...@@ -185,6 +197,14 @@ class EndToEndTestCase(unittest.TestCase):
time.sleep(60) time.sleep(60)
class Test(EndToEndTestCase):
def test_fail(self):
self.assertEqual(0, 1)
def test_succeed(self):
self.assertEqual(0, 0)
class KvmTest(EndToEndTestCase): class KvmTest(EndToEndTestCase):
def test(self): def test(self):
# instance_name = time.strftime('e2e-test-kvm-%Y-%B-%d-%H:%M:%S') # instance_name = time.strftime('e2e-test-kvm-%Y-%B-%d-%H:%M:%S')
...@@ -195,10 +215,5 @@ class KvmTest(EndToEndTestCase): ...@@ -195,10 +215,5 @@ class KvmTest(EndToEndTestCase):
self.assertIn('url', connection_dict) self.assertIn('url', connection_dict)
class Fail(EndToEndTestCase):
def test(self):
self.assertEqual(0, 1)
if __name__ == '__main__': if __name__ == '__main__':
main() main()
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