Merge ~robru/britney/+git/britney2-ubuntu:restrict-sourceppa-policy into ~ubuntu-release/britney/+git/britney2-ubuntu:master

Proposed by Robert Bruce Park on 2017-03-24
Status: Merged
Merged at revision: 16cca9c55d10ea5a90db85e52c1e8a64320b1b9c
Proposed branch: ~robru/britney/+git/britney2-ubuntu:restrict-sourceppa-policy
Merge into: ~ubuntu-release/britney/+git/britney2-ubuntu:master
Diff against target: 148 lines (+36/-24)
4 files modified
britney2/policies/sourceppa.py (+7/-11)
tests/data/sourceppa.json (+3/-3)
tests/test_autopkgtest.py (+10/-8)
tests/test_sourceppa.py (+16/-2)
Reviewer Review Type Date Requested Status
Adam Conrad 2017-03-24 Approve on 2017-03-24
Review via email: mp+320976@code.launchpad.net

Description of the Change

Change SourcePPAPolicy from a blacklist to a whitelist, so that it doesn't interfere with non-bileto PPAs.

To post a comment you must log in.
Adam Conrad (adconrad) wrote :

LGTM, merging.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/britney2/policies/sourceppa.py b/britney2/policies/sourceppa.py
2index 71c9e66..55a0e2d 100644
3--- a/britney2/policies/sourceppa.py
4+++ b/britney2/policies/sourceppa.py
5@@ -13,12 +13,9 @@ from britney2.policies.policy import BasePolicy, PolicyVerdict
6
7 LAUNCHPAD_URL = 'https://api.launchpad.net/1.0/'
8 PRIMARY = LAUNCHPAD_URL + 'ubuntu/+archive/primary'
9-IGNORE = [
10- None,
11- '',
12- 'IndexError',
13- LAUNCHPAD_URL + 'ubuntu/+archive/primary',
14- LAUNCHPAD_URL + 'debian/+archive/primary',
15+INCLUDE = [
16+ '~bileto-ppa-service/',
17+ '~ci-train-ppa-service/',
18 ]
19
20
21@@ -85,9 +82,9 @@ class SourcePPAPolicy(BasePolicy, Rest):
22 accept = excuse.is_valid
23 britney_excuses = self.britney.excuses
24 version = source_data_srcdist.version
25- sourceppa = self.lp_get_source_ppa(source_name, version)
26+ sourceppa = self.lp_get_source_ppa(source_name, version) or ''
27 self.source_ppas_by_pkg[source_name][version] = sourceppa
28- if sourceppa in IGNORE:
29+ if not [team for team in INCLUDE if team in sourceppa]:
30 return PolicyVerdict.PASS
31
32 shortppa = sourceppa.replace(LAUNCHPAD_URL, '')
33@@ -107,9 +104,8 @@ class SourcePPAPolicy(BasePolicy, Rest):
34 friend_exc.is_valid = False
35 friend_exc.addreason('source-ppa')
36 friend_exc.policy_info['source-ppa'] = sourceppa_info
37- self.log("Blocking %s because %s from %s" % (friend, source_name, shortppa))
38- friend_exc.addhtml("Blocking because %s from the same PPA %s is invalid" %
39- (friend, shortppa))
40+ self.log("Grouping %s with PPA %s" % (friend, shortppa))
41+ friend_exc.addhtml("Grouped with PPA %s" % shortppa)
42 return PolicyVerdict.REJECTED_PERMANENTLY
43 return PolicyVerdict.PASS
44
45diff --git a/tests/data/sourceppa.json b/tests/data/sourceppa.json
46index 70e5538..7e1cee8 100644
47--- a/tests/data/sourceppa.json
48+++ b/tests/data/sourceppa.json
49@@ -1,7 +1,7 @@
50 {
51- "pal": {"2.0": "https://api.launchpad.net/1.0/team/ubuntu/ppa"},
52- "buddy": {"2.0": "https://api.launchpad.net/1.0/team/ubuntu/ppa"},
53- "friend": {"2.0": "https://api.launchpad.net/1.0/team/ubuntu/ppa"},
54+ "pal": {"2.0": "https://api.launchpad.net/1.0/~ci-train-ppa-service/+archive/NNNN"},
55+ "buddy": {"2.0": "https://api.launchpad.net/1.0/~ci-train-ppa-service/+archive/NNNN"},
56+ "friend": {"2.0": "https://api.launchpad.net/1.0/~ci-train-ppa-service/+archive/NNNN"},
57 "noppa": {"2.0": ""},
58 "unused": {"2.0": ""}
59 }
60diff --git a/tests/test_autopkgtest.py b/tests/test_autopkgtest.py
61index b4cdfab..bc736ae 100755
62--- a/tests/test_autopkgtest.py
63+++ b/tests/test_autopkgtest.py
64@@ -2181,8 +2181,9 @@ class T(TestBase):
65 def test_sourceppa_policy(self):
66 '''Packages from same source PPA get rejected for failed peer policy'''
67
68- self.sourceppa_cache['green'] = {'2': 'team/ubuntu/ppa'}
69- self.sourceppa_cache['red'] = {'2': 'team/ubuntu/ppa'}
70+ ppa = 'devel/~ci-train-ppa-service/+archive/NNNN'
71+ self.sourceppa_cache['green'] = {'2': ppa}
72+ self.sourceppa_cache['red'] = {'2': ppa}
73 with open(os.path.join(self.data.path, 'data/series-proposed/Blocks'), 'w') as f:
74 f.write('green 12345 1471505000\ndarkgreen 98765 1471500000\n')
75
76@@ -2197,19 +2198,20 @@ class T(TestBase):
77 {'green': [('reason', 'block')],
78 'red': [('reason', 'source-ppa')]}
79 )[1]
80- self.assertEqual(exc['red']['policy_info']['source-ppa'], {'red': 'team/ubuntu/ppa', 'green': 'team/ubuntu/ppa'})
81+ self.assertEqual(exc['red']['policy_info']['source-ppa'], {'red': ppa, 'green': ppa})
82
83 with open(os.path.join(self.data.path, 'data/series-proposed/SourcePPA')) as f:
84 res = json.load(f)
85- self.assertEqual(res, {'red': {'2': 'team/ubuntu/ppa'},
86- 'green': {'2': 'team/ubuntu/ppa'},
87+ self.assertEqual(res, {'red': {'2': ppa},
88+ 'green': {'2': ppa},
89 'gcc-5': {'1': ''}})
90
91 def test_sourceppa_missingbuild(self):
92 '''Packages from same source PPA get rejected for failed peer FTBFS'''
93
94- self.sourceppa_cache['green'] = {'2': 'team/ubuntu/ppa'}
95- self.sourceppa_cache['red'] = {'2': 'team/ubuntu/ppa'}
96+ ppa = 'devel/~ci-train-ppa-service/+archive/ZZZZ'
97+ self.sourceppa_cache['green'] = {'2': ppa}
98+ self.sourceppa_cache['red'] = {'2': ppa}
99
100 self.data.add_src('green', True, {'Version': '2', 'Testsuite': 'autopkgtest'})
101 self.data.add('libgreen1', True, {'Version': '2', 'Source': 'green', 'Architecture': 'i386'}, add_src=False)
102@@ -2221,7 +2223,7 @@ class T(TestBase):
103 'on-unimportant-architectures': []})],
104 'red': [('reason', 'source-ppa')]}
105 )[1]
106- self.assertEqual(exc['red']['policy_info']['source-ppa'], {'red': 'team/ubuntu/ppa', 'green': 'team/ubuntu/ppa'})
107+ self.assertEqual(exc['red']['policy_info']['source-ppa'], {'red': ppa, 'green': ppa})
108
109 if __name__ == '__main__':
110 unittest.main()
111diff --git a/tests/test_sourceppa.py b/tests/test_sourceppa.py
112index 2cfcbd4..180c024 100755
113--- a/tests/test_sourceppa.py
114+++ b/tests/test_sourceppa.py
115@@ -150,7 +150,7 @@ class T(unittest.TestCase):
116
117 def test_approve_ppa(self):
118 """Approve packages by their PPA."""
119- shortppa = 'team/ubuntu/ppa'
120+ shortppa = '~ci-train-ppa-service/+archive/NNNN'
121 pol = SourcePPAPolicy(FakeOptions, {})
122 pol.filename = CACHE_FILE
123 pol.initialise(FakeBritney())
124@@ -159,9 +159,23 @@ class T(unittest.TestCase):
125 self.assertEqual(pol.apply_policy_impl(output, None, pkg, None, FakeData, FakeExcuse), PolicyVerdict.PASS)
126 self.assertEqual(output, dict(pal=shortppa, buddy=shortppa, friend=shortppa))
127
128+ def test_ignore_ppa(self):
129+ """Ignore packages in non-bileto PPAs."""
130+ shortppa = '~kernel-or-whatever/+archive/ppa'
131+ pol = SourcePPAPolicy(FakeOptions, {})
132+ pol.filename = CACHE_FILE
133+ pol.initialise(FakeBritney())
134+ for name, versions in pol.cache.items():
135+ for version in versions:
136+ pol.cache[name][version] = shortppa
137+ output = {}
138+ for pkg in ('pal', 'buddy', 'friend', 'noppa'):
139+ self.assertEqual(pol.apply_policy_impl(output, None, pkg, None, FakeData, FakeExcuse), PolicyVerdict.PASS)
140+ self.assertEqual(output, dict())
141+
142 def test_reject_ppa(self):
143 """Reject packages by their PPA."""
144- shortppa = 'team/ubuntu/ppa'
145+ shortppa = '~ci-train-ppa-service/+archive/NNNN'
146 pol = SourcePPAPolicy(FakeOptions, {})
147 pol.filename = CACHE_FILE
148 brit = FakeBritney()

Subscribers

People subscribed via source and target branches