示例#1
0
    def setUpClass(cls):
        """Create the test Cassandra Cluster as cls.cassandra."""
        super(TestCaseWithAccessor, cls).setUpClass()

        cls.cassandra = None
        if CASSANDRA_HOSTPORT:
            host, cls.port = CASSANDRA_HOSTPORT.split(':')
            cls.contact_points = [host]
        else:
            cls.setUpCassandra()

        # Make it easy to do raw queries to Cassandra.
        cls.cluster = c_cluster.Cluster(cls.contact_points, cls.port)
        cls.session = cls.cluster.connect()
        cls._reset_keyspace(cls.session, cls.KEYSPACE)
        cls._reset_keyspace(cls.session, cls.KEYSPACE + "_metadata")
        cls.accessor = bg_cassandra.build(
            keyspace=cls.KEYSPACE,
            contact_points=cls.contact_points,
            port=cls.port,
            timeout=60,
            **cls.ACCESSOR_SETTINGS
        )
        cls.accessor.syncdb()
        cls.accessor.connect()
示例#2
0
 def setUp(self):
     """Create a new Accessor in self.acessor."""
     super(TestCaseWithAccessor, self).setUp()
     self.accessor = bg_cassandra.build(
         keyspace=self.KEYSPACE,
         contact_points=self.contact_points,
         port=self.port,
         timeout=60,
     )
     self.accessor.connect()
     self.addCleanup(self.accessor.shutdown)
     self.addCleanup(self.__drop_all_metrics)
     self.metadata_cache = bg_metadata_cache.DiskCache(self.accessor, self.tempdir)
     self.metadata_cache.open()
     self.addCleanup(self.metadata_cache.close)
示例#3
0
 def setUp(self):
     """Create a new Accessor in self.acessor."""
     super(TestCaseWithAccessor, self).setUp()
     self.accessor = bg_cassandra.build(
         keyspace=self.KEYSPACE,
         contact_points=self.contact_points,
         port=self.port,
         timeout=60,
     )
     self.accessor.syncdb()
     self.accessor.connect()
     self.addCleanup(self.accessor.shutdown)
     self.addCleanup(self.__drop_all_metrics)
     self.metadata_cache = self.CACHE_CLASS(
         self.accessor, {'path': self.tempdir, 'size': 1024*1024})
     self.metadata_cache.open()
     self.addCleanup(self.metadata_cache.close)