From 9b0d09cfd84ffec855ce52f80560dc3212402760 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 15 Jul 2015 11:25:57 +0200 Subject: [PATCH] Add test case for removed package from unstable This used to trigger an eternal test loop, but this got fixed with the recent commits. --- tests/__init__.py | 9 ++++++ tests/test_autopkgtest.py | 59 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/tests/__init__.py b/tests/__init__.py index f254765..c682229 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -126,6 +126,15 @@ Maintainer: Joe f.write('%s: %s\n' % (k, v)) f.write('\n') + def remove_all(self, unstable): + '''Remove all added packages''' + + self.added_binaries[unstable] = set() + self.added_sources[unstable] = set() + for a in architectures: + open(os.path.join(self.dirs[unstable], 'Packages_' + a), 'w').close() + open(os.path.join(self.dirs[unstable], 'Sources'), 'w').close() + class TestBase(unittest.TestCase): diff --git a/tests/test_autopkgtest.py b/tests/test_autopkgtest.py index e581c0f..537e2c2 100644 --- a/tests/test_autopkgtest.py +++ b/tests/test_autopkgtest.py @@ -359,6 +359,65 @@ lightgreen 2 i386 lightgreen 2 r'autopkgtest for lightgreen 1: .*amd64.*Pass.*i386.*Pass']) self.assertEqual(self.pending_requests, '') + def test_remove_from_unstable(self): + '''broken package gets removed from unstable''' + + self.swift.set_results({'autopkgtest-series': { + 'series/i386/g/green/20150101_100101@': (0, 'green 1'), + 'series/amd64/g/green/20150101_100101@': (0, 'green 1'), + 'series/i386/g/green/20150101_100201@': (0, 'green 2'), + 'series/amd64/g/green/20150101_100201@': (0, 'green 2'), + 'series/i386/l/lightgreen/20150101_100101@': (0, 'lightgreen 1'), + 'series/amd64/l/lightgreen/20150101_100101@': (0, 'lightgreen 1'), + 'series/i386/l/lightgreen/20150101_100201@': (4, 'lightgreen 2'), + 'series/amd64/l/lightgreen/20150101_100201@': (4, 'lightgreen 2'), + 'series/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1'), + 'series/amd64/d/darkgreen/20150101_100001@': (0, 'darkgreen 1'), + }}) + + self.do_test( + [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest'), + ('lightgreen', {'Version': '2', 'Depends': 'libgreen1 (>= 2)'}, 'autopkgtest')], + # FIXME: while we only submit requests through AMQP, but don't consider + # their results, we don't expect this to hold back stuff. + VALID_CANDIDATE, + [r'\bgreen\b.*>1 to .*>2<', + r'\blightgreen\b.*>1 to .*>2<', + r'autopkgtest for green 2: .*amd64.*Pass.*i386.*Pass', + r'autopkgtest for lightgreen 2: .*amd64.*Regression.*i386.*Regression']) + self.assertEqual(self.pending_requests, '') + os.unlink(self.fake_amqp) + + # remove new lightgreen by resetting archive indexes, and re-adding + # green + self.data.remove_all(True) + + # next run should re-trigger lightgreen 1 to test against green/2 + self.do_test( + [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')], + VALID_CANDIDATE, + [r'\bgreen\b.*>1 to .*>2<', + r'autopkgtest for green 2: .*amd64.*Pass.*i386.*Pass', + r'autopkgtest for lightgreen 1: .*amd64.*Pass.*i386.*Pass'], + ['lightgreen 2']) + + # should not trigger new requests + self.assertEqual(self.pending_requests, '') + self.assertEqual(self.amqp_requests, + set(['debci-series-amd64:lightgreen', 'debci-series-i386:lightgreen'])) + + # but the next run should not trigger anything new + os.unlink(self.fake_amqp) + self.do_test( + [], + VALID_CANDIDATE, + [r'\bgreen\b.*>1 to .*>2<', + r'autopkgtest for green 2: .*amd64.*Pass.*i386.*Pass', + r'autopkgtest for lightgreen 1: .*amd64.*Pass.*i386.*Pass'], + ['lightgreen 2']) + self.assertEqual(self.pending_requests, '') + self.assertEqual(self.amqp_requests, set()) + def test_no_amqp_config(self): '''Run without autopkgtest requests'''