Merge "Allow domain remap storage_domain to be configured for func tests"
This commit is contained in:
@@ -381,26 +381,33 @@ def _load_domain_remap_staticweb(proxy_conf_file, swift_conf_file, **kwargs):
|
|||||||
"""
|
"""
|
||||||
_debug('Setting configuration for domain_remap')
|
_debug('Setting configuration for domain_remap')
|
||||||
|
|
||||||
|
# add a domain_remap storage_domain to the test configuration
|
||||||
|
storage_domain = 'example.net'
|
||||||
|
global config
|
||||||
|
config['storage_domain'] = storage_domain
|
||||||
|
|
||||||
# The global conf dict cannot be used to modify the pipeline.
|
# The global conf dict cannot be used to modify the pipeline.
|
||||||
# The pipeline loader requires the pipeline to be set in the local_conf.
|
# The pipeline loader requires the pipeline to be set in the local_conf.
|
||||||
# If pipeline is set in the global conf dict (which in turn populates the
|
# If pipeline is set in the global conf dict (which in turn populates the
|
||||||
# DEFAULTS options) then it prevents pipeline being loaded into the local
|
# DEFAULTS options) then it prevents pipeline being loaded into the local
|
||||||
# conf during wsgi load_app.
|
# conf during wsgi load_app.
|
||||||
# Therefore we must modify the [pipeline:main] section.
|
# Therefore we must modify the [pipeline:main] section.
|
||||||
|
|
||||||
conf = ConfigParser()
|
conf = ConfigParser()
|
||||||
conf.read(proxy_conf_file)
|
conf.read(proxy_conf_file)
|
||||||
try:
|
try:
|
||||||
section = 'pipeline:main'
|
section = 'pipeline:main'
|
||||||
old_pipeline = conf.get(section, 'pipeline')
|
old_pipeline = conf.get(section, 'pipeline')
|
||||||
pipeline = old_pipeline.replace(
|
pipeline = old_pipeline.replace(
|
||||||
"tempauth",
|
" tempauth ",
|
||||||
"domain_remap tempauth staticweb")
|
" domain_remap tempauth staticweb ")
|
||||||
if pipeline == old_pipeline:
|
if pipeline == old_pipeline:
|
||||||
raise InProcessException(
|
raise InProcessException(
|
||||||
"Failed to insert domain_remap and staticweb into pipeline: %s"
|
"Failed to insert domain_remap and staticweb into pipeline: %s"
|
||||||
% old_pipeline)
|
% old_pipeline)
|
||||||
conf.set(section, 'pipeline', pipeline)
|
conf.set(section, 'pipeline', pipeline)
|
||||||
|
# set storage_domain in domain_remap middleware to match test config
|
||||||
|
section = 'filter:domain_remap'
|
||||||
|
conf.set(section, 'storage_domain', storage_domain)
|
||||||
except NoSectionError as err:
|
except NoSectionError as err:
|
||||||
msg = 'Error problem with proxy conf file %s: %s' % \
|
msg = 'Error problem with proxy conf file %s: %s' % \
|
||||||
(proxy_conf_file, err)
|
(proxy_conf_file, err)
|
||||||
@@ -531,6 +538,7 @@ def in_process_setup(the_object_server=object_server):
|
|||||||
storage_policy.reload_storage_policies()
|
storage_policy.reload_storage_policies()
|
||||||
|
|
||||||
global config
|
global config
|
||||||
|
config['__file__'] = 'in_process_setup()'
|
||||||
if constraints.SWIFT_CONSTRAINTS_LOADED:
|
if constraints.SWIFT_CONSTRAINTS_LOADED:
|
||||||
# Use the swift constraints that are loaded for the test framework
|
# Use the swift constraints that are loaded for the test framework
|
||||||
# configuration
|
# configuration
|
||||||
|
|||||||
@@ -36,7 +36,14 @@ def requires_domain_remap(func):
|
|||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
if 'domain_remap' not in cluster_info:
|
if 'domain_remap' not in cluster_info:
|
||||||
raise SkipTest('Domain Remap is not enabled')
|
raise SkipTest('Domain Remap is not enabled')
|
||||||
|
# domain_remap middleware does not advertise its storage_domain values
|
||||||
|
# in swift /info responses so a storage_domain must be configured in
|
||||||
|
# test.conf for these tests to succeed
|
||||||
|
if not tf.config.get('storage_domain'):
|
||||||
|
raise SkipTest('Domain Remap storage_domain not configured in %s' %
|
||||||
|
tf.config['__file__'])
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
@@ -72,7 +79,6 @@ class TestStaticWebEnv(BaseEnv):
|
|||||||
|
|
||||||
cls.objects = {}
|
cls.objects = {}
|
||||||
for item in sorted(objects):
|
for item in sorted(objects):
|
||||||
parent = None
|
|
||||||
if '/' in item.rstrip('/'):
|
if '/' in item.rstrip('/'):
|
||||||
parent, _ = item.rstrip('/').rsplit('/', 1)
|
parent, _ = item.rstrip('/').rsplit('/', 1)
|
||||||
path = '%s/%s' % (cls.objects[parent + '/'].name,
|
path = '%s/%s' % (cls.objects[parent + '/'].name,
|
||||||
@@ -103,12 +109,20 @@ class TestStaticWeb(Base):
|
|||||||
"Expected static_web_enabled to be True/False, got %r" %
|
"Expected static_web_enabled to be True/False, got %r" %
|
||||||
(self.env.static_web_enabled,))
|
(self.env.static_web_enabled,))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def domain_remap_acct(self):
|
||||||
|
# the storage_domain option is test.conf must be set to one of the
|
||||||
|
# domain_remap middleware storage_domain values
|
||||||
_, _, acct = self.env.account.conn.storage_url.split('/')
|
_, _, acct = self.env.account.conn.storage_url.split('/')
|
||||||
|
return '.'.join((acct, tf.config.get('storage_domain')))
|
||||||
|
|
||||||
self.domain_remap_acct = '%s.example.com' % acct
|
@property
|
||||||
|
def domain_remap_cont(self):
|
||||||
self.domain_remap_cont = '%s.%s.example.com' % (
|
# the storage_domain option is test.conf must be set to one of the
|
||||||
self.env.container.name, acct)
|
# domain_remap middleware storage_domain values
|
||||||
|
_, _, acct = self.env.account.conn.storage_url.split('/')
|
||||||
|
return '.'.join(
|
||||||
|
(self.env.container.name, acct, tf.config.get('storage_domain')))
|
||||||
|
|
||||||
def _set_staticweb_headers(self, index=False, listings=False,
|
def _set_staticweb_headers(self, index=False, listings=False,
|
||||||
listings_css=False, error=False):
|
listings_css=False, error=False):
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ collate = C
|
|||||||
# Only necessary if a pre-existing server uses self-signed certificate
|
# Only necessary if a pre-existing server uses self-signed certificate
|
||||||
insecure = no
|
insecure = no
|
||||||
|
|
||||||
|
# Tests that are dependent on domain_remap middleware being installed also
|
||||||
|
# require one of the domain_remap storage_domain values to be specified here,
|
||||||
|
# otherwise those tests will be skipped.
|
||||||
|
storage_domain =
|
||||||
|
|
||||||
[unit_test]
|
[unit_test]
|
||||||
fake_syslog = False
|
fake_syslog = False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user