Skip to content

Commit

Permalink
bug 1481696: add processor rule to fix Focus crashes
Browse files Browse the repository at this point in the history
This reworks the ProductRewrite rule so it logs what it did in the crash
report better. It also adjusts the rule to act as a "this is where we're
going to do all the product rewriting" place.

This adds product rewriting logic for Focus GV. That's using GeckoView,
but incoming crash reports are using ProductName=Fennec. So the ProductRewrite
rule was convering those to FennecAndroid. This will then convert it to
Focus if the ProcessType=content.

We should remove this as soon as we can, but it'll fix an existing issue
we have right now.
  • Loading branch information
willkg committed Aug 16, 2018
1 parent 5c57039 commit 93f2bc7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 22 deletions.
33 changes: 25 additions & 8 deletions socorro/processor/mozilla_transform_rules.py
Expand Up @@ -351,8 +351,10 @@ def _action(self, raw_crash, raw_dumps, processed_crash, processor_meta):


class ProductRewrite(Rule):
"""This rule rewrites the product name for products that fail to report
a useful product name
"""Fix ProductName in raw crash for certain situations
NOTE(willkg): This changes the raw crash which is gross.
"""

PRODUCT_MAP = {
Expand All @@ -363,14 +365,29 @@ def version(self):
return '2.0'

def _predicate(self, raw_crash, raw_dumps, processed_crash, proc_meta):
return raw_crash.get('ProductID') in self.PRODUCT_MAP
return True

def _action(self, raw_crash, raw_dumps, processed_crash, processor_meta):
new_name = self.PRODUCT_MAP[raw_crash['ProductID']]
processor_meta.processor_notes.append(
'Rewriting ProductName from %r to %r' % (raw_crash.get('ProductName'), new_name)
)
raw_crash['ProductName'] = new_name
product_name = raw_crash.get('ProductName', '')
original_product_name = product_name

# Rewrite from PRODUCT_MAP fixes.
if raw_crash.get('ProductID', '') in self.PRODUCT_MAP:
product_name = self.PRODUCT_MAP[raw_crash['ProductID']]

# Rewrite Focus crashes (bug #1481696).
if product_name == 'FennecAndroid' and raw_crash.get('ProcessType', '') == 'content':
product_name = 'Focus'

# If we made any product name changes, persist them and keep the
# original one so we can look at things later
if product_name != original_product_name:
processor_meta.processor_notes.append(
'Rewriting ProductName from %r to %r' % (original_product_name, product_name)
)
raw_crash['ProductName'] = product_name
raw_crash['OriginalProductName'] = original_product_name

return True


Expand Down
32 changes: 18 additions & 14 deletions socorro/unittest/processor/test_mozilla_transform_rules.py
Expand Up @@ -870,43 +870,47 @@ def test_this_is_not_the_crash_you_are_looking_for(self):
assert 'memory_report' not in processed_crash


class TestProductRewrite(TestCase):
def test_everything_we_hoped_for(self):
class TestProductRewriteRule(TestCase):
def test_product_map_rewrite(self):
config = get_basic_config()

raw_crash = copy.copy(canonical_standard_raw_crash)
raw_crash['ProductName'] = 'Fennec'
raw_crash['ProductID'] = '{aa3c5121-dab2-40e2-81ca-7ea25febc110}'
raw_dumps = {}
processed_crash = DotDict()
processor_meta = get_basic_processor_meta()

rule = ProductRewrite(config)

# the call to be tested
rule.act(raw_crash, raw_dumps, processed_crash, processor_meta)
rule.act(raw_crash, {}, processed_crash, processor_meta)

assert raw_crash.ProductName == 'FennecAndroid'
assert raw_crash.OriginalProductName == 'Fennec'

# processed_crash should be unchanged
assert processed_crash == DotDict()
assert processor_meta.processor_notes == [
"Rewriting ProductName from 'Fennec' to 'FennecAndroid'"
]

def test_this_is_not_the_crash_you_are_looking_for(self):
def test_focus_rewrite(self):
config = get_basic_config()

raw_crash = copy.copy(canonical_standard_raw_crash)
raw_dumps = {}
raw_crash['ProductName'] = 'Fennec'
raw_crash['ProductID'] = '{aa3c5121-dab2-40e2-81ca-7ea25febc110}'
raw_crash['ProcessType'] = 'content'
processed_crash = DotDict()
processor_meta = get_basic_processor_meta()

rule = ProductRewrite(config)
rule.act(raw_crash, {}, processed_crash, processor_meta)

# the call to be tested
rule.act(raw_crash, raw_dumps, processed_crash, processor_meta)

assert raw_crash.ProductName == 'Firefox'
assert raw_crash.ProductName == 'Focus'
assert raw_crash.OriginalProductName == 'Fennec'

# processed_crash should be unchanged
assert processed_crash == DotDict()
assert processor_meta.processor_notes == [
"Rewriting ProductName from 'Fennec' to 'Focus'"
]


class TestESRVersionRewrite(TestCase):
Expand Down

0 comments on commit 93f2bc7

Please sign in to comment.