示例#1
0
def wipe_metadata():
    """Wipes all metadata. Should only be used during testing. There is no undo.

    Wipes caches as well.
    """
    _get_realm_coll().remove()
    _get_shards_coll().remove()
    _get_cluster_coll().remove()

    _cluster_uri_cache.clear()
    _realm_cache.clear()
    _metadata_stores.clear()
示例#2
0
def wipe_metadata():
    """Wipes all metadata. Should only be used during testing. There is no undo.

    Wipes caches as well.
    """
    _get_realm_coll().remove()
    _get_shards_coll().remove()
    _get_cluster_coll().remove()

    _cluster_uri_cache.clear()
    _realm_cache.clear()
    _metadata_stores.clear()
示例#3
0
def create_indices():
    realm_coll = _get_realm_coll()
    realm_coll.ensure_index([('name', 1)], unique=True)
    realm_coll.ensure_index([('collection', 1)], unique=True)

    shards_coll = _get_shards_coll()
    shards_coll.ensure_index(
        [('realm', 1), ('shard_key', 1)], unique=True)

    cluster_coll = _get_cluster_coll()
    cluster_coll.ensure_index([('name', 1)], unique=True)
示例#4
0
    def test_ensure_cluster_exists(self):
        # Trying to get a none-existent realm should blow up
        with self.assertRaises(Exception) as catcher:
            uri = get_cluster_uri('best-cluster')
        self.assertEquals(catcher.exception.message,
                          'Cluster best-cluster has not been configured')

        ensure_cluster_exists('best-cluster', 'mongodb://localhost:27017')
        uri = get_cluster_uri('best-cluster')
        self.assertEquals('mongodb://localhost:27017', uri)

        # Try creating the cluster again, ensure it doesn't blow up or create a
        # duplicate
        ensure_cluster_exists('best-cluster', 'mongodb://localhost:27017')
        uri = get_cluster_uri('best-cluster')
        self.assertEquals('mongodb://localhost:27017', uri)

        coll = _get_cluster_coll()
        # Two clusters exist due to the base class
        self.assertEquals(3, coll.count())
示例#5
0
    def test_ensure_cluster_exists(self):
        # Trying to get a none-existent realm should blow up
        with self.assertRaises(Exception) as catcher:
            uri = get_cluster_uri('best-cluster')
        self.assertEquals(
            catcher.exception.message,
            'Cluster best-cluster has not been configured')

        ensure_cluster_exists(
            'best-cluster', 'mongodb://localhost:27017')
        uri = get_cluster_uri('best-cluster')
        self.assertEquals('mongodb://localhost:27017', uri)

        # Try creating the cluster again, ensure it doesn't blow up or create a
        # duplicate
        ensure_cluster_exists(
            'best-cluster', 'mongodb://localhost:27017')
        uri = get_cluster_uri('best-cluster')
        self.assertEquals('mongodb://localhost:27017', uri)

        coll = _get_cluster_coll()
        # Two clusters exist due to the base class
        self.assertEquals(3, coll.count())
示例#6
0
def _reset_sharding_info():
    """Wipes all shard info. For internal test use only.
    """
    _get_cluster_coll().remove({})
    _get_realm_coll().remove({})
    _get_shards_coll().remove({})
示例#7
0
def _reset_sharding_info():
    """Wipes all shard info. For internal test use only.
    """
    _get_cluster_coll().remove({})
    _get_realm_coll().remove({})
    _get_shards_coll().remove({})