diff --git a/gnocchi/storage/incoming/file.py b/gnocchi/storage/incoming/file.py index 743e68ab..439a3ab2 100644 --- a/gnocchi/storage/incoming/file.py +++ b/gnocchi/storage/incoming/file.py @@ -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): diff --git a/gnocchi/storage/incoming/s3.py b/gnocchi/storage/incoming/s3.py index 885c67fd..259d1bab 100644 --- a/gnocchi/storage/incoming/s3.py +++ b/gnocchi/storage/incoming/s3.py @@ -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) diff --git a/gnocchi/storage/incoming/swift.py b/gnocchi/storage/incoming/swift.py index 9ddf6e19..5052f6c7 100644 --- a/gnocchi/storage/incoming/swift.py +++ b/gnocchi/storage/incoming/swift.py @@ -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): diff --git a/gnocchi/tests/base.py b/gnocchi/tests/base.py index d46d0b32..455a76a2 100644 --- a/gnocchi/tests/base.py +++ b/gnocchi/tests/base.py @@ -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() diff --git a/gnocchi/tests/test_statsd.py b/gnocchi/tests/test_statsd.py index 4a35af02..fc0713d6 100644 --- a/gnocchi/tests/test_statsd.py +++ b/gnocchi/tests/test_statsd.py @@ -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):