summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2022-01-17 15:12:42 -0500
committerCole Robinson <crobinso@redhat.com>2022-01-17 15:13:12 -0500
commit4f02ccd7b5e61fea693ce6e6e2ffd1b1c2f23654 (patch)
treeab36116845d1743dc83b79d8139b6a44282c3240
parent92c0c4e1a7c1bcd7205f34f2ffdcc929ffd9ae3a (diff)
downloadvirt-manager-4f02ccd7b5e61fea693ce6e6e2ffd1b1c2f23654.tar.gz
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>
-rw-r--r--tests/uitests/test_createvm.py7
-rw-r--r--virtManager/createvm.py13
-rw-r--r--virtManager/lib/testmock.py11
3 files changed, 22 insertions, 9 deletions
diff --git a/tests/uitests/test_createvm.py b/tests/uitests/test_createvm.py
index 056ce1db..d51ccc32 100644
--- a/tests/uitests/test_createvm.py
+++ b/tests/uitests/test_createvm.py
@@ -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()
diff --git a/virtManager/createvm.py b/virtManager/createvm.py
index 7df8a759..d59818d6 100644
--- a/virtManager/createvm.py
+++ b/virtManager/createvm.py
@@ -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):
diff --git a/virtManager/lib/testmock.py b/virtManager/lib/testmock.py
index 843936d9..3234fcae 100644
--- a/virtManager/lib/testmock.py
+++ b/virtManager/lib/testmock.py
@@ -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)