summaryrefslogtreecommitdiff
path: root/test/functional/__init__.py
diff options
context:
space:
mode:
authorChristian Schwede <cschwede@redhat.com>2016-07-20 09:51:24 +0000
committerThiago da Silva <thiago@redhat.com>2017-07-12 16:23:04 -0400
commit2410b616bba2d68914c2c00e95b2f7c30f391e1b (patch)
tree95928eed905820b5370e2ffec3d5fb5c32780630 /test/functional/__init__.py
parent4cb76a41ce0562a458154be1628b33688a0df802 (diff)
downloadswift-2410b616bba2d68914c2c00e95b2f7c30f391e1b.tar.gz
Fix swiftdir option and usage of storage policy aliases
If swift-recon/swift-get-nodes/swift-object-info is used with the swiftdir option they will read rings from the given directory; however they are still using /etc/swift/swift.conf to find the policies on the current node. This makes it impossible to maintain a local swift.conf copy (if you don't have write access to /etc/swift) or check multiple clusters from the same node. Until now swift-recon was also not usable with storage policy aliases, this patch fixes this as well. Closes-Bug: 1577582 Closes-Bug: 1604707 Closes-Bug: 1617951 Co-Authored-By: Alistair Coles <alistairncoles@gmail.com> Co-Authored-By: Thiago da Silva <thiago@redhat.com> Change-Id: I13188d42ec19e32e4420739eacd1e5b454af2ae3
Diffstat (limited to 'test/functional/__init__.py')
-rw-r--r--test/functional/__init__.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/test/functional/__init__.py b/test/functional/__init__.py
index 5a90d6c22..3e3c4486d 100644
--- a/test/functional/__init__.py
+++ b/test/functional/__init__.py
@@ -39,6 +39,7 @@ from six.moves.http_client import HTTPException
from swift.common.middleware.memcache import MemcacheMiddleware
from swift.common.storage_policy import parse_storage_policies, PolicyError
+from swift.common.utils import set_swift_dir
from test import get_config, listen_zero
from test.functional.swift_test_client import Account, Connection, Container, \
@@ -106,9 +107,6 @@ skip, skip2, skip3, skip_service_tokens, skip_if_no_reseller_admin = \
orig_collate = ''
insecure = False
-orig_hash_path_suff_pref = ('', '')
-orig_swift_conf_name = None
-
in_process = False
_testdir = _test_servers = _test_coros = _test_socks = None
policy_specified = None
@@ -413,6 +411,7 @@ def in_process_setup(the_object_server=object_server):
utils.mkdirs(os.path.join(_testdir, 'sdc1', 'tmp'))
swift_conf = _in_process_setup_swift_conf(swift_conf_src, _testdir)
+ _info('prepared swift.conf: %s' % swift_conf)
# Call the associated method for the value of
# 'SWIFT_TEST_IN_PROCESS_CONF_LOADER', if one exists
@@ -437,12 +436,11 @@ def in_process_setup(the_object_server=object_server):
obj_sockets = _in_process_setup_ring(swift_conf, conf_src_dir, _testdir)
- global orig_swift_conf_name
- orig_swift_conf_name = utils.SWIFT_CONF_FILE
- utils.SWIFT_CONF_FILE = swift_conf
- constraints.reload_constraints()
- storage_policy.SWIFT_CONF_FILE = swift_conf
- storage_policy.reload_storage_policies()
+ # load new swift.conf file
+ if set_swift_dir(os.path.dirname(swift_conf)):
+ constraints.reload_constraints()
+ storage_policy.reload_storage_policies()
+
global config
if constraints.SWIFT_CONSTRAINTS_LOADED:
# Use the swift constraints that are loaded for the test framework
@@ -453,9 +451,6 @@ def in_process_setup(the_object_server=object_server):
else:
# In-process swift constraints were not loaded, somethings wrong
raise SkipTest
- global orig_hash_path_suff_pref
- orig_hash_path_suff_pref = utils.HASH_PATH_PREFIX, utils.HASH_PATH_SUFFIX
- utils.validate_hash_conf()
global _test_socks
_test_socks = []
@@ -918,10 +913,7 @@ def teardown_package():
rmtree(os.path.dirname(_testdir))
except Exception:
pass
- utils.HASH_PATH_PREFIX, utils.HASH_PATH_SUFFIX = \
- orig_hash_path_suff_pref
- utils.SWIFT_CONF_FILE = orig_swift_conf_name
- constraints.reload_constraints()
+
reset_globals()