mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-02-10 22:17:36 +00:00
Change SourcePPAPolicy from a blacklist to a whitelist.
This commit is contained in:
parent
858775a3c1
commit
16cca9c55d
@ -13,12 +13,9 @@ from britney2.policies.policy import BasePolicy, PolicyVerdict
|
||||
|
||||
LAUNCHPAD_URL = 'https://api.launchpad.net/1.0/'
|
||||
PRIMARY = LAUNCHPAD_URL + 'ubuntu/+archive/primary'
|
||||
IGNORE = [
|
||||
None,
|
||||
'',
|
||||
'IndexError',
|
||||
LAUNCHPAD_URL + 'ubuntu/+archive/primary',
|
||||
LAUNCHPAD_URL + 'debian/+archive/primary',
|
||||
INCLUDE = [
|
||||
'~bileto-ppa-service/',
|
||||
'~ci-train-ppa-service/',
|
||||
]
|
||||
|
||||
|
||||
@ -85,9 +82,9 @@ class SourcePPAPolicy(BasePolicy, Rest):
|
||||
accept = excuse.is_valid
|
||||
britney_excuses = self.britney.excuses
|
||||
version = source_data_srcdist.version
|
||||
sourceppa = self.lp_get_source_ppa(source_name, version)
|
||||
sourceppa = self.lp_get_source_ppa(source_name, version) or ''
|
||||
self.source_ppas_by_pkg[source_name][version] = sourceppa
|
||||
if sourceppa in IGNORE:
|
||||
if not [team for team in INCLUDE if team in sourceppa]:
|
||||
return PolicyVerdict.PASS
|
||||
|
||||
shortppa = sourceppa.replace(LAUNCHPAD_URL, '')
|
||||
@ -107,9 +104,8 @@ class SourcePPAPolicy(BasePolicy, Rest):
|
||||
friend_exc.is_valid = False
|
||||
friend_exc.addreason('source-ppa')
|
||||
friend_exc.policy_info['source-ppa'] = sourceppa_info
|
||||
self.log("Blocking %s because %s from %s" % (friend, source_name, shortppa))
|
||||
friend_exc.addhtml("Blocking because %s from the same PPA %s is invalid" %
|
||||
(friend, shortppa))
|
||||
self.log("Grouping %s with PPA %s" % (friend, shortppa))
|
||||
friend_exc.addhtml("Grouped with PPA %s" % shortppa)
|
||||
return PolicyVerdict.REJECTED_PERMANENTLY
|
||||
return PolicyVerdict.PASS
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"pal": {"2.0": "https://api.launchpad.net/1.0/team/ubuntu/ppa"},
|
||||
"buddy": {"2.0": "https://api.launchpad.net/1.0/team/ubuntu/ppa"},
|
||||
"friend": {"2.0": "https://api.launchpad.net/1.0/team/ubuntu/ppa"},
|
||||
"pal": {"2.0": "https://api.launchpad.net/1.0/~ci-train-ppa-service/+archive/NNNN"},
|
||||
"buddy": {"2.0": "https://api.launchpad.net/1.0/~ci-train-ppa-service/+archive/NNNN"},
|
||||
"friend": {"2.0": "https://api.launchpad.net/1.0/~ci-train-ppa-service/+archive/NNNN"},
|
||||
"noppa": {"2.0": ""},
|
||||
"unused": {"2.0": ""}
|
||||
}
|
||||
|
@ -2181,8 +2181,9 @@ class T(TestBase):
|
||||
def test_sourceppa_policy(self):
|
||||
'''Packages from same source PPA get rejected for failed peer policy'''
|
||||
|
||||
self.sourceppa_cache['green'] = {'2': 'team/ubuntu/ppa'}
|
||||
self.sourceppa_cache['red'] = {'2': 'team/ubuntu/ppa'}
|
||||
ppa = 'devel/~ci-train-ppa-service/+archive/NNNN'
|
||||
self.sourceppa_cache['green'] = {'2': ppa}
|
||||
self.sourceppa_cache['red'] = {'2': ppa}
|
||||
with open(os.path.join(self.data.path, 'data/series-proposed/Blocks'), 'w') as f:
|
||||
f.write('green 12345 1471505000\ndarkgreen 98765 1471500000\n')
|
||||
|
||||
@ -2197,19 +2198,20 @@ class T(TestBase):
|
||||
{'green': [('reason', 'block')],
|
||||
'red': [('reason', 'source-ppa')]}
|
||||
)[1]
|
||||
self.assertEqual(exc['red']['policy_info']['source-ppa'], {'red': 'team/ubuntu/ppa', 'green': 'team/ubuntu/ppa'})
|
||||
self.assertEqual(exc['red']['policy_info']['source-ppa'], {'red': ppa, 'green': ppa})
|
||||
|
||||
with open(os.path.join(self.data.path, 'data/series-proposed/SourcePPA')) as f:
|
||||
res = json.load(f)
|
||||
self.assertEqual(res, {'red': {'2': 'team/ubuntu/ppa'},
|
||||
'green': {'2': 'team/ubuntu/ppa'},
|
||||
self.assertEqual(res, {'red': {'2': ppa},
|
||||
'green': {'2': ppa},
|
||||
'gcc-5': {'1': ''}})
|
||||
|
||||
def test_sourceppa_missingbuild(self):
|
||||
'''Packages from same source PPA get rejected for failed peer FTBFS'''
|
||||
|
||||
self.sourceppa_cache['green'] = {'2': 'team/ubuntu/ppa'}
|
||||
self.sourceppa_cache['red'] = {'2': 'team/ubuntu/ppa'}
|
||||
ppa = 'devel/~ci-train-ppa-service/+archive/ZZZZ'
|
||||
self.sourceppa_cache['green'] = {'2': ppa}
|
||||
self.sourceppa_cache['red'] = {'2': ppa}
|
||||
|
||||
self.data.add_src('green', True, {'Version': '2', 'Testsuite': 'autopkgtest'})
|
||||
self.data.add('libgreen1', True, {'Version': '2', 'Source': 'green', 'Architecture': 'i386'}, add_src=False)
|
||||
@ -2221,7 +2223,7 @@ class T(TestBase):
|
||||
'on-unimportant-architectures': []})],
|
||||
'red': [('reason', 'source-ppa')]}
|
||||
)[1]
|
||||
self.assertEqual(exc['red']['policy_info']['source-ppa'], {'red': 'team/ubuntu/ppa', 'green': 'team/ubuntu/ppa'})
|
||||
self.assertEqual(exc['red']['policy_info']['source-ppa'], {'red': ppa, 'green': ppa})
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -150,7 +150,7 @@ class T(unittest.TestCase):
|
||||
|
||||
def test_approve_ppa(self):
|
||||
"""Approve packages by their PPA."""
|
||||
shortppa = 'team/ubuntu/ppa'
|
||||
shortppa = '~ci-train-ppa-service/+archive/NNNN'
|
||||
pol = SourcePPAPolicy(FakeOptions, {})
|
||||
pol.filename = CACHE_FILE
|
||||
pol.initialise(FakeBritney())
|
||||
@ -159,9 +159,23 @@ class T(unittest.TestCase):
|
||||
self.assertEqual(pol.apply_policy_impl(output, None, pkg, None, FakeData, FakeExcuse), PolicyVerdict.PASS)
|
||||
self.assertEqual(output, dict(pal=shortppa, buddy=shortppa, friend=shortppa))
|
||||
|
||||
def test_ignore_ppa(self):
|
||||
"""Ignore packages in non-bileto PPAs."""
|
||||
shortppa = '~kernel-or-whatever/+archive/ppa'
|
||||
pol = SourcePPAPolicy(FakeOptions, {})
|
||||
pol.filename = CACHE_FILE
|
||||
pol.initialise(FakeBritney())
|
||||
for name, versions in pol.cache.items():
|
||||
for version in versions:
|
||||
pol.cache[name][version] = shortppa
|
||||
output = {}
|
||||
for pkg in ('pal', 'buddy', 'friend', 'noppa'):
|
||||
self.assertEqual(pol.apply_policy_impl(output, None, pkg, None, FakeData, FakeExcuse), PolicyVerdict.PASS)
|
||||
self.assertEqual(output, dict())
|
||||
|
||||
def test_reject_ppa(self):
|
||||
"""Reject packages by their PPA."""
|
||||
shortppa = 'team/ubuntu/ppa'
|
||||
shortppa = '~ci-train-ppa-service/+archive/NNNN'
|
||||
pol = SourcePPAPolicy(FakeOptions, {})
|
||||
pol.filename = CACHE_FILE
|
||||
brit = FakeBritney()
|
||||
|
Loading…
x
Reference in New Issue
Block a user