Register swift3 info to swift APIs(/info).
The eetail of swift3 info as follows:
    "swift3": {
        "max_bucket_listing": 1000,
        "max_multi_delete_objects": 1000,
        "max_parts_listing": 1000,
        "max_upload_part_num": 1000
    }
Change-Id: I5148a404a90a73a64ac6890e1d73e7a27198d75f
			
			
This commit is contained in:
		@@ -62,7 +62,7 @@ from swift3.response import ErrorResponse, InternalError, MethodNotAllowed, \
 | 
			
		||||
    ResponseBase
 | 
			
		||||
from swift3.cfg import CONF
 | 
			
		||||
from swift3.utils import LOGGER
 | 
			
		||||
from swift.common.utils import get_logger
 | 
			
		||||
from swift.common.utils import get_logger, register_swift_info
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Swift3Middleware(object):
 | 
			
		||||
@@ -176,6 +176,14 @@ def filter_factory(global_conf, **local_conf):
 | 
			
		||||
    global LOGGER
 | 
			
		||||
    LOGGER = get_logger(CONF, log_route='swift3')
 | 
			
		||||
 | 
			
		||||
    register_swift_info(
 | 
			
		||||
        'swift3',
 | 
			
		||||
        max_bucket_listing=CONF['max_bucket_listing'],
 | 
			
		||||
        max_parts_listing=CONF['max_parts_listing'],
 | 
			
		||||
        max_upload_part_num=CONF['max_upload_part_num'],
 | 
			
		||||
        max_multi_delete_objects=CONF['max_multi_delete_objects']
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    def swift3_filter(app):
 | 
			
		||||
        return Swift3Middleware(app, CONF)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@ class Swift3TestCase(unittest.TestCase):
 | 
			
		||||
    def __init__(self, name):
 | 
			
		||||
        unittest.TestCase.__init__(self, name)
 | 
			
		||||
 | 
			
		||||
        CONF.log_level = 'debug',
 | 
			
		||||
        CONF.log_level = 'debug'
 | 
			
		||||
        CONF.storage_domain = 'localhost'
 | 
			
		||||
 | 
			
		||||
    def setUp(self):
 | 
			
		||||
 
 | 
			
		||||
@@ -21,12 +21,14 @@ import hashlib
 | 
			
		||||
import base64
 | 
			
		||||
from urllib import unquote, quote
 | 
			
		||||
 | 
			
		||||
from swift.common import swob
 | 
			
		||||
from swift.common import swob, utils
 | 
			
		||||
from swift.common.swob import Request
 | 
			
		||||
 | 
			
		||||
from swift3.test.unit import Swift3TestCase
 | 
			
		||||
from swift3.request import Request as S3Request
 | 
			
		||||
from swift3.etree import fromstring
 | 
			
		||||
from swift3.middleware import filter_factory
 | 
			
		||||
from swift3.cfg import CONF
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TestSwift3Middleware(Swift3TestCase):
 | 
			
		||||
@@ -315,6 +317,19 @@ class TestSwift3Middleware(Swift3TestCase):
 | 
			
		||||
        self.assertEquals(elem.find('./Method').text, 'POST')
 | 
			
		||||
        self.assertEquals(elem.find('./ResourceType').text, 'ACL')
 | 
			
		||||
 | 
			
		||||
    def test_registered_defaults(self):
 | 
			
		||||
        filter_factory(CONF)
 | 
			
		||||
        swift_info = utils.get_swift_info()
 | 
			
		||||
        self.assertTrue('swift3' in swift_info)
 | 
			
		||||
        self.assertEqual(swift_info['swift3'].get('max_bucket_listing'),
 | 
			
		||||
                         CONF.max_bucket_listing)
 | 
			
		||||
        self.assertEqual(swift_info['swift3'].get('max_parts_listing'),
 | 
			
		||||
                         CONF.max_parts_listing)
 | 
			
		||||
        self.assertEqual(swift_info['swift3'].get('max_upload_part_num'),
 | 
			
		||||
                         CONF.max_upload_part_num)
 | 
			
		||||
        self.assertEqual(swift_info['swift3'].get('max_multi_delete_objects'),
 | 
			
		||||
                         CONF.max_multi_delete_objects)
 | 
			
		||||
 | 
			
		||||
    def test_check_pipeline(self):
 | 
			
		||||
        with nested(patch("swift3.middleware.CONF"),
 | 
			
		||||
                    patch("swift3.middleware.PipelineWrapper"),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user