'Test backup create and restore to an existing volume.'

@decorators.idempotent_id('b5d837b0-7066-455d-88fc-4a721a899306')
def test_backup_create_and_restore_to_an_existing_volume(self):

    src_vol = self.create_volume()
    self.addCleanup(self.volumes_client.delete_volume, src_vol['id'])
    backup = self.backups_client.create_backup(volume_id=src_vol['id'])['backup']
    self.addCleanup(self.backups_client.delete_backup, backup['id'])
    waiters.wait_for_volume_resource_status(self.backups_client, backup['id'], 'available')
    restore = self.backups_client.restore_backup(backup_id=backup['id'], volume_id=src_vol['id'])['restore']
    waiters.wait_for_volume_resource_status(self.backups_client, backup['id'], 'available')
    waiters.wait_for_volume_resource_status(self.volumes_client, src_vol['id'], 'available')
    self.assertEqual(src_vol['id'], restore['volume_id'])
    self.assertEqual(backup['id'], restore['backup_id'])
