uitests: add connection object blacklist testing
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
a10d746c41
commit
29f866e6f3
|
@ -0,0 +1,40 @@
|
|||
# This work is licensed under the GNU GPLv2 or later.
|
||||
# See the COPYING file in the top-level directory.
|
||||
|
||||
from tests.uitests import utils as uiutils
|
||||
|
||||
|
||||
class UITestConnection(uiutils.UITestCase):
|
||||
"""
|
||||
UI tests for various connection.py related bits
|
||||
"""
|
||||
|
||||
##############
|
||||
# Test cases #
|
||||
##############
|
||||
|
||||
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())
|
|
@ -55,9 +55,8 @@ class _ObjectList(vmmGObject):
|
|||
:returns: number of added object to list
|
||||
"""
|
||||
key = self._blacklist_key(obj)
|
||||
if self.in_blacklist(obj):
|
||||
self._blacklist[key] += 1
|
||||
self._blacklist[key] = 1
|
||||
count = self._blacklist.get(key, 0)
|
||||
self._blacklist[key] = count + 1
|
||||
return self._blacklist[key]
|
||||
|
||||
def remove_blacklist(self, obj):
|
||||
|
@ -65,7 +64,8 @@ class _ObjectList(vmmGObject):
|
|||
:param obj: vmmLibvirtObject to remove from blacklist
|
||||
:returns: True if object was blacklisted or False otherwise.
|
||||
"""
|
||||
return bool(self._blacklist.pop(self._blacklist_key(obj), 0))
|
||||
key = self._blacklist_key(obj)
|
||||
return bool(self._blacklist.pop(key, 0))
|
||||
|
||||
def in_blacklist(self, obj):
|
||||
"""
|
||||
|
@ -75,7 +75,8 @@ class _ObjectList(vmmGObject):
|
|||
:param obj: vmmLibvirtObject to check
|
||||
:returns: True if object is blacklisted
|
||||
"""
|
||||
return self._blacklist.get(self._blacklist_key(obj), 0) > _ObjectList.BLACKLIST_COUNT
|
||||
key = self._blacklist_key(obj)
|
||||
return self._blacklist.get(key, 0) >= _ObjectList.BLACKLIST_COUNT
|
||||
|
||||
def remove(self, obj):
|
||||
"""
|
||||
|
@ -1042,14 +1043,10 @@ class vmmConnection(vmmGObject):
|
|||
if initialize_failed:
|
||||
log.debug("Blacklisting %s=%s", class_name, obj.get_name())
|
||||
count = self._objects.add_blacklist(obj)
|
||||
if count <= _ObjectList.BLACKLIST_COUNT:
|
||||
log.debug("Object added in blacklist, count=%d", count)
|
||||
else:
|
||||
log.debug("Object already blacklisted?")
|
||||
log.debug("Object added in blacklist, count=%d", count)
|
||||
return
|
||||
else:
|
||||
self._objects.remove_blacklist(obj)
|
||||
|
||||
self._objects.remove_blacklist(obj)
|
||||
if not self._objects.add(obj):
|
||||
log.debug("New %s=%s requested, but it's already tracked.",
|
||||
class_name, obj.get_name())
|
||||
|
|
|
@ -113,6 +113,10 @@ class CLITestOptionsClass:
|
|||
Spice doesn't return values here when we are just testing
|
||||
against seabios in uitests, this fakes it to hit more code paths
|
||||
* fake-systray: Enable the fake systray window
|
||||
* object-blacklist=NAME: Make object initialize for that name
|
||||
fail to test some connection code paths
|
||||
* conn-crash: Test connection abruptly closing like when
|
||||
libvirtd is restarted.
|
||||
"""
|
||||
def __init__(self, test_options_str):
|
||||
optset = set()
|
||||
|
@ -151,6 +155,8 @@ class CLITestOptionsClass:
|
|||
self.fake_vnc_username = _get("fake-vnc-username")
|
||||
self.fake_console_resolution = _get("fake-console-resolution")
|
||||
self.fake_systray = _get("fake-systray")
|
||||
self.object_blacklist = _get_value("object-blacklist")
|
||||
self.conn_crash = _get("conn-crash")
|
||||
|
||||
if optset: # pragma: no cover
|
||||
raise RuntimeError("Unknown --test-options keys: %s" % optset)
|
||||
|
|
|
@ -174,6 +174,9 @@ class vmmLibvirtObject(vmmGObject):
|
|||
|
||||
initialize_failed = False
|
||||
try:
|
||||
if self.config.CLITestOptions.object_blacklist == self._name:
|
||||
raise RuntimeError("fake initialization error")
|
||||
|
||||
self._init_libvirt_state()
|
||||
except Exception: # pragma: no cover
|
||||
log.debug("Error initializing libvirt state for %s", self,
|
||||
|
|
Loading…
Reference in New Issue