Skip second-stage upgrade testing if UPGRADE_OUTPUT option is absent or empty

This is useful to speed up britney in dry run mode, if we are only interested
in builds and package tests.
This commit is contained in:
Martin Pitt 2015-12-18 16:37:23 +01:00
parent 7fc34b1ab6
commit 2b61398004
2 changed files with 30 additions and 0 deletions

View File

@ -3335,6 +3335,13 @@ class Britney(object):
else:
self.upgrade_me = self.options.actions.split()
# skip upgrade testing if UPGRADE_OUTPUT option is absent or empty
try:
if not self.options.upgrade_output:
return
except AttributeError:
return
ensuredir(os.path.dirname(self.options.upgrade_output))
with open(self.options.upgrade_output, 'w', encoding='utf-8') as f:
self.__output = f

View File

@ -169,6 +169,11 @@ class T(TestBase):
self.assertEqual(self.pending_requests, {})
self.assertEqual(self.amqp_requests, set())
with open(os.path.join(self.data.path, 'output', 'series', 'output.txt')) as f:
upgrade_out = f.read()
self.assertNotIn('accepted:', upgrade_out)
self.assertIn('SUCCESS (0/0)', upgrade_out)
def test_no_wait_for_always_failed_test(self):
'''We do not need to wait for results for tests which have always failed'''
@ -202,6 +207,11 @@ class T(TestBase):
set(['debci-series-amd64:darkgreen {"triggers": ["darkgreen/2"]}',
'debci-series-i386:darkgreen {"triggers": ["darkgreen/2"]}']))
with open(os.path.join(self.data.path, 'output', 'series', 'output.txt')) as f:
upgrade_out = f.read()
self.assertIn('accepted: darkgreen', upgrade_out)
self.assertIn('SUCCESS (1/0)', upgrade_out)
def test_multi_rdepends_with_tests_all_running(self):
'''Multiple reverse dependencies with tests (all running)'''
@ -1578,6 +1588,19 @@ class T(TestBase):
self.assertEqual(self.amqp_requests, set())
self.assertEqual(self.pending_requests, {})
def test_disable_upgrade_tester(self):
'''Run without second stage upgrade tester'''
for line in fileinput.input(self.britney_conf, inplace=True):
if not line.startswith('UPGRADE_OUTPUT'):
sys.stdout.write(line)
self.do_test(
[('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
{})[1]
self.assertFalse(os.path.exists(os.path.join(self.data.path, 'output', 'series', 'output.txt')))
if __name__ == '__main__':
unittest.main()