Fix test isolation of cachedir in TestCollectAll
TestCollectAll.setUp() copies the global cfg.CONF object with copy.copy() and restores it during cleanup. With oslo.config >= 10.7.0 on Python 3.14 this no longer isolates the tests: a stale cachedir value (a fixtures.TempDir path) leaks into subsequent tests, making TestConf.test_setup_conf fail, and sometimes TestEc2.test_collect_ec2_collected too. Replace the copy/restore hack with the standard oslo.config test isolation pattern already used by the other test modules: register self.addCleanup(cfg.CONF.reset) and set cachedir/backup_cachedir with cfg.CONF.set_override(). Found in the Debian rebuild on forky/sid (oslo.config 10.7.0, Python 3.14): https://bugs.debian.org/1149108 Closes-Bug: #2168664 Change-Id: Ibcc09cbb50a843a8e5e6c1f0beb7f1f26a3b2254 Signed-off-by: Thomas Goirand <zigo@debian.org>
This commit is contained in:
1 parent
00c74bc8cd
commit
f89f95eff8
1 file changed
+3
-8
@@ -13,7 +13,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
@@ -360,16 +359,12 @@ class TestCollectAll(testtools.TestCase):
|
||||
super().setUp()
|
||||
self.log = self.useFixture(fixtures.FakeLogger())
|
||||
collect.setup_conf()
|
||||
self.addCleanup(cfg.CONF.reset)
|
||||
self.cache_dir = self.useFixture(fixtures.TempDir())
|
||||
self.backup_cache_dir = self.useFixture(fixtures.TempDir())
|
||||
self.clean_conf = copy.copy(cfg.CONF)
|
||||
|
||||
def restore_copy():
|
||||
cfg.CONF = self.clean_conf
|
||||
self.addCleanup(restore_copy)
|
||||
|
||||
cfg.CONF.cachedir = self.cache_dir.path
|
||||
cfg.CONF.backup_cachedir = self.backup_cache_dir.path
|
||||
cfg.CONF.set_override('cachedir', self.cache_dir.path)
|
||||
cfg.CONF.set_override('backup_cachedir', self.backup_cache_dir.path)
|
||||
cfg.CONF.cfn.metadata_url = 'http://192.0.2.1:8000/v1/'
|
||||
cfg.CONF.cfn.stack_name = 'foo'
|
||||
cfg.CONF.cfn.path = ['foo.Metadata']
|
||||
|
||||
Reference in new issue
Block a user