From 2b6139800465163501e10c216885b3b1758d6975 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 18 Dec 2015 16:37:23 +0100 Subject: [PATCH] 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. --- britney.py | 7 +++++++ tests/test_autopkgtest.py | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/britney.py b/britney.py index 0a987ed..e62dd90 100755 --- a/britney.py +++ b/britney.py @@ -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 diff --git a/tests/test_autopkgtest.py b/tests/test_autopkgtest.py index a7678fb..6ee3e60 100755 --- a/tests/test_autopkgtest.py +++ b/tests/test_autopkgtest.py @@ -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()