From 18eb7abb015a3f0b278202f291ff531b329223da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=27sil2100=27=20Zemczak?= Date: Wed, 3 Mar 2021 15:00:57 +0100 Subject: [PATCH] Initial handling of private PPAs. --- britney2/policies/autopkgtest.py | 8 +++-- tests/test_autopkgtest.py | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/britney2/policies/autopkgtest.py b/britney2/policies/autopkgtest.py index e59d931..d771340 100644 --- a/britney2/policies/autopkgtest.py +++ b/britney2/policies/autopkgtest.py @@ -147,7 +147,8 @@ class AutopkgtestPolicy(BasePolicy): self.swift_container = 'autopkgtest-' + options.series if self.options.adt_ppas: - self.swift_container += '-' + options.adt_ppas[-1].replace('/', '-') + # private PPAs require the auth credentials given + self.swift_container += '-' + options.adt_ppas[-1].rpartition('@')[2].replace('/', '-') # restrict adt_arches to architectures we actually run for self.adt_arches = [] @@ -469,7 +470,10 @@ class AutopkgtestPolicy(BasePolicy): if status == 'REGRESSION': if self.options.adt_retry_url_mech == 'run_id': retry_url = self.options.adt_ci_url + 'api/v1/retry/' + run_id - else: + elif not any('@' in ppa for ppa in self.options.adt_ppas): + # private PPAs currently should not display a retry + # button until we can guarantee that the secrets + # will not leak retry_url = self.options.adt_ci_url + 'request.cgi?' + \ urllib.parse.urlencode([('release', self.options.series), ('arch', arch), diff --git a/tests/test_autopkgtest.py b/tests/test_autopkgtest.py index 801c166..1ff26d3 100644 --- a/tests/test_autopkgtest.py +++ b/tests/test_autopkgtest.py @@ -2545,6 +2545,60 @@ class AT(TestAutopkgtestBase): self.assertEqual(self.amqp_requests, set()) self.assertEqual(self.pending_requests, {}) + def test_private_ppas(self): + '''Run test requests with an additional private PPA''' + + self.data.add_default_packages(lightgreen=False) + + for line in fileinput.input(self.britney_conf, inplace=True): + if line.startswith('ADT_PPAS'): + print('ADT_PPAS = user:password@joe/foo') + else: + sys.stdout.write(line) + + exc = self.run_it( + [('lightgreen', {'Version': '2'}, 'autopkgtest')], + {'lightgreen': (True, {'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL'}})}, + {'lightgreen': [('old-version', '1'), ('new-version', '2')]} + )[1] + + # add results to PPA specific swift container + self.swift.set_results({'autopkgtest-testing-joe-foo': { + 'testing/i386/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('passedbefore/1')), + 'testing/i386/l/lightgreen/20150101_100100@': (4, 'lightgreen 2', tr('lightgreen/2')), + 'testing/amd64/l/lightgreen/20150101_100101@': (0, 'lightgreen 2', tr('lightgreen/2')), + }}) + + exc = self.run_it( + [], + {'lightgreen': (False, {'lightgreen/2': {'i386': 'REGRESSION', 'amd64': 'PASS'}})}, + {'lightgreen': [('old-version', '1'), ('new-version', '2')]} + )[1] + # check if the right container name is used and that no secrets are + # leaked in the retry url (as it should be None now) + self.assertEqual( + exc['lightgreen']['policy_info']['autopkgtest'], + {'lightgreen/2': { + 'amd64': [ + 'PASS', + 'http://localhost:18085/autopkgtest-testing-joe-foo/' + 'testing/amd64/l/lightgreen/20150101_100101@/log.gz', + None, + 'http://localhost:18085/autopkgtest-testing-joe-foo/' + 'testing/amd64/l/lightgreen/20150101_100101@/artifacts.tar.gz', + None], + 'i386': [ + 'REGRESSION', + 'http://localhost:18085/autopkgtest-testing-joe-foo/' + 'testing/i386/l/lightgreen/20150101_100100@/log.gz', + None, + 'http://localhost:18085/autopkgtest-testing-joe-foo/' + 'testing/i386/l/lightgreen/20150101_100100@/artifacts.tar.gz', + None]}, + 'verdict': 'REJECTED_PERMANENTLY'}) + self.assertEqual(self.amqp_requests, set()) + self.assertEqual(self.pending_requests, {}) + def test_disable_upgrade_tester(self): '''Run without second stage upgrade tester'''