From 93ca29c3aaddd98266122340b2ed9b29c971e0e5 Mon Sep 17 00:00:00 2001 From: Paul Gevers Date: Mon, 5 Mar 2018 14:08:39 +0100 Subject: [PATCH] Load the debci API status file directly --- britney2/policies/autopkgtest.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/britney2/policies/autopkgtest.py b/britney2/policies/autopkgtest.py index f3e7d4a..f14d4c0 100644 --- a/britney2/policies/autopkgtest.py +++ b/britney2/policies/autopkgtest.py @@ -17,6 +17,7 @@ # GNU General Public License for more details. import os +import copy import json import tarfile import io @@ -123,10 +124,28 @@ class AutopkgtestPolicy(BasePolicy): with open(debci_file) as f: test_results = json.load(f) self.log('Read new results from %s' % debci_file) - for result in test_results: - (trigger, src, arch, ver, passed, stamp) = result - self.remove_from_pending(trigger, src, arch) - self.add_trigger_to_results(trigger, src, ver, arch, stamp, passed) + for res in test_results['results']: + # status == null means still running + if res['status'] is not None: + # Blacklisted tests don't get a version + if res['version'] is None: + res['version'] = '0' + (trigger, src, arch, ver, passed, stamp) = ([res['trigger'], res['package'], res['arch'], res['version'], res['status'] == 'pass', res['run_id']]) + self.remove_from_pending(trigger, src, arch) + self.add_trigger_to_results(trigger, src, ver, arch, stamp, passed) + self.log('Checking if britney\'s pending tests are known to debci') + pending_tests = copy.deepcopy(self.pending_tests) # copy because we may change the content + for trigger in pending_tests: + for package in pending_tests[trigger]: + for arch in pending_tests[trigger][package]: + found = False + for res in test_results['results']: + if res['trigger'] == trigger and res['package'] == package and res['arch'] == arch: + found = True + break + if not found: + self.log('Removing %s for %s on %s from britney\'s pending list as it isn\'t on debci\'s list' % (package, trigger, arch), 'W') + self.remove_from_pending(trigger, package, arch) else: self.log('%s does not exist, no new data will be processed' % debci_file)