mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-11 05:17:59 +03:00
uitests: Mock virtBootstrap
It's historically flakey to keep it + skopeo + virt-sandbox all working, let's just mock it Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
92c0c4e1a7
commit
4f02ccd7b5
@ -876,11 +876,8 @@ def testNewVMContainerVZ(app):
|
||||
|
||||
|
||||
def testNewVMContainerBootstrap(app):
|
||||
app.uri = tests.utils.URIs.lxc
|
||||
try:
|
||||
import virtBootstrap # pylint: disable=unused-import
|
||||
except ImportError:
|
||||
pytest.skip("virtBootstrap not installed")
|
||||
app.open(uri=tests.utils.URIs.lxc,
|
||||
extra_opts=["--test-options=fake-virtbootstrap"])
|
||||
|
||||
newvm = _open_newvm(app)
|
||||
newvm.find_fuzzy("Operating system", "radio").click()
|
||||
|
@ -78,8 +78,9 @@ def _pretty_memory(mem):
|
||||
# Helpers for tracking devices we create from this wizard #
|
||||
###########################################################
|
||||
|
||||
def is_virt_bootstrap_installed():
|
||||
return pkgutil.find_loader('virtBootstrap') is not None
|
||||
def is_virt_bootstrap_installed(conn):
|
||||
ret = pkgutil.find_loader('virtBootstrap') is not None
|
||||
return ret or conn.config.CLITestOptions.fake_virtbootstrap
|
||||
|
||||
|
||||
class _GuestData:
|
||||
@ -623,7 +624,7 @@ class vmmCreateVM(vmmGObjectUI):
|
||||
# Allow container bootstrap only for local connection and
|
||||
# only if virt-bootstrap is installed. Otherwise, show message.
|
||||
is_local = not self.conn.is_remote()
|
||||
vb_installed = is_virt_bootstrap_installed()
|
||||
vb_installed = is_virt_bootstrap_installed(self.conn)
|
||||
vb_enabled = is_local and vb_installed
|
||||
|
||||
oscontainer_widget_conf = {
|
||||
@ -2077,7 +2078,11 @@ class vmmCreateVM(vmmGObjectUI):
|
||||
as state/details.
|
||||
"""
|
||||
import logging
|
||||
import virtBootstrap
|
||||
|
||||
if self.conn.config.CLITestOptions.fake_virtbootstrap:
|
||||
from .lib.testmock import fakeVirtBootstrap as virtBootstrap
|
||||
else: # pragma: no cover
|
||||
import virtBootstrap # pylint: disable=import-error
|
||||
|
||||
meter.start(_("Bootstraping container"), None)
|
||||
def progress_update_cb(prog):
|
||||
|
@ -106,6 +106,14 @@ def fake_openauth(conn, cb, data):
|
||||
assert all([bool(cred[4]) for cred in creds])
|
||||
|
||||
|
||||
class fakeVirtBootstrap:
|
||||
def bootstrap(**kwargs):
|
||||
import time
|
||||
time.sleep(1)
|
||||
if "username" in kwargs:
|
||||
raise RuntimeError("fakeVirtBootstrap mock auth failure!")
|
||||
|
||||
|
||||
class CLITestOptionsClass:
|
||||
"""
|
||||
Helper class for parsing and tracking --test-* options.
|
||||
@ -157,6 +165,8 @@ 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
|
||||
* fake-virtbootstrap: Mock the virtBootstrap module, since getting
|
||||
it to actually work across fedora versions is hard
|
||||
* object-denylist=NAME: Make object initialize for that name
|
||||
fail to test some connection code paths
|
||||
* conn-crash: Test connection abruptly closing like when
|
||||
@ -214,6 +224,7 @@ class CLITestOptionsClass:
|
||||
self.fake_openauth = _get("fake-openauth")
|
||||
self.fake_session_error = _get("fake-session-error")
|
||||
self.short_poll = _get("short-poll")
|
||||
self.fake_virtbootstrap = _get("fake-virtbootstrap")
|
||||
|
||||
if optset: # pragma: no cover
|
||||
raise RuntimeError("Unknown --test-options keys: %s" % optset)
|
||||
|
Loading…
Reference in New Issue
Block a user