virtinst: install: Fill out more test coverage

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-01-27 10:13:03 -05:00
parent 3440d8c59d
commit 6d2483f09d
5 changed files with 137 additions and 14 deletions

View File

@ -0,0 +1,117 @@
<domain type="kvm">
<name>fedora17</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://fedoraproject.org/fedora/17"/>
</libosinfo:libosinfo>
</metadata>
<memory>65536</memory>
<currentMemory>65536</currentMemory>
<vcpu>2</vcpu>
<os>
<type arch="x86_64" machine="pc">hvm</type>
<kernel>/VIRTINST-TESTSUITE/vmlinuz</kernel>
<initrd>/VIRTINST-TESTSUITE/initrd.img</initrd>
<cmdline>ks=file:/fedora.ks method=http://archive.fedoraproject.org/pub/archive/fedora/linux/releases/17/Fedora/x86_64/os/</cmdline>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode="host-model"/>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<on_reboot>destroy</on_reboot>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<controller type="usb" model="ich9-ehci1"/>
<controller type="usb" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="bridge">
<source bridge="testsuitebr0"/>
<mac address="00:11:22:33:44:55"/>
<model type="virtio"/>
</interface>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>
<target type="virtio" name="org.qemu.guest_agent.0"/>
</channel>
<memballoon model="virtio"/>
<rng model="virtio">
<backend model="random">/dev/urandom</backend>
</rng>
</devices>
</domain>
<domain type="kvm">
<name>fedora17</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://fedoraproject.org/fedora/17"/>
</libosinfo:libosinfo>
</metadata>
<memory>65536</memory>
<currentMemory>65536</currentMemory>
<vcpu>2</vcpu>
<os>
<type arch="x86_64" machine="pc">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode="host-model"/>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<controller type="usb" model="ich9-ehci1"/>
<controller type="usb" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="bridge">
<source bridge="testsuitebr0"/>
<mac address="00:11:22:33:44:55"/>
<model type="virtio"/>
</interface>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>
<target type="virtio" name="org.qemu.guest_agent.0"/>
</channel>
<memballoon model="virtio"/>
<rng model="virtio">
<backend model="random">/dev/urandom</backend>
</rng>
</devices>
</domain>

View File

@ -17,6 +17,8 @@ try:
except ImportError:
argcomplete = None
from gi.repository import Libosinfo
from virtinst import log
from virtinst import OSDB
from virtinst.install import unattended
@ -35,6 +37,10 @@ OLD_OSINFO = utils.has_old_osinfo()
NO_OSINFO_UNATTEND = not unattended.OSInstallScript.have_new_libosinfo()
HAS_ISOINFO = shutil.which("isoinfo")
# We use this check as a surrogate for a released libosinfo with a bug
# fix we need to get full test coverage
LIBOSINFO_SUPPORT_LOCAL_TREE = hasattr(Libosinfo.Tree, "create_from_treeinfo")
# Images that will be created by virt-install/virt-clone, and removed before
# each run
new_images = [
@ -900,6 +906,7 @@ c.add_valid("--connect %s --pxe --disk size=1" % utils.URIs.test_defaultpool_col
c = vinst.add_category("unattended-install", "--connect %(URI-KVM)s --nographics --noautoconsole --disk none", prerun_check=no_osinfo_unattend_cb)
c.add_compare("--install fedora26 --unattended profile=desktop,admin-password-file=%(ADMIN-PASSWORD-FILE)s,user-password-file=%(USER-PASSWORD-FILE)s,product-key=1234,user-login=foobar,reg-login=regtest", "osinfo-url-unattended", prerun_check=lambda: not unattended.OSInstallScript.have_libosinfo_installation_url()) # unattended install for fedora, using initrd injection
c.add_compare("--location %(TREEDIR)s --unattended", "osinfo-unattended-treeapis", prerun_check=lambda: not LIBOSINFO_SUPPORT_LOCAL_TREE) # unattended install using treeobj libosinfo APIs
c.add_compare("--cdrom %(ISO-WIN7)s --unattended profile=desktop,admin-password-file=%(ADMIN-PASSWORD-FILE)s", "osinfo-win7-unattended", prerun_check=no_osinfo_unattended_win_drivers_cb) # unattended install for win7
c.add_compare("--os-variant fedora26 --unattended profile=jeos,admin-password-file=%(ADMIN-PASSWORD-FILE)s --location %(ISO-F26-NETINST)s", "osinfo-netinst-unattended") # triggering the special netinst checking code
c.add_compare("--os-variant silverblue29 --location http://example.com", "network-install-resources") # triggering network-install resources override

View File

@ -114,3 +114,7 @@ class TestOSDB(unittest.TestCase):
# Just call this for code coverage. Values differ by osinfo-db version
win7.get_post_installable_drivers_location("x86_64")
win10 = OSDB.lookup_os("win10")
win10.get_post_installable_drivers_location("x86_64")
win10.supports_unattended_agents("x86_64")

View File

@ -252,9 +252,8 @@ class InstallerTreeMedia(object):
args = []
for unattended_script in unattended_scripts:
cmdline = unattended_script.generate_cmdline()
if not cmdline:
continue
args.append(cmdline)
if cmdline:
args.append(cmdline)
install_args = (" ").join(args)
log.debug("Generated unattended cmdline: %s", install_args)
elif self.is_network_url():

View File

@ -21,7 +21,8 @@ def _in_testsuite():
def _media_create_from_location(location):
if not hasattr(Libosinfo.Media, "create_from_location_with_flags"):
return Libosinfo.Media.create_from_location(location, None)
return Libosinfo.Media.create_from_location( # pragma: no cover
location, None)
# We prefer this API, because by default it will not
# reject non-bootable media, like debian s390x
@ -277,7 +278,7 @@ class _OSDB(object):
if not db.identify_tree(tree):
return None # pragma: no cover
return tree.get_os().get_short_id(), _OsTree(tree)
else:
else: # pragma: no cover
osobj, treeobj = self._os_loader.get_db().guess_os_from_tree(tree)
if not osobj:
return None # pragma: no cover
@ -369,10 +370,9 @@ class _OsVariant(object):
self._short_ids = ["generic"]
if self._os:
self._short_ids = [self._os.get_short_id()]
if hasattr(self._os, "get_short_id_list"):
self._short_ids = self._os.get_short_id_list()
else:
self._short_ids = [self._os.get_short_id()]
self.name = self._short_ids[0]
self.full_id = self._os and self._os.get_id() or None
@ -629,7 +629,7 @@ class _OsVariant(object):
return "inst.repo"
def _get_generic_location(self, treelist, arch, profile):
if not hasattr(Libosinfo.Tree, "get_os_variants"):
if not hasattr(Libosinfo.Tree, "get_os_variants"): # pragma: no cover
for tree in treelist:
if tree.get_architecture() == arch:
return tree.get_url()
@ -648,12 +648,8 @@ class _OsVariant(object):
continue
variant_list = tree.get_os_variants()
if variant_list.get_length() == 0:
return tree.get_url()
fallback_tree = tree
for i in range(variant_list.get_length()):
variant = variant_list.get_nth(i)
for variant in _OsinfoIter(variant_list):
if profile in variant.get_name():
return tree.get_url()
@ -774,7 +770,7 @@ class _OsMedia(object):
for variant in variants:
if "netinst" in variant.get_id():
return True
return False
return False # pragma: no cover
def get_install_script_list(self):
return list(_OsinfoIter(self._media.get_install_script_list()))