Skip to content

Commit

Permalink
Add tests and comments re constraints in /info
Browse files Browse the repository at this point in the history
Add test to check that only the expected keys are
reported by proxy in /info, and add comments to
raise awareness that default constraints will be
automatically published by proxy in response to /info
requests.

Change-Id: Ia5f6339b06cdc2e1dc960d1f75562a2505530202
  • Loading branch information
anc committed Apr 9, 2014
1 parent daecec6 commit 58fe2f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion etc/swift.conf-sample
Expand Up @@ -10,7 +10,8 @@ swift_hash_path_prefix = changeme


# The swift-constraints section sets the basic constraints on data
# saved in the swift cluster.
# saved in the swift cluster. These constraints are automatically
# published by the proxy server in responses to /info requests.

[swift-constraints]

Expand Down
4 changes: 4 additions & 0 deletions swift/common/constraints.py
Expand Up @@ -34,6 +34,10 @@
MAX_ACCOUNT_NAME_LENGTH = 256
MAX_CONTAINER_NAME_LENGTH = 256

# If adding an entry to DEFAULT_CONSTRAINTS, note that
# these constraints are automatically published by the
# proxy server in responses to /info requests, with values
# updated by reload_constraints()
DEFAULT_CONSTRAINTS = {
'max_file_size': MAX_FILE_SIZE,
'max_meta_name_length': MAX_META_NAME_LENGTH,
Expand Down
4 changes: 4 additions & 0 deletions test/unit/proxy/test_server.py
Expand Up @@ -5915,6 +5915,10 @@ def test_registered_defaults(self):
constraints.MAX_CONTAINER_NAME_LENGTH)
self.assertEqual(si['max_object_name_length'],
constraints.MAX_OBJECT_NAME_LENGTH)
self.assertTrue('strict_cors_mode' in si)
# this next test is deliberately brittle in order to alert if
# other items are added to swift info
self.assertEqual(len(si), 13)


if __name__ == '__main__':
Expand Down

0 comments on commit 58fe2f2

Please sign in to comment.