Skip to content
This repository has been archived by the owner on Feb 1, 2018. It is now read-only.

bug 865481 - CrashPairsByCrashId and report/index with HangID #327

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
100 changes: 100 additions & 0 deletions crashstats/crashstats/tests/test_views.py
Expand Up @@ -1892,6 +1892,106 @@ def mocked_post(url, **options):
ok_(url0 in response.content)
eq_(response.status_code, 200)

@mock.patch('requests.post')
@mock.patch('requests.get')
def test_report_index_with_hangid_in_raw_data(self, rget, rpost):
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod"
comment0 = "This is a comment"
email0 = "some@emailaddress.com"
url0 = "someaddress.com"
email1 = "some@otheremailaddress.com"

def mocked_get(url, **options):
if '/crash_data/' in url and '/datatype/meta/' in url:
return Response("""
{
"InstallTime": "1339289895",
"FramePoisonSize": "4096",
"Theme": "classic/1.0",
"Version": "5.0a1",
"Email": "%s",
"Vendor": "Mozilla",
"URL": "%s",
"HangID": "123456789"
}
""" % (email0, url0))
if '/crashes/paireduuid/' in url:
return Response("""
{
"hits": [{
"uuid": "e8820616-1462-49b6-9784-e99a32120201"
}],
"total": 1
}
""")
if 'crashes/comments' in url:
return Response("""
{
"hits": [
{
"user_comments": "%s",
"date_processed": "2012-08-21T11:17:28-07:00",
"email": "%s",
"uuid": "469bde48-0e8f-3586-d486-b98810120830"
}
],
"total": 1
}
""" % (comment0, email1))

if '/crash_data/' in url and '/datatype/processed' in url:
return Response("""
{
"client_crash_date": "2012-06-11T06:08:45",
"dump": "%s",
"signature": "FakeSignature1",
"user_comments": null,
"uptime": 14693,
"release_channel": "nightly",
"uuid": "11cb72f5-eb28-41e1-a8e4-849982120611",
"flash_version": "[blank]",
"hangid": null,
"distributor_version": null,
"truncated": true,
"process_type": null,
"id": 383569625,
"os_version": "10.6.8 10K549",
"version": "5.0a1",
"build": "20120609030536",
"ReleaseChannel": "nightly",
"addons_checked": null,
"product": "WaterWolf",
"os_name": "Mac OS X",
"last_crash": 371342,
"date_processed": "2012-06-11T06:08:44",
"cpu_name": "amd64",
"reason": "EXC_BAD_ACCESS / KERN_INVALID_ADDRESS",
"address": "0x8",
"completeddatetime": "2012-06-11T06:08:57",
"success": true
}
""" % dump)

raise NotImplementedError(url)
rget.side_effect = mocked_get

def mocked_post(url, **options):
if '/bugs/' in url:
return Response("""
{"hits": [{"id": "123456789",
"signature": "Something"}]}
""")
raise NotImplementedError(url)

rpost.side_effect = mocked_post

url = reverse('crashstats.report_index',
args=['11cb72f5-eb28-41e1-a8e4-849982120611'])
response = self.client.get(url)
ok_('Hang Minidump' in response.content)
# the HangID in the fixture above
ok_('123456789' in response.content)

@mock.patch('requests.get')
def test_report_index_not_found(self, rget):
crash_id = '11cb72f5-eb28-41e1-a8e4-849982120611'
Expand Down
5 changes: 2 additions & 3 deletions crashstats/crashstats/views.py
Expand Up @@ -835,11 +835,10 @@ def report_index(request, crash_id):

if 'HangID' in data['raw']:
data['hang_id'] = data['raw']['HangID']

crash_pair_api = models.CrashPairsByCrashId()
data['crash_pairs'] = crash_pair_api.get(
data['report']['uuid'],
data['hang_id']
crash_id=data['report']['uuid'],
hang_id=data['hang_id']
)

data['raw_dump_urls'] = [
Expand Down