From 77ea1cc8d5112671b5180cef9f1c3780178daa13 Mon Sep 17 00:00:00 2001 From: Paul Gevers Date: Wed, 18 Oct 2017 20:40:22 +0200 Subject: [PATCH] Enable no-penalties urgencies; to exempt urgency >= high from penalties --- britney.conf | 1 + britney2/policies/policy.py | 10 ++++++---- tests/__init__.py | 1 + tests/test_autopkgtest.py | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/britney.conf b/britney.conf index e1e4105..1cb65a6 100644 --- a/britney.conf +++ b/britney.conf @@ -51,6 +51,7 @@ MINDAYS_HIGH = 2 MINDAYS_CRITICAL = 0 MINDAYS_EMERGENCY = 0 DEFAULT_URGENCY = medium +NO_PENALTIES = high critical emergency HINTSDIR = /srv/release.debian.org/britney/hints diff --git a/britney2/policies/policy.py b/britney2/policies/policy.py index ff7e948..946958b 100644 --- a/britney2/policies/policy.py +++ b/britney2/policies/policy.py @@ -285,10 +285,12 @@ class AgePolicy(BasePolicy): self.log('Applying bounty for %s granted by %s: %d days' % (source_name, bounty, excuse.bounty[bounty])) min_days -= excuse.bounty[bounty] - for penalty in excuse.penalty: - self.log('Applying penalty for %s given by %s: %d days' % - (source_name, penalty, excuse.penalty[penalty])) - min_days += excuse.penalty[penalty] + if not hasattr(self.options, 'no_penalties') or \ + urgency not in self.options.no_penalties: + for penalty in excuse.penalty: + self.log('Applying penalty for %s given by %s: %d days' % + (source_name, penalty, excuse.penalty[penalty])) + min_days += excuse.penalty[penalty] age_info['age-requirement'] = min_days age_info['current-age'] = days_old diff --git a/tests/__init__.py b/tests/__init__.py index e0bef89..4f0b3fb 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -367,6 +367,7 @@ MINDAYS_HIGH = 0 MINDAYS_CRITICAL = 0 MINDAYS_EMERGENCY = 0 DEFAULT_URGENCY = medium +NO_PENALTIES = high critical emergency HINTSDIR = data/hints diff --git a/tests/test_autopkgtest.py b/tests/test_autopkgtest.py index 0c1c524..6be4003 100755 --- a/tests/test_autopkgtest.py +++ b/tests/test_autopkgtest.py @@ -2528,6 +2528,43 @@ class T(TestBase): # instead, it should cause the age to sky-rocket self.assertEqual(exc['green']['policy_info']['age']['age-requirement'], 40) + def test_multi_rdepends_with_tests_no_penalty(self): + '''Check that penalties are not applied for "urgency >= high"''' + + # Don't use policy verdics, but age packages appropriate + for line in fileinput.input(self.britney_conf, inplace=True): + if line.startswith('MINDAYS_MEDIUM'): + print('MINDAYS_MEDIUM = 13') + elif line.startswith('ADT_SUCCESS_BOUNTY'): + print('ADT_SUCCESS_BOUNTY = 6') + elif line.startswith('ADT_REGRESSION_PENALTY'): + print('ADT_REGRESSION_PENALTY = 27') + elif line.startswith('NO_PENALTIES'): + print('NO_PENALTIES = medium') + else: + sys.stdout.write(line) + + self.data.add_default_packages(green=False) + + self.swift.set_results({'autopkgtest-testing': { + 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')), + 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')), + 'testing/amd64/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')), + 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')), + 'testing/amd64/g/green/20150101_100201@': (4, 'green 2', tr('green/2')), + }}) + + exc = self.do_test( + [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')], + {'green': (False, {'green/2': {'amd64': 'ALWAYSFAIL', 'i386': 'PASS'}, + 'lightgreen/1': {'amd64': 'REGRESSION', 'i386': 'RUNNING-ALWAYSFAIL'}, + 'darkgreen/1': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'PASS'}, + }) + })[1] + + # age-requirement should remain the same despite regression + 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'''