mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-20 21:27:32 +00:00
testsuite: hashindex: test compact -> merge
This commit is contained in:
parent
1379af22de
commit
295ac86d71
1 changed files with 14 additions and 16 deletions
|
@ -162,22 +162,6 @@ def test_chunk_indexer(self):
|
||||||
# the index should now be empty
|
# the index should now be empty
|
||||||
assert list(index.iteritems()) == []
|
assert list(index.iteritems()) == []
|
||||||
|
|
||||||
def test_vacuum(self):
|
|
||||||
idx1 = ChunkIndex()
|
|
||||||
idx1[H(1)] = 1, 100, 100
|
|
||||||
idx1[H(2)] = 2, 200, 200
|
|
||||||
idx1[H(3)] = 3, 300, 300
|
|
||||||
idx1.compact()
|
|
||||||
assert idx1.size() == 18 + 3 * (32 + 3 * 4)
|
|
||||||
#with self.assert_raises(KeyError):
|
|
||||||
# idx1[H(1)]
|
|
||||||
data = list(idx1.iteritems())
|
|
||||||
print(data)
|
|
||||||
assert (H(1), ChunkIndexEntry(1, 100, 100)) in data
|
|
||||||
assert (H(2), ChunkIndexEntry(2, 200, 200)) in data
|
|
||||||
assert (H(3), ChunkIndexEntry(3, 300, 300)) in data
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class HashIndexSizeTestCase(BaseTestCase):
|
class HashIndexSizeTestCase(BaseTestCase):
|
||||||
def test_size_on_disk(self):
|
def test_size_on_disk(self):
|
||||||
|
@ -487,6 +471,20 @@ def test_empty(self):
|
||||||
self.index(num_entries=0, num_buckets=0)
|
self.index(num_entries=0, num_buckets=0)
|
||||||
assert compact_index == self.index_data.getvalue()
|
assert compact_index == self.index_data.getvalue()
|
||||||
|
|
||||||
|
def test_merge(self):
|
||||||
|
master = ChunkIndex()
|
||||||
|
idx1 = ChunkIndex()
|
||||||
|
idx1[H(1)] = 1, 100, 100
|
||||||
|
idx1[H(2)] = 2, 200, 200
|
||||||
|
idx1[H(3)] = 3, 300, 300
|
||||||
|
idx1.compact()
|
||||||
|
assert idx1.size() == 18 + 3 * (32 + 3 * 4)
|
||||||
|
|
||||||
|
master.merge(idx1)
|
||||||
|
assert master[H(1)] == (1, 100, 100)
|
||||||
|
assert master[H(2)] == (2, 200, 200)
|
||||||
|
assert master[H(3)] == (3, 300, 300)
|
||||||
|
|
||||||
|
|
||||||
class NSIndexTestCase(BaseTestCase):
|
class NSIndexTestCase(BaseTestCase):
|
||||||
def test_nsindex_segment_limit(self):
|
def test_nsindex_segment_limit(self):
|
||||||
|
|
Loading…
Reference in a new issue