mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-21 21:57:36 +00:00
add extra test for the hashindex
Insert a few keys, delete some of them, check we still have the values we expect, check the deleted ones aren't there.
This commit is contained in:
parent
2c1607caa6
commit
8c2064cc5a
1 changed files with 25 additions and 0 deletions
|
@ -125,6 +125,31 @@ def test_chunkindex_summarize(self):
|
|||
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()
|
||||
|
|
Loading…
Reference in a new issue