uitests: Finish asyncjob.py coverage
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
cfd6d6ead4
commit
f74c061061
|
@ -161,6 +161,18 @@ class Manager(uiutils.UITestCase):
|
|||
self._click_alert_button("remove the saved state", "Yes")
|
||||
uiutils.check(lambda: not run.sensitive)
|
||||
|
||||
def testManagerVMRunFail(self):
|
||||
# Force VM startup to fail so we can test the error path
|
||||
self.app.open(extra_opts=["--test-options=test-vm-run-fail"])
|
||||
|
||||
manager = self.app.topwin
|
||||
|
||||
c = manager.find("test-clone-simple", "table cell")
|
||||
c.click()
|
||||
manager.find("Run", "push button").click()
|
||||
self._click_alert_button("fake error", "Close")
|
||||
|
||||
|
||||
def testManagerColumns(self):
|
||||
# Enable all stat options
|
||||
# Need to expand the window size so all columns are onscreen
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.20.0 -->
|
||||
<!-- Generated with glade 3.36.0 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.22"/>
|
||||
<object class="GtkWindow" id="vmm-progress">
|
||||
|
@ -14,7 +14,6 @@
|
|||
<property name="skip_taskbar_hint">True</property>
|
||||
<property name="urgency_hint">True</property>
|
||||
<property name="deletable">False</property>
|
||||
<signal name="delete-event" handler="on_async_job_delete_event" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkBox" id="vbox13">
|
||||
<property name="visible">True</property>
|
||||
|
@ -199,5 +198,8 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
@ -29,10 +29,7 @@ class vmmMeter(virtinst.progress.BaseMeter):
|
|||
|
||||
|
||||
def _do_start(self, now=None):
|
||||
if self.text is not None:
|
||||
text = self.text
|
||||
else:
|
||||
text = self.basename
|
||||
text = self.text or self.basename
|
||||
if self.size is None:
|
||||
out = " %5sB" % (0)
|
||||
self._vmm_pulse(out, text)
|
||||
|
@ -42,12 +39,9 @@ class vmmMeter(virtinst.progress.BaseMeter):
|
|||
self.started = True
|
||||
|
||||
def _do_update(self, amount_read, now=None):
|
||||
if self.text is not None:
|
||||
text = self.text
|
||||
else:
|
||||
text = self.basename
|
||||
text = self.text or self.basename
|
||||
fread = virtinst.progress.format_number(amount_read)
|
||||
if self.size is None:
|
||||
if self.size is None: # pragma: no cover
|
||||
out = " %5sB" % (fread)
|
||||
self._vmm_pulse(out, text)
|
||||
else:
|
||||
|
@ -56,10 +50,7 @@ class vmmMeter(virtinst.progress.BaseMeter):
|
|||
self._vmm_fraction(frac, out, text)
|
||||
|
||||
def _do_end(self, amount_read, now=None):
|
||||
if self.text is not None:
|
||||
text = self.text
|
||||
else:
|
||||
text = self.basename
|
||||
text = self.text or self.basename
|
||||
fread = virtinst.progress.format_number(amount_read)
|
||||
if self.size is None:
|
||||
out = " %5sB" % (fread)
|
||||
|
@ -78,7 +69,7 @@ def cb_wrapper(callback, asyncjob, *args, **kwargs):
|
|||
if (isinstance(e, libvirt.libvirtError) and
|
||||
asyncjob.can_cancel() and
|
||||
asyncjob.job_canceled):
|
||||
return
|
||||
return # pragma: no cover
|
||||
|
||||
asyncjob.set_error(str(e), "".join(traceback.format_exc()))
|
||||
|
||||
|
@ -180,7 +171,6 @@ class vmmAsyncJob(vmmGObjectUI):
|
|||
self._bg_thread.daemon = True
|
||||
|
||||
self.builder.connect_signals({
|
||||
"on_async_job_delete_event": self._on_window_delete,
|
||||
"on_async_job_cancel_clicked": self._on_cancel,
|
||||
})
|
||||
|
||||
|
@ -205,27 +195,22 @@ class vmmAsyncJob(vmmGObjectUI):
|
|||
# pbar idle callbacks and cancel routine which is invoked from the
|
||||
# main thread
|
||||
if self.job_canceled and not canceling:
|
||||
return
|
||||
return # pragma: no cover
|
||||
self.widget("pbar-stage").set_text(text)
|
||||
|
||||
def _hide_warning(self):
|
||||
self.widget("warning-box").hide()
|
||||
|
||||
|
||||
################
|
||||
# UI listeners #
|
||||
################
|
||||
|
||||
def _on_window_delete(self, ignore1=None, ignore2=None):
|
||||
return 1
|
||||
|
||||
def _on_cancel(self, ignore1=None, ignore2=None):
|
||||
if not self.cancel_cb or not self._bg_thread.is_alive():
|
||||
return
|
||||
return # pragma: no cover
|
||||
|
||||
self.cancel_cb(*self.cancel_args)
|
||||
if self.job_canceled:
|
||||
self._hide_warning()
|
||||
if self.job_canceled: # pragma: no cover
|
||||
self.widget("warning-box").hide()
|
||||
self._set_stage_text(_("Cancelling job..."), canceling=True)
|
||||
|
||||
|
||||
|
@ -300,14 +285,14 @@ class vmmAsyncJob(vmmGObjectUI):
|
|||
@idle_wrapper
|
||||
def _pbar_do_pulse(self):
|
||||
if not self.builder:
|
||||
return
|
||||
return # pragma: no cover
|
||||
self.widget("pbar").pulse()
|
||||
|
||||
@idle_wrapper
|
||||
def _pbar_pulse(self, progress="", stage=None):
|
||||
self._is_pulsing = True
|
||||
if not self.builder:
|
||||
return
|
||||
return # pragma: no cover
|
||||
self.widget("pbar").set_text(progress)
|
||||
self._set_stage_text(stage or _("Processing..."))
|
||||
|
||||
|
@ -315,21 +300,19 @@ class vmmAsyncJob(vmmGObjectUI):
|
|||
def _pbar_fraction(self, frac, progress, stage=None):
|
||||
self._is_pulsing = False
|
||||
if not self.builder:
|
||||
return
|
||||
return # pragma: no cover
|
||||
self._set_stage_text(stage or _("Processing..."))
|
||||
self.widget("pbar").set_text(progress)
|
||||
|
||||
if frac > 1:
|
||||
frac = 1.0
|
||||
if frac < 0:
|
||||
frac = 0
|
||||
frac = min(frac, 1)
|
||||
frac = max(frac, 0)
|
||||
self.widget("pbar").set_fraction(frac)
|
||||
|
||||
@idle_wrapper
|
||||
def _pbar_done(self, progress, stage=None):
|
||||
self._is_pulsing = False
|
||||
if not self.builder:
|
||||
return
|
||||
return # pragma: no cover
|
||||
self._set_stage_text(stage or _("Completed"))
|
||||
self.widget("pbar").set_text(progress)
|
||||
self.widget("pbar").set_fraction(1)
|
||||
|
|
|
@ -40,6 +40,8 @@ class CLITestOptionsClass:
|
|||
|
||||
* test-managed-save: Triggers a couple conditions for testing
|
||||
managed save issues
|
||||
|
||||
* test-vm-run-fail: Make VM run fail, so we can test the error path
|
||||
"""
|
||||
def __init__(self, test_options_str, test_first_run):
|
||||
optset = set()
|
||||
|
@ -72,6 +74,7 @@ class CLITestOptionsClass:
|
|||
self.break_setfacl = _get("break-setfacl")
|
||||
self.config_libguestfs = _get("config-libguestfs")
|
||||
self.test_managed_save = _get("test-managed-save")
|
||||
self.test_vm_run_fail = _get("test-vm-run-fail")
|
||||
|
||||
if optset: # pragma: no cover
|
||||
raise RuntimeError("Unknown --test-options keys: %s" % optset)
|
||||
|
|
|
@ -1319,7 +1319,8 @@ class vmmDomain(vmmLibvirtObject):
|
|||
@vmmLibvirtObject.lifecycle_action
|
||||
def startup(self):
|
||||
has_managed = self.has_managed_save()
|
||||
if has_managed and self.config.CLITestOptions.test_managed_save:
|
||||
if (self.config.CLITestOptions.test_vm_run_fail or
|
||||
(has_managed and self.config.CLITestOptions.test_managed_save)):
|
||||
raise RuntimeError("fake error for managed save")
|
||||
|
||||
self._backend.create()
|
||||
|
|
Loading…
Reference in New Issue