1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 11:16:47 +00:00

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.
This commit is contained in:
catborise 2026-10-24 00:24:21 +03:00
parent ab5ed59ea1
commit 0a37ca8b70
2 changed files with 9 additions and 3 deletions

View file

@ -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())

View file

@ -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)