Beispiel #1
0
    def _common_throttle_test(self, config, crashstorage):
        fake_dump = 'this is a fake dump'
        crashstorage = FileSystemThrottledCrashStorage(config)
        self.assertEqual(list(crashstorage.new_crashes()), [])
        raw = {"name": "Peter", "legacy_processing": 1}
        self.assertRaises(
          CrashIDNotFound,
          crashstorage.save_raw_crash,
          raw,
          fake_dump  # as a stand in for the binary dump file
        )
        raw = {"name": "Peter",
               #"ooid":"114559a5-d8e6-428c-8b88-1c1f22120314",
               "legacy_processing": 1}
        crashstorage.save_raw_crash(
          raw,
          fake_dump,
          "114559a5-d8e6-428c-8b88-1c1f22120314"
        )
        self.assertTrue(
          os.path.exists(
            crashstorage.def_crash_store.getJson(
                '114559a5-d8e6-428c-8b88-1c1f22120314')))
        self.assertTrue(
          os.path.exists(
            crashstorage.def_crash_store.getDump(
                '114559a5-d8e6-428c-8b88-1c1f22120314')))
        self.assertRaises(OSError,
                          crashstorage.std_crash_store.getJson,
                          '114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertRaises(OSError,
                          crashstorage.std_crash_store.getDump,
                          '114559a5-d8e6-428c-8b88-1c1f22120314')

        meta = crashstorage.get_raw_crash(
          '114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertTrue(isinstance(meta, DotDict))
        self.assertEqual(meta['name'], 'Peter')

        dump = crashstorage.get_raw_dump(
          '114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertTrue(isinstance(dump, basestring))
        self.assertTrue("fake dump" in dump)

        crashstorage.remove('114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertRaises(OSError,
                          crashstorage.def_crash_store.getJson,
                          '114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertRaises(OSError,
                          crashstorage.def_crash_store.getDump,
                          '114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertRaises(OSError,
                          crashstorage.std_crash_store.getJson,
                          '114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertRaises(OSError,
                          crashstorage.std_crash_store.getDump,
                          '114559a5-d8e6-428c-8b88-1c1f22120314')
Beispiel #2
0
    def _common_throttle_test(self, config, crashstorage):
        fake_dump = 'this is a fake dump'
        crashstorage = FileSystemThrottledCrashStorage(config)
        eq_(list(crashstorage.new_crashes()), [])
        raw = {
            "name": "Peter",
            "legacy_processing": 1,
            "submitted_timestamp": '2012-05-04 15:10:33'
        }
        crashstorage.save_raw_crash(raw, fake_dump,
                                    "114559a5-d8e6-428c-8b88-1c1f22120314")

        fake_dumps = {None: 'this is a fake dump', 'aux01': 'aux01 fake dump'}
        raw = {
            "name": "Lars",
            "legacy_processing": 0,
            "submitted_timestamp": '2012-05-04 15:10:33'
        }
        crashstorage.save_raw_crash(raw, fake_dumps,
                                    "114559a5-d8e6-428c-8b88-1c1f22120504")
        eq_(list(crashstorage.new_crashes()), [
            "114559a5-d8e6-428c-8b88-1c1f22120504",
        ])

        ok_(
            os.path.exists(
                crashstorage.def_crash_store.getJson(
                    '114559a5-d8e6-428c-8b88-1c1f22120314')))
        ok_(
            os.path.exists(
                crashstorage.def_crash_store.getDump(
                    '114559a5-d8e6-428c-8b88-1c1f22120314')))
        assert_raises(OSError, crashstorage.std_crash_store.getJson,
                      '114559a5-d8e6-428c-8b88-1c1f22120314')
        assert_raises(OSError, crashstorage.std_crash_store.getDump,
                      '114559a5-d8e6-428c-8b88-1c1f22120314')

        meta = crashstorage.get_raw_crash(
            '114559a5-d8e6-428c-8b88-1c1f22120314')
        ok_(isinstance(meta, DotDict))
        eq_(meta['name'], 'Peter')

        dump = crashstorage.get_raw_dump(
            '114559a5-d8e6-428c-8b88-1c1f22120314')
        ok_(isinstance(dump, basestring))
        ok_("fake dump" in dump)

        crashstorage.remove('114559a5-d8e6-428c-8b88-1c1f22120314')
        assert_raises(OSError, crashstorage.def_crash_store.getJson,
                      '114559a5-d8e6-428c-8b88-1c1f22120314')
        assert_raises(OSError, crashstorage.def_crash_store.getDump,
                      '114559a5-d8e6-428c-8b88-1c1f22120314')
        assert_raises(OSError, crashstorage.std_crash_store.getJson,
                      '114559a5-d8e6-428c-8b88-1c1f22120314')
        assert_raises(OSError, crashstorage.std_crash_store.getDump,
                      '114559a5-d8e6-428c-8b88-1c1f22120314')
Beispiel #3
0
    def _common_throttle_test(self, config, crashstorage):
        fake_dump = 'this is a fake dump'
        crashstorage = FileSystemThrottledCrashStorage(config)
        self.assertEqual(list(crashstorage.new_crashes()), [])
        raw = {"name": "Peter",
               "legacy_processing": 1,
               "submitted_timestamp": '2012-05-04 15:10:33'}
        crashstorage.save_raw_crash(
          raw,
          fake_dump,
          "114559a5-d8e6-428c-8b88-1c1f22120314"
        )

        fake_dumps = {None: 'this is a fake dump', 'aux01': 'aux01 fake dump'}
        raw = {"name": "Lars",
               "legacy_processing": 0,
               "submitted_timestamp": '2012-05-04 15:10:33'}
        crashstorage.save_raw_crash(
          raw,
          fake_dumps,
          "114559a5-d8e6-428c-8b88-1c1f22120504"
        )
        self.assertEqual(list(crashstorage.new_crashes()),
                         ["114559a5-d8e6-428c-8b88-1c1f22120504",])

        self.assertTrue(
          os.path.exists(
            crashstorage.def_crash_store.getJson(
                '114559a5-d8e6-428c-8b88-1c1f22120314')))
        self.assertTrue(
          os.path.exists(
            crashstorage.def_crash_store.getDump(
                '114559a5-d8e6-428c-8b88-1c1f22120314')))
        self.assertRaises(OSError,
                          crashstorage.std_crash_store.getJson,
                          '114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertRaises(OSError,
                          crashstorage.std_crash_store.getDump,
                          '114559a5-d8e6-428c-8b88-1c1f22120314')

        meta = crashstorage.get_raw_crash(
          '114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertTrue(isinstance(meta, DotDict))
        self.assertEqual(meta['name'], 'Peter')

        dump = crashstorage.get_raw_dump(
          '114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertTrue(isinstance(dump, basestring))
        self.assertTrue("fake dump" in dump)

        crashstorage.remove('114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertRaises(OSError,
                          crashstorage.def_crash_store.getJson,
                          '114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertRaises(OSError,
                          crashstorage.def_crash_store.getDump,
                          '114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertRaises(OSError,
                          crashstorage.std_crash_store.getJson,
                          '114559a5-d8e6-428c-8b88-1c1f22120314')
        self.assertRaises(OSError,
                          crashstorage.std_crash_store.getDump,
                          '114559a5-d8e6-428c-8b88-1c1f22120314')