def testAddControllers(self): """ Add various controller configs """ details = self._open_details_window() addhw = self._open_addhw_window(details) # Default SCSI tab = self._select_hw(addhw, "Controller", "controller-tab") tab.combo_select("Type:", "SCSI") self._finish(addhw, check=details) # Virtio SCSI addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Controller", "controller-tab") tab.combo_select("Type:", "SCSI") tab.combo_select("Model:", "VirtIO SCSI") self._finish(addhw, check=details) # USB 2 addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Controller", "controller-tab") tab.combo_select("Type:", "USB") tab.combo_select("Model:", "USB 2") self._finish(addhw, check=details) # USB 3 addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Controller", "controller-tab") tab.combo_select("Type:", "USB") tab.combo_select("Model:", "USB 3") # Can't add more than 1 USB controller, so finish isn't sensitive finish = addhw.find("Finish", "push button") uiutils.check(lambda: not finish.sensitive)
def testAddHWCornerCases(self): """ Random addhardware related tests """ details = self._open_details_window("test-many-devices") addhw = self._open_addhw_window(details) # Test cancel addhw.find("Cancel", "push button").click() # Test live adding, error dialog, click no self._open_addhw_window(details) self._finish(addhw, check=None) alert = self.app.root.find("vmm dialog", "alert") alert.find("This device could not be attached to the running machine", "label") alert.find("Details", "toggle button").click_expander() alert.find("No", "push button").click() uiutils.check(lambda: details.active) # Test live adding, error dialog, click yes self._open_addhw_window(details) self._finish(addhw, check=None) alert = self.app.root.find("vmm dialog", "alert") alert.find("This device could not be attached to the running machine", "label") alert.find("Details", "toggle button").click_expander() alert.find("Yes", "push button").click() uiutils.check(lambda: alert.dead)
def testCLITraceLibvirt(self): # Just test this for code coverage self.app.open(keyfile="allstats.ini", extra_opts=["--trace-libvirt=mainloop"]) # Give it a little time to work self.sleep(2) uiutils.check(lambda: self.app.topwin.active)
def testAddDiskSearchPermsFail(self, uri, tmpdir): """ Force perms fixing to fail """ self.app.uri = uri self.app.open(break_setfacl=True) details = self._open_details_window() # Say 'Yes' and it should fail, then blacklist the paths addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Storage", "storage-tab") tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo1.img" tab.find("storage-entry").set_text(path) self._finish(addhw, check=None) self._click_alert_button("emulator may not have", "Yes") alert = self.app.root.find("vmm dialog", "alert") alert.find_fuzzy("Errors were encountered", "label") alert.find_fuzzy("Don't ask", "check box").click() alert.find_fuzzy("OK", "push button").click() uiutils.check(lambda: details.active) # Confirm it doesn't ask about path again addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Storage", "storage-tab") tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo2.img" tab.find("storage-entry").set_text(path) self._finish(addhw, check=details)
def testNewKVMQ35UEFI(self): """ New VM that should default to Q35, and set UEFI """ self.app.uri = tests.utils.URIs.kvm newvm = self._open_create_wizard() newvm.find_fuzzy("Import", "radio").click() self.forward(newvm) newvm.find("import-entry").set_text("/dev/default-pool/testvol1.img") newvm.find("oslist-entry").set_text("fedora30") popover = newvm.find("oslist-popover") popover.find("include-eol").click() popover.find_fuzzy("Fedora 30").click() self.forward(newvm) self.forward(newvm) # Select customize wizard, we will use this VM to # hit some PPC64 code paths elsewhere newvm.find_fuzzy("Customize", "check").click() newvm.find_fuzzy("Finish", "button").click() vmname = "fedora30" details = self.app.root.find_fuzzy("%s on" % vmname, "frame") # Change to UEFI details.combo_check_default("Chipset:", "Q35") details.combo_check_default("Firmware:", "BIOS") details.combo_select("Firmware:", ".*x86_64.*") details.find("config-apply").click() # Finish details.find_fuzzy("Begin Installation", "button").click() uiutils.check(lambda: details.dead) self.app.root.find_fuzzy("%s on" % vmname, "frame")
def testDeleteDeviceNoStorage(self): """ Verify successful device remove with storage doesn't touch host storage """ details = self._open_details_window("test-many-devices", shutdown=True) hwlist = details.find("hw-list") hwlist.click() c = hwlist.find("USB Disk 1") c.bring_on_screen() c.click() tab = details.find("disk-tab") uiutils.check(lambda: tab.showing) details.find("config-remove").click() delete = self.app.root.find_fuzzy("Remove Disk", "frame") chk = delete.find("Delete associated", "check box") uiutils.check(lambda: not chk.checked) self._finish(delete, []) details.click() details.keyCombo("<alt>F4") browser = self._open_storage_browser() browser.find_fuzzy("default-pool", "table cell").click() browser.find("vol-refresh", "push button").click() self.sleep(.5) browser.find("overlay.img", "table cell")
def testConnectionConnCrash(self): self.app.open(extra_opts=["--test-options=conn-crash"]) manager = self.app.topwin self.sleep(1) manager.find(r"^test testdriver.xml - Not Connected", "table cell") uiutils.check(lambda: manager.active)
def testConnectionBlacklist(self): self.app.open( extra_opts=["--test-options=object-blacklist=test-many-devices"]) manager = self.app.topwin def _delete_vm(vmname): cell = manager.find(vmname, "table cell") cell.click() cell.click(button=3) menu = self.app.root.find("vm-action-menu") menu.find("Delete", "menu item").click() delete = self.app.root.find_fuzzy("Delete", "frame") delete.find("Delete associated", "check box").click() delete.find("Delete", "push button").click() uiutils.check(lambda: cell.dead) uiutils.check(lambda: manager.active) uiutils.check( lambda: "test-many-devices" not in self.app.topwin.fmt_nodes()) _delete_vm("test-arm-kernel") _delete_vm("test alternate") _delete_vm("test-clone-simple") self.sleep(.5) uiutils.check( lambda: "test-many-devices" not in self.app.topwin.fmt_nodes())
def testDetailsNetIPAddress(self): """ Test all the IP code paths with a few mock cases """ win = self._open_details_window(vmname="test-many-devices") def check_ip(*args): for ip in args: tab.find_fuzzy(ip, "label") # First case has a virtual network, so hits the leases path tab = self._select_hw(win, "NIC :54:32:10", "network-tab") check_ip("10.0.0.2", "fd00:beef::2") tab.find("IP address:", "push button").click() check_ip("10.0.0.2", "fd00:beef::2") # Next case has a missing virtual network, so hits the arp path tab = self._select_hw(win, "NIC :11:11:11", "network-tab") check_ip("Unknown") tab.find("IP address:", "push button").click() check_ip("10.0.0.3") win.keyCombo("<alt>F4") uiutils.check(lambda: not win.showing) self.app.topwin.click_title() # Tests the fake qemu guest agent path win = self._open_details_window(vmname="test alternate devs title") tab = self._select_hw(win, "NIC :11:72:72", "network-tab") check_ip("10.0.0.1", "fd00:beef::1/128")
def _testRename(self, origname, newname): # Enable all stats prefs to hit some extra code win = self._open_details_window(origname) # Ensure the Overview page is the first selected win.find("Hypervisor Details", "label") win.find("Overview", "table cell").click() oldcell = self.app.root.find_fuzzy(origname, "table cell") badname = "foo/bar" win.find("Name:", "text").set_text(badname) appl = win.find("config-apply") appl.click() self._click_alert_button(badname, "Close") # Actual name change win.find("Name:", "text").set_text(newname) appl.click() uiutils.check(lambda: not appl.sensitive) # Confirm lists were updated self.app.root.find("%s on" % newname, "frame") self.app.root.find_fuzzy(newname, "table cell") # Make sure the old entry is gone uiutils.check(lambda: origname not in oldcell.name)
def testNewVMContainerTree(self): """ Simple LXC tree install """ self.app.uri = tests.utils.URIs.lxc newvm = self._open_create_wizard() newvm.find_fuzzy("Operating system", "radio").click() self.forward(newvm) # Set directory path dirtext = newvm.find_fuzzy(None, "text", "root directory") dirtext.set_text("") self.forward(newvm, check=False) self._click_alert_button("path is required", "OK") newvm.find("install-oscontainer-browse").click() self._select_storagebrowser_volume("default-pool", "dir-vol") uiutils.check(lambda: "dir-vol" in dirtext.text) self.forward(newvm) self.forward(newvm) newvm.find_fuzzy("Finish", "button").click() uiutils.check(lambda: not newvm.showing) self.app.root.find_fuzzy("container1 on", "frame")
def testCreateVolXMLEditor(self): self.app.open(xmleditor_enabled=True) hostwin = self._open_host_window("Storage") poolcell = hostwin.find("default-pool", "table cell") poolcell.click() win = self._open_create_win(hostwin) finish = win.find("Finish", "push button") name = win.find("Name:", "text") vollist = hostwin.find("vol-list", "table") # Create a new obj with XML edited name, verify it worked tmpname = "objtmpname" newname = "aafroofroo" name.set_text(tmpname) win.find("XML", "page tab").click() xmleditor = win.find("XML editor") newtext = xmleditor.text.replace(">%s.qcow2<" % tmpname, ">%s<" % newname) xmleditor.set_text(newtext) finish.click() uiutils.check(lambda: hostwin.active) vollist.find(newname) # Do standard xmleditor tests win = self._open_create_win(hostwin) self._test_xmleditor_interactions(win, finish) win.find("Cancel", "push button").click() uiutils.check(lambda: not win.visible)
def testNewVMInactiveNetwork(self): """ Test with an inactive 'default' network """ self.app.uri = tests.utils.URIs.test_default hostwin = self._open_host_window("Virtual Networks", conn_label="test default") cell = hostwin.find("default", "table cell") cell.click() hostwin.find("net-stop").click() hostwin.keyCombo("<ctrl>w") newvm = self._open_create_wizard() newvm.find_fuzzy("Import", "radio").click() self.forward(newvm) newvm.find("import-entry").set_text(__file__) newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm) self.forward(newvm) newvm.find_fuzzy("Finish", "button").click() self._click_alert_button("start the network", "Yes") uiutils.check(lambda: not newvm.showing)
def testDetailsXMLEdit(self): """ Test XML editing interaction """ self.app.open(xmleditor_enabled=True) win = self._open_details_window(vmname="test-clone-simple") finish = win.find("config-apply") xmleditor = win.find("XML editor") # Edit vcpu count and verify it's reflected in CPU page tab = self._select_hw(win, "CPUs", "cpu-tab") win.find("XML", "page tab").click() xmleditor.set_text(xmleditor.text.replace(">5</vcpu", ">8</vcpu")) finish.click() win.find("Details", "page tab").click() vcpualloc = tab.find("vCPU allocation:", "spin button") uiutils.check(lambda: vcpualloc.text == "8") # Make some disk edits tab = self._select_hw(win, "IDE Disk 1", "disk-tab") win.find("XML", "page tab").click() origpath = "/dev/default-pool/test-clone-simple.img" newpath = "/path/FOOBAR" xmleditor.set_text(xmleditor.text.replace(origpath, newpath)) finish.click() win.find("Details", "page tab").click() disksrc = win.find("disk-source-path") uiutils.check(lambda: disksrc.text == newpath) # Do standard xmleditor tests self._test_xmleditor_interactions(win, finish)
def testManagerConnOpenFail(self): self.app.open(keyfile="baduri.ini") manager = self.app.topwin manager.find_fuzzy("bad uri", "table cell").doubleClick() uiutils.check(lambda: not manager.active) self._click_alert_button("Unable to connect", "Close") uiutils.check(lambda: manager.active)
def testShowRemoteDBusConnect(self): """ Test the remote app dbus connection """ self.app.open() uiutils.check(lambda: "testdriver" in self.app.topwin.fmt_nodes()) uiutils.check( lambda: "test default" not in self.app.topwin.fmt_nodes()) def _run_remote(opts): newapp = uiutils.VMMDogtailApp("test:///default") newapp.open(check_already_running=False, extra_opts=opts) uiutils.check(lambda: not newapp.is_running()) import dogtail.tree vapps = [ a for a in dogtail.tree.root.applications() if a.name == "virt-manager" ] uiutils.check(lambda: len(vapps) == 1) # Ensure connection showed up self.app.topwin.find("test default", "table cell") _run_remote([]) # Run remote again to trigger engine.py code when a connection # is already there and connected _run_remote(["--show-domain-console=test"])
def _get_conn_action(connstr, actionstr): if not menu.showing: systray.click(button=3) uiutils.check(lambda: menu.showing) connmenu = menu.find(connstr, "menu") connmenu.point() return connmenu.find(actionstr, "menu")
def testShowPerformance(self): domid = "1" self.app.open(extra_opts=["--show-domain-performance", domid]) uiutils.check(lambda: "test on" in self.app.topwin.name) cpulabel = self.app.topwin.find_fuzzy("CPU usage", "label") uiutils.check(lambda: cpulabel.showing)
def testMigrateXMLEditor(self): self.app.open(xmleditor_enabled=True) manager = self.app.topwin # Add an additional connection self._add_conn("test:///default") # Run it and check some values vmname = "test-many-devices" win = self._open_migrate(vmname) win.find("address-text").set_text("TESTSUITE-FAKE") # Create a new obj with XML edited name, verify it worked newname = "aafroofroo" win.find("XML", "page tab").click() xmleditor = win.find("XML editor") newtext = xmleditor.text.replace( ">%s<" % vmname, ">%s<" % newname) xmleditor.set_text(newtext) win.find("Migrate", "push button").click() uiutils.check(lambda: not win.showing, timeout=10) manager.find(newname, "table cell") # Do standard xmleditor tests win = self._open_migrate(vmname) win.find("address-text").set_text("TESTSUITE-FAKE") finish = win.find("Migrate", "push button") self._test_xmleditor_interactions(win, finish) win.find("Cancel", "push button").click() uiutils.check(lambda: not win.visible)
def testConnectionFakeEvents(self): self.app.open(extra_opts=[ "--test-options=fake-nodedev-event=computer", "--test-options=fake-agent-event=test-many-devices" ]) manager = self.app.topwin self.sleep(2.5) uiutils.check(lambda: manager.active)
def _run(): username = dialog.find("Username:.*entry") password = dialog.find("Password:.*entry") username.click() username.text = "foo" self.pressKey("Enter") uiutils.check(lambda: password.focused) password.typeText("bar")
def testCLILeakDebug(self): # Just test this for code coverage self.app.open(keyfile="allstats.ini", extra_opts=["--test-options=leak-debug"]) self.sleep(2) # Give it a little time to work uiutils.check(lambda: self.app.topwin.active) self.app.topwin.keyCombo("<alt>F4")
def _add_conn(self, uri): manager = self.app.root manager.find("File", "menu").click() manager.find("Add Connection...", "menu item").click() win = manager.find_fuzzy("Add Connection", "dialog") win.combo_select("Hypervisor", "Custom URI") win.find("uri-entry", "text").set_text(uri) win.find("Connect", "push button").click() uiutils.check(lambda: win.showing is False)
def testCLINoFork(self): # Test app without forking self.app.open(first_run=False, enable_libguestfs=None, use_uri=False, no_fork=False) assert self.app.wait_for_exit() is True uiutils.check(lambda: self.app.topwin.showing) self.app.topwin.keyCombo("<alt>F4")
def _delete_vm(vmname): cell = manager.find(vmname, "table cell") cell.click() cell.click(button=3) menu = self.app.root.find("vm-action-menu") menu.find("Delete", "menu item").click() delete = self.app.root.find_fuzzy("Delete", "frame") delete.find("Delete associated", "check box").click() delete.find("Delete", "push button").click() uiutils.check(lambda: cell.dead) uiutils.check(lambda: manager.active)
def _select_hw(self, win, hwname, tabname): c = win.find(hwname, "table cell") if not c.onscreen: hwlist = win.find("hw-list") hwlist.click() while not c.onscreen: self.pressKey("Down") c.click() tab = win.find(tabname, None) uiutils.check(lambda: tab.showing) return tab
def testShowDelete(self): self.app.open(extra_opts=["--show-domain-delete", "test-clone"], window_name="Delete") # Ensure details opened too self.app.root.find("test-clone on", "frame", check_active=False) delete = self.app.topwin delete.find_fuzzy("Delete", "button").click() self._click_alert_button("Are you sure", "Yes") # Ensure app exits uiutils.check(lambda: not self.app.is_running())
def testDetailsRenameNVRAM(self): """ Rename a VM that will trigger the nvram behavior """ origname = "test-many-devices" # Shutdown the VM self.app.root.find_fuzzy(origname, "table cell").click() b = self.app.root.find("Shut Down", "push button") b.click() uiutils.check(lambda: b.sensitive is False) self._testRename(origname, "test-new-name")
def _run_remote(opts): newapp = uiutils.VMMDogtailApp("test:///default") newapp.open(check_already_running=False, extra_opts=opts) uiutils.check(lambda: not newapp.is_running()) import dogtail.tree vapps = [ a for a in dogtail.tree.root.applications() if a.name == "virt-manager" ] uiutils.check(lambda: len(vapps) == 1) # Ensure connection showed up self.app.topwin.find("test default", "table cell")
def testAbout(self): self.app.root.find("Help", "menu").click() self.app.root.find("About", "menu item").click() win = self.app.root.find_fuzzy("About", "dialog") l = win.find_fuzzy("Copyright", "label") curyear = datetime.datetime.today().strftime("%Y") if curyear not in l.text: print("Current year=%s not in about.ui dialog!" % curyear) win.keyCombo("<ESC>") uiutils.check(lambda: win.visible is False)