From 30b7c43f246d3436c96f17ce9116ea55e0e5b971 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Thu, 21 Aug 2014 23:39:24 -0700 Subject: [PATCH] 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 --- elastic_recheck/elasticRecheck.py | 4 ++-- elastic_recheck/tests/unit/test_bot.py | 10 +++++----- elastic_recheck/tests/unit/test_stream.py | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/elastic_recheck/elasticRecheck.py b/elastic_recheck/elasticRecheck.py index 037026a1..bc28d53d 100644 --- a/elastic_recheck/elasticRecheck.py +++ b/elastic_recheck/elasticRecheck.py @@ -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: diff --git a/elastic_recheck/tests/unit/test_bot.py b/elastic_recheck/tests/unit/test_bot.py index c85669fa..9a96613a 100644 --- a/elastic_recheck/tests/unit/test_bot.py +++ b/elastic_recheck/tests/unit/test_bot.py @@ -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 diff --git a/elastic_recheck/tests/unit/test_stream.py b/elastic_recheck/tests/unit/test_stream.py index 9944aad9..696a7daa 100644 --- a/elastic_recheck/tests/unit/test_stream.py +++ b/elastic_recheck/tests/unit/test_stream.py @@ -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'])