Add a test for the device factory.

Create an lvm-over-md layout across the two virtio scratch disks, then
test blivet's ability to populate and print the devicetree with that
setup.

Also, remove the task to copy out logs as it doesn't work.
This commit is contained in:
David Lehman 2018-12-10 13:23:04 -05:00
parent 26fd9bab40
commit bb102032d3
4 changed files with 58 additions and 9 deletions

1
tests/.fmf/version Normal file
View File

@ -0,0 +1 @@
1

42
tests/lvm_factory.py Normal file
View File

@ -0,0 +1,42 @@
#!/usr/bin/python3
import argparse
import sys
import blivet
POOL_NAME = "blivet_test"
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--disks', default='')
args = parser.parse_args()
b = blivet.Blivet()
b.reset()
disks = list()
for disk_id in args.disks.split(','):
disk = b.devicetree.resolve_device(disk_id)
if not disk.is_disk:
sys.stderr.write("specified disk '%s' is not a disk\n" % disk_id)
sys.exit(1)
disks.append(disk)
b.initialize_disk(disk)
if len(disks) > 1:
container_raid_level = "raid1"
total_size = min(d.size for d in disks)
else:
container_raid_level = None
total_size = sum(d.size for d in disks)
lv1 = b.factory_device(size=total_size*0.8, disks=disks,
name="lv1", container_name=POOL_NAME,
fstype='xfs', device_type=blivet.devicefactory.DEVICE_TYPE_LVM)
lv2 = b.factory_device(disks=disks, name="lv2",
container_name=POOL_NAME, container_raid_level='raid1',
fstype='ext4', device_type=blivet.devicefactory.DEVICE_TYPE_LVM)
b.do_it()

8
tests/provision.fmf Normal file
View File

@ -0,0 +1,8 @@
---
standard-inventory-qcow2:
qemu:
m: 1G
drive:
- size: 10737418240
- size: 10737418240

View File

@ -5,14 +5,12 @@
tags:
- classic
tests:
- list-devices:
- list-devices-1:
dir: .
run: python3 /usr/share/doc/python3-blivet/examples/list_devices.py
- lvm-factory:
dir: .
run: python3 ./lvm_factory.py --disks=vda,vdb
- list-devices-2:
dir: .
run: python3 /usr/share/doc/python3-blivet/examples/list_devices.py
tasks:
- name: copy out blivet logs
fetch:
dest: "{{ artifacts }}"
src: "{{ item }}"
flat: yes
loop: ["/tmp/blivet.log", "/tmp/program.log"]