From 5c8785aaee959177258511d7adbe74afed0cb9fb Mon Sep 17 00:00:00 2001 From: Kun Huang Date: Wed, 19 Jun 2013 01:02:37 +0800 Subject: [PATCH] Add max_header_size to swift.conf-sample and relative UT 1. Add explanation of MAX_HEADER_SIZE into swift.conf-sample as same as other settings in swift.conf. Especially point out the default size of header line in eventlet is 8192 which is the main reason why we set 8192 for MAX_HEADER_SIZE in swift. 2. Add some unit tests to check valid settings in swift.conf. Test cases in test_constraints use /etc/swift/swift.conf if exists, and if any wrong settings are in it (MAX_META_VALE > MAX_META_OVERALL_SIZE), swift's unit test must fail. These new unit tests is used in this case. Change-Id: I7bb21951d46050163c1b7bceac8d49302b9209f7 --- etc/swift.conf-sample | 14 +++++++++++--- test/unit/common/test_constraints.py | 7 +++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/etc/swift.conf-sample b/etc/swift.conf-sample index 75501b3d17..18f649b047 100644 --- a/etc/swift.conf-sample +++ b/etc/swift.conf-sample @@ -1,9 +1,9 @@ [swift-hash] # swift_hash_path_suffix and swift_hash_path_prefix are used as part of the -# the hashing algorithm when determining data placement in the cluster. -# These values should remain secret and MUST NOT change -# once a cluster has been deployed. +# the hashing algorithm when determining data placement in the cluster. +# These values should remain secret and MUST NOT change +# once a cluster has been deployed. swift_hash_path_suffix = changeme swift_hash_path_prefix = changeme @@ -48,6 +48,14 @@ swift_hash_path_prefix = changeme #max_meta_overall_size = 4096 +# max_header_size is the max number of bytes in the utf8 encoding of each +# header. Using 8192 as default becasue eventlet use 8192 as max size of +# header line and the longest header passed from Keystone(PKI token) uses +# 8192 as default too. + +#max_header_size = 8192 + + # max_object_name_length is the max number of bytes in the utf8 encoding # of an object name diff --git a/test/unit/common/test_constraints.py b/test/unit/common/test_constraints.py index ce786bb4f1..a16df5afae 100644 --- a/test/unit/common/test_constraints.py +++ b/test/unit/common/test_constraints.py @@ -210,5 +210,12 @@ class TestConstraints(unittest.TestCase): self.assertEquals(constraints.check_metadata(req, 'object').status_int, HTTP_BAD_REQUEST) + def test_validate_constraints(self): + c = constraints + self.assertTrue(c.MAX_META_OVERALL_SIZE > c.MAX_META_NAME_LENGTH) + self.assertTrue(c.MAX_META_OVERALL_SIZE > c.MAX_META_VALUE_LENGTH) + self.assertTrue(c.MAX_HEADER_SIZE > c.MAX_META_NAME_LENGTH) + self.assertTrue(c.MAX_HEADER_SIZE > c.MAX_META_VALUE_LENGTH) + if __name__ == '__main__': unittest.main()