Sort the gerrit failed event bug urls map for predictive tests

The bug_urls_map method is actually returning a list so just sort the
list and fix the tests that are racing due to random hashseed issues
with the dict.

This also updates the docstring which was incorrect before.

Related-Bug: #1348818

Change-Id: I13ca69b3e685083d4ced2b054e0d42a440259854
This commit is contained in:
Matt Riedemann 2014-08-21 23:39:24 -07:00
parent 3223d5fced
commit 30b7c43f24
3 changed files with 10 additions and 10 deletions

View File

@ -137,7 +137,7 @@ class FailEvent(object):
return "- " + "\n- ".join(self.bug_urls_map())
def bug_urls_map(self):
"""Produce map of which jobs failed due to which bugs."""
"""Produce sorted list of which jobs failed due to which bugs."""
if not self.get_all_bugs():
return None
bug_map = {}
@ -152,7 +152,7 @@ class FailEvent(object):
bug_list.append("%s: unrecognized error" % job)
else:
bug_list.append("%s: %s" % (job, bug_map[job]))
return bug_list
return sorted(bug_list)
def is_fully_classified(self):
if self.get_all_bugs() is None:

View File

@ -108,11 +108,11 @@ class TestBotWithTestTools(tests.TestCase):
def fake_print(self, channel, msg):
reference = ("openstack/keystone change: https://review.openstack.org/"
"64750 failed because of: gate-keystone-python27: "
"unrecognized error", "gate-keystone-python2"
"6: https://bugs.launchpad.net/bugs/123456")
for ref in reference:
self.assertIn(ref, msg)
"64750 failed because of: "
"gate-keystone-python26: "
"https://bugs.launchpad.net/bugs/123456, "
"gate-keystone-python27: unrecognized error")
self.assertEqual(reference, msg)
def fake_display(self, channel, msg):
return True

View File

@ -180,9 +180,9 @@ class TestStream(tests.TestCase):
self.assertEqual(event.bug_urls(),
['https://bugs.launchpad.net/bugs/123456'])
self.assertEqual(event.bug_urls_map(),
['gate-keystone-python27: unrecognized error',
'gate-keystone-python26: '
'https://bugs.launchpad.net/bugs/123456'])
['gate-keystone-python26: '
'https://bugs.launchpad.net/bugs/123456',
'gate-keystone-python27: unrecognized error'])
self.assertEqual(sorted(event.failed_job_names()),
['gate-keystone-python26',
'gate-keystone-python27'])