Example #1
0
    def test_make_sure_old_style_date_directories_are_traversed(self):
        with self._secondary_config_setup().context() as config:
            self.fsrts_old = FSLegacyDatedRadixTreeStorage(config)
        self.fsrts_old._current_slot = lambda: ['00', '00_00']
        # save crash 1 in old system
        self.fsrts_old.save_raw_crash({"test": "TEST"},
                                      MemoryDumpsMapping({
                                          'foo':
                                          'bar',
                                          self.fsrts.config.dump_field:
                                          'baz'
                                      }), self.CRASH_ID_1)
        ok_(
            os.path.exists(
                FS_ROOT +
                '/20071025/date/00/00_00/0bba929f-8721-460c-dead-a43c20071025')
        )

        self.fsrts._current_slot = lambda: ['00', '00_00']
        #save crash 3 in new system
        self._make_test_crash_3()

        ok_(
            os.path.exists(
                FS_ROOT +
                '/25/date/00/00_00/0bba929f-8721-460c-dddd-a43c20071025'))

        # consume crashes
        for x in self.fsrts.new_crashes():
            pass

        # should be consumed because it isn't in our working tree or slot
        ok_(not os.path.exists(
            FS_ROOT +
            '/20071025/date/00/00_00/0bba929f-8721-460c-dead-a43c20071025'))

        # should not be consumed, while in working tree, it is in active slot
        ok_(
            os.path.exists(
                FS_ROOT +
                '/25/date/00/00_00/0bba929f-8721-460c-dddd-a43c20071025'))

        # switch to next active slot
        self.fsrts._current_slot = lambda: ['00', '00_01']

        # consume crashes
        for x in self.fsrts.new_crashes():
            pass

        # should be consumed because it is in working tree and inactive slot
        ok_(not os.path.exists(
            FS_ROOT +
            '/25/date/00/00_00/0bba929f-8721-460c-dddd-a43c20071025'))
 def setUp(self):
     with self._common_config_setup().context() as config:
         self.fsrts = FSLegacyDatedRadixTreeStorage(config)