diff options
author | Ryan Harper <[email protected]> | 2020-02-14 09:50:10 -0600 |
---|---|---|
committer | Ryan Harper <[email protected]> | 2020-02-14 09:50:10 -0600 |
commit | d06c0ce4113fda3a08ed38ff1fc4ad6ab234c1a1 (patch) | |
tree | d3bd19d343e46b5e1c370e94af33926457508fc8 | |
parent | e95a4cfda532aa89782ef25d246cef5f023b0e08 (diff) | |
parent | 82f23e3d28741e4d1ec50e94a6bc966500cca0bf (diff) |
merge from upstream/master at 19.3-26-g82f23e3d
58 files changed, 1422 insertions, 283 deletions
diff --git a/HACKING.rst b/HACKING.rst index 7c26a25d..58adf765 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -47,7 +47,7 @@ Do these things once git push LP_USER master .. _repository: https://git.launchpad.net/curtin -.. _contributor license agreement: http://www.canonical.com/contributors +.. _contributor license agreement: https://ubuntu.com/legal/contributors .. _contributor-agreement-canonical: https://launchpad.net/%7Econtributor-agreement-canonical/+members .. _Launchpad git documentation: https://help.launchpad.net/Code/Git diff --git a/curtin/block/clear_holders.py b/curtin/block/clear_holders.py index b6918413..8e6fc621 100644 --- a/curtin/block/clear_holders.py +++ b/curtin/block/clear_holders.py @@ -304,6 +304,22 @@ def wipe_superblock(device): LOG.debug('Found multipath device over %s, wiping holder %s', blockdev, mp_dev) + # check if we can remove the parent mpath_id mapping; this is + # is possible after removing all dependent mpath devices (like + # mpath partitions. Once the mpath parts are wiped and unmapped + # we can remove the parent mpath mapping which releases the lock + # on the underlying disk partitions. + dm_map = multipath.dmname_to_blkdev_mapping() + LOG.debug('dm map: %s', dm_map) + parent_mp_dev = dm_map.get(parent_mpath_id) + if parent_mp_dev is not None: + parent_mp_holders = get_holders(parent_mp_dev) + if len(parent_mp_holders) == 0: + LOG.debug('Parent multipath device (%s, %s) has no ' + 'holders, removing.', parent_mpath_id, + parent_mp_dev) + multipath.remove_map(parent_mpath_id) + _wipe_superblock(mp_dev if mp_dev else blockdev) # if we had partitions, make sure they've been removed diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py index f287bd44..c48ddbfd 100644 --- a/curtin/commands/block_meta.py +++ b/curtin/commands/block_meta.py @@ -320,8 +320,8 @@ def make_dname(volume, storage_config): matches += [[compose_udev_equality("ENV{CACHED_UUID}", bdev_uuid)]] bcache.write_label(sanitize_dname(dname), backing_dev) elif vol.get('type') == "lvm_partition": - volgroup_name = storage_config.get(vol.get('volgroup')).get('name') - dname = "%s-%s" % (volgroup_name, dname) + info = udevadm_info(path=path) + dname = info['DM_NAME'] matches += [[compose_udev_equality("ENV{DM_NAME}", dname)]] else: raise ValueError('cannot make dname for device with type: {}' @@ -600,6 +600,21 @@ def find_previous_partition(disk_id, part_id, storage_config): return last_partnum +def find_extended_partition(part_device, storage_config): + """ Scan storage config for a partition entry from the same device + with the 'extended' flag set. + + :param: part_device: string specifiying the device id to match + :param: storage_config: Ordered dict of storage configation + :returns: string: item_id if found or None + """ + for item_id, item in storage_config.items(): + if item.get('type') == "partition" and \ + item.get('device') == part_device and \ + item.get('flag') == "extended": + return item_id + + def partition_handler(info, storage_config): device = info.get('device') size = info.get('size') @@ -615,30 +630,36 @@ def partition_handler(info, storage_config): partnumber = determine_partition_number(info.get('id'), storage_config) disk_kname = block.path_to_kname(disk) disk_sysfs_path = block.sys_block_path(disk) + # consider the disks logical sector size when calculating sectors try: - lbs_path = os.path.join(disk_sysfs_path, 'queue', 'logical_block_size') - with open(lbs_path, 'r') as f: - logical_block_size_bytes = int(f.readline()) - except Exception: + (logical_block_size_bytes, _) = block.get_blockdev_sector_size(disk) + LOG.debug( + "{} logical_block_size_bytes: {}".format(disk_kname, + logical_block_size_bytes)) + except OSError as e: + LOG.warning("Couldn't read block size, using default size 512: %s", e) logical_block_size_bytes = 512 - LOG.debug( - "{} logical_block_size_bytes: {}".format(disk_kname, - logical_block_size_bytes)) if partnumber > 1: + pnum = None if partnumber == 5 and disk_ptable == "msdos": - for key, item in storage_config.items(): - if item.get('type') == "partition" and \ - item.get('device') == device and \ - item.get('flag') == "extended": - extended_part_no = determine_partition_number( - key, storage_config) - break - pnum = extended_part_no + extended_part_id = find_extended_partition(device, storage_config) + if not extended_part_id: + msg = ("Logical partition id=%s requires an extended partition" + " and no extended partition '(type: partition, flag: " + "extended)' was found in the storage config.") + LOG.error(msg, info['id']) + raise RuntimeError(msg, info['id']) + pnum = determine_partition_number(extended_part_id, storage_config) else: pnum = find_previous_partition(device, info['id'], storage_config) + # In case we fail to find previous partition let's error out now + if pnum is None: + raise RuntimeError( + 'Cannot find previous partition on disk %s' % disk) + LOG.debug("previous partition number for '%s' found to be '%s'", info.get('id'), pnum) partition_kname = block.partition_kname(disk_kname, pnum) @@ -880,9 +901,14 @@ def get_volume_spec(device_path): """ info = udevadm_info(path=device_path) block_type = _get_volume_type(device_path) + LOG.debug('volspec: path=%s type=%s', device_path, block_type) + LOG.debug('info[DEVLINKS] = %s', info['DEVLINKS']) devlinks = [] - if 'raid' in block_type: + # util-linux lsblk may return type=part or type=md for raid partitions + # handle both by checking path (e.g. /dev/md0p1 should use md-uuid + # https://github.com/karelzak/util-linux/commit/ef2ce68b1f + if 'raid' in block_type or device_path.startswith('/dev/md'): devlinks = [link for link in info['DEVLINKS'] if os.path.basename(link).startswith('md-uuid-')] elif block_type in ['crypt', 'lvm', 'mpath']: diff --git a/curtin/commands/curthooks.py b/curtin/commands/curthooks.py index 542557c5..fd48a5b3 100644 --- a/curtin/commands/curthooks.py +++ b/curtin/commands/curthooks.py @@ -593,6 +593,7 @@ def setup_grub(cfg, target, osfamily=DISTROS.debian): args = ['install-grub'] if util.is_uefi_bootable(): args.append("--uefi") + LOG.debug("grubcfg: %s", grubcfg) if grubcfg.get('update_nvram', True): LOG.debug("GRUB UEFI enabling NVRAM updates") args.append("--update-nvram") diff --git a/curtin/net/deps.py b/curtin/net/deps.py index cbebae94..fd9e3c01 100644 --- a/curtin/net/deps.py +++ b/curtin/net/deps.py @@ -27,8 +27,15 @@ def network_config_required_packages(network_config, mapping=None): for device in network_config['config']) else: # v2 has no config key - dev_configs = set(cfgtype for (cfgtype, cfg) in - network_config.items() if cfgtype not in ['version']) + dev_configs = set() + for cfgtype, cfg in network_config.items(): + if cfgtype == 'version': + continue + dev_configs.add(cfgtype) + # the renderer type may trigger package adds + for entry, entry_cfg in cfg.items(): + if entry_cfg.get('renderer'): + dev_configs.add(entry_cfg.get('renderer')) needed_packages = [] for dev_type in dev_configs: @@ -50,6 +57,9 @@ def detect_required_packages_mapping(osfamily=DISTROS.debian): 'bonds': ['ifenslave'], 'bridge': ['bridge-utils'], 'bridges': ['bridge-utils'], + 'openvswitch': ['openvswitch-switch'], + 'networkd': ['systemd'], + 'NetworkManager': ['network-manager'], 'vlan': ['vlan'], 'vlans': ['vlan']}, DISTROS.redhat: { @@ -57,6 +67,7 @@ def detect_required_packages_mapping(osfamily=DISTROS.debian): 'bonds': [], 'bridge': [], 'bridges': [], + 'openvswitch': ['openvswitch-switch'], 'vlan': [], 'vlans': []}, } diff --git a/curtin/storage_config.py b/curtin/storage_config.py index 4244b3e6..cdfdb706 100644 --- a/curtin/storage_config.py +++ b/curtin/storage_config.py @@ -665,6 +665,8 @@ class BlockdevParser(ProbertParser): # https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs # to # curtin/commands/block_meta.py:partition_handler()sgdisk_flags/types + # MBR types + # https://www.win.tue.nl/~aeb/partitions/partition_types-2.html guid_map = { 'C12A7328-F81F-11D2-BA4B-00A0C93EC93B': ('boot', 'EF00'), '21686148-6449-6E6F-744E-656564454649': ('bios_grub', 'EF02'), @@ -677,6 +679,9 @@ class BlockdevParser(ProbertParser): '0657FD6D-A4AB-43C4-84E5-0933C84B4F4F': ('swap', '8200'), '0X83': ('linux', '83'), '0XF': ('extended', 'f'), + '0X5': ('extended', 'f'), + '0X85': ('extended', 'f'), + '0XC5': ('extended', 'f'), } name = code = None if guid and guid.upper() in guid_map: diff --git a/examples/tests/bcache-ceph-nvme-simple.yaml b/examples/tests/bcache-ceph-nvme-simple.yaml index 83cb04cd..ffb4aecf 100644 --- a/examples/tests/bcache-ceph-nvme-simple.yaml +++ b/examples/tests/bcache-ceph-nvme-simple.yaml @@ -31,7 +31,7 @@ storage: name: sda-part1 number: 1 offset: 4194304B - size: 5G + size: 1G type: partition uuid: 1e27e7af-26dc-4af4-9ef5-aea928204997 wipe: superblock @@ -39,7 +39,7 @@ storage: id: sda-part2 name: sda-part2 number: 2 - size: 2G + size: 1G type: partition uuid: 0040d622-41f1-4596-842f-82d731ba9054 wipe: superblock @@ -47,7 +47,7 @@ storage: id: sda-part3 name: sda-part3 number: 3 - size: 2G + size: 7G type: partition uuid: cb59d827-662c-4da6-b1ef-7967218bd0db wipe: superblock diff --git a/examples/tests/network_v2_ovs.yaml b/examples/tests/network_v2_ovs.yaml new file mode 100644 index 00000000..6d1dc3d2 --- /dev/null +++ b/examples/tests/network_v2_ovs.yaml @@ -0,0 +1,42 @@ +# example netplan config with openvswitch support +# showtrace: true +network: + version: 2 + ethernets: + eth0: + dhcp4: true + match: + macaddress: '52:54:00:12:34:00' + set-name: eth0 + eth1: + match: + macaddress: '52:54:00:12:34:02' + set-name: eth1 + eth2: + match: + macaddress: '52:54:00:12:34:04' + set-name: eth2 + openvswitch: + bridges: + br-int: + fail-mode: secure + datapath_type: system + stp: false + rstp: false + mcast-snooping: false + controller: + addresses: + - tcp:127.0.0.1:6653 + protocols: + - OpenFlow10 + - OpenFlow12 + - OpenFlow13 + ports: + patch-tun: + type: patch + options: + peer: patch-int + eth1: + tag: 2 + eth2: + tag: 2 diff --git a/examples/tests/uefi_reuse_esp.yaml b/examples/tests/uefi_reuse_esp.yaml new file mode 100644 index 00000000..c53064c3 --- /dev/null +++ b/examples/tests/uefi_reuse_esp.yaml @@ -0,0 +1,105 @@ +showtrace: true + +bucket: + - &setup | + parted /dev/disk/by-id/virtio-disk-a --script -- \ + mklabel gpt \ + mkpart primary fat32 1MiB 512MiB \ + set 1 esp on \ + mkpart primary ext4 512MiB 3512Mib + + udevadm settle + mkfs.vfat -I -n EFI -F 32 /dev/disk/by-id/virtio-disk-a-part1 + mkfs.ext4 /dev/disk/by-id/virtio-disk-a-part2 + udevadm settle + apt install -qy grub-efi-amd64-signed shim-signed + mount /dev/disk/by-id/virtio-disk-a-part2 /mnt + mkdir -p /mnt/boot/efi + mount /dev/disk/by-id/virtio-disk-a-part1 /mnt/boot/efi + udevadm settle + distro="ubuntu" + if grep -q centos /var/lib/cloud/instance/scripts/part-002; then + distro="centos" + fi + grub-install --root-directory=/mnt --efi-directory=/mnt/boot/efi --force \ + --target=x86_64-efi --skip-fs-probe --bootloader-id=$distro + efibootmgr -v + find /mnt/boot/efi + umount /mnt/boot/efi + umount /mnt + + - &reinstall_grub | + # on centos we reinstall grub packages to clobber the ubuntu grub we used + if command -v yum; then + yum makecache + for pkg in grub2-efi-x64 shim-x64 grub2-efi-x64-modules; do + echo "installing $pkg" + yum reinstall -y $pkg |: + yum install -y $pkg |: + done + fi + +early_commands: + 00-setup-esp: [sh, -exuc, *setup] + +late_commands: + 01_grub: ['curtin', 'in-target', '--', 'sh', '-xc', *reinstall_grub] + +storage: + config: + - id: id_disk0 + type: disk + name: main_disk + serial: disk-a + ptable: gpt + preserve: true + grub_device: true + - device: id_disk0 + flag: boot + id: id_disk0_part1 + number: 1 + offset: 1M + size: 512M + type: partition + preserve: true + - device: id_disk0 + id: id_disk0_part2 + number: 2 + size: 3G + type: partition + preserve: true + - fstype: fat32 + id: id_efi_format + label: efi + type: format + volume: id_disk0_part1 + preserve: true + - fstype: ext4 + id: id_root_format + label: root + type: format + volume: id_disk0_part2 + - device: id_root_format + id: id_root_mount + path: / + type: mount + - device: id_efi_format + id: id_efi_mount + path: /boot/efi + type: mount + - id: pnum_disk + type: disk + serial: disk-b + name: pnum_disk + ptable: gpt + - id: pnum_disk_p1 + type: partition + number: 1 + size: 1GB + device: pnum_disk + - id: pnum_disk_p2 + type: partition + number: 10 + size: 1GB + device: pnum_disk + version: 1 diff --git a/helpers/common b/helpers/common index 6c8e4f09..1def1bcf 100644 --- a/helpers/common +++ b/helpers/common @@ -577,6 +577,27 @@ apply_grub_cmdline_linux_default() { } } +get_parent_disk() { + # Look up the parent /dev path via sysfs. Using the partition + # kname (nvme0n1p1), construct a /sys/class/block path, use + # realpath to resolve this to an absolute path which includes + # the parent: + # /sys/devices/pci0000:00/*/*/nvme/nvme0/nvme0n1/nvme0n1p1 + # dirname to extract the parent, then read the 'dev' entry + # /sys/devices/pci0000:00/*/*/nvme/nvme0/nvme0n1/dev + # which contains the MAJOR:MINOR value and construct a /dev/block + # path which is a symbolic link that udev constructs that points + # to the real device name and use realpath to return the absolute path. + # /dev/block/259:0 -> ../nvme0n1 + local devpath="${1}" + local kname=$(basename "$devpath") + local syspath=$(realpath "/sys/class/block/$kname") + local disksyspath=$(dirname "$syspath") + local diskmajmin=$(cat "${disksyspath}/dev") + local diskdevpath=$(realpath "/dev/block/${diskmajmin}") + echo $diskdevpath +} + install_grub() { local long_opts="uefi,update-nvram,os-family:" local getopt_out="" mp_efi="" @@ -607,6 +628,7 @@ install_grub() { if [ "${#grubdevs[@]}" = "1" -a "${grubdevs[0]}" = "none" ]; then grubdevs=( ) fi + debug 1 "grubdevs: [${grubdevs[@]}]" # find the mp device local mp_dev="" fstype="" @@ -614,6 +636,7 @@ install_grub() { error "unable to determine device for mount $mp"; return 1; } + debug 1 "/proc/mounts shows $mp_dev is mounted at $mp" fstype=$(awk -v MP=$mp '$2 == MP { print $3 }' /proc/mounts) || { error "unable to fstype for mount $mp"; @@ -805,46 +828,71 @@ install_grub() { } >> "$mp/$mygrub_cfg" fi + debug 1 "processing grubdevs values for expansion if needed" local short="" bd="" grubdev grubdevs_new="" grubdevs_new=() for grubdev in "${grubdevs[@]}"; do if is_md "$grubdev"; then + debug 1 "$grubdev is raid, find members" short=${grubdev##*/} for bd in "/sys/block/$short/slaves/"/*; do [ -d "$bd" ] || continue bd=${bd##*/} bd="/dev/${bd%[0-9]}" # FIXME: part2bd + debug 1 "Add dev $bd to grubdevs_new" grubdevs_new[${#grubdevs_new[@]}]="$bd" done else + debug 1 "Found dev [$grubdev] add to grubdevs_new" grubdevs_new[${#grubdevs_new[@]}]="$grubdev" fi done grubdevs=( "${grubdevs_new[@]}" ) + debug 1 "updated grubdevs: [${grubdevs[@]}]" if [ "$uefi" -ge 1 ]; then nvram="--no-nvram" if [ "$update_nvram" -ge 1 ]; then nvram="" fi - if [ "${#grubdevs_new[@]}" -eq 1 ] && [ -f "${grubdevs_new[0]}" ]; then + debug 1 "number of entries in grubdevs_new: ${#grubdevs[@]}" + if [ "${#grubdevs_new[@]}" -eq 1 ] && [ -b "${grubdevs_new[0]}" ]; then + debug 1 "Found a single entry in grubdevs, ${grubdevs_new[0]}" # Currently UEFI can only be pointed to one system partition. If # for some reason multiple install locations are given only use the # first. efi_dev="${grubdevs_new[0]}" + debug 1 "efi_dev=[${efi_dev}]" elif [ "${#grubdevs_new[@]}" -gt 1 ]; then error "Only one grub device supported on UEFI!" exit 1 else + debug 1 "no storage config, parsing /proc/mounts with awk" # If no storage configuration was given try to determine the system # partition. efi_dev=$(awk -v "MP=${mp}/boot/efi" '$2 == MP { print $1 }' /proc/mounts) + debug 1 "efi_dev=[${efi_dev}]" + [ -n "$efi_dev" ] || { + error "Failed to find efi device from parsing /proc/mounts" + return 1 + } + fi # The partition number of block device name need to be determined here # so both getting the UEFI device from Curtin config and discovering it # work. efi_part_num=$(cat /sys/class/block/$(basename $efi_dev)/partition) - efi_disk="/dev/$(lsblk -no pkname $efi_dev)" + debug 1 "efi_part_num: $efi_part_num" + [ -n "${efi_part_num}" ] || { + error "Failed to determine $efi_dev partition number" + return 1 + } + efi_disk=$(get_parent_disk "$efi_dev") + debug 1 "efi_disk: [$efi_disk]" + [ -b "${efi_disk}" ] || { + error "${efi_disk} is not a valid block device" + return 1 + } debug 1 "curtin uefi: installing ${grub_name} to: /boot/efi" chroot "$mp" env DEBIAN_FRONTEND=noninteractive sh -exc ' echo "before grub-install efiboot settings" @@ -902,6 +950,9 @@ install_grub() { # the filesystem it will be copied into /boot/efi/EFI/$bootid. # Stock Ubuntu images do not ship with anything in /boot. Those # files are generated by installing a kernel and grub. + echo "Dumping /boot/efi contents" + find /boot/efi + echo "Checking for existing EFI grub entry on ESP" if [ -f /boot/efi/EFI/$bootid/grubx64.efi ]; then if [ -z "$no_nvram" ]; then # UEFI firmware should be pointed to the shim if available to @@ -917,8 +968,15 @@ install_grub() { loader=$(echo ${boot_uefi##/boot/efi} | sed "s|/|\\\|g") efibootmgr --create --write-signature --label $bootid \ --disk $efi_disk --part $efi_part_num --loader $loader + rc=$? + [ "$rc" != "0" ] && { exit $rc; } + # check and remove duplicates + efibootmgr --verbose --remove-dups + else + echo "skip EFI entry creation due to \"$no_nvram\" flag" fi else + echo "No previous EFI grub entry found on ESP, use $grubcmd" $grubcmd $target $efi_dir \ --bootloader-id=$bootid --recheck $no_nvram fi diff --git a/tests/data/probert_storage_msdos_mbr_extended.json b/tests/data/probert_storage_msdos_mbr_extended.json new file mode 100644 index 00000000..5bb0aec6 --- /dev/null +++ b/tests/data/probert_storage_msdos_mbr_extended.json @@ -0,0 +1,689 @@ +{ + "blockdev": { + "/dev/sda2": { + "ID_PATH_TAG": "pci-0000_00_0d_0-ata-1", + "SUBSYSTEM": "block", + "ID_PART_ENTRY_TYPE": "0x5", + "ID_ATA_FEATURE_SET_PM_ENABLED": "1", + "TAGS": ":systemd:", + "ID_PART_ENTRY_DISK": "8:0", + "DEVPATH": "/devices/pci0000:00/0000:00:0d.0/ata3/host2/target2:0:0/2:0:0:0/block/sda/sda2", + "ID_PART_ENTRY_SIZE": "3028992", + "DEVNAME": "/dev/sda2", + "DEVLINKS": "/dev/disk/by-partuuid/8264fad8-02 /dev/disk/by-id/ata-VBOX_HARDDISK_VB8c19b19a-f4bb9832-part2 /dev/disk/by-path/pci-0000:00:0d.0-ata-1-part2", + "ID_REVISION": "1.0", + "partitiontable": { + "device": "/dev/sda2", + "partitions": [ + { + "type": "82", + "node": "/dev/sda2p1", + "start": 2048, + "size": 3026944 + } + ], + "label": "dos", + "id": "0x00000000", + "unit": "sectors" + }, + "ID_PART_ENTRY_OFFSET": "38914048", + "ID_MODEL_ENC": "VBOX\\x20HARDDISK\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20", + "ID_SERIAL_SHORT": "VB8c19b19a-f4bb9832", + "ID_ATA_FEATURE_SET_PM": "1", + "ID_ATA_SATA": "1", + "ID_PART_ENTRY_UUID": "8264fad8-02", + "ID_SERIAL": "VBOX_HARDDISK_VB8c19b19a-f4bb9832", + "USEC_INITIALIZED": "2429997", + "ID_PART_TABLE_UUID": "8264fad8", + "ID_PART_ENTRY_NUMBER": "2", + "ID_PATH": "pci-0000:00:0d.0-ata-1", + "ID_ATA_WRITE_CACHE": "1", + "attrs": { + "size": "1024", + "subsystem": "block", + "dev": "8:2", + "alignment_offset": "0", + "start": "38914048", + "discard_alignment": "0", + "uevent": "MAJOR=8\nMINOR=2\nDEVNAME=sda2\nDEVTYPE=partition\nPARTN=2", + "stat": " 15 0 66 56 0 0 0 0 0 56 56", + "partition": "2", + "inflight": " 0 0", + "ro": "0" + }, + "ID_BUS": "ata", + "ID_ATA": "1", + "ID_TYPE": "disk", + "PARTN": "2", + "ID_MODEL": "VBOX_HARDDISK", + "DEVTYPE": "partition", + "ID_ATA_SATA_SIGNAL_RATE_GEN2": "1", + "ID_ATA_WRITE_CACHE_ENABLED": "1", + "MINOR": "2", + "ID_PART_ENTRY_SCHEME": "dos", + "MAJOR": "8", + "ID_PART_TABLE_TYPE": "dos" + }, + "/dev/sdb": { + "SUBSYSTEM": "block", + "ID_ATA_FEATURE_SET_PM_ENABLED": "1", + "TAGS": ":systemd:", + "DEVPATH": "/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb", + "ID_PATH_TAG": "pci-0000_00_0d_0-ata-2", + "ID_ATA_WRITE_CACHE_ENABLED": "1", + "DEVLINKS": "/dev/disk/by-id/ata-VBOX_HARDDISK_VB2ee24240-b9b86f0e /dev/disk/by-path/pci-0000:00:0d.0-ata-2", + "ID_SERIAL_SHORT": "VB2ee24240-b9b86f0e", + "ID_REVISION": "1.0", + "ID_ATA_SATA": "1", + "ID_MODEL_ENC": "VBOX\\x20HARDDISK\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20", + "ID_SERIAL": "VBOX_HARDDISK_VB2ee24240-b9b86f0e", + "USEC_INITIALIZED": "2397357", + "DEVTYPE": "disk", + "ID_PATH": "pci-0000:00:0d.0-ata-2", + "ID_ATA_WRITE_CACHE": "1", + "attrs": { + "hidden": "0", + "range": "16", + "removable": "0", + "events_poll_msecs": "-1", + "discard_alignment": "0", + "subsystem": "block", + "dev": "8:16", + "ext_range": "256", + "size": "10737418240", + "bdi": null, + "device": null, + "capability": "50", + "events": "", + "alignment_offset": "0", + "uevent": "MAJOR=8\nMINOR=16\nDEVNAME=sdb\nDEVTYPE=disk", + "stat": " 307 0 14768 88 0 0 0 0 0 32 88", + "ro": "0", + "inflight": " 0 0", + "events_async": "" + }, + "ID_ATA": "1", + "ID_TYPE": "disk", + "ID_MODEL": "VBOX_HARDDISK", + "DEVNAME": "/dev/sdb", + "ID_ATA_SATA_SIGNAL_RATE_GEN2": "1", + "ID_ATA_FEATURE_SET_PM": "1", + "ID_BUS": "ata", + "MAJOR": "8", + "MINOR": "16" + }, + "/dev/sda5": { + "ID_PATH_TAG": "pci-0000_00_0d_0-ata-1", + "ID_FS_UUID": "36557ca7-29da-4253-b288-b626ace8e472", + "ID_PART_ENTRY_TYPE": "0x82", + "ID_ATA_FEATURE_SET_PM_ENABLED": "1", + "TAGS": ":systemd:", + "ID_PART_ENTRY_DISK": "8:0", + "DEVPATH": "/devices/pci0000:00/0000:00:0d.0/ata3/host2/target2:0:0/2:0:0:0/block/sda/sda5", + "ID_PART_ENTRY_SIZE": "3026944", + "DEVNAME": "/dev/sda5", + "DEVLINKS": "/dev/disk/by-uuid/36557ca7-29da-4253-b288-b626ace8e472 /dev/disk/by-path/pci-0000:00:0d.0-ata-1-part5 /dev/disk/by-partuuid/8264fad8-05 /dev/disk/by-id/ata-VBOX_HARDDISK_VB8c19b19a-f4bb9832-part5", + "ID_REVISION": "1.0", + "ID_PART_ENTRY_OFFSET": "38916096", + "ID_PART_ENTRY_UUID": "8264fad8-05", + "ID_SERIAL_SHORT": "VB8c19b19a-f4bb9832", + "ID_ATA_FEATURE_SET_PM": "1", + "ID_ATA_SATA": "1", + "ID_MODEL_ENC": "VBOX\\x20HARDDISK\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20", + "ID_SERIAL": "VBOX_HARDDISK_VB8c19b19a-f4bb9832", + "USEC_INITIALIZED": "2449055", + "SUBSYSTEM": "block", + "ID_PART_TABLE_UUID": "8264fad8", + "ID_TYPE": "disk", + "ID_PART_ENTRY_NUMBER": "5", + "DEVTYPE": "partition", + "ID_PATH": "pci-0000:00:0d.0-ata-1", + "ID_FS_UUID_ENC": "36557ca7-29da-4253-b288-b626ace8e472", + "ID_ATA_WRITE_CACHE": "1", + "attrs": { + "size": "1549795328", + "subsystem": "block", + "dev": "8:5", + "alignment_offset": "0", + "start": "38916096", + "discard_alignment": "0", + "uevent": "MAJOR=8\nMINOR=5\nDEVNAME=sda5\nDEVTYPE=partition\nPARTN=5", + "stat": " 294 0 15648 280 0 0 0 0 0 156 280", + "partition": "5", + "inflight": " 0 0", + "ro": "0" + }, + "ID_PART_ENTRY_SCHEME": "dos", + "ID_ATA": "1", + "ID_FS_USAGE": "other", + "PARTN": "5", + "ID_MODEL": "VBOX_HARDDISK", + "ID_FS_VERSION": "1", + "ID_ATA_SATA_SIGNAL_RATE_GEN2": "1", + "ID_ATA_WRITE_CACHE_ENABLED": "1", + "ID_FS_TYPE": "swap", + "MINOR": "5", + "ID_BUS": "ata", + "MAJOR": "8", + "ID_PART_TABLE_TYPE": "dos" + }, + "/dev/sr0": { + "ID_PATH_TAG": "pci-0000_00_01_1-ata-2", + "ID_FS_UUID": "2019-08-05-20-00-00-00", + "ID_CDROM_MRW": "1", + "ID_SERIAL_SHORT": "VB2-01700376", + "ID_MODEL": "VBOX_CD-ROM", + "DEVPATH": "/devices/pci0000:00/0000:00:01.1/ata2/host1/target1:0:0/1:0:0:0/block/sr0", + "DEVNAME": "/dev/sr0", + "DEVLINKS": "/dev/cdrom /dev/disk/by-id/ata-VBOX_CD-ROM_VB2-01700376 /dev/disk/by-path/pci-0000:00:01.1-ata-2 /dev/dvd /dev/disk/by-label/Ubuntu-Server\\x2018.04.3\\x20LTS\\x20amd64 /dev/disk/by-uuid/2019-08-05-20-00-00-00", + "partitiontable": { + "device": "/dev/sr0", + "partitions": [ + { + "type": "0", + "node": "/dev/sr0p1", + "start": 0, + "size": 1736704, + "bootable": true + }, + { + "type": "ef", + "node": "/dev/sr0p2", + "start": 1295064, + "size": 4928 + } + ], + "label": "dos", + "id": "0x2f10bd40", + "unit": "sectors" + }, + "TAGS": ":uaccess:seat:systemd:", + "ID_FS_LABEL": "Ubuntu-Server_18.04.3_LTS_amd64", + "ID_TYPE": "cd", + "ID_REVISION": "1.0", + "ID_PART_TABLE_TYPE": "dos", + "ID_MODEL_ENC": "VBOX\\x20CD-ROM\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20", + "ID_SERIAL": "VBOX_CD-ROM_VB2-01700376", + "USEC_INITIALIZED": "1496247", + "SUBSYSTEM": "block", + "ID_PART_TABLE_UUID": "2f10bd40", + "ID_FS_BOOT_SYSTEM_ID": "EL\\x20TORITO\\x20SPECIFICATION", + "ID_FS_LABEL_ENC": "Ubuntu-Server\\x2018.04.3\\x20LTS\\x20amd64", + "ID_CDROM": "1", + "DEVTYPE": "disk", + "ID_PATH": "pci-0000:00:01.1-ata-2", + "ID_FS_UUID_ENC": "2019-08-05-20-00-00-00", + "ID_FS_VERSION": "Joliet Extension", + "attrs": { + "hidden": "0", + "range": "1", + "removable": "1", + "events_poll_msecs": "-1", + "discard_alignment": "0", + "subsystem": "block", + "dev": "11:0", + "ext_range": "1", + "size": "3556769792", + "bdi": null, + "device": null, + "capability": "119", + "events": "media_change eject_request", + "alignment_offset": "0", + "uevent": "MAJOR=11\nMINOR=0\nDEVNAME=sr0\nDEVTYPE=disk", + "stat": " 3071 4 422308 5892 0 0 0 0 0 4952 5876", + "ro": "0", + "inflight": " 0 0", + "events_async": "" + }, + "ID_ATA": "1", + "ID_CDROM_MRW_W": "1", + "ID_CDROM_MEDIA_CD": "1", + "MAJOR": "11", + "ID_FS_USAGE": "filesystem", + "SYSTEMD_MOUNT_DEVICE_BOUND": "1", + "ID_CDROM_MEDIA_TRACK_COUNT_DATA": "1", + "ID_CDROM_MEDIA_SESSION_COUNT": "1", + "ID_FOR_SEAT": "block-pci-0000_00_01_1-ata-2", + "ID_CDROM_MEDIA": "1", + "ID_FS_TYPE": "iso9660", + "ID_CDROM_MEDIA_TRACK_COUNT": "1", + "ID_BUS": "ata", + "ID_CDROM_DVD": "1", + "MINOR": "0" + }, + "/dev/sda1": { + "ID_PATH_TAG": "pci-0000_00_0d_0-ata-1", + "ID_FS_UUID": "fc27e66e-1c3a-41bf-ab6c-4b276fb3c49e", + "ID_PART_ENTRY_TYPE": "0x83", + "ID_ATA_FEATURE_SET_PM_ENABLED": "1", + "TAGS": ":systemd:", + "ID_PART_ENTRY_DISK": "8:0", + "DEVPATH": "/devices/pci0000:00/0000:00:0d.0/ata3/host2/target2:0:0/2:0:0:0/block/sda/sda1", + "ID_PART_ENTRY_SIZE": "38912000", + "DEVNAME": "/dev/sda1", + "DEVLINKS": "/dev/disk/by-uuid/fc27e66e-1c3a-41bf-ab6c-4b276fb3c49e /dev/disk/by-partuuid/8264fad8-01 /dev/disk/by-path/pci-0000:00:0d.0-ata-1-part1 /dev/disk/by-id/ata-VBOX_HARDDISK_VB8c19b19a-f4bb9832-part1", + "ID_REVISION": "1.0", + "ID_PART_ENTRY_OFFSET": "2048", + "ID_PART_ENTRY_UUID": "8264fad8-01", + "ID_SERIAL_SHORT": "VB8c19b19a-f4bb9832", + "ID_ATA_FEATURE_SET_PM": "1", + "ID_ATA_SATA": "1", + "ID_MODEL_ENC": "VBOX\\x20HARDDISK\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20", + "ID_SERIAL": "VBOX_HARDDISK_VB8c19b19a-f4bb9832", + "USEC_INITIALIZED": "2439884", + "SUBSYSTEM": "block", + "ID_PART_TABLE_UUID": "8264fad8", + "ID_TYPE": "disk", + "ID_PART_ENTRY_NUMBER": "1", + "DEVTYPE": "partition", + "ID_PATH": "pci-0000:00:0d.0-ata-1", + "ID_FS_UUID_ENC": "fc27e66e-1c3a-41bf-ab6c-4b276fb3c49e", + "ID_ATA_WRITE_CACHE": "1", + "attrs": { + "size": "19922944000", + "subsystem": "block", + "dev": "8:1", + "alignment_offset": "0", + "start": "2048", + "discard_alignment": "0", + "uevent": "MAJOR=8\nMINOR=1\nDEVNAME=sda1\nDEVTYPE=partition\nPARTN=1", + "stat": " 137 0 10634 196 0 0 0 0 0 188 196", + "partition": "1", + "inflight": " 0 0", + "ro": "0" + }, + "ID_PART_ENTRY_SCHEME": "dos", + "ID_ATA": "1", + "ID_FS_USAGE": "filesystem", + "PARTN": "1", + "ID_MODEL": "VBOX_HARDDISK", + "ID_FS_VERSION": "1.0", + "ID_ATA_SATA_SIGNAL_RATE_GEN2": "1", + "ID_ATA_WRITE_CACHE_ENABLED": "1", + "ID_FS_TYPE": "ext4", + "MINOR": "1", + "ID_BUS": "ata", + "MAJOR": "8", + "ID_PART_TABLE_TYPE": "dos" + }, + "/dev/sda": { + "SUBSYSTEM": "block", + "partitiontable": { + "device": "/dev/sda", + "partitions": [ + { + "type": "83", + "node": "/dev/sda1", + "start": 2048, + "size": 38912000 + }, + { + "type": "5", + "node": "/dev/sda2", + "start": 38914048, + "size": 3028992 + }, + { + "type": "82", + "node": "/dev/sda5", + "start": 38916096, + "size": 3026944 + } + ], + "label": "dos", + "id": "0x8264fad8", + "unit": "sectors" + }, + "ID_ATA_FEATURE_SET_PM_ENABLED": "1", + "TAGS": ":systemd:", + "DEVPATH": "/devices/pci0000:00/0000:00:0d.0/ata3/host2/target2:0:0/2:0:0:0/block/sda", + "ID_PATH_TAG": "pci-0000_00_0d_0-ata-1", + "ID_ATA_WRITE_CACHE_ENABLED": "1", + "DEVLINKS": "/dev/disk/by-id/ata-VBOX_HARDDISK_VB8c19b19a-f4bb9832 /dev/disk/by-path/pci-0000:00:0d.0-ata-1", + "ID_SERIAL_SHORT": "VB8c19b19a-f4bb9832", + "ID_REVISION": "1.0", + "ID_ATA_SATA": "1", + "ID_MODEL_ENC": "VBOX\\x20HARDDISK\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20", + "ID_SERIAL": "VBOX_HARDDISK_VB8c19b19a-f4bb9832", + "USEC_INITIALIZED": "2418170", + "ID_PART_TABLE_UUID": "8264fad8", + "DEVTYPE": "disk", + "ID_PATH": "pci-0000:00:0d.0-ata-1", + "ID_ATA_WRITE_CACHE": "1", + "attrs": { + "hidden": "0", + "range": "16", + "removable": "0", + "events_poll_msecs": "-1", + "discard_alignment": "0", + "subsystem": "block", + "dev": "8:0", + "ext_range": "256", + "size": "21474836480", + "bdi": null, + "device": null, + "capability": "50", + "events": "", + "alignment_offset": "0", + "uevent": "MAJOR=8\nMINOR=0\nDEVNAME=sda\nDEVTYPE=disk", + "stat": " 531 0 33684 700 0 0 0 0 0 444 700", + "ro": "0", + "inflight": " 0 0", + "events_async": "" + }, + "ID_ATA": "1", + "ID_TYPE": "disk", + "ID_MODEL": "VBOX_HARDDISK", + "DEVNAME": "/dev/sda", + "ID_ATA_SATA_SIGNAL_RATE_GEN2": "1", + "ID_ATA_FEATURE_SET_PM": "1", + "MINOR": "0", + "ID_BUS": "ata", + "MAJOR": "8", + "ID_PART_TABLE_TYPE": "dos" + } + }, + "mount": [ + { + "children": [ + { + "children": [ + { + "target": "/sys/kernel/security", + "fstype": "securityfs", + "source": "securityfs", + "options": "rw,nosuid,nodev,noexec,relatime" + }, + { + "children": [ + { + "target": "/sys/fs/cgroup/unified", + "fstype": "cgroup2", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime" + }, + { + "target": "/sys/fs/cgroup/systemd", + "fstype": "cgroup", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime,xattr,name=systemd" + }, + { + "target": "/sys/fs/cgroup/pids", + "fstype": "cgroup", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime,pids" + }, + { + "target": "/sys/fs/cgroup/cpu,cpuacct", + "fstype": "cgroup", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime,cpu,cpuacct" + }, + { + "target": "/sys/fs/cgroup/perf_event", + "fstype": "cgroup", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime,perf_event" + }, + { + "target": "/sys/fs/cgroup/hugetlb", + "fstype": "cgroup", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime,hugetlb" + }, + { + "target": "/sys/fs/cgroup/devices", + "fstype": "cgroup", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime,devices" + }, + { + "target": "/sys/fs/cgroup/blkio", + "fstype": "cgroup", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime,blkio" + }, + { + "target": "/sys/fs/cgroup/net_cls,net_prio", + "fstype": "cgroup", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime,net_cls,net_prio" + }, + { + "target": "/sys/fs/cgroup/memory", + "fstype": "cgroup", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime,memory" + }, + { + "target": "/sys/fs/cgroup/cpuset", + "fstype": "cgroup", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime,cpuset" + }, + { + "target": "/sys/fs/cgroup/rdma", + "fstype": "cgroup", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime,rdma" + }, + { + "target": "/sys/fs/cgroup/freezer", + "fstype": "cgroup", + "source": "cgroup", + "options": "rw,nosuid,nodev,noexec,relatime,freezer" + } + ], + "target": "/sys/fs/cgroup", + "fstype": "tmpfs", + "source": "tmpfs", + "options": "ro,nosuid,nodev,noexec,mode=755" + }, + { + "target": "/sys/fs/pstore", + "fstype": "pstore", + "source": "pstore", + "options": "rw,nosuid,nodev,noexec,relatime" + }, + { + "target": "/sys/kernel/debug", + "fstype": "debugfs", + "source": "debugfs", + "options": "rw,relatime" + }, + { + "target": "/sys/kernel/config", + "fstype": "configfs", + "source": "configfs", + "options": "rw,relatime" + }, + { + "target": "/sys/fs/fuse/connections", + "fstype": "fusectl", + "source": "fusectl", + "options": "rw,relatime" + } + ], + "target": "/sys", + "fstype": "sysfs", + "source": "sysfs", + "options": "rw,nosuid,nodev,noexec,relatime" + }, + { + "children": [ + { + "target": "/proc/sys/fs/binfmt_misc", + "fstype": "autofs", + "source": "systemd-1", + "options": "rw,relatime,fd=25,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=12482" + } + ], + "target": "/proc", + "fstype": "proc", + "source": "proc", + "options": "rw,nosuid,nodev,noexec,relatime" + }, + { + "children": [ + { + "target": "/dev/pts", + "fstype": "devpts", + "source": "devpts", + "options": "rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000" + }, + { + "target": "/dev/shm", + "fstype": "tmpfs", + "source": "tmpfs", + "options": "rw,nosuid,nodev" + }, + { + "target": "/dev/mqueue", + "fstype": "mqueue", + "source": "mqueue", + "options": "rw,relatime" + }, + { + "target": "/dev/hugepages", + "fstype": "hugetlbfs", + "source": "hugetlbfs", + "options": "rw,relatime,pagesize=2M" + } + ], + "target": "/dev", + "fstype": "devtmpfs", + "source": "udev", + "options": "rw,nosuid,relatime,size=1988640k,nr_inodes=497160,mode=755" + }, + { + "children": [ + { + "target": "/run/lock", + "fstype": "tmpfs", + "source": "tmpfs", + "options": "rw,nosuid,nodev,noexec,relatime,size=5120k" + } + ], + "target": "/run", + "fstype": "tmpfs", + "source": "tmpfs", + "options": "rw,nosuid,noexec,relatime,size=403972k,mode=755" + }, + { + "target": "/cdrom", + "fstype": "iso9660", + "source": "/dev/sr0", + "options": "ro,noatime,nojoliet,check=s,map=n,blocksize=2048" + }, + { + "target": "/rofs", + "fstype": "squashfs", + "source": "/dev/loop0", + "options": "ro,noatime" + }, + { + "target": "/lib/modules", + "fstype": "squashfs", + "source": "/dev/loop2", + "options": "ro,relatime" + }, + { + "target": "/tmp", + "fstype": "tmpfs", + "source": "tmpfs", + "options": "rw,nosuid,nodev,relatime" + }, + { + "target": "/media/filesystem", + "fstype": "squashfs", + "source": "/dev/loop0", + "options": "ro,relatime" + }, + { + "target": "/media/rack.lower", + "fstype": "squashfs", + "source": "/dev/loop3", + "options": "ro,relatime" + }, + { + "target": "/media/region.lower", + "fstype": "squashfs", + "source": "/dev/loop4", + "options": "ro,relatime" + }, + { + "target": "/media/region", + "fstype": "overlay", + "source": "overlay", + "options": "ro,relatime,lowerdir=/media/region.lower:/media/rack.lower:/media/filesystem" + }, + { + "target": "/media/rack", + "fstype": "overlay", + "source": "overlay", + "options": "ro,relatime,lowerdir=/media/rack.lower:/media/filesystem" + }, + { + "target": "/var/lib/lxcfs", + "fstype": "fuse.lxcfs", + "source": "lxcfs", + "options": "rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other" + }, + { + "target": "/snap/core/7270", + "fstype": "squashfs", + "source": "/dev/loop5", + "options": "ro,nodev,relatime" + }, + { + "target": "/snap/subiquity/1093", + "fstype": "squashfs", + "source": "/dev/loop6", + "options": "ro,nodev,relatime" + } + ], + "target": "/", + "fstype": "overlay", + "source": "/cow", + "options": "rw,relatime,lowerdir=//installer.squashfs://filesystem.squashfs,upperdir=/cow/upper,workdir=/cow/work" + } + ], + "bcache": { + "caching": {}, + "backing": {} + }, + "raid": {}, + "lvm": {}, + "multipath": {}, + "dmcrypt": {}, + "zfs": { + "zpools": {} + }, + "filesystem": { + "/dev/sda1": { + "UUID_ENC": "fc27e66e-1c3a-41bf-ab6c-4b276fb3c49e", + "UUID": "fc27e66e-1c3a-41bf-ab6c-4b276fb3c49e", + "USAGE": "filesystem", + "TYPE": "ext4", + "VERSION": "1.0" + }, + "/dev/sda5": { + "UUID_ENC": "36557ca7-29da-4253-b288-b626ace8e472", + "UUID": "36557ca7-29da-4253-b288-b626ace8e472", + "USAGE": "other", + "TYPE": "swap", + "VERSION": "1" + }, + "/dev/sr0": { + "UUID_ENC": "2019-08-05-20-00-00-00", + "UUID": "2019-08-05-20-00-00-00", + "TYPE": "iso9660", + "LABEL": "Ubuntu-Server_18.04.3_LTS_amd64", + "BOOT_SYSTEM_ID": "EL\\x20TORITO\\x20SPECIFICATION", + "LABEL_ENC": "Ubuntu-Server\\x2018.04.3\\x20LTS\\x20amd64", + "USAGE": "filesystem", + "VERSION": "Joliet Extension" + } + } +} diff --git a/tests/unittests/test_clear_holders.py b/tests/unittests/test_clear_holders.py index fca5dd36..a91e0034 100644 --- a/tests/unittests/test_clear_holders.py +++ b/tests/unittests/test_clear_holders.py @@ -535,6 +535,7 @@ class TestClearHolders(CiTestCase): mock_block.wipe_volume.assert_called_with( self.test_blockdev, exclusive=True, mode='superblock', strict=True) + @mock.patch('curtin.block.clear_holders.get_holders') @mock.patch('curtin.block.clear_holders.multipath') @mock.patch('curtin.block.clear_holders.is_swap_device') @mock.patch('curtin.block.clear_holders.time') @@ -543,7 +544,8 @@ class TestClearHolders(CiTestCase): def test_clear_holders_mp_enabled_and_active_wipes_dm_dev(self, mock_block, mock_log, m_time, mock_swap, - mock_mpath): + mock_mpath, + m_get_holders): """wipe_superblock wipes parent mp_dev and removes from dev mapper.""" mock_swap.return_value = False mock_block.sysfs_to_devpath.return_value = self.test_blockdev @@ -555,16 +557,19 @@ class TestClearHolders(CiTestCase): mock_mpath.multipath_supported.return_value = True mock_mpath.find_mpath_id_by_path.return_value = 'mpath-wark' mp_dev = '/wark/dm-1' + parent_mpath_id = 'mpath-wark' mock_mpath.find_mpath_id_by_parent.return_value = ( - 'mpath-wark', mp_dev) + parent_mpath_id, mp_dev) mock_mpath.is_mpath_partition.return_value = False mock_block.get_sysfs_partitions.side_effect = iter([ [], # partitions are now gone ]) + m_get_holders.return_value = [] clear_holders.wipe_superblock(self.test_syspath) mock_block.sysfs_to_devpath.assert_called_with(self.test_syspath) mock_block.wipe_volume.assert_called_with( mp_dev, exclusive=True, mode='superblock', strict=True) + mock_mpath.remove_map.assert_called_with(parent_mpath_id) mock_mpath.remove_partition.assert_called_with(mp_dev) @mock.patch('curtin.block.clear_holders.LOG') diff --git a/tests/unittests/test_commands_block_meta.py b/tests/unittests/test_commands_block_meta.py index 858d57f3..bc4f1cc3 100644 --- a/tests/unittests/test_commands_block_meta.py +++ b/tests/unittests/test_commands_block_meta.py @@ -242,6 +242,8 @@ class TestBlockMeta(CiTestCase): 'mock_block_zero_file') self.add_patch('curtin.block.rescan_block_devices', 'mock_block_rescan') + self.add_patch('curtin.block.get_blockdev_sector_size', + 'mock_block_sector_size') self.target = "my_target" self.config = { @@ -316,6 +318,7 @@ class TestBlockMeta(CiTestCase): kname = 'xxx' self.mock_block_path_to_kname.return_value = kname self.mock_block_sys_block_path.return_value = '/sys/class/block/xxx' + self.mock_block_sector_size.return_value = (512, 512) block_meta.partition_handler(part_info, self.storage_config) part_offset = 2048 * 512 @@ -1428,4 +1431,141 @@ class TestDmCryptHandler(CiTestCase): self.m_subp.assert_has_calls(expected_calls) self.assertEqual(len(util.load_file(self.crypttab).splitlines()), 1) + +class TestPartitionHandler(CiTestCase): + + def setUp(self): + super(TestPartitionHandler, self).setUp() + + basepath = 'curtin.commands.block_meta.' + self.add_patch(basepath + 'get_path_to_storage_volume', 'm_getpath') + self.add_patch(basepath + 'util', 'm_util') + self.add_patch(basepath + 'make_dname', 'm_dname') + self.add_patch(basepath + 'block', 'm_block') + self.add_patch(basepath + 'udevadm_settle', 'm_uset') + + self.target = "my_target" + self.config = { + 'storage': { + 'version': 1, + 'config': [ + {'id': 'sda', + 'type': 'disk', + 'name': 'main_disk', + 'ptable': 'msdos', + 'serial': 'disk-a'}, + {'id': 'disk-sda-part-1', + 'type': 'partition', + 'device': 'sda', + 'name': 'main_part', + 'number': 1, + 'size': '3GB', + 'flag': 'boot'}, + {'id': 'disk-sda-part-2', + 'type': 'partition', + 'device': 'sda', + 'name': 'extended_part', + 'number': 2, + 'size': '5GB', + 'flag': 'extended'}, + {'id': 'disk-sda-part-5', + 'type': 'partition', + 'device': 'sda', + 'name': 'logical_part', + 'number': 5, + 'size': '2GB', + 'flag': 'logical'}, + {'id': 'disk-sda-part-6', + 'type': 'partition', + 'device': 'sda', + 'name': 'logical_part', + 'number': 6, + 'size': '2GB', + 'flag': 'logical'}, + ], + } + } + self.storage_config = ( + block_meta.extract_storage_ordered_dict(self.config)) + + def test_find_extended_partition(self): + """ + find_extended_partition returns extended part_id of logical partition. + """ + extended_parts = [item for item_id, item in self.storage_config.items() + if item['type'] == 'partition' and + item.get('flag') == 'extended'] + self.assertEqual(1, len(extended_parts)) + extended_part = extended_parts[0] + logical_parts = [item for item_id, item in self.storage_config.items() + if item['type'] == 'partition' and + item.get('flag') == 'logical'] + + for logical in logical_parts: + ext_part_id = ( + block_meta.find_extended_partition(logical['device'], + self.storage_config)) + self.assertEqual(extended_part['id'], ext_part_id) + + def test_find_extended_partition_returns_none_if_not_found(self): + """ + find_extended_partition returns none if no extended part is found. + """ + + del self.storage_config['disk-sda-part-2']['flag'] + logical_parts = [item for item_id, item in self.storage_config.items() + if item['type'] == 'partition' and + item.get('flag') == 'logical'] + + for logical in logical_parts: + ext_part_id = ( + block_meta.find_extended_partition(logical['device'], + self.storage_config)) + self.assertIsNone(ext_part_id) + + @patch('curtin.commands.block_meta.find_extended_partition') + def test_part_handler_finds_extended_part_for_logical_part_5(self, + m_ex_part): + """ + part_handler_finds_extended_part_number_for_logical_part_5. + """ + extended_parts = [item for item_id, item in self.storage_config.items() + if item['type'] == 'partition' and + item.get('flag') == 'extended'] + self.assertEqual(1, len(extended_parts)) + logical_parts = [item for item_id, item in self.storage_config.items() + if item['type'] == 'partition' and + item.get('number') == 5] + self.assertEqual(1, len(logical_parts)) + logical_part = logical_parts[0] + + self.m_getpath.return_value = '/wark/sda' + self.m_block.path_to_kname.return_value = 'sda' + self.m_block.partition_kname.return_value = 'sda2' + self.m_block.sys_block_path.return_value = 'sys/class/block/sda' + self.m_block.get_blockdev_sector_size.return_value = (512, 512) + m_ex_part.return_value = 'disk-sda-part-2' + block_meta.partition_handler(logical_part, self.storage_config) + m_ex_part.assert_called_with('sda', self.storage_config) + + def test_part_handler_raise_exception_missing_extended_part(self): + """ + part_handler raises exception on missing extended partition. + """ + del self.storage_config['disk-sda-part-2']['flag'] + logical_parts = [item for item_id, item in self.storage_config.items() + if item['type'] == 'partition' and + item.get('number') == 5] + self.assertEqual(1, len(logical_parts)) + logical_part = logical_parts[0] + + self.m_getpath.return_value = '/wark/sda' + self.m_block.path_to_kname.return_value = 'sda' + self.m_block.partition_kname.return_value = 'sda2' + self.m_block.sys_block_path.return_value = 'sys/class/block/sda' + self.m_block.get_blockdev_sector_size.return_value = (512, 512) + with self.assertRaises(RuntimeError): + block_meta.partition_handler(logical_part, self.storage_config) + + # vi: ts=4 expandtab syntax=python diff --git a/tests/unittests/test_curthooks.py b/tests/unittests/test_curthooks.py index 3fefd268..ff382408 100644 --- a/tests/unittests/test_curthooks.py +++ b/tests/unittests/test_curthooks.py @@ -984,11 +984,24 @@ class TestDetectRequiredPackages(CiTestCase): {'type': 'static', 'address': '192.168.14.2/24'}, {'type': 'static', 'address': '2001:1::1/64'}]}}, 2: { - 'vlan': { + 'openvswitch': { + 'openvswitch': { + 'bridges': { + 'br-int': {'ports': {'eth15': {'tag': 2}}}}}}, + 'vlans': { 'vlans': { 'en-intra': {'id': 1, 'link': 'eno1', 'dhcp4': 'yes'}, 'en-vpn': {'id': 2, 'link': 'eno1'}}}, - 'bridge': { + 'renderers': { + 'bridges': { + 'br-ext': {'renderer': 'openvswitch', + 'ports': {'eth7': {'tag': 9}}}}, + 'wifis': { + 'wlps0': {'renderer': 'NetworkManager', + 'dhcp4': True}}, + 'ethernets': { + 'ens7p0': {'renderer': 'networkd', 'dhcp6': True}}}, + 'bridges': { 'bridges': { 'br0': { 'interfaces': ['wlp1s0', 'switchports'], @@ -1014,6 +1027,8 @@ class TestDetectRequiredPackages(CiTestCase): def _test_req_mappings(self, req_mappings): for (config_items, expected_reqs) in req_mappings: cfg = self._fmt_config(config_items) + print('test_config:\n%s' % config.dump_config(cfg)) + print() actual_reqs = curthooks.detect_required_packages(cfg) self.assertEqual(set(actual_reqs), set(expected_reqs), 'failed for config: {}'.format(config_items)) @@ -1084,27 +1099,52 @@ class TestDetectRequiredPackages(CiTestCase): ('e2fsprogs', '^btrfs-(progs|tools)$', 'vlan', 'ifenslave')), )) - def test_network_v2_detect(self): + def test_network_v2_detect_bridges(self): self._test_req_mappings(( ({'network': { 'version': 2, - 'items': ('bridge',)}}, + 'items': ('bridges',)}}, ('bridge-utils', )), + )) + + def test_network_v2_detect_vlan(self): + self._test_req_mappings(( ({'network': { 'version': 2, - 'items': ('vlan',)}}, + 'items': ('vlans',)}}, ('vlan',)), + )) + + def test_network_v2_detect_openvswitch(self): + self._test_req_mappings(( + ({'network': { + 'version': 2, + 'items': ('openvswitch',)}}, + ('openvswitch-switch', )), + )) + + def test_network_v2_detect_renderers(self): + self._test_req_mappings(( + ({'network': { + 'version': 2, + 'items': ('renderers',)}}, + ('bridge-utils', 'openvswitch-switch', + 'systemd', 'network-manager', )), + )) + + def test_network_v2_detect_all(self): + self._test_req_mappings(( ({'network': { 'version': 2, - 'items': ('vlan', 'bridge')}}, - ('bridge-utils', 'vlan')), + 'items': ('vlans', 'bridges', 'openvswitch')}}, + ('bridge-utils', 'vlan', 'openvswitch-switch')), )) def test_mixed_storage_v1_network_v2_detect(self): self._test_req_mappings(( ({'network': { 'version': 2, - 'items': ('bridge', 'vlan')}, + 'items': ('bridges', 'vlans')}, 'storage': { 'version': 1, 'items': ('raid', 'bcache', 'ext4')}}, diff --git a/tests/unittests/test_make_dname.py b/tests/unittests/test_make_dname.py index a0886602..eb58cfdc 100644 --- a/tests/unittests/test_make_dname.py +++ b/tests/unittests/test_make_dname.py @@ -223,15 +223,17 @@ class TestMakeDname(CiTestCase): self._content( [self._formatted_rule(rule_identifiers, res_dname)])) + @mock.patch('curtin.commands.block_meta.udevadm_info') @mock.patch('curtin.commands.block_meta.LOG') @mock.patch('curtin.commands.block_meta.get_path_to_storage_volume') @mock.patch('curtin.commands.block_meta.util') def test_make_dname_lvm_partition(self, mock_util, mock_get_path, - mock_log): + mock_log, mock_info): mock_util.load_command_environment.return_value = self.state # simple res_dname = 'vg1-lpartition1' + mock_info.return_value = {'DM_NAME': res_dname} rule_identifiers = [('DM_NAME', res_dname)] block_meta.make_dname('lpart_id', self.storage_config) self.assertTrue(mock_log.debug.called) @@ -243,6 +245,7 @@ class TestMakeDname(CiTestCase): # with invalid name res_dname = 'vg1-lvm-part-2' + mock_info.return_value = {'DM_NAME': 'vg1-lvm part/2'} rule_identifiers = [('DM_NAME', 'vg1-lvm part/2')] block_meta.make_dname('lpart2_id', self.storage_config) self.assertTrue(mock_log.warning.called) diff --git a/tests/unittests/test_storage_config.py b/tests/unittests/test_storage_config.py index 33b65bdc..199dd688 100644 --- a/tests/unittests/test_storage_config.py +++ b/tests/unittests/test_storage_config.py @@ -341,6 +341,7 @@ class TestBlockdevParser(CiTestCase): with self.assertRaises(ValueError): self.bdevp.blockdev_to_id(test_value) + # XXX: Parameterize me def test_blockdev_detects_extended_partitions(self): self.probe_data = _get_data('probert_storage_lvm.json') self.bdevp = BlockdevParser(self.probe_data) @@ -354,8 +355,10 @@ class TestBlockdevParser(CiTestCase): 'size': 5370806272, 'flag': 'extended', } - self.assertDictEqual(expected_dict, - self.bdevp.asdict(blockdev)) + for ext_part_entry in ['0xf', '0x5', '0x85', '0xc5']: + blockdev['ID_PART_ENTRY_TYPE'] = ext_part_entry + self.assertDictEqual(expected_dict, + self.bdevp.asdict(blockdev)) def test_blockdev_detects_logical_partitions(self): self.probe_data = _get_data('probert_storage_lvm.json') @@ -773,5 +776,14 @@ class TestExtractStorageConfig(CiTestCase): 'device': 'raid-md1', 'offset': 1048576}, raid_partitions[0]) + @skipUnlessJsonSchema() + def test_find_extended_partition(self): + """ finds extended partition and set flag in config """ + self.probe_data = _get_data('probert_storage_msdos_mbr_extended.json') + extracted = storage_config.extract_storage_config(self.probe_data) + config = extracted['storage']['config'] + partitions = [cfg for cfg in config if cfg['type'] == 'partition'] + extended = [part for part in partitions if part['flag'] == 'extended'] + self.assertEqual(1, len(extended)) # vi: ts=4 expandtab syntax=python diff --git a/tests/vmtests/__init__.py b/tests/vmtests/__init__.py index 80f545a6..39dfb40b 100644 --- a/tests/vmtests/__init__.py +++ b/tests/vmtests/__init__.py @@ -913,6 +913,9 @@ class VMBaseClass(TestCase): logger.debug('Install console log: {}'.format(cls.install_log)) logger.debug('Boot console log: {}'.format(cls.boot_log)) + # load the curtin config for this testcas + cls.testcase_config = yaml.safe_load(cls.load_conf_file()) + # if interactive, launch qemu without 'background & wait' if cls.interactive: dowait = "--no-dowait" @@ -1083,12 +1086,19 @@ class VMBaseClass(TestCase): nvram = os.path.join(cls.td.disks, "ovmf_vars.fd") uefi_flags = ["--uefi-nvram=%s" % nvram] - # always attempt to update target nvram (via grub) - grub_config = os.path.join(cls.td.install, 'grub.cfg') - if not os.path.exists(grub_config) and not cls.td.restored: - with open(grub_config, "w") as fp: - fp.write(json.dumps({'grub': {'update_nvram': True}})) - configs.append(grub_config) + # always attempt to update target nvram (via grub), unless + # test has an 'update_nvram' setting + update_nvram = ( + cls.testcase_config.get('grub', {}).get('update_nvram')) + if update_nvram is None: + grub_config = os.path.join(cls.td.install, 'grub.cfg') + if not os.path.exists(grub_config) and not cls.td.restored: + util.write_file( + grub_config, + json.dumps({'grub': {'update_nvram': True}})) + configs.append(grub_config) + else: + logger.debug('Using testcase update_nvram setting') if cls.dirty_disks and storage_config: logger.debug("Injecting early_command to dirty storage devices") @@ -1448,9 +1458,10 @@ class VMBaseClass(TestCase): keep_fail=KEEP_DATA['fail']) if TAR_DISKS: tar_disks(cls.td.tmpdir) - cls.cleanIscsiState(success, - keep_pass=KEEP_DATA['pass'], - keep_fail=KEEP_DATA['fail']) + if not REUSE_TOPDIR: + cls.cleanIscsiState(success, + keep_pass=KEEP_DATA['pass'], + keep_fail=KEEP_DATA['fail']) @classmethod def expected_interfaces(cls): @@ -1604,7 +1615,7 @@ class VMBaseClass(TestCase): ] """ expected = self.get_fstab_expected() - if expected is None: + if not expected: return path = self.collect_path("fstab") if not os.path.exists(path): diff --git a/tests/vmtests/test_basic.py b/tests/vmtests/test_basic.py index 5cab5569..91c05db2 100644 --- a/tests/vmtests/test_basic.py +++ b/tests/vmtests/test_basic.py @@ -245,10 +245,6 @@ class BionicTestBasic(relbase.bionic, TestBasicAbs): __test__ = True -class DiscoTestBasic(relbase.disco, TestBasicAbs): - __test__ = True - - class EoanTestBasic(relbase.eoan, TestBasicAbs): __test__ = True @@ -352,10 +348,6 @@ class BionicTestScsiBasic(relbase.bionic, TestBasicScsiAbs): __test__ = True -class DiscoTestScsiBasic(relbase.disco, TestBasicScsiAbs): - __test__ = True - - class EoanTestScsiBasic(relbase.eoan, TestBasicScsiAbs): __test__ = True diff --git a/tests/vmtests/test_basic_dasd.py b/tests/vmtests/test_basic_dasd.py index 8079edd8..391bafc6 100644 --- a/tests/vmtests/test_basic_dasd.py +++ b/tests/vmtests/test_basic_dasd.py @@ -52,10 +52,6 @@ class BionicTestBasicDasd(relbase.bionic, TestBasicDasd): __test__ = True -class DiscoTestBasicDasd(relbase.disco, TestBasicDasd): - __test__ = True - - class EoanTestBasicDasd(relbase.eoan, TestBasicDasd): __test__ = True diff --git a/tests/vmtests/test_bcache_basic.py b/tests/vmtests/test_bcache_basic.py index bf77381c..54bac814 100644 --- a/tests/vmtests/test_bcache_basic.py +++ b/tests/vmtests/test_bcache_basic.py @@ -64,10 +64,6 @@ class BionicBcacheBasic(relbase.bionic, TestBcacheBasic): __test__ = True -class DiscoBcacheBasic(relbase.disco, TestBcacheBasic): - __test__ = True - - class EoanBcacheBasic(relbase.eoan, TestBcacheBasic): __test__ = True diff --git a/tests/vmtests/test_bcache_bug1718699.py b/tests/vmtests/test_bcache_bug1718699.py index f4937ab1..8c290469 100644 --- a/tests/vmtests/test_bcache_bug1718699.py +++ b/tests/vmtests/test_bcache_bug1718699.py @@ -19,10 +19,6 @@ class BionicTestBcacheBug1718699(relbase.bionic, TestBcacheBug1718699): __test__ = True -class DiscoTestBcacheBug1718699(relbase.disco, TestBcacheBug1718699): - __test__ = True - - class EoanTestBcacheBug1718699(relbase.eoan, TestBcacheBug1718699): __test__ = True diff --git a/tests/vmtests/test_bcache_ceph.py b/tests/vmtests/test_bcache_ceph.py index f94a8b01..d24994a0 100644 --- a/tests/vmtests/test_bcache_ceph.py +++ b/tests/vmtests/test_bcache_ceph.py @@ -75,10 +75,6 @@ class BionicTestBcacheCeph(relbase.bionic, TestBcacheCeph): __test__ = True -class DiscoTestBcacheCeph(relbase.disco, TestBcacheCeph): - __test__ = True - - class EoanTestBcacheCeph(relbase.eoan, TestBcacheCeph): __test__ = True diff --git a/tests/vmtests/test_bcache_partitions.py b/tests/vmtests/test_bcache_partitions.py index faa23a01..f41e6455 100644 --- a/tests/vmtests/test_bcache_partitions.py +++ b/tests/vmtests/test_bcache_partitions.py @@ -25,10 +25,6 @@ class BionicTestBcachePartitions(relbase.bionic, TestBcachePartitions): __test__ = True -class DiscoTestBcachePartitions(relbase.disco, TestBcachePartitions): - __test__ = True - - class EoanTestBcachePartitions(relbase.eoan, TestBcachePartitions): __test__ = True diff --git a/tests/vmtests/test_fs_battery.py b/tests/vmtests/test_fs_battery.py index 58eb4415..6c8cfc26 100644 --- a/tests/vmtests/test_fs_battery.py +++ b/tests/vmtests/test_fs_battery.py @@ -231,10 +231,6 @@ class BionicTestFsBattery(relbase.bionic, TestFsBattery): __test__ = True -class DiscoTestFsBattery(relbase.disco, TestFsBattery): - __test__ = True - - class EoanTestFsBattery(relbase.eoan, TestFsBattery): __test__ = True diff --git a/tests/vmtests/test_iscsi.py b/tests/vmtests/test_iscsi.py index 227e96bd..c99264ce 100644 --- a/tests/vmtests/test_iscsi.py +++ b/tests/vmtests/test_iscsi.py @@ -72,10 +72,6 @@ class BionicTestIscsiBasic(relbase.bionic, TestBasicIscsiAbs): __test__ = True -class DiscoTestIscsiBasic(relbase.disco, TestBasicIscsiAbs): - __test__ = True - - class EoanTestIscsiBasic(relbase.eoan, TestBasicIscsiAbs): __test__ = True diff --git a/tests/vmtests/test_journald_reporter.py b/tests/vmtests/test_journald_reporter.py index de060d5b..d29b4d46 100644 --- a/tests/vmtests/test_journald_reporter.py +++ b/tests/vmtests/test_journald_reporter.py @@ -32,10 +32,6 @@ class BionicTestJournaldReporter(relbase.bionic, TestJournaldReporter): __test__ = True -class DiscoTestJournaldReporter(relbase.disco, TestJournaldReporter): - __test__ = True - - class EoanTestJournaldReporter(relbase.eoan, TestJournaldReporter): __test__ = True diff --git a/tests/vmtests/test_lvm.py b/tests/vmtests/test_lvm.py index 429b5c24..a79a705a 100644 --- a/tests/vmtests/test_lvm.py +++ b/tests/vmtests/test_lvm.py @@ -77,10 +77,6 @@ class BionicTestLvm(relbase.bionic, TestLvmAbs): __test__ = True -class DiscoTestLvm(relbase.disco, TestLvmAbs): - __test__ = True - - class EoanTestLvm(relbase.eoan, TestLvmAbs): __test__ = True diff --git a/tests/vmtests/test_lvm_iscsi.py b/tests/vmtests/test_lvm_iscsi.py index 5578d22c..077b31a9 100644 --- a/tests/vmtests/test_lvm_iscsi.py +++ b/tests/vmtests/test_lvm_iscsi.py @@ -27,12 +27,6 @@ class TestLvmIscsiAbs(TestLvmAbs, TestBasicIscsiAbs): exit 0 """)]) - fstab_expected = { - 'UUID=6de56115-9500-424b-8151-221b270ec708': '/mnt/iscsi1', - 'UUID=9604e4c4-e5ae-40dd-ab1f-940de6b59047': '/mnt/iscsi2', - 'UUID=18bec31c-09a8-4a02-91c6-e9bf6efb6fad': '/mnt/iscsi3', - 'UUID=a98f706b-b064-4682-8eb2-6c2c1284060c': '/mnt/iscsi4', - } disk_to_check = [('main_disk', 1), ('main_disk', 2), ('iscsi_disk1', 5), @@ -44,6 +38,22 @@ class TestLvmIscsiAbs(TestLvmAbs, TestBasicIscsiAbs): ('vg2-lv3', 0), ('vg2-lv4', 0)] + def get_fstab_expected(self): + iscsi1 = self._dname_to_kname('vg1-lv1') + iscsi2 = self._dname_to_kname('vg1-lv2') + iscsi3 = self._dname_to_kname('vg2-lv3') + iscsi4 = self._dname_to_kname('vg2-lv4') + return [ + (self._kname_to_uuid_devpath('dm-uuid', iscsi1), + '/mnt/iscsi1', 'defaults,_netdev'), + (self._kname_to_uuid_devpath('dm-uuid', iscsi2), + '/mnt/iscsi2', 'defaults,_netdev'), + (self._kname_to_uuid_devpath('dm-uuid', iscsi3), + '/mnt/iscsi3', 'defaults,_netdev'), + (self._kname_to_uuid_devpath('dm-uuid', iscsi4), + '/mnt/iscsi4', 'defaults,_netdev'), + ] + def test_lvs(self): self.check_file_strippedline("lvs", "lv1=vg1") self.check_file_strippedline("lvs", "lv2=vg1") @@ -85,10 +95,6 @@ class BionicTestIscsiLvm(relbase.bionic, TestLvmIscsiAbs): __test__ = True -class DiscoTestIscsiLvm(relbase.disco, TestLvmIscsiAbs): - __test__ = True - - class EoanTestIscsiLvm(relbase.eoan, TestLvmIscsiAbs): __test__ = True diff --git a/tests/vmtests/test_lvm_raid.py b/tests/vmtests/test_lvm_raid.py index 24c2765e..8d42a1a5 100644 --- a/tests/vmtests/test_lvm_raid.py +++ b/tests/vmtests/test_lvm_raid.py @@ -26,15 +26,19 @@ class TestLvmOverRaidAbs(TestMdadmAbs, TestLvmAbs): exit 0 """)] ) - - fstab_expected = { - '/dev/vg1/lv1': '/srv/data', - '/dev/vg1/lv2': '/srv/backup', - } disk_to_check = [('main_disk', 1), ('md0', 0), ('md1', 0)] + def get_fstab_expected(self): + rootdev = self._dname_to_kname('main_disk') + homedev = self._dname_to_kname('vg0-lv--0') + return [ + (self._kname_to_byuuid(rootdev + '2'), '/', 'defaults'), + (self._kname_to_uuid_devpath('dm-uuid', homedev), + '/home', 'defaults'), + ] + def test_lvs(self): self.check_file_strippedline("lvs", "lv-0=vg0") @@ -51,10 +55,6 @@ class EoanTestLvmOverRaid(relbase.eoan, TestLvmOverRaidAbs): __test__ = True -class DiscoTestLvmOverRaid(relbase.disco, TestLvmOverRaidAbs): - __test__ = True - - class BionicTestLvmOverRaid(relbase.bionic, TestLvmOverRaidAbs): __test__ = True diff --git a/tests/vmtests/test_lvm_root.py b/tests/vmtests/test_lvm_root.py index e49a18c4..117406ed 100644 --- a/tests/vmtests/test_lvm_root.py +++ b/tests/vmtests/test_lvm_root.py @@ -29,11 +29,14 @@ class TestLvmRootAbs(VMBaseClass): exit 0 """)] - fstab_expected = { - 'UUID=04836770-e989-460f-8774-8e277ddcb40f': '/', - } conf_replace = {} + def get_fstab_output(self): + rootvg = self._dname_to_kname('root_vg-lv1_root') + return [ + (self._kname_to_uuid_devpath('dm-uuid', rootvg), '/', 'defaults') + ] + def test_output_files_exist(self): self.output_files_exist(["fstab"]) diff --git a/tests/vmtests/test_mdadm_bcache.py b/tests/vmtests/test_mdadm_bcache.py index 9819ebf7..f8d3e6ab 100644 --- a/tests/vmtests/test_mdadm_bcache.py +++ b/tests/vmtests/test_mdadm_bcache.py @@ -151,10 +151,6 @@ class BionicTestMdadmBcache(relbase.bionic, TestMdadmBcacheAbs): __test__ = True -class DiscoTestMdadmBcache(relbase.disco, TestMdadmBcacheAbs): - __test__ = True - - class EoanTestMdadmBcache(relbase.eoan, TestMdadmBcacheAbs): __test__ = True @@ -162,6 +158,10 @@ class EoanTestMdadmBcache(relbase.eoan, TestMdadmBcacheAbs): class FocalTestMdadmBcache(relbase.focal, TestMdadmBcacheAbs): __test__ = True + @TestMdadmBcacheAbs.skip_by_date("1861941", fixby="2020-04-15") + def test_fstab(self): + return super().test_fstab() + class TestMirrorbootAbs(TestMdadmAbs): # alternative config for more complex setup @@ -200,10 +200,6 @@ class BionicTestMirrorboot(relbase.bionic, TestMirrorbootAbs): __test__ = True -class DiscoTestMirrorboot(relbase.disco, TestMirrorbootAbs): - __test__ = True - - class EoanTestMirrorboot(relbase.eoan, TestMirrorbootAbs): __test__ = True @@ -223,7 +219,7 @@ class TestMirrorbootPartitionsAbs(TestMdadmAbs): def get_fstab_expected(self): return [ - (self._kname_to_uuid_devpath('md-uuid', 'md0'), '/', 'defaults') + (self._kname_to_uuid_devpath('md-uuid', 'md0p1'), '/', 'defaults') ] @@ -252,11 +248,6 @@ class BionicTestMirrorbootPartitions(relbase.bionic, __test__ = True -class DiscoTestMirrorbootPartitions(relbase.disco, - TestMirrorbootPartitionsAbs): - __test__ = True - - class EoanTestMirrorbootPartitions(relbase.eoan, TestMirrorbootPartitionsAbs): __test__ = True @@ -315,11 +306,6 @@ class BionicTestMirrorbootPartitionsUEFI(relbase.bionic, __test__ = True -class DiscoTestMirrorbootPartitionsUEFI(relbase.disco, - TestMirrorbootPartitionsUEFIAbs): - __test__ = True - - class EoanTestMirrorbootPartitionsUEFI(relbase.eoan, TestMirrorbootPartitionsUEFIAbs): __test__ = True @@ -367,10 +353,6 @@ class BionicTestRaid5boot(relbase.bionic, TestRaid5bootAbs): __test__ = True -class DiscoTestRaid5boot(relbase.disco, TestRaid5bootAbs): - __test__ = True - - class EoanTestRaid5boot(relbase.eoan, TestRaid5bootAbs): __test__ = True @@ -432,10 +414,6 @@ class BionicTestRaid6boot(relbase.bionic, TestRaid6bootAbs): __test__ = True -class DiscoTestRaid6boot(relbase.disco, TestRaid6bootAbs): - __test__ = True - - class EoanTestRaid6boot(relbase.eoan, TestRaid6bootAbs): __test__ = True @@ -483,10 +461,6 @@ class BionicTestRaid10boot(relbase.bionic, TestRaid10bootAbs): __test__ = True -class DiscoTestRaid10boot(relbase.disco, TestRaid10bootAbs): - __test__ = True - - class EoanTestRaid10boot(relbase.eoan, TestRaid10bootAbs): __test__ = True @@ -591,10 +565,6 @@ class BionicTestAllindata(relbase.bionic, TestAllindataAbs): __test__ = True -class DiscoTestAllindata(relbase.disco, TestAllindataAbs): - __test__ = True - - class EoanTestAllindata(relbase.eoan, TestAllindataAbs): __test__ = True diff --git a/tests/vmtests/test_mdadm_iscsi.py b/tests/vmtests/test_mdadm_iscsi.py index c0e6989a..26b1f71f 100644 --- a/tests/vmtests/test_mdadm_iscsi.py +++ b/tests/vmtests/test_mdadm_iscsi.py @@ -50,10 +50,6 @@ class BionicTestIscsiMdadm(relbase.bionic, TestMdadmIscsiAbs): __test__ = True -class DiscoTestIscsiMdadm(relbase.disco, TestMdadmIscsiAbs): - __test__ = True - - class EoanTestIscsiMdadm(relbase.eoan, TestMdadmIscsiAbs): __test__ = True diff --git a/tests/vmtests/test_multipath.py b/tests/vmtests/test_multipath.py index c807a9bc..b00303ec 100644 --- a/tests/vmtests/test_multipath.py +++ b/tests/vmtests/test_multipath.py @@ -81,10 +81,6 @@ class BionicTestMultipathBasic(relbase.bionic, TestMultipathBasicAbs): __test__ = True -class DiscoTestMultipathBasic(relbase.disco, TestMultipathBasicAbs): - __test__ = True - - class EoanTestMultipathBasic(relbase.eoan, TestMultipathBasicAbs): __test__ = True diff --git a/tests/vmtests/test_network.py b/tests/vmtests/test_network.py index f54e40a0..601cad4b 100644 --- a/tests/vmtests/test_network.py +++ b/tests/vmtests/test_network.py @@ -472,10 +472,6 @@ class BionicTestNetworkBasic(relbase.bionic, TestNetworkBasicAbs): __test__ = True -class DiscoTestNetworkBasic(relbase.disco, TestNetworkBasicAbs): - __test__ = True - - class EoanTestNetworkBasic(relbase.eoan, TestNetworkBasicAbs): __test__ = True diff --git a/tests/vmtests/test_network_alias.py b/tests/vmtests/test_network_alias.py index 13c89eee..68e7de48 100644 --- a/tests/vmtests/test_network_alias.py +++ b/tests/vmtests/test_network_alias.py @@ -52,10 +52,6 @@ class BionicTestNetworkAlias(relbase.bionic, TestNetworkAliasAbs): __test__ = True -class DiscoTestNetworkAlias(relbase.disco, TestNetworkAliasAbs): - __test__ = True - - class EoanTestNetworkAlias(relbase.eoan, TestNetworkAliasAbs): __test__ = True diff --git a/tests/vmtests/test_network_bonding.py b/tests/vmtests/test_network_bonding.py index b808aecd..913c7ff3 100644 --- a/tests/vmtests/test_network_bonding.py +++ b/tests/vmtests/test_network_bonding.py @@ -57,10 +57,6 @@ class BionicTestBonding(relbase.bionic, TestNetworkBondingAbs): __test__ = True -class DiscoTestBonding(relbase.disco, TestNetworkBondingAbs): - __test__ = True - - class EoanTestBonding(relbase.eoan, TestNetworkBondingAbs): __test__ = True diff --git a/tests/vmtests/test_network_bridging.py b/tests/vmtests/test_network_bridging.py index 3b5b99c6..daaade54 100644 --- a/tests/vmtests/test_network_bridging.py +++ b/tests/vmtests/test_network_bridging.py @@ -236,10 +236,6 @@ class BionicTestBridging(relbase.bionic, TestBridgeNetworkAbs): __test__ = True -class DiscoTestBridging(relbase.disco, TestBridgeNetworkAbs): - __test__ = True - - class EoanTestBridging(relbase.eoan, TestBridgeNetworkAbs): __test__ = True diff --git a/tests/vmtests/test_network_ipv6.py b/tests/vmtests/test_network_ipv6.py index e0a39a05..8f0dd542 100644 --- a/tests/vmtests/test_network_ipv6.py +++ b/tests/vmtests/test_network_ipv6.py @@ -53,10 +53,6 @@ class BionicTestNetworkIPV6(relbase.bionic, TestNetworkIPV6Abs): __test__ = True -class DiscoTestNetworkIPV6(relbase.disco, TestNetworkIPV6Abs): - __test__ = True - - class EoanTestNetworkIPV6(relbase.eoan, TestNetworkIPV6Abs): __test__ = True diff --git a/tests/vmtests/test_network_ipv6_static.py b/tests/vmtests/test_network_ipv6_static.py index 278c8377..8a1ba2f4 100644 --- a/tests/vmtests/test_network_ipv6_static.py +++ b/tests/vmtests/test_network_ipv6_static.py @@ -23,10 +23,6 @@ class BionicTestNetworkIPV6Static(relbase.bionic, TestNetworkIPV6StaticAbs): __test__ = True -class DiscoTestNetworkIPV6Static(relbase.disco, TestNetworkIPV6StaticAbs): - __test__ = True - - class EoanTestNetworkIPV6Static(relbase.eoan, TestNetworkIPV6StaticAbs): __test__ = True diff --git a/tests/vmtests/test_network_ipv6_vlan.py b/tests/vmtests/test_network_ipv6_vlan.py index f0f73890..6d38621a 100644 --- a/tests/vmtests/test_network_ipv6_vlan.py +++ b/tests/vmtests/test_network_ipv6_vlan.py @@ -22,16 +22,12 @@ class BionicTestNetworkIPV6Vlan(relbase.bionic, TestNetworkIPV6VlanAbs): __test__ = True -class DiscoTestNetworkIPV6Vlan(relbase.disco, TestNetworkIPV6VlanAbs): - __test__ = True - - class EoanTestNetworkIPV6Vlan(relbase.eoan, TestNetworkIPV6VlanAbs): __test__ = True - @TestNetworkVlanAbs.skip_by_date("1846232", fixby="2020-01-10") + @TestNetworkVlanAbs.skip_by_date("1846232", fixby="2020-03-10") def test_ip_output(self): - pass + return super().test_ip_output() class FocalTestNetworkIPV6Vlan(relbase.focal, TestNetworkIPV6VlanAbs): diff --git a/tests/vmtests/test_network_mtu.py b/tests/vmtests/test_network_mtu.py index e1a55654..bf134596 100644 --- a/tests/vmtests/test_network_mtu.py +++ b/tests/vmtests/test_network_mtu.py @@ -189,14 +189,6 @@ class BionicTestNetworkMtu(relbase.bionic, TestNetworkMtuAbs): upgrade_packages = "cloud-init,systemd" -class DiscoTestNetworkMtu(relbase.disco, TestNetworkMtuAbs): - conf_file = "examples/tests/network_mtu_networkd.yaml" - __test__ = True - # Until systemd is released with the fix for LP:#1671951 - add_repos = "ppa:ddstreet/systemd" - upgrade_packages = "cloud-init,systemd" - - class EoanTestNetworkMtu(relbase.eoan, TestNetworkMtuAbs): conf_file = "examples/tests/network_mtu_networkd.yaml" __test__ = True diff --git a/tests/vmtests/test_network_ovs.py b/tests/vmtests/test_network_ovs.py new file mode 100644 index 00000000..3e23bd01 --- /dev/null +++ b/tests/vmtests/test_network_ovs.py @@ -0,0 +1,45 @@ +# This file is part of curtin. See LICENSE file for copyright and license info. + +from .releases import base_vm_classes as relbase +from .test_network import TestNetworkBaseTestsAbs + + +class TestNetworkOvsAbs(TestNetworkBaseTestsAbs): + """ This class only needs to verify that when provided a v2 config + that on Bionic+ openvswitch packages are installed. """ + conf_file = "examples/tests/network_v2_ovs.yaml" + + def test_openvswitch_package_status(self): + """openvswitch-switch is expected installed in Ubuntu >= bionic.""" + rel = self.target_release + pkg = "openvswitch-switch" + self.assertIn( + pkg, self.debian_packages, + "%s package expected in %s but not found" % (pkg, rel)) + + def test_etc_network_interfaces(self): + pass + + def test_ip_output(self): + pass + + def test_etc_resolvconf(self): + pass + + def test_bridge_params(self): + pass + + +class BionicTestNetworkOvs(relbase.bionic, TestNetworkOvsAbs): + __test__ = True + + +class EoanTestNetworkOvs(relbase.eoan, TestNetworkOvsAbs): + __test__ = True + + +class FocalTestNetworkOvs(relbase.focal, TestNetworkOvsAbs): + __test__ = True + + +# vi: ts=4 expandtab syntax=python diff --git a/tests/vmtests/test_network_static.py b/tests/vmtests/test_network_static.py index b2fac163..80ff2cd6 100644 --- a/tests/vmtests/test_network_static.py +++ b/tests/vmtests/test_network_static.py @@ -28,10 +28,6 @@ class BionicTestNetworkStatic(relbase.bionic, TestNetworkStaticAbs): __test__ = True -class DiscoTestNetworkStatic(relbase.disco, TestNetworkStaticAbs): - __test__ = True - - class EoanTestNetworkStatic(relbase.eoan, TestNetworkStaticAbs): __test__ = True diff --git a/tests/vmtests/test_network_static_routes.py b/tests/vmtests/test_network_static_routes.py index 8e63df8f..dfcbffe7 100644 --- a/tests/vmtests/test_network_static_routes.py +++ b/tests/vmtests/test_network_static_routes.py @@ -28,11 +28,6 @@ class BionicTestNetworkStaticRoutes(relbase.bionic, __test__ = True -class DiscoTestNetworkStaticRoutes(relbase.disco, - TestNetworkStaticRoutesAbs): - __test__ = True - - class EoanTestNetworkStaticRoutes(relbase.eoan, TestNetworkStaticRoutesAbs): __test__ = True diff --git a/tests/vmtests/test_network_vlan.py b/tests/vmtests/test_network_vlan.py index 27aaa2b5..cdd06c31 100644 --- a/tests/vmtests/test_network_vlan.py +++ b/tests/vmtests/test_network_vlan.py @@ -76,24 +76,20 @@ class BionicTestNetworkVlan(relbase.bionic, TestNetworkVlanAbs): __test__ = True -class DiscoTestNetworkVlan(relbase.disco, TestNetworkVlanAbs): - __test__ = True - - class EoanTestNetworkVlan(relbase.eoan, TestNetworkVlanAbs): __test__ = True - @TestNetworkBaseTestsAbs.skip_by_date("1846232", fixby="2020-01-10") + @TestNetworkBaseTestsAbs.skip_by_date("1846232", fixby="2020-03-10") def test_ip_output(self): - pass + return super().test_ip_output() class FocalTestNetworkVlan(relbase.focal, TestNetworkVlanAbs): __test__ = True - @TestNetworkBaseTestsAbs.skip_by_date("1846232", fixby="2020-01-10") + @TestNetworkBaseTestsAbs.skip_by_date("1846232", fixby="2020-03-10") def test_ip_output(self): - pass + return super().test_ip_output() class Centos66TestNetworkVlan(centos_relbase.centos66_xenial, diff --git a/tests/vmtests/test_nvme.py b/tests/vmtests/test_nvme.py index 4f0b4d77..ca36ca80 100644 --- a/tests/vmtests/test_nvme.py +++ b/tests/vmtests/test_nvme.py @@ -73,10 +73,6 @@ class BionicTestNvme(relbase.bionic, TestNvmeAbs): __test__ = True -class DiscoTestNvme(relbase.disco, TestNvmeAbs): - __test__ = True - - class EoanTestNvme(relbase.eoan, TestNvmeAbs): __test__ = True @@ -143,14 +139,11 @@ class BionicTestNvmeBcache(relbase.bionic, TestNvmeBcacheAbs): __test__ = True -class DiscoTestNvmeBcache(relbase.disco, TestNvmeBcacheAbs): - __test__ = True - - class EoanTestNvmeBcache(relbase.eoan, TestNvmeBcacheAbs): __test__ = True [email protected]_by_date("1861941", fixby="2020-04-15") class FocalTestNvmeBcache(relbase.focal, TestNvmeBcacheAbs): __test__ = True diff --git a/tests/vmtests/test_pollinate_useragent.py b/tests/vmtests/test_pollinate_useragent.py index 046fff54..ff21f20d 100644 --- a/tests/vmtests/test_pollinate_useragent.py +++ b/tests/vmtests/test_pollinate_useragent.py @@ -61,10 +61,6 @@ class BionicTestPollinateUserAgent(relbase.bionic, TestPollinateUserAgent): __test__ = True -class DiscoTestPollinateUserAgent(relbase.disco, TestPollinateUserAgent): - __test__ = True - - class EoanTestPollinateUserAgent(relbase.eoan, TestPollinateUserAgent): __test__ = True diff --git a/tests/vmtests/test_preserve.py b/tests/vmtests/test_preserve.py index 6194ab09..f02ba6c0 100644 --- a/tests/vmtests/test_preserve.py +++ b/tests/vmtests/test_preserve.py @@ -25,10 +25,6 @@ class BionicTestPreserve(relbase.bionic, TestPreserve): __test__ = True -class DiscoTestPreserve(relbase.disco, TestPreserve): - __test__ = True - - class EoanTestPreserve(relbase.eoan, TestPreserve): __test__ = True diff --git a/tests/vmtests/test_preserve_raid.py b/tests/vmtests/test_preserve_raid.py index 3168f574..cf3a6bb7 100644 --- a/tests/vmtests/test_preserve_raid.py +++ b/tests/vmtests/test_preserve_raid.py @@ -25,10 +25,6 @@ class BionicTestPreserveRAID(relbase.bionic, TestPreserveRAID): __test__ = True -class DiscoTestPreserveRAID(relbase.disco, TestPreserveRAID): - __test__ = True - - class EoanTestPreserveRAID(relbase.eoan, TestPreserveRAID): __test__ = True diff --git a/tests/vmtests/test_raid5_bcache.py b/tests/vmtests/test_raid5_bcache.py index a2df2182..7138a2ce 100644 --- a/tests/vmtests/test_raid5_bcache.py +++ b/tests/vmtests/test_raid5_bcache.py @@ -43,12 +43,17 @@ class TestMdadmBcacheAbs(TestMdadmAbs): bcache-super-show /dev/vda2 > bcache_super_vda2 ls /sys/fs/bcache > bcache_ls cat /sys/block/bcache0/bcache/cache_mode > bcache_cache_mode + ls -al /dev/bcache/by-uuid/ > ls_al_bcache_byuuid exit 0""")]) - fstab_expected = { - '/dev/bcache0': '/', - '/dev/md0': '/srv/data', - } + + def get_fstab_expected(self): + bcache0_kname = self._dname_to_kname('bcache0') + return [ + (self._bcache_to_byuuid(bcache0_kname), '/', 'defaults'), + (self._kname_to_uuid_devpath('md-uuid', 'md0'), + '/srv/data', 'defaults') + ] def test_bcache_output_files_exist(self): self.output_files_exist(["bcache_super_vda2", "bcache_ls", @@ -83,10 +88,6 @@ class BionicTestRaid5Bcache(relbase.bionic, TestMdadmBcacheAbs): __test__ = True -class DiscoTestRaid5Bcache(relbase.disco, TestMdadmBcacheAbs): - __test__ = True - - class EoanTestRaid5Bcache(relbase.eoan, TestMdadmBcacheAbs): __test__ = True @@ -94,5 +95,9 @@ class EoanTestRaid5Bcache(relbase.eoan, TestMdadmBcacheAbs): class FocalTestRaid5Bcache(relbase.focal, TestMdadmBcacheAbs): __test__ = True + @TestMdadmBcacheAbs.skip_by_date("1861941", fixby="2020-04-15") + def test_fstab(self): + return super().test_fstab() + # vi: ts=4 expandtab syntax=python diff --git a/tests/vmtests/test_reuse_raid_member.py b/tests/vmtests/test_reuse_raid_member.py index af46a9b5..07259660 100644 --- a/tests/vmtests/test_reuse_raid_member.py +++ b/tests/vmtests/test_reuse_raid_member.py @@ -28,10 +28,6 @@ class BionicTestReuseRAIDMember(relbase.bionic, TestReuseRAIDMember): __test__ = True -class DiscoTestReuseRAIDMember(relbase.disco, TestReuseRAIDMember): - __test__ = True - - class EoanTestReuseRAIDMember(relbase.eoan, TestReuseRAIDMember): __test__ = True @@ -45,11 +41,6 @@ class BionicTestReuseRAIDMemberPartition(relbase.bionic, __test__ = True -class DiscoTestReuseRAIDMemberPartition(relbase.disco, - TestReuseRAIDMemberPartition): - __test__ = True - - class EoanTestReuseRAIDMemberPartition(relbase.eoan, TestReuseRAIDMemberPartition): __test__ = True diff --git a/tests/vmtests/test_reuse_uefi_esp.py b/tests/vmtests/test_reuse_uefi_esp.py new file mode 100644 index 00000000..1e999355 --- /dev/null +++ b/tests/vmtests/test_reuse_uefi_esp.py @@ -0,0 +1,52 @@ +# This file is part of curtin. See LICENSE file for copyright and license info. + +from .test_uefi_basic import TestBasicAbs +from .releases import base_vm_classes as relbase +from .releases import centos_base_vm_classes as cent_rbase + + +class TestUefiReuseEspAbs(TestBasicAbs): + conf_file = "examples/tests/uefi_reuse_esp.yaml" + + def test_efiboot_menu_has_one_distro_entry(self): + efiboot_mgr_content = self.load_collect_file("efibootmgr.out") + distro_lines = [line for line in efiboot_mgr_content.splitlines() + if self.target_distro in line] + print(distro_lines) + self.assertEqual(1, len(distro_lines)) + + +class Cent70TestUefiReuseEsp(cent_rbase.centos70_bionic, TestUefiReuseEspAbs): + __test__ = True + + +# grub-efi-amd64 + shim-signed isn't happy on XenialGA ephemeral env +class XenialGATestUefiReuseEsp(relbase.xenial_ga, TestUefiReuseEspAbs): + __test__ = False + + +class BionicTestUefiReuseEsp(relbase.bionic, TestUefiReuseEspAbs): + __test__ = True + + @TestUefiReuseEspAbs.skip_by_date("1863015", fixby="2020-04-15") + def test_efiboot_menu_has_one_distro_entry(self): + return super().test_efiboot_menu_has_one_distro_entry() + + +class EoanTestUefiReuseEsp(relbase.eoan, TestUefiReuseEspAbs): + __test__ = True + + @TestUefiReuseEspAbs.skip_by_date("1863015", fixby="2020-04-15") + def test_efiboot_menu_has_one_distro_entry(self): + return super().test_efiboot_menu_has_one_distro_entry() + + +class FocalTestUefiReuseEsp(relbase.focal, TestUefiReuseEspAbs): + __test__ = True + + @TestUefiReuseEspAbs.skip_by_date("1863015", fixby="2020-04-15") + def test_efiboot_menu_has_one_distro_entry(self): + return super().test_efiboot_menu_has_one_distro_entry() + + +# vi: ts=4 expandtab syntax=python diff --git a/tests/vmtests/test_simple.py b/tests/vmtests/test_simple.py index 9a218797..b34a6fc7 100644 --- a/tests/vmtests/test_simple.py +++ b/tests/vmtests/test_simple.py @@ -49,13 +49,6 @@ class BionicTestSimple(relbase.bionic, TestSimple): self.output_files_exist(["netplan.yaml"]) -class DiscoTestSimple(relbase.disco, TestSimple): - __test__ = True - - def test_output_files_exist(self): - self.output_files_exist(["netplan.yaml"]) - - class EoanTestSimple(relbase.eoan, TestSimple): __test__ = True @@ -112,13 +105,6 @@ class BionicTestSimpleStorage(relbase.bionic, TestSimpleStorage): self.output_files_exist(["netplan.yaml"]) -class DiscoTestSimpleStorage(relbase.disco, TestSimpleStorage): - __test__ = True - - def test_output_files_exist(self): - self.output_files_exist(["netplan.yaml"]) - - class EoanTestSimpleStorage(relbase.eoan, TestSimpleStorage): __test__ = True diff --git a/tests/vmtests/test_uefi_basic.py b/tests/vmtests/test_uefi_basic.py index a20506d3..90940dde 100644 --- a/tests/vmtests/test_uefi_basic.py +++ b/tests/vmtests/test_uefi_basic.py @@ -105,10 +105,6 @@ class BionicUefiTestBasic(relbase.bionic, TestBasicAbs): __test__ = True -class DiscoUefiTestBasic(relbase.disco, TestBasicAbs): - __test__ = True - - class EoanUefiTestBasic(relbase.eoan, TestBasicAbs): __test__ = True @@ -132,11 +128,6 @@ class BionicUefiTestBasic4k(relbase.bionic, TestBasicAbs): disk_block_size = 4096 -class DiscoUefiTestBasic4k(relbase.disco, TestBasicAbs): - __test__ = True - disk_block_size = 4096 - - class EoanUefiTestBasic4k(relbase.eoan, TestBasicAbs): __test__ = True disk_block_size = 4096 diff --git a/tests/vmtests/test_zfsroot.py b/tests/vmtests/test_zfsroot.py index 86992c3c..c9c73a37 100644 --- a/tests/vmtests/test_zfsroot.py +++ b/tests/vmtests/test_zfsroot.py @@ -96,11 +96,6 @@ class BionicTestZfsRoot(relbase.bionic, TestZfsRootAbs): __test__ = True -class DiscoTestZfsRoot(relbase.disco, TestZfsRootAbs): - __test__ = True - mem = 4096 - - class EoanTestZfsRoot(relbase.eoan, TestZfsRootAbs): __test__ = True mem = 4096 @@ -130,11 +125,6 @@ class BionicTestZfsRootFsType(relbase.bionic, TestZfsRootFsTypeAbs): __test__ = True -class DiscoTestZfsRootFsType(relbase.disco, TestZfsRootFsTypeAbs): - __test__ = True - mem = 4096 - - class EoanTestZfsRootFsType(relbase.eoan, TestZfsRootFsTypeAbs): __test__ = True mem = 4096 diff --git a/tools/remove-vmtest-release b/tools/remove-vmtest-release new file mode 100644 index 00000000..8ab9b2e9 --- /dev/null +++ b/tools/remove-vmtest-release @@ -0,0 +1,54 @@ +#!/usr/bin/python3 + +import argparse +import glob +import os + + +def clean_file(fname, distro): + new_content = [] + modified = False + with open(fname, 'r') as fh: + delete = False + # using read().splitlines() to strip the newline char + for line in fh.read().splitlines(): + if line.startswith('class %s' % distro): + delete = True + # ensure we don't remove final block of text outside + # of the distro test class definition scope. + # N.B: we match the empty line right before the next class scope + elif delete and line and not line[0].isspace(): + delete = False + + if delete: + modified = True + continue + else: + new_content.append(line) + + # skip a re-write of content if no modifications + if modified: + cleaned_fn = fname + with open(cleaned_fn, 'w') as wfh: + wfh.write("\n".join(new_content) + '\n') + print("Wrote cleaned file: %s" % cleaned_fn) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + prog="remove-vmtest-release", + description="Tool to remove vmtest classes by distro release") + parser.add_argument('--distro-release', '-d', + action='store', required=True) + parser.add_argument('--path', '-p', action='store', required=True) + + args = parser.parse_args() + distro = args.distro_release.title() + target = args.path + if os.path.isdir(target): + files = glob.glob(os.path.normpath(target) + '/' + 'test_*.py') + else: + files = [target] + + for fname in files: + clean_file(fname, distro) diff --git a/tools/run-pep8 b/tools/run-pep8 index b1dd7c09..c27a96c8 100755 --- a/tools/run-pep8 +++ b/tools/run-pep8 @@ -9,6 +9,7 @@ pycheck_dirs=( "tools/block-discover-to-config" "tools/curtin-log-print" "tools/noproxy" + "tools/remove-vmtest-release" "tools/schema-validate-storage" "tools/ssh-keys-list" "tools/vmtest-filter" diff --git a/tools/run-pyflakes b/tools/run-pyflakes index f9c21851..86eb3cc2 100755 --- a/tools/run-pyflakes +++ b/tools/run-pyflakes @@ -17,6 +17,7 @@ pycheck_dirs=( "tools/block-discover-to-config" "tools/curtin-log-print" "tools/noproxy" + "tools/remove-vmtest-release" "tools/schema-validate-storage" "tools/ssh-keys-list" "tools/vmtest-filter" |