def add_snapshot_for_backup(api):
    engine = api.system_service()

    vm2_disk_attachments_service = test_utils.get_disk_attachments_service(engine, VM2_NAME)
    disk = vm2_disk_attachments_service.list()[0]

    backup_snapshot_params = types.Snapshot(
        description=SNAPSHOT_FOR_BACKUP_VM,
        persist_memorystate=False,
        disk_attachments=[
            types.DiskAttachment(
                disk=types.Disk(
                    id=disk.id
                )
            )
        ]
    )

    vm2_snapshots_service = test_utils.get_vm_snapshots_service(engine, VM2_NAME)

    correlation_id = uuid.uuid4()
    with test_utils.TestEvent(engine, [45, 68]):
        # USER_CREATE_SNAPSHOT(41) event
        # USER_CREATE_SNAPSHOT_FINISHED_SUCCESS(68) event
        vm2_snapshots_service.add(backup_snapshot_params,
                                  query={'correlation_id': correlation_id})

        testlib.assert_true_within_long(
            lambda:
            test_utils.all_jobs_finished(engine, correlation_id)
        )
        testlib.assert_true_within_long(
            lambda:
            vm2_snapshots_service.list()[-1].snapshot_status == types.SnapshotStatus.OK,
        )
示例#2
0
def test_live_storage_migration(api_v4):
    pytest.skip("TODO: el8 fails all the time")

    engine = api_v4.system_service()
    disk_service = test_utils.get_disk_service(engine, DISK0_NAME)
    correlation_id = 'live_storage_migration'
    disk_service.move(async=False,
                      filter=False,
                      storage_domain=types.StorageDomain(name=SD_ISCSI_NAME),
                      query={'correlation_id': correlation_id})

    testlib.assert_true_within_long(
        lambda: test_utils.all_jobs_finished(engine, correlation_id))

    # Assert that the disk is on the correct storage domain,
    # its status is OK and the snapshot created for the migration
    # has been merged
    testlib.assert_true_within_long(lambda: api_v4.follow_link(
        disk_service.get().storage_domains[0]).name == SD_ISCSI_NAME)

    vm0_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM0_NAME)
    testlib.assert_true_within_long(
        lambda: len(vm0_snapshots_service.list()) == 1)
    testlib.assert_true_within_long(
        lambda: disk_service.get().status == types.DiskStatus.OK)
示例#3
0
def test_add_snapshot_for_backup(api_v4):
    engine = api_v4.system_service()

    vm2_disk_attachments_service = test_utils.get_disk_attachments_service(
        engine, VM2_NAME)
    disk = vm2_disk_attachments_service.list()[0]

    backup_snapshot_params = types.Snapshot(
        description=SNAPSHOT_FOR_BACKUP_VM,
        persist_memorystate=False,
        disk_attachments=[types.DiskAttachment(disk=types.Disk(id=disk.id))])

    vm2_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM2_NAME)

    correlation_id = uuid.uuid4()
    with test_utils.TestEvent(engine, [45, 68]):
        # USER_CREATE_SNAPSHOT(41) event
        # USER_CREATE_SNAPSHOT_FINISHED_SUCCESS(68) event
        vm2_snapshots_service.add(backup_snapshot_params,
                                  query={'correlation_id': correlation_id})

        testlib.assert_true_within_long(
            lambda: test_utils.all_jobs_finished(engine, correlation_id))
        testlib.assert_true_within_long(
            lambda: vm2_snapshots_service.list()[-1].snapshot_status == types.
            SnapshotStatus.OK, )
示例#4
0
def test_verify_backup_snapshot_removed(api_v4):
    engine = api_v4.system_service()
    vm2_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM2_NAME)

    testlib.assert_true_within_long(
        lambda: len(vm2_snapshots_service.list()) == 1)
def verify_backup_snapshot_removed(api):
    engine = api.system_service()
    vm2_snapshots_service = test_utils.get_vm_snapshots_service(engine, VM2_NAME)

    testlib.assert_true_within_long(
        lambda: len(vm2_snapshots_service.list()) == 1
    )
示例#6
0
def test_verify_backup_snapshot_removed(engine_api):
    engine = engine_api.system_service()
    vm2_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM2_NAME)

    assertions.assert_true_within_long(
        lambda: len(vm2_snapshots_service.list()) == 1)
def live_storage_migration(api):
    engine = api.system_service()
    disk_service = test_utils.get_disk_service(engine, DISK0_NAME)
    correlation_id = uuid.uuid4()
    disk_service.move(
        async=False,
        filter=False,
        storage_domain=types.StorageDomain(
            name=SD_ISCSI_NAME
        ),
        query={'correlation_id': correlation_id}
    )

    testlib.assert_true_within_long(lambda: test_utils.all_jobs_finished(engine, correlation_id))

    # Assert that the disk is on the correct storage domain,
    # its status is OK and the snapshot created for the migration
    # has been merged
    testlib.assert_true_within_long(
        lambda: api.follow_link(disk_service.get().storage_domains[0]).name == SD_ISCSI_NAME
    )

    vm0_snapshots_service = test_utils.get_vm_snapshots_service(engine, VM0_NAME)
    testlib.assert_true_within_long(
        lambda: len(vm0_snapshots_service.list()) == 1
    )
    testlib.assert_true_within_long(
        lambda: disk_service.get().status == types.DiskStatus.OK
    )
def verify_backup_snapshot_created(api):
    engine = api.system_service()

    vm2_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM2_NAME)

    testlib.assert_true_within_long(
        lambda: vm2_snapshots_service.list()[-1].snapshot_status == types.
        SnapshotStatus.OK, )
def add_snapshot_for_backup(api):
    engine = api.system_service()

    vm2_disk_attachments_service = test_utils.get_disk_attachments_service(
        engine, VM2_NAME)
    disk = vm2_disk_attachments_service.list()[0]

    backup_snapshot_params = types.Snapshot(
        description=SNAPSHOT_FOR_BACKUP_VM,
        persist_memorystate=False,
        disk_attachments=[types.DiskAttachment(disk=types.Disk(id=disk.id))])

    vm2_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM2_NAME)
    vm2_snapshots_service.add(backup_snapshot_params)
def remove_backup_vm_and_backup_snapshot(api):
    engine = api.system_service()
    backup_vm_service = test_utils.get_vm_service(engine, BACKUP_VM_NAME)
    vm2_snapshots_service = (test_utils.get_vm_snapshots_service(
        engine, VM2_NAME))
    vm2_snapshot = vm2_snapshots_service.list()[-1]
    # power-off backup-vm
    backup_vm_service.stop()

    testlib.assert_true_within_long(
        lambda: backup_vm_service.get().status == types.VmStatus.DOWN)
    # remove backup_vm
    num_of_vms = len(engine.vms_service().list())
    backup_vm_service.remove()
    nt.assert_true(len(engine.vms_service().list()) == (num_of_vms - 1))
    # remove vm2 snapshot
    vm2_snapshots_service.snapshot_service(vm2_snapshot.id).remove()
示例#11
0
def snapshot_cold_merge(engine_api):
    engine = engine_api.system_service()
    vm1_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM1_NAME)
    if vm1_snapshots_service is None:
        pytest.skip('Glance is not available')

    disk = engine.disks_service().list(
        search='name={} and vm_names={}'.format(DISK1_NAME, VM1_NAME))[0]

    dead_snap1_params = types.Snapshot(
        description=SNAPSHOT_DESC_1,
        persist_memorystate=False,
        disk_attachments=[types.DiskAttachment(disk=types.Disk(id=disk.id))])
    correlation_id = uuid.uuid4()

    vm1_snapshots_service.add(dead_snap1_params,
                              query={'correlation_id': correlation_id})

    assertions.assert_true_within_long(
        lambda: test_utils.all_jobs_finished(engine, correlation_id))
    assertions.assert_true_within_long(lambda: vm1_snapshots_service.list()[
        -1].snapshot_status == types.SnapshotStatus.OK)

    dead_snap2_params = types.Snapshot(
        description=SNAPSHOT_DESC_2,
        persist_memorystate=False,
        disk_attachments=[types.DiskAttachment(disk=types.Disk(id=disk.id))])
    correlation_id_snap2 = uuid.uuid4()

    vm1_snapshots_service.add(dead_snap2_params,
                              query={'correlation_id': correlation_id_snap2})

    assertions.assert_true_within_long(
        lambda: test_utils.all_jobs_finished(engine, correlation_id_snap2))
    assertions.assert_true_within_long(lambda: vm1_snapshots_service.list()[
        -1].snapshot_status == types.SnapshotStatus.OK)

    snapshot = vm1_snapshots_service.list()[-2]
    vm1_snapshots_service.snapshot_service(snapshot.id).remove()

    assertions.assert_true_within_long(
        lambda: len(vm1_snapshots_service.list()) == 2)
    assertions.assert_true_within_long(lambda: vm1_snapshots_service.list()[
        -1].snapshot_status == types.SnapshotStatus.OK)
def attach_snapshot_to_backup_vm(api):
    engine = api.system_service()
    vm2_snapshots_service = (test_utils.get_vm_snapshots_service(
        engine, VM2_NAME))
    vm2_disk_attachments_service = (test_utils.get_disk_attachments_service(
        engine, VM2_NAME))
    vm2_disk = vm2_disk_attachments_service.list()[0]
    disk_attachments_service = (test_utils.get_disk_attachments_service(
        engine, BACKUP_VM_NAME))

    disk_attachments_service.add(
        types.DiskAttachment(disk=types.Disk(
            id=vm2_disk.id,
            snapshot=types.Snapshot(id=vm2_snapshots_service.list()[-1].id)),
                             interface=types.DiskInterface.VIRTIO_SCSI,
                             bootable=False,
                             active=True))
    nt.assert_true(len(disk_attachments_service.list()) > 0)
示例#13
0
def test_attach_snapshot_to_backup_vm(api_v4):
    engine = api_v4.system_service()
    vm2_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM2_NAME)
    vm2_disk_attachments_service = test_utils.get_disk_attachments_service(
        engine, VM2_NAME)
    vm2_disk = vm2_disk_attachments_service.list()[0]
    disk_attachments_service = test_utils.get_disk_attachments_service(
        engine, BACKUP_VM_NAME)

    with test_utils.TestEvent(engine, 2016):  # USER_ATTACH_DISK_TO_VM event
        disk_attachments_service.add(
            types.DiskAttachment(disk=types.Disk(
                id=vm2_disk.id,
                snapshot=types.Snapshot(
                    id=vm2_snapshots_service.list()[-1].id)),
                                 interface=types.DiskInterface.VIRTIO_SCSI,
                                 bootable=False,
                                 active=True))
        assert len(disk_attachments_service.list()) > 0
示例#14
0
def test_remove_backup_vm_and_backup_snapshot(api_v4):
    engine = api_v4.system_service()
    backup_vm_service = test_utils.get_vm_service(engine, BACKUP_VM_NAME)
    vm2_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM2_NAME)
    vm2_snapshot = vm2_snapshots_service.list()[-1]
    # power-off backup-vm
    with test_utils.TestEvent(engine, [33, 61]):
        # VM_DOWN(61) event
        # USER_STOP_VM(33) event
        backup_vm_service.stop()
        testlib.assert_true_within_long(
            lambda: backup_vm_service.get().status == types.VmStatus.DOWN)
    # remove backup_vm
    num_of_vms = len(engine.vms_service().list())
    backup_vm_service.remove()
    assert len(engine.vms_service().list()) == (num_of_vms - 1)
    with test_utils.TestEvent(engine, 342):  # USER_REMOVE_SNAPSHOT event
        # remove vm2 snapshot
        vm2_snapshots_service.snapshot_service(vm2_snapshot.id).remove()
def snapshot_merge(api):
    engine = api.system_service()
    vm0_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM0_NAME)

    disk = engine.disks_service().list(
        search='name={}'.format(GLANCE_DISK_NAME))[0]

    dead_snap1_params = types.Snapshot(
        description='dead_snap1',
        persist_memorystate=False,
        disk_attachments=[types.DiskAttachment(disk=types.Disk(id=disk.id))])

    correlation_id = uuid.uuid4()
    vm0_snapshots_service.add(dead_snap1_params,
                              query={'correlation_id': correlation_id})
    testlib.assert_true_within_short(
        lambda: test_utils.all_jobs_finished(engine, correlation_id))
    testlib.assert_true_within_short(lambda: vm0_snapshots_service.list()[
        -1].snapshot_status == types.SnapshotStatus.OK)

    dead_snap2_params = types.Snapshot(
        description='dead_snap2',
        persist_memorystate=False,
        disk_attachments=[types.DiskAttachment(disk=types.Disk(id=disk.id))])

    correlation_id_snap2 = uuid.uuid4()

    vm0_snapshots_service.add(dead_snap2_params,
                              query={'correlation_id': correlation_id_snap2})
    testlib.assert_true_within_short(
        lambda: test_utils.all_jobs_finished(engine, correlation_id_snap2))
    testlib.assert_true_within_short(lambda: vm0_snapshots_service.list()[
        -1].snapshot_status == types.SnapshotStatus.OK)

    snapshot = vm0_snapshots_service.list()[-2]
    vm0_snapshots_service.snapshot_service(snapshot.id).remove()
    testlib.assert_true_within_short(
        lambda: (len(vm0_snapshots_service.list()) == 2) and
        (vm0_snapshots_service.list()[-1].snapshot_status == types.
         SnapshotStatus.OK), )
def remove_backup_vm_and_backup_snapshot(api):
    engine = api.system_service()
    backup_vm_service = test_utils.get_vm_service(engine, BACKUP_VM_NAME)
    vm2_snapshots_service = test_utils.get_vm_snapshots_service(engine, VM2_NAME)
    vm2_snapshot = vm2_snapshots_service.list()[-1]
    # power-off backup-vm
    with test_utils.TestEvent(engine, [33, 61]):
        # VM_DOWN(61) event
        # USER_STOP_VM(33) event
        backup_vm_service.stop()
        testlib.assert_true_within_long(
            lambda:
            backup_vm_service.get().status == types.VmStatus.DOWN
        )
    # remove backup_vm
    num_of_vms = len(engine.vms_service().list())
    backup_vm_service.remove()
    nt.assert_true(len(engine.vms_service().list()) == (num_of_vms-1))
    with test_utils.TestEvent(engine, 342): # USER_REMOVE_SNAPSHOT event
        # remove vm2 snapshot
        vm2_snapshots_service.snapshot_service(vm2_snapshot.id).remove()
def attach_snapshot_to_backup_vm(api):
    engine = api.system_service()
    vm2_snapshots_service = test_utils.get_vm_snapshots_service(engine, VM2_NAME)
    vm2_disk_attachments_service = test_utils.get_disk_attachments_service(engine, VM2_NAME)
    vm2_disk = vm2_disk_attachments_service.list()[0]
    disk_attachments_service = test_utils.get_disk_attachments_service(engine, BACKUP_VM_NAME)

    with test_utils.TestEvent(engine, 2016): # USER_ATTACH_DISK_TO_VM event
        disk_attachments_service.add(
            types.DiskAttachment(
                disk=types.Disk(
                    id=vm2_disk.id,
                    snapshot=types.Snapshot(
                        id=vm2_snapshots_service.list()[-1].id
                    )
                ),
                interface=types.DiskInterface.VIRTIO_SCSI,
                bootable=False,
                active=True
            )
        )
        nt.assert_true(len(disk_attachments_service.list()) > 0)
def live_storage_migration(api):
    engine = api.system_service()
    disk_service = test_utils.get_disk_service(engine, DISK0_NAME)
    disk_service.move(async=False,
                      filter=False,
                      storage_domain=types.StorageDomain(name=SD_ISCSI_NAME))

    # Assert that the disk is on the correct storage domain,
    # its status is OK and the snapshot created for the migration
    # has been merged
    testlib.assert_true_within_long(lambda: api.follow_link(disk_service.get(
    ).storage_domains[0]).name == SD_ISCSI_NAME)

    vm0_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM0_NAME)
    testlib.assert_true_within_long(
        lambda: len(vm0_snapshots_service.list()) == 1)
    testlib.assert_true_within_long(
        lambda: disk_service.get().status == types.DiskStatus.OK)

    # This sleep is a temporary solution to the race condition
    # https://bugzilla.redhat.com/1456504
    time.sleep(3)
def snapshot_cold_merge(api):
    engine = api.system_service()
    vm1_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM1_NAME)
    if vm1_snapshots_service is None:
        raise SkipTest('Glance is not available')

    disk = engine.disks_service().list(search='name={}'.format(DISK1_NAME))[0]

    dead_snap1_params = types.Snapshot(
        description=SNAPSHOT_DESC_1,
        persist_memorystate=False,
        disk_attachments=[types.DiskAttachment(disk=types.Disk(id=disk.id))])

    vm1_snapshots_service.add(dead_snap1_params)

    testlib.assert_true_within_long(lambda: vm1_snapshots_service.list()[-1].
                                    snapshot_status == types.SnapshotStatus.OK)

    dead_snap2_params = types.Snapshot(
        description=SNAPSHOT_DESC_2,
        persist_memorystate=False,
        disk_attachments=[types.DiskAttachment(disk=types.Disk(id=disk.id))])

    vm1_snapshots_service.add(dead_snap2_params)

    testlib.assert_true_within_long(lambda: vm1_snapshots_service.list()[-1].
                                    snapshot_status == types.SnapshotStatus.OK)

    snapshot = vm1_snapshots_service.list()[-2]
    vm1_snapshots_service.snapshot_service(snapshot.id).remove()

    testlib.assert_true_within_long(
        lambda: len(vm1_snapshots_service.list()) == 2)
    testlib.assert_true_within_long(lambda: vm1_snapshots_service.list()[-1].
                                    snapshot_status == types.SnapshotStatus.OK)
示例#20
0
def test_verify_vm1_exported(engine_api):
    engine = engine_api.system_service()
    vm1_snapshots_service = test_utils.get_vm_snapshots_service(
        engine, VM1_NAME)
    assertions.assert_true_within_long(
        lambda: len(vm1_snapshots_service.list()) == 1, )
def snapshot_merge(api):
    engine = api.system_service()
    vm0_snapshots_service = test_utils.get_vm_snapshots_service(engine, VM0_NAME)

    disk = engine.disks_service().list(search='name={}'.format(DISK0_NAME))[0]

    dead_snap1_params = types.Snapshot(
        description='dead_snap1',
        persist_memorystate=False,
        disk_attachments=[
            types.DiskAttachment(
                disk=types.Disk(
                    id=disk.id
                )
            )
        ]
    )

    correlation_id = uuid.uuid4()
    vm0_snapshots_service.add(
        dead_snap1_params,
        query={'correlation_id': correlation_id}
    )
    testlib.assert_true_within_short(
        lambda:
        test_utils.all_jobs_finished(engine, correlation_id)
    )
    testlib.assert_true_within_short(
        lambda:
        vm0_snapshots_service.list()[-1].snapshot_status == types.SnapshotStatus.OK
    )

    dead_snap2_params = types.Snapshot(
        description='dead_snap2',
        persist_memorystate=False,
        disk_attachments=[
            types.DiskAttachment(
                disk=types.Disk(
                    id=disk.id
                )
            )
        ]
    )

    correlation_id_snap2 = uuid.uuid4()

    vm0_snapshots_service.add(
        dead_snap2_params,
        query={'correlation_id': correlation_id_snap2}
    )
    testlib.assert_true_within_short(
        lambda:
        test_utils.all_jobs_finished(engine, correlation_id_snap2)
    )
    testlib.assert_true_within_short(
        lambda:
        vm0_snapshots_service.list()[-1].snapshot_status == types.SnapshotStatus.OK
    )

    snapshot = vm0_snapshots_service.list()[-2]
    vm0_snapshots_service.snapshot_service(snapshot.id).remove()
    testlib.assert_true_within_short(
        lambda:
        (len(vm0_snapshots_service.list()) == 2) and
        (vm0_snapshots_service.list()[-1].snapshot_status == types.SnapshotStatus.OK),
    )
def snapshot_cold_merge(api):
    engine = api.system_service()
    vm1_snapshots_service = test_utils.get_vm_snapshots_service(engine, VM1_NAME)
    if vm1_snapshots_service is None:
        raise SkipTest('Glance is not available')

    disk = engine.disks_service().list(search='name={}'.format(DISK1_NAME))[0]

    dead_snap1_params = types.Snapshot(
        description=SNAPSHOT_DESC_1,
        persist_memorystate=False,
        disk_attachments=[
            types.DiskAttachment(
                disk=types.Disk(
                    id=disk.id
                )
            )
        ]
    )
    correlation_id = uuid.uuid4()

    vm1_snapshots_service.add(dead_snap1_params,
                              query={'correlation_id': correlation_id})

    testlib.assert_true_within_long(
        lambda:
        test_utils.all_jobs_finished(engine, correlation_id)
    )
    testlib.assert_true_within_long(
        lambda:
        vm1_snapshots_service.list()[-1].snapshot_status == types.SnapshotStatus.OK
    )

    dead_snap2_params = types.Snapshot(
        description=SNAPSHOT_DESC_2,
        persist_memorystate=False,
        disk_attachments=[
            types.DiskAttachment(
                disk=types.Disk(
                    id=disk.id
                )
            )
        ]
    )
    correlation_id_snap2 = uuid.uuid4()

    vm1_snapshots_service.add(dead_snap2_params,
                              query={'correlation_id': correlation_id_snap2})

    testlib.assert_true_within_long(
        lambda:
        test_utils.all_jobs_finished(engine, correlation_id_snap2)
    )
    testlib.assert_true_within_long(
        lambda:
        vm1_snapshots_service.list()[-1].snapshot_status == types.SnapshotStatus.OK
    )

    snapshot = vm1_snapshots_service.list()[-2]
    vm1_snapshots_service.snapshot_service(snapshot.id).remove()

    testlib.assert_true_within_long(
        lambda:
        len(vm1_snapshots_service.list()) == 2
    )
    testlib.assert_true_within_long(
        lambda:
        vm1_snapshots_service.list()[-1].snapshot_status == types.SnapshotStatus.OK
    )