Followup to address open review comments

This patch is a followup of [1] to address review comments.

[1] https://review.opendev.org/#/c/705876/

Change-Id: I41edec1877106165576ef6bacff24d354460f2ef
This commit is contained in:
xuanyandong 2020-04-07 22:17:31 +08:00
parent 55de6d8866
commit 2e0e37c549
2 changed files with 10 additions and 5 deletions

View File

@ -1316,6 +1316,9 @@ class BackupTestCase(BaseBackupTest):
with mock.patch('os.name', os_name): with mock.patch('os.name', os_name):
self.backup_mgr.restore_backup(self.ctxt, backup, vol2_id) self.backup_mgr.restore_backup(self.ctxt, backup, vol2_id)
vol2.refresh()
old_src_backup_id = vol2.metadata["src_backup_id"]
self.assertEqual(backup.id, old_src_backup_id)
vol2.status = 'restoring-backup' vol2.status = 'restoring-backup'
db.volume_update(self.ctxt, vol2.id, {"status": "restoring-backup"}) db.volume_update(self.ctxt, vol2.id, {"status": "restoring-backup"})
vol2.obj_reset_changes() vol2.obj_reset_changes()
@ -1325,11 +1328,12 @@ class BackupTestCase(BaseBackupTest):
vol2.status = 'available' vol2.status = 'available'
vol2.obj_reset_changes() vol2.obj_reset_changes()
vol = objects.Volume.get_by_id(self.ctxt, new_vol_id) vol.refresh()
vol2 = objects.Volume.get_by_id(self.ctxt, vol2_id) vol2.refresh()
self.assertEqual('available', vol['status']) self.assertEqual('available', vol.status)
backup = db.backup_get(self.ctxt, backup.id) backup.refresh()
self.assertEqual(backup.id, vol.metadata["src_backup_id"]) self.assertEqual(backup.id, vol.metadata["src_backup_id"])
self.assertNotEqual(old_src_backup_id, vol2.metadata["src_backup_id"])
self.assertEqual(backup2.id, vol2.metadata["src_backup_id"]) self.assertEqual(backup2.id, vol2.metadata["src_backup_id"])
self.assertEqual(fields.BackupStatus.AVAILABLE, backup['status']) self.assertEqual(fields.BackupStatus.AVAILABLE, backup['status'])

View File

@ -1,7 +1,8 @@
--- ---
features: features:
- | - |
Add the property ``src_backup_id`` to the volume's metadata, Added the property ``src_backup_id`` to the volume's metadata,
to record from which backup the new volume was created. to record from which backup the new volume was created.
If the ``src_backup_id`` exists in the volume's metadata, it will be updated.
When restoring from a chain of incremental backups, ``src_backup_id`` When restoring from a chain of incremental backups, ``src_backup_id``
is set to the last incremental backup used for the restore. is set to the last incremental backup used for the restore.