Last active
December 31, 2015 02:49
-
-
Save portante/7923353 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 6f9ef7f..05ffd78 100644 | |
--- a/test/unit/obj/test_diskfile.py | |
+++ b/test/unit/obj/test_diskfile.py | |
@@ -327,7 +327,7 @@ class TestDiskFileModuleMethods(unittest.TestCase): | |
self.assertEquals(diskfile.hash_cleanup_listdir('/whatever'), | |
[file2]) | |
- # keep .meta and .data if meta newer than data | |
+ # keep .meta and .data if meta newer than data and purge .ts | |
file1 = normalize_timestamp(time()) + '.ts' | |
file2 = normalize_timestamp(time() + 1) + '.data' | |
file3 = normalize_timestamp(time() + 2) + '.meta' | |
@@ -343,6 +343,36 @@ class TestDiskFileModuleMethods(unittest.TestCase): | |
self.assertEquals(diskfile.hash_cleanup_listdir('/whatever'), | |
[file3]) | |
+ # A more recent orphaned .meta file will prevent old .ts files | |
+ # from being cleaned up otherwise | |
+ file1 = normalize_timestamp(time()) + '.ts' | |
+ file2 = normalize_timestamp(time() + 1) + '.ts' | |
+ file3 = normalize_timestamp(time() + 2) + '.meta' | |
+ file_list = [file1, file2, file3] | |
+ self.assertEquals(diskfile.hash_cleanup_listdir('/whatever'), | |
+ [file3, file2]) | |
+ | |
+ # Oldest .data will be purge, .meta and .ts won't be touched | |
+ file1 = normalize_timestamp(time()) + '.data' | |
+ file2 = normalize_timestamp(time() + 1) + '.ts' | |
+ file3 = normalize_timestamp(time() + 2) + '.meta' | |
+ file_list = [file1, file2, file3] | |
+ self.assertEquals(diskfile.hash_cleanup_listdir('/whatever'), | |
+ [file3, file2]) | |
+ | |
+ # A single old .ts file will be removed | |
+ file1 = normalize_timestamp(time() - (86400 * 8)) + '.ts' | |
+ file_list = [file1] | |
+ self.assertEquals(diskfile.hash_cleanup_listdir('/whatever'), | |
+ []) | |
+ | |
+ # An orphaned .meta will not clean up a very old .ts | |
+ file1 = normalize_timestamp(time() - (86400 * 8)) + '.ts' | |
+ file2 = normalize_timestamp(time() + 2) + '.meta' | |
+ file_list = [file1, file2] | |
+ self.assertEquals(diskfile.hash_cleanup_listdir('/whatever'), | |
+ [file2, file1]) | |
+ | |
class TestObjectAuditLocationGenerator(unittest.TestCase): | |
def _make_file(self, path): | |
@@ -1577,7 +1607,7 @@ class TestDiskFile(unittest.TestCase): | |
with df.open(): | |
self.assertEqual(df.timestamp, '1383181759.12345') | |
- def test_error_in_hashdir_cleanup_listdir(self): | |
+ def test_error_in_hash_cleanup_listdir(self): | |
def mock_hcl(*args, **kwargs): | |
raise OSError() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment