Example #1
0
def test_redefine_checkpoints_using_config():
    checkpoint_1 = FakeCheckpoint(CHECKPOINT_1_WITH_CREATION_TIME_XML,
                                  CHECKPOINT_1_ID)
    checkpoint_2 = FakeCheckpoint(CHECKPOINT_2_WITH_CREATION_TIME_XML,
                                  CHECKPOINT_2_ID)
    dom = FakeDomainAdapter(output_checkpoints=[checkpoint_1, checkpoint_2])
    vm = FakeVm()

    fake_disks = create_fake_disks()
    fake_checkpoint_config_cfg = [
        {
            'id': CHECKPOINT_1_ID,
            'config': {
                'backup_id': BACKUP_1_ID,
                'disks': fake_disks,
                'to_checkpoint_id': CHECKPOINT_1_ID,
                'creation_time': 1
            }
        },
        {
            'id': CHECKPOINT_2_ID,
            'config': {
                'backup_id': BACKUP_2_ID,
                'disks': fake_disks,
                'from_checkpoint_id': CHECKPOINT_1_ID,
                'to_checkpoint_id': CHECKPOINT_2_ID,
                'creation_time': 2
            }
        },
    ]
    res = backup.redefine_checkpoints(vm, dom, fake_checkpoint_config_cfg)

    expected_result = {
        'checkpoint_ids': [checkpoint_1.getName(),
                           checkpoint_2.getName()],
    }
    assert res["result"] == expected_result
Example #2
0
def test_redefine_diskless_checkpoints_using_config():
    diskless_checkpoint = FakeCheckpoint(DISKLESS_CHECKPOINT_XML,
                                         DISKLESS_CHECKPOINT_ID)
    dom = FakeDomainAdapter(output_checkpoints=[diskless_checkpoint])
    vm = FakeVm()

    fake_checkpoint_config_cfg = [
        {
            'id': DISKLESS_CHECKPOINT_ID,
            'config': {
                'backup_id': BACKUP_1_ID,
                'disks': [],
                'to_checkpoint_id': DISKLESS_CHECKPOINT_ID,
                'creation_time': 1
            }
        },
    ]
    res = backup.redefine_checkpoints(vm, dom, fake_checkpoint_config_cfg)

    expected_result = {
        'checkpoint_ids': [diskless_checkpoint.getName()],
    }
    assert res["result"] == expected_result