virt-manager/tests/uitests/test_createvol.py

158 lines
5.1 KiB
Python

# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
from . import lib
#####################################
# UI tests for the createvol wizard #
#####################################
def _open_createvol(app, hostwin):
hostwin.find("vol-new", "push button").click()
win = app.find_window("Add a Storage Volume")
lib.utils.check(lambda: win.active)
return win
def testCreateVolDefault(app):
"""
Create default volume, clean it up
"""
hostwin = app.manager_open_host("Storage")
poolcell = hostwin.find("default-pool", "table cell")
poolcell.click()
vollist = hostwin.find("vol-list", "table")
win = _open_createvol(app, hostwin)
finish = win.find("Finish", "push button")
name = win.find("Name:", "text")
# Create a default qcow2 volume
lib.utils.check(lambda: name.text == "vol")
newname = "a-newvol"
name.set_text(newname)
win.find("Max Capacity:", "spin button").set_text("10.5")
finish.click()
# Delete it, clicking 'No' first
volcell = vollist.find(newname + ".qcow2")
volcell.click()
hostwin.find("vol-refresh", "push button").click()
hostwin.find("vol-delete", "push button").click()
app.click_alert_button("permanently delete the volume", "No")
volcell = vollist.find(newname + ".qcow2")
hostwin.find("vol-delete", "push button").click()
app.click_alert_button("permanently delete the volume", "Yes")
lib.utils.check(lambda: volcell.dead)
# Ensure host window closes fine
hostwin.keyCombo("<ctrl>w")
lib.utils.check(lambda: not hostwin.showing and
not hostwin.active)
def testCreateVolMisc(app):
"""
Cover all createvol options
"""
hostwin = app.manager_open_host("Storage")
poolcell = hostwin.find("default-pool", "table cell")
poolcell.click()
win = _open_createvol(app, hostwin)
name = win.find("Name:", "text")
finish = win.find("Finish", "push button")
vollist = hostwin.find("vol-list", "table")
# Create a qcow2 with backing file
newname = "aaa-qcow2-backing.qcow2"
name.set_text(newname)
win.combo_select("Format:", "qcow2")
win.find("Backing store").click_expander()
win.find("Browse...").click()
browsewin = app.root.find("vmm-storage-browser")
# Test cancel button
browsewin.find("Cancel", "push button").click()
lib.utils.check(lambda: not browsewin.active)
win.find("Browse...").click()
browsewin = app.root.find("vmm-storage-browser")
# Test browse local opening
browsewin.find("Browse Local", "push button").click()
chooser = app.root.find(
"Locate existing storage", "file chooser")
chooser.keyCombo("<alt>F4")
app.select_storagebrowser_volume(
"default-pool", "bochs-vol", doubleclick=True)
backingstore = win.find("backing-store")
lib.utils.check(lambda: "bochs-vol" in backingstore.text)
finish.click()
vollist.find(newname)
# Create a raw volume with some size tweaking
win = _open_createvol(app, hostwin)
# Using previous name so we collide
name.set_text(newname)
win.combo_select("Format:", "raw")
cap = win.find("Max Capacity:", "spin button")
alloc = win.find("Allocation:", "spin button")
alloc.set_text("50.0")
alloc.click()
app.rawinput.pressKey("Enter")
lib.utils.check(lambda: cap.text == "50.0")
cap.set_text("1.0")
cap.click()
app.rawinput.pressKey("Enter")
lib.utils.check(lambda: alloc.text == "1.0")
alloc.set_text("0.5")
alloc.click()
app.rawinput.pressKey("Enter")
lib.utils.check(lambda: cap.text == "1.0")
finish.click()
app.click_alert_button("Error validating volume", "Close")
newname = "a-newvol.raw"
name.set_text(newname)
finish.click()
vollist.find(newname)
# Create LVM backing store
hostwin.find("disk-pool", "table cell").click()
win = _open_createvol(app, hostwin)
newname = "aaa-lvm"
name.set_text(newname)
win.find("Backing store").click_expander()
win.find("Browse...").click()
app.select_storagebrowser_volume("disk-pool", "diskvol7")
finish.click()
vollist.find(newname)
def testCreateVolXMLEditor(app):
app.open(xmleditor_enabled=True)
hostwin = app.manager_open_host("Storage")
poolcell = hostwin.find("default-pool", "table cell")
poolcell.click()
win = _open_createvol(app, 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()
lib.utils.check(lambda: hostwin.active)
vollist.find(newname)
# Do standard xmleditor tests
win = _open_createvol(app, hostwin)
lib.utils.test_xmleditor_interactions(app, win, finish)
win.find("Cancel", "push button").click()
lib.utils.check(lambda: not win.visible)