___________ RemoteArchiverTestCase.test_related_repos_deduplication ____________
[gw1] linux -- Python 3.10.20 /home/runner/work/borg/borg/.tox/py310-fuse2/bin/python
self = <borg.testsuite.archiver.RemoteArchiverTestCase testMethod=test_related_repos_deduplication>
def test_related_repos_deduplication(self):
CHUNKER_PARAMS = 'buzhash,10,18,14,4095' # ~16kiB chunks
# 1. Create repo1
self.cmd('init', '--encryption=repokey', self.repository_location)
self.create_regular_file('file1', contents=os.urandom(128 * 1024))
self.cmd('create', f'--chunker-params={CHUNKER_PARAMS}', self.repository_location + '::archive1', 'input')
# 2. Export related secrets
secrets_path = os.path.join(self.tmpdir, 'secrets.json')
self.cmd('key', 'export-related-secrets', self.repository_location, secrets_path)
with open(secrets_path, 'r') as f:
secrets = json.load(f)
assert secrets['version'] == 1
assert 'id_key' in secrets
assert 'chunk_seed' in secrets
assert 'key_name' in secrets
# 3. Create repo2 using imported secrets
repo2_path = os.path.join(self.tmpdir, 'repo2')
repo2_location = self.prefix + repo2_path
self.cmd('init', '--encryption=repokey', '--import-related-secrets', secrets_path, repo2_location)
# 4. Create backup in repo2 with same data
self.cmd('create', f'--chunker-params={CHUNKER_PARAMS}', repo2_location + '::archive2', 'input')
# 5. Verify chunk IDs are identical
def get_chunk_ids(repo_path, archive_name):
with Repository(repo_path) as repository:
manifest, key = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
archive = Archive(repository, key, manifest, archive_name)
ids = []
for item in archive.iter_items():
chunks = getattr(item, 'chunks', None)
if chunks:
ids.extend(c.id for c in chunks)
return ids
ids1 = get_chunk_ids(self.repository_path, 'archive1')
ids2 = get_chunk_ids(repo2_path, 'archive2')
assert ids1 == ids2
> assert len(ids1) > 3
E assert 3 > 3
E + where 3 = len([b'\x19+\xa2R\xb7\xb7\x84J-\xad`#\xb4\x0bpQ\xa8\x9dX<P8ZrL.\xaf\xf6\x05\x86\xa9\xdf', b'kE\x9c\xbe\xae\xeb\xc4\x10\x94&S\xb4\xf5\xda\x17\x91{\xc1\x9bE"6\x00\xc3\xca\xf0/\xfat/\x97{', b"f\x10\xe3V\xe0\xe5\x8d\xf8\xd0\x82\xda\xc1\x93\xce.\x85*\xcc\n'\xdf\xf6\xaa\x88}\xc3\x86\xad\xcf\x01\x046"])
src/borg/testsuite/archiver.py:4457: AssertionError
Sometimes there are only 3 chunks: