'Regression test for bug #1595962.
If the graphical consoles VNC and SPICE are disabled, the
live-migration of an instance will result in an ERROR state.
VNC and SPICE are usually disabled on IBM z systems platforms
where graphical consoles are not available. The serial console
is then enabled and VNC + SPICE are disabled.
The error will be raised at
https://github.com/openstack/nova/blob/
4f33047d07f5a11b208c344fe206aba01cd8e6fe/
nova/virt/libvirt/driver.py#L5842-L5852'

@mock.patch('nova.virt.libvirt.LibvirtDriver.get_volume_connector')
@mock.patch('nova.virt.libvirt.guest.Guest.get_job_info')
@mock.patch.object(fakelibvirt.Domain, 'migrateToURI2')
@mock.patch('nova.virt.libvirt.host.Host.get_connection')
@mock.patch('nova.virt.disk.api.get_disk_size', return_value=1024)
@mock.patch('os.path.getsize', return_value=1024)
@mock.patch('nova.conductor.tasks.live_migrate.LiveMigrationTask._check_destination_is_not_source', return_value=False)
@mock.patch('nova.virt.libvirt.LibvirtDriver._create_image')
def test_serial_console_live_migrate(self, mock_create_image, mock_conductor_source_check, mock_path_get_size, mock_get_disk_size, mock_host_get_connection, mock_migrate_to_uri, mock_get_job_info, mock_get_volume_connector):

    mock_get_job_info.return_value = libvirt_guest.JobInfo(type=fakelibvirt.VIR_DOMAIN_JOB_COMPLETED)
    fake_connection = fakelibvirt.Connection('qemu:///system', version=1002007, hv_version=2001000)
    mock_host_get_connection.return_value = fake_connection
    server_attr = dict(name='server1', imageRef=self.image_id, flavorRef=self.flavor_id)
    server = self.api.post_server({'server': server_attr})
    server_id = server['id']
    self.wait_till_active_or_timeout(server_id)
    post = {'os-migrateLive': {'block_migration': False, 'disk_over_commit': False, 'host': 'test_compute1'}}
    try:
        self.admin_api.post_server_action(server_id, post)
        self.wait_till_active_or_timeout(server_id)
    except Exception as ex:
        self.fail(ex.response.content)
