---
tests/upgradepath/upgradepath.py | 53 ++++++++++++++++++++++++++-----------
1 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/tests/upgradepath/upgradepath.py b/tests/upgradepath/upgradepath.py
index b7527f3..c2f8c92 100755
--- a/tests/upgradepath/upgradepath.py
+++ b/tests/upgradepath/upgradepath.py
@@ -25,6 +25,7 @@ import rpmUtils.miscutils
from autoqa.repoinfo import repoinfo
from autoqa.test import AutoQATest
from autoqa.decorators import ExceptionCatcher
+from autoqa.bodhi_utils import bodhi_post_testresult, query_update
class upgradepath(AutoQATest):
version = 1 # increment if setup() changes
@@ -202,24 +203,44 @@ class upgradepath(AutoQATest):
self.summary = '%s for %s' % (summary, update_id)
- # send results to Bodhi
- print 'Sending results to Bodhi...'
- exc = False
+ # This code simply takes all nvrs (=builds), and creates a dictionary
+ # of update metadata (taken from bodhi).
+ # The variable 'updates' then looks like
+ #
+ # updates = {updatename : bodhi_metadata}
+
+ exc = False # variable to detect presence of builds not-found-in-bodhi
+ updates = {}
for nvr in nvrs:
- result = self.nvr_results[nvr]
- try:
- update = autoqa.bodhi_utils.query_update(nvr)
- assert update is not None, 'No such update object in Bodhi: %s' % nvr
- update_title = update['title']
- print 'Sending results to Bodhi: %s %s' % (update_title, result)
- autoqa.bodhi_utils.bodhi_post_testresult(update_title, 'upgradepath',
- result, self.autotest_url, 'noarch')
- except AssertionError, e:
- msg = 'Failed to send Bodhi results to %s:\n %s' % (nvr, e)
- print msg
- self.outputs.append(msg)
+ bodhi_info = None
+ bodhi_info = query_update(nvr)
+ if bodhi_info is None:
+ print >> sys.stderr, "Update containing %s not found in Bodhi" % nvr
exc = True
- # if assert failed (some Bodhi update doesn't exist), end the test as NEEDS_INSPECTION
+ continue
+
+ if bodhi_info['title'] not in updates.keys():
+ updates[bodhi_info['title']] = bodhi_info
+
+ # Becase bodhi is working on top of updates, we need to check whether
+ # all nvrs (builds) from the respective update were accepted. If at least
+ # one of the nvrs in update was in rejected/ignored set, whole
+ # update is 'failed'.
+
+ update_result = dict() # update_title -> update_result
+ for update in updates.values():
+ update_result[update['title']] = 'PASSED'
+ for build in update['builds']:
+ if self.result_order.index(self.nvr_results[build['nvr']]) > self.result_order.index(update_result[update['title']]):
+ update_result[update['title']] = self.nvr_results[build['nvr']]
+
+ # Report all results to Bodhi
+ for title, result in update_result.items():
+ print "Posting to Bodhi: %s %s" % (title, result)
+ bodhi_post_testresult(title, 'upgradepath', result,
+ self.autotest_url, 'noarch', karma=0)
+
+ # if some Bodhi update doesn't exist, end the test as NEEDS_INSPECTION
if exc and self.result == 'PASSED':
print >> sys.stderr, 'Nonexistent updates found, setting result to NEEDS_INSPECTION'
self.result = 'NEEDS_INSPECTION'
--
1.7.2.3