]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix backup.rpcapi to pass object backup
authorlisali <xiaoyan.li@intel.com>
Wed, 1 Jul 2015 06:32:28 +0000 (14:32 +0800)
committerlisali <xiaoyan.li@intel.com>
Wed, 1 Jul 2015 08:37:15 +0000 (16:37 +0800)
Transfer object backup instead of backup.id in
rpcapi.import_record().

Change-Id: Ie535c48d3987971f0541cdb1594363a4decd4d1c
Closes-Bug: #1470355

cinder/backup/manager.py
cinder/tests/unit/test_backup.py

index 4c6d7e877b2a5270e079b66e1f3e565182326dac..381905d6b3a7da46c8b20d4978c45cfe87346e78 100644 (file)
@@ -552,7 +552,7 @@ class BackupManager(manager.SchedulerDependentManager):
                 first_host = backup_hosts.pop()
                 self.backup_rpcapi.import_record(context,
                                                  first_host,
-                                                 backup.id,
+                                                 backup,
                                                  backup_service,
                                                  backup_url,
                                                  backup_hosts)
index 63f5c0cf928991a744bd0222423d2b1ecbdf1759..1d0da26fe421a72d63b1699c0855ddf9694d9b6b 100644 (file)
@@ -552,6 +552,7 @@ class BackupTestCase(BaseBackupTest):
         # Test that the import backup keeps calling other hosts to find a
         # suitable host for the backup service
         backup_hosts = ['fake1', 'fake2']
+        backup_hosts_expect = list(backup_hosts)
         BackupAPI_import = 'cinder.backup.rpcapi.BackupAPI.import_record'
         with mock.patch(BackupAPI_import) as _mock_backup_import:
             self.backup_mgr.import_record(self.ctxt,
@@ -559,7 +560,15 @@ class BackupTestCase(BaseBackupTest):
                                           export['backup_service'],
                                           export['backup_url'],
                                           backup_hosts)
-            self.assertTrue(_mock_backup_import.called)
+
+            next_host = backup_hosts_expect.pop()
+            _mock_backup_import.assert_called_once_with(
+                self.ctxt,
+                next_host,
+                imported_record,
+                export['backup_service'],
+                export['backup_url'],
+                backup_hosts_expect)
 
     def test_import_record_with_invalid_backup(self):
         """Test error handling when attempting an import of a backup