コード例 #1
0
    def test_restore_backup_with_bad_service(self):
        """Test error handling when attempting a restore of a backup
        with a different service to that used to create the backup
        """
        vol_id = self._create_volume_db_entry(status='restoring-backup',
                                              size=1)
        backup_id = self._create_backup_db_entry(status='restoring',
                                                 volume_id=vol_id)

        def fake_restore_backup(context, backup, volume, backup_service):
            pass

        self.stubs.Set(self.backup_mgr.driver, 'restore_backup',
                       fake_restore_backup)

        service = 'cinder.tests.backup.bad_service'
        db.backup_update(self.ctxt, backup_id, {'service': service})
        self.assertRaises(exception.InvalidBackup,
                          self.backup_mgr.restore_backup,
                          self.ctxt,
                          backup_id,
                          vol_id)
        vol = db.volume_get(self.ctxt, vol_id)
        self.assertEqual(vol['status'], 'error')
        backup = db.backup_get(self.ctxt, backup_id)
        self.assertEqual(backup['status'], 'available')
コード例 #2
0
 def test_delete_backup_with_no_service(self):
     """Test error handling when attempting a delete of a backup
     with no service defined for that backup, relates to bug #1162908"""
     vol_id = self._create_volume_db_entry(size=1)
     backup_id = self._create_backup_db_entry(status='deleting',
                                              volume_id=vol_id)
     db.backup_update(self.ctxt, backup_id, {'service': None})
     self.backup_mgr.delete_backup(self.ctxt, backup_id)
コード例 #3
0
ファイル: test_backup.py プロジェクト: aglarendil/cinder
 def test_delete_backup_with_no_service(self):
     """Test error handling when attempting a delete of a backup
     with no service defined for that backup, relates to bug #1162908"""
     vol_id = self._create_volume_db_entry(size=1)
     backup_id = self._create_backup_db_entry(status='deleting',
                                              volume_id=vol_id)
     db.backup_update(self.ctxt, backup_id, {'service': None})
     self.backup_mgr.delete_backup(self.ctxt, backup_id)
コード例 #4
0
 def test_export_record_with_bad_service(self):
     """Test error handling when attempting an export of a backup
     record with a different service to that used to create the backup.
     """
     vol_id = self._create_volume_db_entry(size=1)
     backup_id = self._create_backup_db_entry(status="available", volume_id=vol_id)
     service = "cinder.tests.backup.bad_service"
     db.backup_update(self.ctxt, backup_id, {"service": service})
     self.assertRaises(exception.InvalidBackup, self.backup_mgr.export_record, self.ctxt, backup_id)
コード例 #5
0
ファイル: backup.py プロジェクト: zjjfeng111/cinder
    def save(self):
        updates = self.cinder_obj_get_changes()
        if updates:
            if 'metadata' in updates:
                metadata = updates.pop('metadata', None)
                self.metadata = db.backup_metadata_update(
                    self._context, self.id, metadata, True)
            db.backup_update(self._context, self.id, updates)

        self.obj_reset_changes()
コード例 #6
0
 def test_delete_backup_with_bad_service(self):
     """Test error handling when attempting a delete of a backup
     with a different service to that used to create the backup"""
     vol_id = self._create_volume_db_entry(size=1)
     backup_id = self._create_backup_db_entry(status="deleting", volume_id=vol_id)
     service = "cinder.tests.backup.bad_service"
     db.backup_update(self.ctxt, backup_id, {"service": service})
     self.assertRaises(exception.InvalidBackup, self.backup_mgr.delete_backup, self.ctxt, backup_id)
     backup = db.backup_get(self.ctxt, backup_id)
     self.assertEquals(backup["status"], "available")
コード例 #7
0
ファイル: backup.py プロジェクト: j-griffith/cinder
    def save(self):
        updates = self.cinder_obj_get_changes()
        if updates:
            if 'metadata' in updates:
                metadata = updates.pop('metadata', None)
                self.metadata = db.backup_metadata_update(self._context,
                                                          self.id, metadata,
                                                          True)
            db.backup_update(self._context, self.id, updates)

        self.obj_reset_changes()
コード例 #8
0
 def test_export_record_with_bad_service(self):
     """Test error handling when attempting an export of a backup
     record with a different service to that used to create the backup.
     """
     vol_id = self._create_volume_db_entry(size=1)
     backup_id = self._create_backup_db_entry(status='available',
                                              volume_id=vol_id)
     service = 'cinder.tests.backup.bad_service'
     db.backup_update(self.ctxt, backup_id, {'service': service})
     self.assertRaises(exception.InvalidBackup,
                       self.backup_mgr.export_record, self.ctxt, backup_id)
コード例 #9
0
 def test_delete_backup_with_bad_service(self):
     """Test error handling when attempting a delete of a backup
     with a different service to that used to create the backup"""
     vol_id = self._create_volume_db_entry(size=1)
     backup_id = self._create_backup_db_entry(status='deleting',
                                              volume_id=vol_id)
     service = 'cinder.tests.backup.bad_service'
     db.backup_update(self.ctxt, backup_id, {'service': service})
     self.assertRaises(exception.InvalidBackup,
                       self.backup_mgr.delete_backup, self.ctxt, backup_id)
     backup = db.backup_get(self.ctxt, backup_id)
     self.assertEquals(backup['status'], 'error')
コード例 #10
0
ファイル: test_backup.py プロジェクト: CloudVPS/cinder
 def test_delete_backup_with_bad_service(self):
     """Test error handling when attempting a delete of a backup
     with a different service to that used to create the backup
     """
     vol_id = self._create_volume_db_entry(size=1)
     backup_id = self._create_backup_db_entry(status='deleting',
                                              volume_id=vol_id)
     service = 'cinder.tests.backup.bad_service'
     db.backup_update(self.ctxt, backup_id, {'service': service})
     self.assertRaises(exception.InvalidBackup,
                       self.backup_mgr.delete_backup,
                       self.ctxt,
                       backup_id)
     backup = db.backup_get(self.ctxt, backup_id)
     self.assertEqual(backup['status'], 'error')
コード例 #11
0
 def test_backup_update(self):
     updated_values = self._get_values(one=True)
     update_id = self.created[1]['id']
     updated_backup = db.backup_update(self.ctxt, update_id,
                                       updated_values)
     self._assertEqualObjects(updated_values, updated_backup,
                              self._ignored_keys)
コード例 #12
0
    def test_restore_backup_with_bad_service(self):
        """Test error handling when attempting a restore of a backup
        with a different service to that used to create the backup"""
        vol_id = self._create_volume_db_entry(status="restoring-backup", size=1)
        backup_id = self._create_backup_db_entry(status="restoring", volume_id=vol_id)

        def fake_restore_backup(context, backup, volume, backup_service):
            pass

        self.stubs.Set(self.backup_mgr.driver, "restore_backup", fake_restore_backup)

        service = "cinder.tests.backup.bad_service"
        db.backup_update(self.ctxt, backup_id, {"service": service})
        self.assertRaises(exception.InvalidBackup, self.backup_mgr.restore_backup, self.ctxt, backup_id, vol_id)
        vol = db.volume_get(self.ctxt, vol_id)
        self.assertEquals(vol["status"], "error")
        backup = db.backup_get(self.ctxt, backup_id)
        self.assertEquals(backup["status"], "available")
コード例 #13
0
ファイル: backup.py プロジェクト: nikesh-mahalka/copy_volume
    def save(self):
        updates = self.cinder_obj_get_changes()
        if updates:
            db.backup_update(self._context, self.id, updates)

        self.obj_reset_changes()