handle bugs with no fix committed date

During Mitaka we are planning to change the bug workflow so that the
post merge script moves bugs directly to Fix Released rather than Fix
Committed. That may result in bugs without date_fix_committed set, so we
should also check for date_fix_released.

http://lists.openstack.org/pipermail/openstack-dev/2015-November/079225.html

Change-Id: I04ddf12345bc5cb68cb9e09ba8f50afd507d778c
This commit is contained in:
Doug Hellmann
2015-11-11 14:54:44 +00:00
parent 83efb0a444
commit 4474e97891
4 changed files with 100 additions and 3 deletions

View File

@@ -23,7 +23,7 @@ LOG = logging.getLogger(__name__)
LINK_FIELDS = ['owner', 'assignee']
BUG_FIELDS = ['web_link', 'status', 'title', 'importance']
DATE_FIELDS = ['date_created', 'date_fix_committed']
DATE_FIELDS = ['date_created', 'date_fix_committed', 'date_fix_released']
def _get_bug_id(web_link):

View File

@@ -521,12 +521,22 @@ class RecordProcessor(object):
yield bug_created
FIXED_BUGS = ['Fix Committed', 'Fix Released']
if 'date_fix_committed' in record and record['status'] in FIXED_BUGS:
if (('date_fix_committed' in record or 'date_fix_released' in record)
and record['status'] in FIXED_BUGS):
bug_fixed = record.copy()
bug_fixed['primary_key'] = 'bugr:' + record['id']
bug_fixed['record_type'] = 'bugr'
bug_fixed['launchpad_id'] = record.get('assignee') or '*unassigned'
bug_fixed['date'] = record['date_fix_committed']
# It appears that launchpad automatically sets the
# date_fix_committed field when a bug moves from an open
# state to Fix Released, however it isn't clear that this
# is documented. So, we take the commit date if it is
# present or the release date if no commit date is
# present.
bug_fixed['date'] = (
record['date_fix_committed'] or
record['date_fix_released']
)
self._update_record_and_user(bug_fixed)

View File

@@ -120,6 +120,39 @@ LINKED_BUG = json.loads("""
}
""")
RELEASED_NOT_COMMITTED_BUG = json.loads("""
{
"date_closed": "2015-06-02T17:31:05.820479+00:00",
"date_assigned": "2015-06-02T17:31:44.957976+00:00",
"title": "Bug #1458945 in Sahara: \\\"Use graduated oslo.policy\\\"",
"bug_link": "https://api.launchpad.net/devel/bugs/1458945",
"bug_watch_link": null,
"milestone_link": null,
"date_left_closed": null,
"date_fix_committed": null,
"date_fix_released": "2015-06-02T17:31:05.820479+00:00",
"date_in_progress": "2015-06-02T17:31:05.820479+00:00",
"resource_type_link": "https://api.launchpad.net/devel/#bug_task",
"status": "Fix Released",
"bug_target_name": "sahara",
"importance": "Medium",
"assignee_link": "https://api.launchpad.net/devel/~slukjanov",
"date_triaged": "2015-06-02T17:31:05.820479+00:00",
"self_link": "https://api.launchpad.net/devel/sahara/+bug/1458945",
"target_link": "https://api.launchpad.net/devel/sahara",
"bug_target_display_name": "Sahara",
"related_tasks_collection_link":
"https://api.launchpad.net/devel/sahara/+bug/1458945/related_tasks",
"date_confirmed": "2015-06-02T17:31:05.820479+00:00",
"date_left_new": "2015-06-02T17:31:05.820479+00:00",
"web_link": "https://bugs.launchpad.net/sahara/+bug/1458945",
"owner_link": "https://api.launchpad.net/devel/~samueldmq",
"date_created": "2015-06-02T13:35:54.101235+00:00",
"date_incomplete": null,
"is_complete": true
}
""")
class TestBps(testtools.TestCase):
def setUp(self):
@@ -141,6 +174,32 @@ class TestBps(testtools.TestCase):
'assignee': 'slukjanov',
'date_created': 1433252154,
'date_fix_committed': 1433266265,
'date_fix_released': 1433266265,
'id': 'sahara/1458945',
'importance': 'Medium',
'module': 'sahara',
'owner': 'samueldmq',
'status': 'Fix Released',
'title': 'Bug #1458945 in Sahara: "Use graduated oslo.policy"',
'web_link': 'https://bugs.launchpad.net/sahara/+bug/1458945'
}]
actual = list(bps.log(repo, modified_since))
self.assertEqual(expected, actual)
@mock.patch('stackalytics.processor.launchpad_utils.lp_bug_generator')
def test_log_released_not_committed(self, lp_bug_generator):
repo = {
'module': 'sahara'
}
modified_since = 1234567890
lp_bug_generator.return_value = iter([RELEASED_NOT_COMMITTED_BUG])
expected = [{
'assignee': 'slukjanov',
'date_created': 1433252154,
'date_fix_released': 1433266265,
'id': 'sahara/1458945',
'importance': 'Medium',
'module': 'sahara',
@@ -167,6 +226,7 @@ class TestBps(testtools.TestCase):
'assignee': 'slukjanov',
'date_created': 1433252154,
'date_fix_committed': 1433266265,
'date_fix_released': 1433266265,
'id': 'sahara/1458945',
'importance': 'Medium',
'module': 'sahara',
@@ -193,6 +253,7 @@ class TestBps(testtools.TestCase):
'assignee': 'slukjanov',
'date_created': 1433252154,
'date_fix_committed': 1433266265,
'date_fix_released': 1433266265,
'id': 'sahara/1458945',
'importance': 'Medium',
'module': 'sahara',
@@ -204,6 +265,7 @@ class TestBps(testtools.TestCase):
'assignee': 'slukjanov',
'date_created': 1433252154,
'date_fix_committed': 1433266265,
'date_fix_released': 1433266265,
'id': 'sahara/kilo/1458945',
'importance': 'Medium',
'module': 'sahara',
@@ -236,6 +298,7 @@ class TestBps(testtools.TestCase):
'assignee': 'slukjanov',
'date_created': 1433252154,
'date_fix_committed': 1433266265,
'date_fix_released': 1433266265,
'id': 'savanna/1458945',
'importance': 'Medium',
'module': 'savanna', # should be the same as primary module name

View File

@@ -477,6 +477,7 @@ class TestRecordProcessor(testtools.TestCase):
self.assertRecordsMatch(expected_mark, records[2])
def generate_bugs(self, assignee=None, date_fix_committed=None,
date_fix_released=None,
status='Confirmed'):
yield {
'record_type': 'bug',
@@ -485,6 +486,7 @@ class TestRecordProcessor(testtools.TestCase):
'assignee': assignee,
'date_created': 1234567890,
'date_fix_committed': date_fix_committed,
'date_fix_released': date_fix_released,
'module': 'nova',
'status': status
}
@@ -524,6 +526,7 @@ class TestRecordProcessor(testtools.TestCase):
def test_process_bug_fix_released(self):
record = self.generate_bugs(status='Fix Released',
date_fix_committed=1234567891,
date_fix_released=1234567892,
assignee='assignee')
record_processor_inst = self.make_record_processor()
bugs = list(record_processor_inst.process(record))
@@ -541,6 +544,27 @@ class TestRecordProcessor(testtools.TestCase):
'date': 1234567891,
}, bugs[1])
def test_process_bug_fix_released_without_committed(self):
record = self.generate_bugs(status='Fix Released',
date_fix_committed=None,
date_fix_released=1234567892,
assignee='assignee')
record_processor_inst = self.make_record_processor()
bugs = list(record_processor_inst.process(record))
self.assertEqual(len(bugs), 2)
self.assertRecordsMatch({
'primary_key': 'bugf:bug_id',
'record_type': 'bugf',
'launchpad_id': 'owner',
'date': 1234567890,
}, bugs[0])
self.assertRecordsMatch({
'primary_key': 'bugr:bug_id',
'record_type': 'bugr',
'launchpad_id': 'assignee',
'date': 1234567892,
}, bugs[1])
def test_process_bug_fix_committed_without_assignee(self):
record = self.generate_bugs(status='Fix Committed',
date_fix_committed=1234567891)