Last active
August 29, 2015 14:17
-
-
Save clayg/44b341b9e131289c2603 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/swift/obj/diskfile.py b/swift/obj/diskfile.py | |
index 2e99792..532a61d 100644 | |
--- a/swift/obj/diskfile.py | |
+++ b/swift/obj/diskfile.py | |
@@ -2152,12 +2152,13 @@ class ECDiskFileManager(DiskFileManager): | |
return dict((fi, md5.hexdigest()) for fi, md5 in hash_per_fi.items()) | |
def _get_hashes(self, partition_path, recalculate=None, do_listdir=False, | |
- reclaim_age=ONE_WEEK): | |
+ reclaim_age=None): | |
""" | |
The only difference with this method and the module level function | |
get_hashes is the call to hash_suffix routes to a method _hash_suffix | |
on this instance. | |
""" | |
+ reclaim_age = reclaim_age or self.reclaim_age | |
hashed = 0 | |
hashes_file = join(partition_path, HASH_FILE) | |
modified = False | |
diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py | |
index 88a79e4..7748c8f 100644 | |
--- a/test/unit/obj/test_diskfile.py | |
+++ b/test/unit/obj/test_diskfile.py | |
@@ -3056,6 +3056,27 @@ class TestSuffixHashes(unittest.TestCase): | |
}[policy.policy_type] | |
self.assertEqual(hashes, expected) | |
+ def test_hash_suffix_one_reclaim_tombstone(self): | |
+ for policy in self.iter_policies(): | |
+ df_mgr = self.df_router[policy] | |
+ df = df_mgr.get_diskfile( | |
+ 'sda1', '0', 'a', 'c', 'o', policy=policy) | |
+ suffix = os.path.basename(os.path.dirname(df._datadir)) | |
+ # scale back this tests manager's reclaim age a bit | |
+ df_mgr.reclaim_age = 1000 | |
+ # write a tombstone that's just a *little* older | |
+ old_time = time() - 1001 | |
+ timestamp = Timestamp(old_time) | |
+ df.delete(timestamp.internal) | |
+ tombstone_hash = md5(timestamp.internal + '.ts').hexdigest() | |
+ hashes = df_mgr.get_hashes('sda1', '0', [], policy) | |
+ expected = { | |
+ # repl is broken, it doesn't use self.reclaim_age | |
+ REPL_POLICY: tombstone_hash, | |
+ EC_POLICY: {}, | |
+ }[policy.policy_type] | |
+ self.assertEqual(hashes, {suffix: expected}) | |
+ | |
def test_hash_suffix_one_datafile(self): | |
for policy in self.iter_policies(): | |
df_mgr = self.df_router[policy] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment