Merge "Expose basic constraints in /info"

This commit is contained in:
Jenkins 2013-12-14 07:58:44 +00:00 committed by Gerrit Code Review
commit f0aea5a707
2 changed files with 41 additions and 2 deletions
swift/proxy
test/unit/proxy

@ -24,6 +24,7 @@ import itertools
from eventlet import Timeout
from swift import __canonical_version__ as swift_version
from swift.common import constraints
from swift.common.ring import Ring
from swift.common.utils import cache_from_env, get_logger, \
get_remote_client, split_path, config_true_value, generate_trans_id, \
@ -171,7 +172,17 @@ class Application(object):
self.disallowed_sections = list_from_csv(
conf.get('disallowed_sections'))
self.admin_key = conf.get('admin_key', None)
register_swift_info(version=swift_version)
register_swift_info(
version=swift_version,
max_file_size=constraints.MAX_FILE_SIZE,
max_meta_name_length=constraints.MAX_META_NAME_LENGTH,
max_meta_value_length=constraints.MAX_META_VALUE_LENGTH,
max_meta_count=constraints.MAX_META_COUNT,
account_listing_limit=constraints.ACCOUNT_LISTING_LIMIT,
container_listing_limit=constraints.CONTAINER_LISTING_LIMIT,
max_account_name_length=constraints.MAX_ACCOUNT_NAME_LENGTH,
max_container_name_length=constraints.MAX_CONTAINER_NAME_LENGTH,
max_object_name_length=constraints.MAX_OBJECT_NAME_LENGTH)
def get_controller(self, path):
"""

@ -44,7 +44,8 @@ from swift.common.middleware import proxy_logging
from swift.common.exceptions import ChunkReadTimeout, SegmentError
from swift.common.constraints import MAX_META_NAME_LENGTH, \
MAX_META_VALUE_LENGTH, MAX_META_COUNT, MAX_META_OVERALL_SIZE, \
MAX_FILE_SIZE, MAX_ACCOUNT_NAME_LENGTH, MAX_CONTAINER_NAME_LENGTH
MAX_FILE_SIZE, MAX_ACCOUNT_NAME_LENGTH, MAX_CONTAINER_NAME_LENGTH, \
ACCOUNT_LISTING_LIMIT, CONTAINER_LISTING_LIMIT, MAX_OBJECT_NAME_LENGTH
from swift.common import utils
from swift.common.utils import mkdirs, normalize_timestamp, NullLogger
from swift.common.wsgi import monkey_patch_mimetools
@ -6910,6 +6911,33 @@ class TestProxyObjectPerformance(unittest.TestCase):
print "Run %02d took %07.03f" % (i, end - start)
class TestSwiftInfo(unittest.TestCase):
def setUp(self):
utils._swift_info = {}
utils._swift_admin_info = {}
def test_registered_defaults(self):
proxy_server.Application({}, FakeMemcache(),
account_ring=FakeRing(),
container_ring=FakeRing(),
object_ring=FakeRing)
si = utils.get_swift_info()['swift']
self.assertTrue('version' in si)
self.assertEqual(si['max_file_size'], MAX_FILE_SIZE)
self.assertEqual(si['max_meta_name_length'], MAX_META_NAME_LENGTH)
self.assertEqual(si['max_meta_value_length'], MAX_META_VALUE_LENGTH)
self.assertEqual(si['max_meta_count'], MAX_META_COUNT)
self.assertEqual(si['account_listing_limit'], ACCOUNT_LISTING_LIMIT)
self.assertEqual(si['container_listing_limit'],
CONTAINER_LISTING_LIMIT)
self.assertEqual(si['max_account_name_length'],
MAX_ACCOUNT_NAME_LENGTH)
self.assertEqual(si['max_container_name_length'],
MAX_CONTAINER_NAME_LENGTH)
self.assertEqual(si['max_object_name_length'], MAX_OBJECT_NAME_LENGTH)
if __name__ == '__main__':
setup()
try: