From 0a37ca8b705cbdbf9705ab67ec883817dc49a6b7 Mon Sep 17 00:00:00 2001 From: catborise Date: Sat, 24 Oct 2026 00:24:21 +0300 Subject: [PATCH] test: the live suite passes on v3.1.0 again The live suite run against v3.1.0 on two Vagrant computes (TCP and SSH, TLS, a socket inside compute1) found two tests that no longer held, and nothing else: - A SATA disk added to a running VM is refused by libvirt; since 90c148d a refused form goes back to its page with the reason instead of a 500. The test expected the 500; it now expects the redirect and the message, and still checks that neither definition changed. - The NVRAM copy test built its libvirtError("define failed") and matched that text, but libvirt-python gives a new libvirtError the message of the last error its thread recorded: in the socket run a connection of an earlier live test was closed by then ("client socket is closed"). The test now checks that its own error object is raised. --- instances/tests/test_live_dataloss.py | 4 +++- vrtManager/tests/test_migration.py | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/instances/tests/test_live_dataloss.py b/instances/tests/test_live_dataloss.py index 0079f278..eb8700e2 100644 --- a/instances/tests/test_live_dataloss.py +++ b/instances/tests/test_live_dataloss.py @@ -529,7 +529,9 @@ class LiveDataLossTestCase(TestCase): before = (self.disk_sources(dom), self.disk_sources(dom, libvirt.VIR_DOMAIN_XML_INACTIVE)) response = self.post("add_new_vol", inst, {"storage": livetest.POOL, "name": P + "sata-new", "format": "qcow2", "size": "1", "bus": "sata", "cache": "default"}) - self.assertEqual(response.status_code, 500) + # libvirt refuses it: the form goes back to the VM page with the reason + self.assertRedirects(response, reverse("instances:instance", args=[inst.id]), fetch_redirect_response=False) + self.assertTrue(any("libvirt Error" in str(m) for m in get_messages(response.wsgi_request))) self.assertEqual((self.disk_sources(dom), self.disk_sources(dom, libvirt.VIR_DOMAIN_XML_INACTIVE)), before) # the new volume stays in the pool: it is never deleted unasked self.assertIn(P + "sata-new.qcow2", self.conn.storagePoolLookupByName(livetest.POOL).listVolumes()) diff --git a/vrtManager/tests/test_migration.py b/vrtManager/tests/test_migration.py index 61bb949e..444053dc 100644 --- a/vrtManager/tests/test_migration.py +++ b/vrtManager/tests/test_migration.py @@ -472,8 +472,12 @@ class NvramCopyTestCase(unittest.TestCase): self.shared.start() def test_the_copy_is_deleted_when_the_definition_fails(self): - self.host.defineXML = mock.MagicMock(side_effect=libvirt.libvirtError("define failed")) - with self.assertRaisesRegex(libvirt.libvirtError, "define failed"): + # the raised error is this one: its message can be another libvirt + # error the thread recorded (a closed connection of an earlier live test) + error = libvirt.libvirtError("define failed") + self.host.defineXML = mock.MagicMock(side_effect=error) + with self.assertRaises(libvirt.libvirtError) as raised: self.move() + self.assertIs(raised.exception, error) self.dest_pool.storageVolLookupByName.assert_called_once_with("vm_VARS.fd") self.dest_pool.storageVolLookupByName.return_value.delete.assert_called_once_with(0)