|
@@ -125,6 +125,31 @@ class HashIndexTestCase(BaseTestCase):
|
|
|
assert unique_chunks == 3
|
|
|
|
|
|
|
|
|
+class HashIndexExtraTestCase(BaseTestCase):
|
|
|
+ """These tests are separate because they should not become part of the selftest
|
|
|
+ """
|
|
|
+ def test_chunk_indexer(self):
|
|
|
+ # see _hashindex.c hash_sizes, we want to be close to the max fill rate
|
|
|
+ # because interesting errors happen there
|
|
|
+ max_key = int(65537 * 0.75) - 10
|
|
|
+ index = ChunkIndex(max_key)
|
|
|
+ deleted_keys = [
|
|
|
+ hashlib.sha256(H(k)).digest()
|
|
|
+ for k in range(-1, -(max_key//3), -1)]
|
|
|
+ keys = [hashlib.sha256(H(k)).digest() for k in range(max_key)]
|
|
|
+ for i, key in enumerate(keys):
|
|
|
+ index[key] = (i, i, i)
|
|
|
+ for i, key in enumerate(deleted_keys):
|
|
|
+ index[key] = (i, i, i)
|
|
|
+
|
|
|
+ for key in deleted_keys:
|
|
|
+ del index[key]
|
|
|
+ for i, key in enumerate(keys):
|
|
|
+ assert index[key] == (i, i, i)
|
|
|
+ for key in deleted_keys:
|
|
|
+ assert index.get(key) is None
|
|
|
+
|
|
|
+
|
|
|
class HashIndexSizeTestCase(BaseTestCase):
|
|
|
def test_size_on_disk(self):
|
|
|
idx = ChunkIndex()
|