diff --git a/ceilometer/tests/api/v2/test_statistics_scenarios.py b/ceilometer/tests/api/v2/test_statistics_scenarios.py index 4a850058e..817e50ea0 100644 --- a/ceilometer/tests/api/v2/test_statistics_scenarios.py +++ b/ceilometer/tests/api/v2/test_statistics_scenarios.py @@ -1231,7 +1231,7 @@ class TestGroupBySource(FunctionalTest, scenarios = [ ('mongodb', dict(database_connection=tests_db.MongoDBFakeConnectionUrl())), - ('hbase', dict(database_connection='hbase://__test__')), + ('hbase', dict(database_connection=tests_db.HBaseFakeConnectionUrl())), ('db2', dict(database_connection=tests_db.DB2FakeConnectionUrl())), ] @@ -1291,6 +1291,10 @@ class TestGroupBySource(FunctionalTest, ) self.conn.record_metering_data(msg) + def tearDown(self): + self.conn.clear() + super(TestGroupBySource, self).tearDown() + def test_group_by_source(self): data = self.get_json(self.PATH, groupby=['source']) groupby_keys_set = set(x for sub_dict in data diff --git a/ceilometer/tests/db.py b/ceilometer/tests/db.py index 91fbbaa2b..368839d78 100644 --- a/ceilometer/tests/db.py +++ b/ceilometer/tests/db.py @@ -94,12 +94,25 @@ class DB2FakeConnectionUrl(MongoDBFakeConnectionUrl): self.url = self.url.replace('mongodb:', 'db2:', 1) +class HBaseFakeConnectionUrl(object): + def __init__(self): + self.url = os.environ.get('CEILOMETER_TEST_HBASE_URL') + if not self.url: + self.url = 'hbase://__test__' + + def __str__(self): + s = '%s?table_prefix=%s' % ( + self.url, + uuid.uuid4().hex) + return s + + @six.add_metaclass(test_base.SkipNotImplementedMeta) class MixinTestsWithBackendScenarios(object): scenarios = [ ('sqlalchemy', dict(database_connection='sqlite://')), ('mongodb', dict(database_connection=MongoDBFakeConnectionUrl())), - ('hbase', dict(database_connection='hbase://__test__')), + ('hbase', dict(database_connection=HBaseFakeConnectionUrl())), ('db2', dict(database_connection=DB2FakeConnectionUrl())), ] diff --git a/ceilometer/tests/storage/test_impl_hbase.py b/ceilometer/tests/storage/test_impl_hbase.py index 0ac662313..d4e5cf188 100644 --- a/ceilometer/tests/storage/test_impl_hbase.py +++ b/ceilometer/tests/storage/test_impl_hbase.py @@ -31,13 +31,13 @@ from ceilometer.tests import db as tests_db class HBaseEngineTestBase(tests_db.TestBase): - database_connection = 'hbase://__test__' + database_connection = tests_db.HBaseFakeConnectionUrl() class ConnectionTest(HBaseEngineTestBase): def test_hbase_connection(self): - self.CONF.database.connection = self.database_connection + self.CONF.database.connection = str(self.database_connection) conn = hbase.Connection(self.CONF) self.assertIsInstance(conn.conn, hbase.MConnection)