def test_stackwalker_fails_2(self, mocked_subprocess_module): config = self.get_basic_config() raw_crash = copy.copy(canonical_standard_raw_crash) raw_dumps = {config.dump_field: 'a_fake_dump.dump'} processed_crash = DotDict() processor_meta = self.get_basic_processor_meta() mocked_subprocess_handle = ( mocked_subprocess_module.Popen.return_value) mocked_subprocess_handle.stdout.read.return_value = int mocked_subprocess_handle.wait.return_value = -1 rule = BreakpadStackwalkerRule2015(config) # the call to be tested rule.act(raw_crash, raw_dumps, processed_crash, processor_meta) assert processed_crash.json_dump == {} assert processed_crash.mdsw_return_code == -1 assert processed_crash.mdsw_status_string == "unknown error" assert not processed_crash.success command_line = rule.expand_commandline( dump_file_pathname='a_fake_dump.dump', raw_crash_pathname= ('/tmp/00000000-0000-0000-0000-000002140504.MainThread.TEMPORARY.json' )) expected = [ '%s output failed in json: Expected String or Unicode' % config.command_pathname, 'MDSW failed on \'%s\': unknown error' % command_line ] assert processor_meta.processor_notes == expected
def test_stackwalker_fails_2(self, mocked_subprocess_module): config = self.get_basic_config() raw_crash = copy.copy(canonical_standard_raw_crash) raw_dumps = { config.dump_field: 'a_fake_dump.dump' } processed_crash = DotDict() processor_meta = get_basic_processor_meta() mocked_subprocess_handle = mocked_subprocess_module.Popen.return_value # This will cause json.loads to throw an error mocked_subprocess_handle.stdout.read.return_value = '{ff' mocked_subprocess_handle.wait.return_value = -1 rule = BreakpadStackwalkerRule2015(config) rule.act(raw_crash, raw_dumps, processed_crash, processor_meta) assert processed_crash.json_dump == {} assert processed_crash.mdsw_return_code == -1 assert processed_crash.mdsw_status_string == "unknown error" assert not processed_crash.success assert ( config.command_pathname + ' output failed in json: Expecting property name' in processor_meta.processor_notes[0] ) assert ( processor_meta.processor_notes[1] == 'MDSW failed with -1: unknown error' )
def test_stackwalker_fails(self, mocked_subprocess_module): config = self.get_basic_config() raw_crash = copy.copy(canonical_standard_raw_crash) raw_dumps = {config.dump_field: 'a_fake_dump.dump'} processed_crash = DotDict() processor_meta = self.get_basic_processor_meta() mocked_subprocess_handle = \ mocked_subprocess_module.Popen.return_value mocked_subprocess_handle.stdout.read.return_value = '{}\n' mocked_subprocess_handle.wait.return_value = 124 rule = BreakpadStackwalkerRule2015(config) # the call to be tested rule.act(raw_crash, raw_dumps, processed_crash, processor_meta) assert processed_crash.json_dump == {} assert processed_crash.mdsw_return_code == 124 assert processed_crash.mdsw_status_string == "unknown error" assert not processed_crash.success assert processor_meta.processor_notes == [ "MDSW terminated with SIGKILL due to timeout" ]
def test_stackwalker_fails(self, mocked_subprocess_module): config = self.get_basic_config() raw_crash = copy.copy(canonical_standard_raw_crash) raw_dumps = {config.dump_field: 'a_fake_dump.dump'} processed_crash = DotDict() processor_meta = get_basic_processor_meta() mocked_subprocess_handle = mocked_subprocess_module.Popen.return_value mocked_subprocess_handle.stdout.read.return_value = '{}\n' mocked_subprocess_handle.wait.return_value = 124 with MetricsMock() as mm: rule = BreakpadStackwalkerRule2015(config) rule.act(raw_crash, raw_dumps, processed_crash, processor_meta) assert processed_crash.json_dump == {} assert processed_crash.mdsw_return_code == 124 assert processed_crash.mdsw_status_string == 'unknown error' assert processed_crash.success is False assert processor_meta.processor_notes == ['MDSW timeout (SIGKILL)'] assert mm.has_record( 'incr', stat='processor.breakpadstackwalkerrule.run', value=1, tags=['outcome:fail', 'exitcode:124'] )
def test_everything_we_hoped_for(self, mocked_subprocess_module): config = self.get_basic_config() raw_crash = copy.copy(canonical_standard_raw_crash) raw_dumps = {config.dump_field: 'a_fake_dump.dump'} processed_crash = DotDict() processor_meta = get_basic_processor_meta() mocked_subprocess_handle = mocked_subprocess_module.Popen.return_value mocked_subprocess_handle.stdout.read.return_value = canonical_stackwalker_output_str mocked_subprocess_handle.wait.return_value = 0 with MetricsMock() as mm: rule = BreakpadStackwalkerRule2015(config) rule.act(raw_crash, raw_dumps, processed_crash, processor_meta) assert processed_crash.json_dump == canonical_stackwalker_output assert processed_crash.mdsw_return_code == 0 assert processed_crash.mdsw_status_string == "OK" assert processed_crash.success is True assert mm.has_record( 'incr', stat='processor.breakpadstackwalkerrule.run', value=1, tags=['outcome:success', 'exitcode:0'] )
def test_stackwalker_fails_2(self, mocked_subprocess_module): config = self.get_basic_config() raw_crash = copy.copy(canonical_standard_raw_crash) raw_dumps = {config.dump_field: 'a_fake_dump.dump'} processed_crash = DotDict() processor_meta = self.get_basic_processor_meta() mocked_subprocess_handle = ( mocked_subprocess_module.Popen.return_value) mocked_subprocess_handle.stdout.read.return_value = int mocked_subprocess_handle.wait.return_value = -1 rule = BreakpadStackwalkerRule2015(config) # the call to be tested rule.act(raw_crash, raw_dumps, processed_crash, processor_meta) eq_(processed_crash.json_dump, {}) eq_(processed_crash.mdsw_return_code, -1) eq_(processed_crash.mdsw_status_string, "unknown error") ok_(not processed_crash.success) eq_(processor_meta.processor_notes, [ "{command_pathname} output failed in json: Expected String " "or Unicode".format(**config), "MDSW failed on 'timeout -s KILL 30 /bin/stackwalker " "--raw-json /tmp/00000000-0000-0000-0000-000002140504." "MainThread.TEMPORARY.json --symbols-url https://localhost " "--symbols-url https://localhost " "--symbols-cache /mnt/socorro/symbols a_fake_dump.dump " "2>/dev/null': unknown error" ])
def test_everything_we_hoped_for(self, mocked_subprocess_module): config = self.get_basic_config() raw_crash = copy.copy(canonical_standard_raw_crash) raw_dumps = {config.dump_field: 'a_fake_dump.dump'} processed_crash = DotDict() processor_meta = self.get_basic_processor_meta() mocked_subprocess_handle = ( mocked_subprocess_module.Popen.return_value ) mocked_subprocess_handle.stdout.read.return_value = ( cannonical_stackwalker_output_str ) mocked_subprocess_handle.wait.return_value = 0 rule = BreakpadStackwalkerRule2015(config) # the call to be tested rule.act(raw_crash, raw_dumps, processed_crash, processor_meta) eq_(processed_crash.json_dump, cannonical_stackwalker_output) eq_(processed_crash.mdsw_return_code, 0) eq_(processed_crash.mdsw_status_string, "OK") ok_(processed_crash.success)
def test_temp_file_context(self, mocked_unlink): config = self.get_basic_config() rule = BreakpadStackwalkerRule2015(config) with rule._temp_raw_crash_json_file('foo.json', example_uuid): pass mocked_unlink.assert_called_once_with('/tmp/%s.MainThread.TEMPORARY.json' % example_uuid) mocked_unlink.reset_mock() try: with rule._temp_raw_crash_json_file('foo.json', example_uuid): raise KeyError('oops') except KeyError: pass mocked_unlink.assert_called_once_with('/tmp/%s.MainThread.TEMPORARY.json' % example_uuid) mocked_unlink.reset_mock()