diff options
author | Cole Robinson <crobinso@redhat.com> | 2019-06-05 13:19:44 -0400 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2019-06-05 16:28:05 -0400 |
commit | d2462367ee84cba0f5a7cded8931b287b7842533 (patch) | |
tree | b30b710d9b7dcb0ba7896c2a84cbb097bb6850a9 /virtManager/connection.py | |
parent | d65f54dc9d2052a5d6eaeca31297ee235c2777e9 (diff) | |
download | virt-manager-d2462367ee84cba0f5a7cded8931b287b7842533.tar.gz |
virt-manager: Add --test-options
Will take a string of comma separated options which we can use to
tweak app behavior, for testing. Convert the existing --test-* options
to use the same abstraction internally. This will make it easier to
add new test options in the future
Diffstat (limited to 'virtManager/connection.py')
-rw-r--r-- | virtManager/connection.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/virtManager/connection.py b/virtManager/connection.py index 1ab434ff..e86e458f 100644 --- a/virtManager/connection.py +++ b/virtManager/connection.py @@ -27,11 +27,6 @@ from .statsmanager import vmmStatsManager from .storagepool import vmmStoragePool -# debugging helper to turn off events -# Can be enabled with virt-manager --test-no-events -FORCE_DISABLE_EVENTS = False - - class _ObjectList(vmmGObject): """ Class that wraps our internal list of libvirt objects @@ -819,9 +814,12 @@ class vmmConnection(vmmGObject): self._backend.SUPPORT_CONN_WORKING_XEN_EVENTS): return + def _check_events_disabled(): + if self.config.CLITestOptions.no_events: + raise RuntimeError("events disabled via cli") + try: - if FORCE_DISABLE_EVENTS: - raise RuntimeError("FORCE_DISABLE_EVENTS = True") + _check_events_disabled() self._domain_cb_ids.append( self.get_backend().domainEventRegisterAny( @@ -855,8 +853,7 @@ class vmmConnection(vmmGObject): self._domain_agent_lifecycle_event) try: - if FORCE_DISABLE_EVENTS: - raise RuntimeError("FORCE_DISABLE_EVENTS = True") + _check_events_disabled() eventid = getattr(libvirt, "VIR_NETWORK_EVENT_ID_LIFECYCLE", 0) self._network_cb_ids.append( @@ -869,8 +866,7 @@ class vmmConnection(vmmGObject): logging.debug("Error registering network events: %s", e) try: - if FORCE_DISABLE_EVENTS: - raise RuntimeError("FORCE_DISABLE_EVENTS = True") + _check_events_disabled() eventid = getattr(libvirt, "VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE", 0) @@ -889,8 +885,7 @@ class vmmConnection(vmmGObject): logging.debug("Error registering storage pool events: %s", e) try: - if FORCE_DISABLE_EVENTS: - raise RuntimeError("FORCE_DISABLE_EVENTS = True") + _check_events_disabled() eventid = getattr(libvirt, "VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE", 0) updateid = getattr(libvirt, "VIR_NODE_DEVICE_EVENT_ID_UPDATE", 1) @@ -956,7 +951,7 @@ class vmmConnection(vmmGObject): self._objects = _ObjectList() closeret = self._backend.close() - if closeret == 1 and self.config.test_leak_debug: + if closeret == 1 and self.config.CLITestOptions.leak_debug: logging.debug("LEAK: conn close() returned 1, " "meaning refs may have leaked.") |