mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-08 21:18:04 +03:00
tests: uitests: Add createvol.py coverage
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
0babd6b27f
commit
6f8c305d62
@ -21,47 +21,113 @@ class CreateVol(uiutils.UITestCase):
|
||||
# Test cases #
|
||||
##############
|
||||
|
||||
def testCreateVol(self):
|
||||
def testCreateVolDefault(self):
|
||||
"""
|
||||
Create default volume, clean it up
|
||||
"""
|
||||
hostwin = self._open_host_window("Storage")
|
||||
poolcell = hostwin.find("default-pool", "table cell")
|
||||
poolcell.click()
|
||||
vollist = hostwin.find("vol-list", "table")
|
||||
win = self._open_create_win(hostwin)
|
||||
|
||||
# Create a default qcow2 volume
|
||||
finish = win.find("Finish", "push button")
|
||||
name = win.find("Name:", "text")
|
||||
|
||||
# Create a default qcow2 volume
|
||||
self.assertEqual(name.text, "vol")
|
||||
newname = "a-newvol"
|
||||
name.text = newname
|
||||
win.find("Max Capacity:", "spin button").text = "10.5"
|
||||
finish.click()
|
||||
|
||||
# Delete it
|
||||
vollist = hostwin.find("vol-list", "table")
|
||||
# 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()
|
||||
self._click_alert_button("permanently delete the volume", "No")
|
||||
volcell = vollist.find(newname + ".qcow2")
|
||||
hostwin.find("vol-delete", "push button").click()
|
||||
self._click_alert_button("permanently delete the volume", "Yes")
|
||||
uiutils.check_in_loop(lambda: volcell.dead)
|
||||
|
||||
|
||||
# Create a raw volume too
|
||||
win = self._open_create_win(hostwin)
|
||||
newname = "a-newvol.raw"
|
||||
name.text = newname
|
||||
combo = win.find("Format:", "combo box")
|
||||
combo.click_combo_entry()
|
||||
combo.find("raw", "menu item").click()
|
||||
win.find("Allocation:", "spin button").text = "0.5"
|
||||
finish.click()
|
||||
vollist.find(newname)
|
||||
|
||||
# Ensure host window closes fine
|
||||
hostwin.keyCombo("<ctrl>w")
|
||||
uiutils.check_in_loop(lambda: not hostwin.showing and
|
||||
not hostwin.active)
|
||||
|
||||
def testCreateVolMisc(self):
|
||||
"""
|
||||
Cover all createvol options
|
||||
"""
|
||||
hostwin = self._open_host_window("Storage")
|
||||
poolcell = hostwin.find("default-pool", "table cell")
|
||||
poolcell.click()
|
||||
win = self._open_create_win(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.text = newname
|
||||
combo = win.find("Format:", "combo box")
|
||||
combo.click_combo_entry()
|
||||
combo.find("qcow2", "menu item").click()
|
||||
win.find("Backing store").click_expander()
|
||||
win.find("Browse...").click()
|
||||
browsewin = self.app.root.find(
|
||||
"Choose Storage Volume", "frame")
|
||||
browsewin.find_fuzzy("default-pool", "table cell").click()
|
||||
browsewin.find("bochs-vol", "table cell").doubleClick()
|
||||
uiutils.check_in_loop(lambda: not browsewin.active)
|
||||
assert "bochs-vol" in win.find("backing-store").text
|
||||
finish.click()
|
||||
vollist.find(newname)
|
||||
|
||||
# Create a raw volume with some size tweaking
|
||||
win = self._open_create_win(hostwin)
|
||||
# Using previous name so we collide
|
||||
name.text = newname
|
||||
combo = win.find("Format:", "combo box")
|
||||
combo.click_combo_entry()
|
||||
combo.find("raw", "menu item").click()
|
||||
cap = win.find("Max Capacity:", "spin button")
|
||||
alloc = win.find("Allocation:", "spin button")
|
||||
alloc.text = "50.0"
|
||||
alloc.click()
|
||||
self.pressKey("Enter")
|
||||
uiutils.check_in_loop(lambda: cap.text == "50.0")
|
||||
cap.text = "1.0"
|
||||
cap.click()
|
||||
self.pressKey("Enter")
|
||||
uiutils.check_in_loop(lambda: alloc.text == "1.0")
|
||||
alloc.text = "0.5"
|
||||
alloc.click()
|
||||
self.pressKey("Enter")
|
||||
assert cap.text == "1.0"
|
||||
|
||||
finish.click()
|
||||
self._click_alert_button("Error validating volume", "Close")
|
||||
newname = "a-newvol.raw"
|
||||
name.text = newname
|
||||
finish.click()
|
||||
vollist.find(newname)
|
||||
|
||||
# Create LVM backing store
|
||||
hostwin.find("disk-pool", "table cell").click()
|
||||
win = self._open_create_win(hostwin)
|
||||
newname = "aaa-lvm"
|
||||
name.text = newname
|
||||
win.find("Backing store").click_expander()
|
||||
win.find("Browse...").click()
|
||||
browsewin = self.app.root.find(
|
||||
"Choose Storage Volume", "frame")
|
||||
browsewin.find_fuzzy("disk-pool", "table cell").click()
|
||||
browsewin.find("diskvol7", "table cell").doubleClick()
|
||||
finish.click()
|
||||
vollist.find(newname)
|
||||
|
||||
|
||||
def testCreateVolXMLEditor(self):
|
||||
self.app.open(xmleditor_enabled=True)
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<!-- Generated with glade 3.36.0 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.22"/>
|
||||
<object class="GtkAdjustment" id="adjustment1">
|
||||
@ -29,9 +29,6 @@
|
||||
<property name="title" translatable="yes">Add a Storage Volume</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<signal name="delete-event" handler="on_vmm_create_vol_delete_event" swapped="no"/>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
@ -451,6 +448,11 @@
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<signal name="changed" handler="on_backing_store_changed" swapped="no"/>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="backing-store-atkobject">
|
||||
<property name="AtkObject::accessible-name">backing-store</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
@ -556,5 +558,8 @@
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
@ -58,7 +58,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||
def show(self, parent):
|
||||
try:
|
||||
parent_xml = self._parent_pool.xmlobj.get_xml()
|
||||
except Exception:
|
||||
except Exception: # pragma: no cover
|
||||
log.debug("Error getting parent_pool xml", exc_info=True)
|
||||
parent_xml = None
|
||||
|
||||
@ -97,8 +97,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||
def set_modal(self, modal):
|
||||
self.topwin.set_modal(bool(modal))
|
||||
|
||||
def set_parent_pool(self, conn, pool):
|
||||
self.conn = conn
|
||||
def set_parent_pool(self, pool):
|
||||
self._parent_pool = pool
|
||||
|
||||
|
||||
@ -171,7 +170,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||
hint, suffix=suffix)
|
||||
if ret and suffix:
|
||||
ret = ret.rsplit(".", 1)[0]
|
||||
except Exception:
|
||||
except Exception: # pragma: no cover
|
||||
log.exception("Error finding a default vol name")
|
||||
|
||||
return ret
|
||||
@ -215,11 +214,6 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||
self.widget("backing-expander"), self._can_backing())
|
||||
|
||||
def _browse_file(self):
|
||||
if (self._storage_browser and
|
||||
self._storage_browser.conn != self.conn):
|
||||
self._storage_browser.cleanup()
|
||||
self._storage_browser = None
|
||||
|
||||
if self._storage_browser is None:
|
||||
def cb(src, text):
|
||||
ignore = src
|
||||
@ -295,14 +289,14 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||
def _finish_cb(self, error, details, vol):
|
||||
self.reset_finish_cursor()
|
||||
|
||||
if error:
|
||||
if error: # pragma: no cover
|
||||
error = _("Error creating vol: %s") % error
|
||||
self._show_err(error, details=details)
|
||||
else:
|
||||
self._parent_pool.connect("refreshed",
|
||||
self._pool_refreshed_cb, vol.name)
|
||||
self.idle_add(self._parent_pool.refresh)
|
||||
self.close()
|
||||
return
|
||||
self._parent_pool.connect("refreshed",
|
||||
self._pool_refreshed_cb, vol.name)
|
||||
self.idle_add(self._parent_pool.refresh)
|
||||
self.close()
|
||||
|
||||
def _finish(self):
|
||||
vol = self._build_xmlobj(check_xmleditor=True)
|
||||
|
@ -546,7 +546,7 @@ class vmmHostStorage(vmmGObjectUI):
|
||||
self._addvol = vmmCreateVolume(self.conn, pool)
|
||||
self._addvol.connect("vol-created", self._vol_created_cb)
|
||||
else:
|
||||
self._addvol.set_parent_pool(self.conn, pool)
|
||||
self._addvol.set_parent_pool(pool)
|
||||
self._addvol.set_modal(self.topwin.get_modal())
|
||||
self._addvol.set_name_hint(self._name_hint)
|
||||
self._addvol.show(self.topwin)
|
||||
|
Loading…
Reference in New Issue
Block a user