コード例 #1
0
 def clean(self, resource):
     """See `TestResource`"""
     assert self is resource, "Unknown resource passed to clean()"
     if DEBUG_RESOURCES:
         print "*** Clean %s ***" % self.dbname
     self.tx_manager.abort()
     # Someone committed to the database: clean it up.
     if self.saw_commit:
         store = get_filesync_store()
         for s in reversed(self.schemas):
             s.delete(store)
         transaction.commit()
     watcher = self.get_watcher()
     watcher.unhook(self.dbname, self._notify_change)
     watcher.reset(self.dbname)
     watcher.disable(self.dbname)
コード例 #2
0
    def test__check_stores_and_invalidate(self):
        """Test _check_stores_and_invalidate invalidate case."""
        logger = logging.getLogger('storage.server.noninv')

        h = MementoHandler()
        logger.addHandler(h)

        make_storage_user(1, 'foo', 'foo', 10000)
        store = get_filesync_store()
        self._sto = store  # for later cleanup
        obj = StorageObject(1, 'foo', StorageObject.FILE)
        store.add(obj)
        store.flush()
        self.assertFalse(obj.__storm_object_info__.get("invalidated", False))
        _check_stores_and_invalidate(filesync_zstorm)
        self.assertTrue(obj.__storm_object_info__.get("invalidated", False))
        self.assertEqual(1, len(h.records))
        self.assertEqual((obj,), h.records[0].args)
コード例 #3
0
 def make(self, dependent_resources=None):
     """See `TestResource`"""
     if DEBUG_RESOURCES:
         print "*** Make %s ***" % self.dbname
     watcher = self.get_watcher()
     watcher.enable(self.dbname)
     if self.schemas is None:
         self.schemas = [s.create_schema() for s in self.schema_modules]
     store = get_filesync_store()
     transaction.abort()
     for s in self.schemas:
         s.upgrade(store)
     transaction.commit()
     transaction.begin()
     for s in reversed(self.schemas):
         s.delete(store)
     transaction.commit()
     self.saw_commit = False
     watcher.hook(self.dbname, self._notify_change)
     watcher.reset(self.dbname)
     return self
コード例 #4
0
 def test_get_filesync_store(self):
     """Test get_filesync_store returns the expected store."""
     db = store.get_filesync_store('shard0').get_database()
     self.assertTrue(isinstance(db, store.FilesyncDatabase))
     self.assertEqual('shard0', db.name)
コード例 #5
0
def get_storage_store():
    """Return the default storage store.

    This is primarily for legacy tests while transaction handling is migrated
    """
    return get_filesync_store('storage')
コード例 #6
0
def get_user_store():
    """Get the main storage store."""
    return get_filesync_store('storage')
コード例 #7
0
def get_shard_store(shard_id):
    """Return the Storm.Store for the given shard_id"""
    try:
        return get_filesync_store(shard_id)
    except KeyError:
        raise InvalidShardId("Invalid Shard ID: %s" % shard_id)
コード例 #8
0
 def test_get_filesync_store(self):
     """Test get_filesync_store returns the expected store."""
     db = store.get_filesync_store('shard0').get_database()
     self.assertTrue(isinstance(db, store.FilesyncDatabase))
     self.assertEqual('shard0', db.name)
コード例 #9
0
def delete_all_data():
    """Delete all data from the database."""
    # they must be reversed to avoid dependency issues
    storage().delete(get_filesync_store())
コード例 #10
0
def get_storage_store():
    """Return the default storage store.

    This is primarily for legacy tests while transaction handling is migrated
    """
    return get_filesync_store('storage')
コード例 #11
0
def get_user_store():
    """Get the main storage store."""
    return get_filesync_store('storage')
コード例 #12
0
def get_shard_store(shard_id):
    """Return the Storm.Store for the given shard_id"""
    try:
        return get_filesync_store(shard_id)
    except KeyError:
        raise InvalidShardId("Invalid Shard ID: %s" % shard_id)