Merge "Allow domain remap storage_domain to be configured for func tests"

This commit is contained in:
Zuul
2018-06-12 21:12:54 +00:00
committed by Gerrit Code Review
3 changed files with 35 additions and 8 deletions

View File

@@ -381,26 +381,33 @@ def _load_domain_remap_staticweb(proxy_conf_file, swift_conf_file, **kwargs):
"""
_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 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
# DEFAULTS options) then it prevents pipeline being loaded into the local
# conf during wsgi load_app.
# Therefore we must modify the [pipeline:main] section.
conf = ConfigParser()
conf.read(proxy_conf_file)
try:
section = 'pipeline:main'
old_pipeline = conf.get(section, 'pipeline')
pipeline = old_pipeline.replace(
"tempauth",
"domain_remap tempauth staticweb")
" tempauth ",
" domain_remap tempauth staticweb ")
if pipeline == old_pipeline:
raise InProcessException(
"Failed to insert domain_remap and staticweb into pipeline: %s"
% old_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:
msg = 'Error problem with proxy conf file %s: %s' % \
(proxy_conf_file, err)
@@ -531,6 +538,7 @@ def in_process_setup(the_object_server=object_server):
storage_policy.reload_storage_policies()
global config
config['__file__'] = 'in_process_setup()'
if constraints.SWIFT_CONSTRAINTS_LOADED:
# Use the swift constraints that are loaded for the test framework
# configuration

View File

@@ -36,7 +36,14 @@ def requires_domain_remap(func):
def wrapper(*args, **kwargs):
if 'domain_remap' not in cluster_info:
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 wrapper
@@ -72,7 +79,6 @@ class TestStaticWebEnv(BaseEnv):
cls.objects = {}
for item in sorted(objects):
parent = None
if '/' in item.rstrip('/'):
parent, _ = item.rstrip('/').rsplit('/', 1)
path = '%s/%s' % (cls.objects[parent + '/'].name,
@@ -103,12 +109,20 @@ class TestStaticWeb(Base):
"Expected static_web_enabled to be True/False, got %r" %
(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('/')
return '.'.join((acct, tf.config.get('storage_domain')))
self.domain_remap_acct = '%s.example.com' % acct
self.domain_remap_cont = '%s.%s.example.com' % (
self.env.container.name, acct)
@property
def domain_remap_cont(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('/')
return '.'.join(
(self.env.container.name, acct, tf.config.get('storage_domain')))
def _set_staticweb_headers(self, index=False, listings=False,
listings_css=False, error=False):

View File

@@ -75,6 +75,11 @@ collate = C
# Only necessary if a pre-existing server uses self-signed certificate
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]
fake_syslog = False