Merge "Set backup available after verify"

This commit is contained in:
Jenkins 2017-03-10 02:16:37 +00:00 committed by Gerrit Code Review
commit 83b137657a
2 changed files with 12 additions and 3 deletions

View File

@ -764,7 +764,6 @@ class BackupManager(manager.ThreadPoolManager):
raise exception.InvalidBackup(reason=msg) raise exception.InvalidBackup(reason=msg)
# Overwrite some fields # Overwrite some fields
backup_options['status'] = fields.BackupStatus.AVAILABLE
backup_options['service'] = self.driver_name backup_options['service'] = self.driver_name
backup_options['availability_zone'] = self.az backup_options['availability_zone'] = self.az
backup_options['host'] = self.host backup_options['host'] = self.host
@ -772,7 +771,7 @@ class BackupManager(manager.ThreadPoolManager):
# Remove some values which are not actual fields and some that # Remove some values which are not actual fields and some that
# were set by the API node # were set by the API node
for key in ('name', 'user_id', 'project_id', 'deleted_at', for key in ('name', 'user_id', 'project_id', 'deleted_at',
'deleted', 'fail_reason'): 'deleted', 'fail_reason', 'status'):
backup_options.pop(key, None) backup_options.pop(key, None)
# Update the database # Update the database
@ -793,6 +792,10 @@ class BackupManager(manager.ThreadPoolManager):
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
self._update_backup_error(backup, six.text_type(err)) self._update_backup_error(backup, six.text_type(err))
# Update the backup's status
backup.update({"status": fields.BackupStatus.AVAILABLE})
backup.save()
LOG.info(_LI('Import record id %s metadata from driver ' LOG.info(_LI('Import record id %s metadata from driver '
'finished.'), backup.id) 'finished.'), backup.id)

View File

@ -1227,7 +1227,13 @@ class BackupTestCaseWithVerify(BaseBackupTest):
(backup_driver.__module__, (backup_driver.__module__,
backup_driver.__class__.__name__, backup_driver.__class__.__name__,
'verify')) 'verify'))
with mock.patch(_mock_backup_verify_class):
def mock_verify(backup_id):
backup = db.backup_get(self.ctxt, backup_id)
self.assertEqual(fields.BackupStatus.CREATING, backup['status'])
with mock.patch(_mock_backup_verify_class) as mock_backup_verify:
mock_backup_verify.side_effect = mock_verify
self.backup_mgr.import_record(self.ctxt, self.backup_mgr.import_record(self.ctxt,
imported_record, imported_record,
export['backup_service'], export['backup_service'],