コード例 #1
0
ファイル: transientdisk_test.py プロジェクト: vjuranek/vdsm
def test_remove_transient_disk(tmpdir, tmp_basedir):
    owner_name = 'vm-id'
    disk1_name = 'sda'
    disk2_name = 'sdb'

    for disk_name in [disk1_name, disk2_name]:
        transientdisk.create_disk(owner_name=owner_name,
                                  disk_name=disk_name,
                                  size=10 * MiB)

    transientdisk.remove_disk(owner_name, disk1_name)
    # owner dir should remain
    assert transientdisk.list_disks(owner_name) == [disk2_name]

    transientdisk.remove_disk(owner_name, disk2_name)
    # owner dir should be removed now
    assert transientdisk.list_disks(owner_name) == []
コード例 #2
0
ファイル: transientdisk_test.py プロジェクト: vjuranek/vdsm
def test_remove_disk_not_exists(tmp_basedir):
    owner_name = 'vm-id'
    disk1_name = 'sda'
    disk2_name = 'sdb'

    transientdisk.create_disk(owner_name=owner_name,
                              disk_name=disk1_name,
                              size=10 * MiB)
    # removal of disk that isn't exists should not
    # raise any exception
    transientdisk.remove_disk(owner_name, disk2_name)
    assert transientdisk.list_disks(owner_name) == [disk1_name]
コード例 #3
0
ファイル: transientdisk_test.py プロジェクト: vjuranek/vdsm
def test_add_existing_transient_disk(tmp_basedir):
    owner_name = 'vm-id'
    disk_name = 'sda'

    def create_disk():
        return transientdisk.create_disk(owner_name=owner_name,
                                         disk_name=disk_name,
                                         size=10 * MiB)

    create_disk()
    with pytest.raises(se.TransientDiskAlreadyExists):
        create_disk()

    assert transientdisk.list_disks(owner_name) == [disk_name]
コード例 #4
0
ファイル: transientdisk_test.py プロジェクト: vjuranek/vdsm
def test_list_disks(tmp_basedir):
    owner_name = 'vm-id'
    disk1_name = 'sda'
    disk2_name = 'sdb'

    for disk_name in [disk1_name, disk2_name]:
        res = transientdisk.create_disk(owner_name=owner_name,
                                        disk_name=disk_name,
                                        size=10 * MiB)

        actual_path = res['path']
        assert os.path.isfile(actual_path)

    disks_list = transientdisk.list_disks(owner_name)
    assert sorted(disks_list) == [disk1_name, disk2_name]
コード例 #5
0
ファイル: transientdisk_test.py プロジェクト: vjuranek/vdsm
def test_list_disks_no_dir(tmp_basedir):
    owner_name = 'vm-id'
    disks_list = transientdisk.list_disks(owner_name)

    assert disks_list == []