file, s3, swift: create incoming buckets/containers on upgrade
And not on __init__ Change-Id: Id40fbfc01428d25a10a222ec5029ebf4d279e3af
This commit is contained in:
parent
2814b6f40d
commit
14eb4c50e8
@ -30,6 +30,9 @@ class FileStorage(_carbonara.CarbonaraBasedStorage):
|
||||
self.basepath = conf.file_basepath
|
||||
self.basepath_tmp = os.path.join(self.basepath, 'tmp')
|
||||
self.measure_path = os.path.join(self.basepath, 'measure')
|
||||
|
||||
def upgrade(self, indexer):
|
||||
super(FileStorage, self).upgrade(indexer)
|
||||
utils.ensure_paths([self.basepath_tmp, self.measure_path])
|
||||
|
||||
def _build_measure_path(self, metric_id, random_id=None):
|
||||
|
@ -39,6 +39,9 @@ class S3Storage(_carbonara.CarbonaraBasedStorage):
|
||||
self._bucket_name_measures = (
|
||||
self._bucket_prefix + "-" + self.MEASURE_PREFIX
|
||||
)
|
||||
|
||||
def upgrade(self, indexer):
|
||||
super(S3Storage, self).upgrade(indexer)
|
||||
try:
|
||||
s3.create_bucket(self.s3, self._bucket_name_measures,
|
||||
self._region_name)
|
||||
|
@ -29,6 +29,9 @@ class SwiftStorage(_carbonara.CarbonaraBasedStorage):
|
||||
def __init__(self, conf):
|
||||
super(SwiftStorage, self).__init__(conf)
|
||||
self.swift = swift.get_connection(conf)
|
||||
|
||||
def upgrade(self, indexer):
|
||||
super(SwiftStorage, self).upgrade(indexer)
|
||||
self.swift.put_container(self.MEASURE_PREFIX)
|
||||
|
||||
def _store_new_measures(self, metric, data):
|
||||
|
@ -313,17 +313,13 @@ class TestCase(base.BaseTestCase):
|
||||
"storage")
|
||||
|
||||
self.storage = storage.get_driver(self.conf)
|
||||
|
||||
if self.conf.storage.driver == 'redis':
|
||||
# Create one prefix per test
|
||||
self.storage.STORAGE_PREFIX = str(uuid.uuid4())
|
||||
self.storage.incoming.STORAGE_PREFIX = str(uuid.uuid4())
|
||||
|
||||
# NOTE(jd) Do not upgrade the storage. We don't really need the storage
|
||||
# upgrade for now, and the code that upgrade from pre-1.3
|
||||
# (TimeSerieArchive) uses a lot of parallel lock, which makes tooz
|
||||
# explodes because MySQL does not support that many connections in real
|
||||
# life.
|
||||
# self.storage.upgrade(self.index)
|
||||
self.storage.upgrade(self.index)
|
||||
|
||||
def tearDown(self):
|
||||
self.index.disconnect()
|
||||
|
@ -40,10 +40,10 @@ class TestStatsd(tests_base.TestCase):
|
||||
self.conf.set_override("archive_policy_name",
|
||||
self.STATSD_ARCHIVE_POLICY_NAME, "statsd")
|
||||
|
||||
# NOTE(jd) Always use self.stats.storage and self.stats.indexer to
|
||||
# pick at the right storage/indexer used by the statsd server, and not
|
||||
# new instances from the base test class.
|
||||
self.stats = statsd.Stats(self.conf)
|
||||
# Replace storage/indexer with correct ones that have been upgraded
|
||||
self.stats.storage = self.storage
|
||||
self.stats.indexer = self.index
|
||||
self.server = statsd.StatsdServer(self.stats)
|
||||
|
||||
def test_flush_empty(self):
|
||||
|
Loading…
Reference in New Issue
Block a user