Last active
August 1, 2016 02:25
-
-
Save bloodeagle40234/b97ccf55f7e6526a646603ba63185f44 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/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py | |
index cc7d97d..d5eaafa 100644 | |
--- a/test/unit/obj/test_diskfile.py | |
+++ b/test/unit/obj/test_diskfile.py | |
@@ -5052,6 +5052,46 @@ class TestSuffixHashes(unittest.TestCase): | |
hashes = df_mgr.get_hashes('sda1', '0', [], policy) | |
self.assertEqual(hashes, {}) | |
+ def test_hash_suffix_one_reclaim_tombstone_with_hash_pkl(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) | |
+ # 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) | |
+ hashes = df_mgr.get_hashes('sda1', '0', [], policy) | |
+ # sanity | |
+ self.assertEqual(hashes, {}) | |
+ | |
+ # if hash.pkl exists, that .ts file is not reclaimed | |
+ df = df_mgr.get_diskfile( | |
+ 'sda1', '0', 'a', 'c', 'o', policy=policy) | |
+ df.delete(timestamp.internal) | |
+ hashes = df_mgr.get_hashes('sda1', '0', [], policy) | |
+ # yes, tis was a cached value so the value looks empty | |
+ self.assertEqual(hashes, {}) | |
+ # but we still have tombstone entry on the file sytem which causes | |
+ # DiskFileDeleted | |
+ self.assertRaises(DiskFileDeleted, df.open) | |
+ | |
+ # however if we call invalidate_hash for the suffix dir, | |
+ # get_hashes can reclaim the tombstone | |
+ suffix_dir = os.path.dirname(df._datadir) | |
+ with mock.patch('swift.obj.diskfile.lock_path'): | |
+ df_mgr.invalidate_hash(suffix_dir) | |
+ | |
+ df = df_mgr.get_diskfile( | |
+ 'sda1', '0', 'a', 'c', 'o', policy=policy) | |
+ hashes = df_mgr.get_hashes('sda1', '0', [], policy) | |
+ # sanity | |
+ self.assertEqual(hashes, {}) | |
+ # YEAH, we can remove the actual tombstone file here! | |
+ self.assertRaises(DiskFileNotExist, df.open) | |
+ | |
def test_hash_suffix_one_reclaim_and_one_valid_tombstone(self): | |
for policy in self.iter_policies(): | |
paths, suffix = find_paths_with_matching_suffixes(2, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment