mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-02-23 19:31:55 +00:00
Limit accumulated bounties to configurable minum age
This commit is contained in:
parent
77ea1cc8d5
commit
f2f20eb460
@ -52,6 +52,7 @@ MINDAYS_CRITICAL = 0
|
||||
MINDAYS_EMERGENCY = 0
|
||||
DEFAULT_URGENCY = medium
|
||||
NO_PENALTIES = high critical emergency
|
||||
BOUNTY_MIN_AGE = 2
|
||||
|
||||
HINTSDIR = /srv/release.debian.org/britney/hints
|
||||
|
||||
|
@ -291,6 +291,22 @@ class AgePolicy(BasePolicy):
|
||||
self.log('Applying penalty for %s given by %s: %d days' %
|
||||
(source_name, penalty, excuse.penalty[penalty]))
|
||||
min_days += excuse.penalty[penalty]
|
||||
try:
|
||||
bounty_min_age = int(self.options.bounty_min_age)
|
||||
except ValueError:
|
||||
if self.options.bounty_min_age in self._min_days:
|
||||
bounty_min_age = self._min_days[self.options.bounty_min_age]
|
||||
else:
|
||||
raise ValueError('Please fix BOUNTY_MIN_AGE in the britney configuration')
|
||||
except AttributeError:
|
||||
# The option wasn't defined in the configuration
|
||||
bounty_min_age = 0
|
||||
# the age in BOUNTY_MIN_AGE can be higher than the one associated with
|
||||
# the real urgency, so don't forget to take it into account
|
||||
bounty_min_age = min(bounty_min_age, self._min_days[urgency])
|
||||
if min_days < bounty_min_age:
|
||||
min_days = bounty_min_age
|
||||
excuse.addhtml('Required age is not allowed to drop below %d days' % min_days)
|
||||
age_info['age-requirement'] = min_days
|
||||
age_info['current-age'] = days_old
|
||||
|
||||
|
@ -368,6 +368,7 @@ MINDAYS_CRITICAL = 0
|
||||
MINDAYS_EMERGENCY = 0
|
||||
DEFAULT_URGENCY = medium
|
||||
NO_PENALTIES = high critical emergency
|
||||
BOUNTY_MIN_AGE = 8
|
||||
|
||||
HINTSDIR = data/hints
|
||||
|
||||
|
@ -2566,7 +2566,7 @@ class T(TestBase):
|
||||
self.assertEqual(exc['green']['policy_info']['age']['age-requirement'], 13)
|
||||
|
||||
def test_passing_package_receives_bounty(self):
|
||||
'''Does not request a test for an uninstallable package'''
|
||||
'''Test bounty system (instead of policy verdict)'''
|
||||
|
||||
# Don't use policy verdics, but age packages appropriate
|
||||
for line in fileinput.input(self.britney_conf, inplace=True):
|
||||
@ -2596,7 +2596,8 @@ class T(TestBase):
|
||||
{})[1]
|
||||
|
||||
# it should cause the age to drop
|
||||
self.assertEqual(exc['green']['policy_info']['age']['age-requirement'], 7)
|
||||
self.assertEqual(exc['green']['policy_info']['age']['age-requirement'], 8)
|
||||
self.assertEqual(exc['green']['excuses'][-1], 'Required age is not allowed to drop below 8 days')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
x
Reference in New Issue
Block a user