fix(updater): retain two verified backup generations

This commit is contained in:
2026-10-02 15:27:07 +02:00
parent 23d49f7186
commit b01cf2c207
5 changed files with 434 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Real migration -> adoption -> two updates, including a backup restore, on synthetic data.
"""Real migration -> adoption -> three updates, retention and restore on synthetic data.
Requires local storage test images and registry:2; never contacts a FEDEO instance.
Release HTTP/health responses are fixtures; Compose, registry, SDK, PostgreSQL,
@@ -101,7 +101,8 @@ def run():
docker('push', image['repository'] + ':fixture')
# Copy health, networking and SDK settings from the original fixture, but start the new image's migration script.
updater.releases = Releases(config, images)
for version in ('3.4.0', '3.5.0'):
backups = []
for version in ('3.4.0', '3.5.0', '3.6.0'):
http.version = version
checked = updater.execute('check', version)
assert checked['plan']['storageProvider'] == 'seaweedfs'
@@ -112,6 +113,15 @@ def run():
old_matrix = migration.inspect(retained)
assert not old_matrix['State']['Running'] and old_matrix['HostConfig']['RestartPolicy']['Name'] == 'no'
backup = Path(result['backup'])
backups.append(backup)
retention = result['backupRetention']
assert retention['status'] == 'complete', retention
assert len(retention['retained']) == min(len(backups), 2)
if len(backups) == 3:
assert not backups[0].exists()
assert u.read_json(backups[0].parent / 'backup-pruned.json')['status'] == 'removed'
assert backups[1].is_dir() and backups[2].is_dir()
assert (root / '.updates/storage-migration/backup/complete.json').is_file()
with tarfile.open(backup / 'files.tar') as archive:
assert archive.extractfile('matrix/postgres/retained.txt').read() == b'retired Matrix'
assert 'storage/config/s3.json' in archive.getnames()
@@ -136,7 +146,8 @@ def run():
migration.helper('restore-verify', endpoint='http://' + restore_name + ':9000')
finally:
docker('rm', '-f', restore_name)
print(json.dumps({'result': 'passed', 'restoredUpdaterBackup': str(backup), 'evidence': str(root)}), flush=True)
print(json.dumps({'result': 'passed', 'retention': 'two_generations_verified',
'restoredUpdaterBackup': str(backup), 'evidence': str(root)}), flush=True)
except BaseException:
print('Failure evidence: ' + str(root), flush=True)
for path in sorted((root / '.updates').glob('*/commands.log')):