Merge "Add table prefix for unit tests with hbase"

This commit is contained in:
Jenkins 2014-02-08 07:16:39 +00:00 committed by Gerrit Code Review
commit 1004191f1c
3 changed files with 21 additions and 4 deletions

View File

@ -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

View File

@ -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())),
]

View File

@ -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)