def test_external_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 = ExternalProcessRule(config)

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

        eq_(processed_crash.bogus_command_result, {})
        eq_(processed_crash.bogus_command_return_code, -1)
        eq_(
            processor_meta.processor_notes,
            [
                'bogus_command output failed in '
                'json: Expected String or Unicode',
            ]
        )
    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_external_output_str)
        mocked_subprocess_handle.wait.return_value = 0

        rule = ExternalProcessRule(config)

        # the call to be tested
        rule.act(raw_crash, raw_dumps, processed_crash, processor_meta)
        mocked_subprocess_module.Popen.assert_called_with(
            'timeout -s KILL 30 bogus_command a_fake_dump.dump '
            '/mnt/socorro/symbols/symbols_ffx,/mnt/socorro/symbols/'
            'symbols_sea,/mnt/socorro/symbols/symbols_tbrd,/mnt/socorro/'
            'symbols/symbols_sbrd,/mnt/socorro/symbols/symbols_os'
            ' 2>/dev/null',
            shell=True,
            stdout=mocked_subprocess_module.PIPE)

        assert processed_crash.bogus_command_result == cannonical_external_output

        assert processed_crash.bogus_command_return_code == 0
    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_external_output_str
        )
        mocked_subprocess_handle.wait.return_value = 0

        rule = ExternalProcessRule(config)

        # the call to be tested
        rule.act(raw_crash, raw_dumps, processed_crash, processor_meta)
        mocked_subprocess_module.Popen.assert_called_with(
            'timeout -s KILL 30 bogus_command a_fake_dump.dump '
            '/mnt/socorro/symbols/symbols_ffx,/mnt/socorro/symbols/'
            'symbols_sea,/mnt/socorro/symbols/symbols_tbrd,/mnt/socorro/'
            'symbols/symbols_sbrd,/mnt/socorro/symbols/symbols_os'
            ' 2>/dev/null',
            shell=True,
            stdout=mocked_subprocess_module.PIPE
        )

        eq_(
            processed_crash.bogus_command_result,
            cannonical_external_output
        )
        eq_(processed_crash.bogus_command_return_code, 0)
    def test_external_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 = ExternalProcessRule(config)

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

        assert processed_crash.bogus_command_result == {}
        assert processed_crash.bogus_command_return_code == -1
        expected = [
            'bogus_command output failed in '
            'json: Expected String or Unicode',
        ]
        assert processor_meta.processor_notes == expected
Beispiel #5
0
    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_external_output_str
        mocked_subprocess_handle.wait.return_value = 0

        rule = ExternalProcessRule(config)

        # the call to be tested
        rule.act(raw_crash, raw_dumps, processed_crash, processor_meta)
        mocked_subprocess_module.Popen.assert_called_with(
            [
                'timeout', '-s', 'KILL', '30',
                'bogus_command',
                'a_fake_dump.dump',
                '/mnt/socorro/symbols/symbols_ffx,/mnt/socorro/symbols/symbols_sea,/mnt/socorro/symbols/symbols_tbrd,/mnt/socorro/symbols/symbols_sbrd,/mnt/socorro/symbols/symbols_os'  # noqa
            ],
            stderr=mocked_subprocess_module.DEVNULL,
            stdout=mocked_subprocess_module.PIPE
        )

        assert processed_crash.bogus_command_result == canonical_external_output
        assert processed_crash.bogus_command_return_code == 0
Beispiel #6
0
    def test_external_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 = '{}'
        mocked_subprocess_handle.wait.return_value = 124

        rule = ExternalProcessRule(config)
        rule.act(raw_crash, raw_dumps, processed_crash, processor_meta)

        assert processed_crash.bogus_command_result == {}
        assert processed_crash.bogus_command_return_code == 124
        assert processor_meta.processor_notes == []
    def test_external_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 data will fail in json.loads and throw an error
        mocked_subprocess_handle.stdout.read.return_value = '{ff'
        mocked_subprocess_handle.wait.return_value = -1

        rule = ExternalProcessRule(config)
        rule.act(raw_crash, raw_dumps, processed_crash, processor_meta)

        assert processed_crash.bogus_command_result == {}
        assert processed_crash.bogus_command_return_code == -1
        assert ('bogus_command output failed in json: Expecting property name'
                in processor_meta.processor_notes[0])
    def test_external_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 data will fail in json.loads and throw an error
        mocked_subprocess_handle.stdout.read.return_value = '{ff'
        mocked_subprocess_handle.wait.return_value = -1

        rule = ExternalProcessRule(config)
        rule.act(raw_crash, raw_dumps, processed_crash, processor_meta)

        assert processed_crash.bogus_command_result == {}
        assert processed_crash.bogus_command_return_code == -1
        assert (
            'bogus_command output failed in json: Expecting property name'
            in processor_meta.processor_notes[0]
        )
    def test_dot_save(self):
        d = {}
        ExternalProcessRule.dot_save(d, 'x', 1)
        ok_(d['x'], 1)

        ExternalProcessRule.dot_save(d, 'z.y', 10)
        ok_(d['z']['y'], 10)

        d['a'] = {}
        d['a']['b'] = {}
        ExternalProcessRule.dot_save(d, 'a.b.c', 100)
        ok_(d['a']['b']['c'], 100)

        dd = CDotDict()
        ExternalProcessRule.dot_save(dd, 'a.b.c.d.e.f', 1000)
        ok_(dd.a.b.c.d.e.f, 1000)
    def test_dot_save(self):
        d = {}
        ExternalProcessRule.dot_save(d, 'x', 1)
        assert d['x'] == 1

        ExternalProcessRule.dot_save(d, 'z.y', 10)
        assert d['z']['y'] == 10

        d['a'] = {}
        d['a']['b'] = {}
        ExternalProcessRule.dot_save(d, 'a.b.c', 100)
        assert d['a']['b']['c'] == 100

        dd = CDotDict()
        ExternalProcessRule.dot_save(dd, 'a.b.c.d.e.f', 1000)
        assert dd.a.b.c.d.e.f == 1000
    def test_dot_save(self):
        d = {}
        ExternalProcessRule.dot_save(d, 'x', 1)
        assert d['x'] == 1

        ExternalProcessRule.dot_save(d, 'z.y', 10)
        assert d['z']['y'] == 10

        d['a'] = {}
        d['a']['b'] = {}
        ExternalProcessRule.dot_save(d, 'a.b.c', 100)
        assert d['a']['b']['c'] == 100

        dd = DotDict()
        ExternalProcessRule.dot_save(dd, 'a.b.c.d.e.f', 1000)
        assert dd.a.b.c.d.e.f == 1000
    def test_dot_save(self):
        d = {}
        ExternalProcessRule.dot_save(d, 'x', 1)
        ok_(d['x'], 1)

        ExternalProcessRule.dot_save(d, 'z.y', 10)
        ok_(d['z']['y'], 10)

        d['a'] = {}
        d['a']['b'] = {}
        ExternalProcessRule.dot_save(d, 'a.b.c', 100)
        ok_(d['a']['b']['c'], 100)

        dd = CDotDict()
        ExternalProcessRule.dot_save(dd, 'a.b.c.d.e.f', 1000)
        ok_(dd.a.b.c.d.e.f, 1000)