Merge lp:~clay-gerrard/swift/ring_hash_endcap_1.2 into lp:swift/1.2

Proposed by clayg
Status: Merged
Approved by: Chuck Thier
Approved revision: 209
Merged at revision: 212
Proposed branch: lp:~clay-gerrard/swift/ring_hash_endcap_1.2
Merge into: lp:swift/1.2
Diff against target: 39 lines (+10/-1)
2 files modified
swift/common/ring/ring.py (+3/-1)
test/unit/common/ring/test_ring.py (+7/-0)
To merge this branch: bzr merge lp:~clay-gerrard/swift/ring_hash_endcap_1.2
Reviewer Review Type Date Requested Status
Jay Payne (community) Approve
OpenStack Infra Pending
Review via email: mp+50063@code.launchpad.net

Commit message

creating a Ring will ensure a valid HASH_PATH_SUFFIX

Description of the change

creating a Ring will ensure a valid HASH_PATH_SUFFIX

To post a comment you must log in.
Revision history for this message
Jay Payne (letterj) wrote :

Test this on all the swift-* files in the bin directory

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'swift/common/ring/ring.py'
2--- swift/common/ring/ring.py 2011-01-04 23:34:43 +0000
3+++ swift/common/ring/ring.py 2011-02-16 22:37:19 +0000
4@@ -18,7 +18,7 @@
5 from os.path import getmtime
6 from struct import unpack_from
7 from time import time
8-from swift.common.utils import hash_path
9+from swift.common.utils import hash_path, validate_configuration
10
11
12 class RingData(object):
13@@ -39,6 +39,8 @@
14 """
15
16 def __init__(self, pickle_gz_path, reload_time=15):
17+ # can't use the ring unless HASH_PATH_SUFFIX is set
18+ validate_configuration()
19 self.pickle_gz_path = pickle_gz_path
20 self.reload_time = reload_time
21 self._reload(force=True)
22
23=== modified file 'test/unit/common/ring/test_ring.py'
24--- test/unit/common/ring/test_ring.py 2011-01-04 23:34:43 +0000
25+++ test/unit/common/ring/test_ring.py 2011-02-16 22:37:19 +0000
26@@ -69,6 +69,13 @@
27 self.assertEquals(self.ring.devs, self.intended_devs)
28 self.assertEquals(self.ring.reload_time, self.intended_reload_time)
29 self.assertEquals(self.ring.pickle_gz_path, self.testgz)
30+ # test invalid endcap
31+ _orig_hash_path_suffix = utils.HASH_PATH_SUFFIX
32+ try:
33+ utils.HASH_PATH_SUFFIX = ''
34+ self.assertRaises(SystemExit, ring.Ring, self.testgz)
35+ finally:
36+ utils.HASH_PATH_SUFFIX = _orig_hash_path_suffix
37
38 def test_has_changed(self):
39 self.assertEquals(self.ring.has_changed(), False)

Subscribers

People subscribed via source and target branches