Support Storage Policy - Rev 5
* Sync to Swift 2.0.0rc1 release. * Use separate conf files for functional tests * Define swiftonfile as policy with index 2 Signed-off-by: Prashanth Pai <ppai@redhat.com>
This commit is contained in:
parent
d91e33a0f4
commit
8ea7bd718d
12
.functests
12
.functests
@ -80,15 +80,15 @@ print "Invoking SAIO's remakerings script"
|
||||
remakerings
|
||||
|
||||
print "Copying conf files into /etc/swift. This will replace swift.conf and test.conf"
|
||||
cp etc/object-server.conf-gluster /etc/swift/object-server/5.conf
|
||||
cp etc/swift.conf-gluster /etc/swift/swift.conf
|
||||
cp etc/test.conf /etc/swift/test.conf
|
||||
\cp etc/object-server.conf-gluster /etc/swift/object-server/5.conf
|
||||
\cp test/functional/conf/swift.conf /etc/swift/swift.conf
|
||||
\cp test/functional/conf/test.conf /etc/swift/test.conf
|
||||
|
||||
print "Generating additional object-rings for swiftonfile SP"
|
||||
cd /etc/swift
|
||||
swift-ring-builder object-1.builder create 1 1 1
|
||||
swift-ring-builder object-1.builder add r1z1-127.0.0.1:6050/test 1
|
||||
swift-ring-builder object-1.builder rebalance
|
||||
swift-ring-builder object-2.builder create 1 1 1
|
||||
swift-ring-builder object-2.builder add r1z1-127.0.0.1:6050/test 1
|
||||
swift-ring-builder object-2.builder rebalance
|
||||
cd -
|
||||
|
||||
export SWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf
|
||||
|
@ -24,15 +24,26 @@ swift_hash_path_prefix = changeme
|
||||
# storage-policy:0.
|
||||
[storage-policy:0]
|
||||
name = Policy-0
|
||||
# default = yes
|
||||
# Default has beeen turned off here and set for policy-1 for running SoF
|
||||
# functional tests.
|
||||
default = yes
|
||||
|
||||
# the following section would declare a policy called 'silver', the number of
|
||||
# replicas will be determined by how the ring is built. In this example the
|
||||
# 'silver' policy could have a lower or higher # of replicas than the
|
||||
# 'Policy-0' policy above. The ring filename will be 'object-1.ring.gz'. You
|
||||
# may only specify one storage policy section as the default. If you changed
|
||||
# this section to specify 'silver' as the default, when a client created a new
|
||||
# container w/o a policy specified, it will get the 'silver' policy because
|
||||
# this config has specified it as the default. However if a legacy container
|
||||
# (one created with a pre-policy version of swift) is accessed, it is known
|
||||
# implicitly to be assigned to the policy with index 0 as opposed to the
|
||||
# current default.
|
||||
#[storage-policy:1]
|
||||
#name = silver
|
||||
|
||||
# The following section defines a policy called 'sof' to be used by swiftonfile
|
||||
# object-server implementation.
|
||||
[storage-policy:1]
|
||||
[storage-policy:2]
|
||||
name = sof
|
||||
default = yes
|
||||
|
||||
# The swift-constraints section sets the basic constraints on data
|
||||
# saved in the swift cluster. These constraints are automatically
|
||||
|
@ -38,7 +38,7 @@ from test.functional.swift_test_client import Connection, ResponseError
|
||||
# on file systems that don't support extended attributes.
|
||||
from test.unit import debug_logger, FakeMemcache
|
||||
|
||||
from swift.common import constraints, utils, ring
|
||||
from swift.common import constraints, utils, ring, storage_policy
|
||||
from swift.common.wsgi import monkey_patch_mimetools
|
||||
from swift.common.middleware import catch_errors, gatekeeper, healthcheck, \
|
||||
proxy_logging, container_sync, bulk, tempurl, slo, dlo, ratelimit, \
|
||||
@ -152,6 +152,8 @@ def in_process_setup(the_object_server=object_server):
|
||||
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()
|
||||
global config
|
||||
if constraints.SWIFT_CONSTRAINTS_LOADED:
|
||||
# Use the swift constraints that are loaded for the test framework
|
||||
@ -345,7 +347,7 @@ def get_cluster_info():
|
||||
# test.conf data
|
||||
pass
|
||||
else:
|
||||
eff_constraints.update(cluster_info['swift'])
|
||||
eff_constraints.update(cluster_info.get('swift', {}))
|
||||
|
||||
# Finally, we'll allow any constraint present in the swift-constraints
|
||||
# section of test.conf to override everything. Note that only those
|
||||
@ -714,18 +716,14 @@ class FunctionalStoragePolicyCollection(object):
|
||||
def requires_policies(f):
|
||||
@functools.wraps(f)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
rv = None
|
||||
if skip:
|
||||
raise SkipTest
|
||||
try:
|
||||
self.policies = FunctionalStoragePolicyCollection.from_info()
|
||||
assert len(self.policies) > 1
|
||||
except AssertionError:
|
||||
raise SkipTest("Unable to determine available policies")
|
||||
if len(self.policies) < 2:
|
||||
raise SkipTest("Multiple policies not enabled")
|
||||
try:
|
||||
rv = f(self, *args, **kwargs)
|
||||
except:
|
||||
raise
|
||||
return rv
|
||||
return f(self, *args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
21
test/functional/conf/swift.conf
Normal file
21
test/functional/conf/swift.conf
Normal file
@ -0,0 +1,21 @@
|
||||
[swift-hash]
|
||||
# random unique strings that can never change (DO NOT LOSE)
|
||||
swift_hash_path_prefix = changeme
|
||||
swift_hash_path_suffix = changeme
|
||||
|
||||
[storage-policy:0]
|
||||
name = gold
|
||||
|
||||
[storage-policy:1]
|
||||
name = silver
|
||||
|
||||
# SwiftOnFile
|
||||
[storage-policy:2]
|
||||
name = sof
|
||||
default = yes
|
||||
|
||||
[swift-constraints]
|
||||
max_object_name_length = 221
|
||||
max_account_name_length = 255
|
||||
max_container_name_length = 255
|
||||
|
@ -32,9 +32,7 @@ class TestSwiftOnFileEnv:
|
||||
cls.conn.authenticate()
|
||||
cls.account = Account(cls.conn, tf.config.get('account',
|
||||
tf.config['username']))
|
||||
cls.root_dir = os.path.join('/mnt/gluster-object',
|
||||
cls.account.conn.storage_url.split(
|
||||
'/')[2].split('_')[1])
|
||||
cls.root_dir = os.path.join('/mnt/gluster-object/test')
|
||||
cls.account.delete_containers()
|
||||
|
||||
cls.file_size = 8
|
||||
|
@ -270,6 +270,19 @@ class TestAccount(Base):
|
||||
self.assertEqual(sorted(containers, cmp=locale.strcoll),
|
||||
containers)
|
||||
|
||||
def testQuotedWWWAuthenticateHeader(self):
|
||||
conn = Connection(tf.config)
|
||||
conn.authenticate()
|
||||
inserted_html = '<b>Hello World'
|
||||
hax = 'AUTH_haxx"\nContent-Length: %d\n\n%s' % (len(inserted_html),
|
||||
inserted_html)
|
||||
quoted_hax = urllib.quote(hax)
|
||||
conn.connection.request('GET', '/v1/' + quoted_hax, None, {})
|
||||
resp = conn.connection.getresponse()
|
||||
resp_headers = resp.getheaders()
|
||||
expected = ('www-authenticate', 'Swift realm="%s"' % quoted_hax)
|
||||
self.assert_(expected in resp_headers)
|
||||
|
||||
|
||||
class TestAccountUTF8(Base2, TestAccount):
|
||||
set_up = False
|
||||
@ -2199,7 +2212,6 @@ class TestTempurlEnv(object):
|
||||
cls.tempurl_enabled = 'tempurl' in cluster_info
|
||||
if not cls.tempurl_enabled:
|
||||
return
|
||||
cls.tempurl_methods = cluster_info['tempurl']['methods']
|
||||
|
||||
cls.tempurl_key = Utils.create_name()
|
||||
cls.tempurl_key2 = Utils.create_name()
|
||||
|
2
tox.ini
2
tox.ini
@ -21,7 +21,7 @@ setenv = VIRTUAL_ENV={envdir}
|
||||
deps =
|
||||
# GitHub's .zip URL won't work! pip supports installing from git repos.
|
||||
# https://pip.pypa.io/en/latest/reference/pip_install.html#git
|
||||
git+https://github.com/openstack/swift.git@feature/ec
|
||||
git+https://github.com/openstack/swift.git@2.0.0.rc1
|
||||
-r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
changedir = {toxinidir}/test/unit
|
||||
|
Loading…
x
Reference in New Issue
Block a user