Merge "Add table prefix for unit tests with hbase"
This commit is contained in:
commit
1004191f1c
@ -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
|
||||
|
@ -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())),
|
||||
]
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user