From ade47c08af18209e8c2b6825db665c6daee406a2 Mon Sep 17 00:00:00 2001 From: catborise Date: Sun, 18 Oct 2026 11:21:06 +0300 Subject: [PATCH] test: live tests with one host for TCP and SSH, and order-independent migration fakes The serial console test names its compute and VM per connection type, so the TCP and SSH host can be the same machine. The shut-off migration fakes reset libvirt's last error first: a libvirtError takes the message of an earlier real error in the thread, which a live test can leave. --- console/tests/test_live_serial.py | 4 ++-- vrtManager/tests/test_migration.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/console/tests/test_live_serial.py b/console/tests/test_live_serial.py index 728fbdac..aafd6adf 100644 --- a/console/tests/test_live_serial.py +++ b/console/tests/test_live_serial.py @@ -47,12 +47,12 @@ class LiveSerialConsoleTestCase(TransactionTestCase): self.server, self.port = start_socketiod(self) def token(self, host, login, password, conn_type): - compute = Compute.objects.create(name=P + host, hostname=host, login=login, password=password, type=conn_type) + compute = Compute.objects.create(name=f"{P}{host}-{conn_type}", hostname=host, login=login, password=password, type=conn_type) conn = connection_manager.get_connection(host, login, password, conn_type) before = livetest.inventory(conn) self.addCleanup(lambda: self.assertEqual(livetest.inventory(conn), before)) self.addCleanup(livetest.cleanup, conn) - dom = serial_vm(conn, P + "serial") + dom = serial_vm(conn, f"{P}serial-{conn_type}") vm = Instance.objects.create(compute=compute, name=dom.name(), uuid=dom.UUIDString()) UserInstance.objects.create(user=self.user, instance=vm) return tokens.SIGNER.sign(f"{compute.id}:{vm.uuid}:{self.user.id}"), dom diff --git a/vrtManager/tests/test_migration.py b/vrtManager/tests/test_migration.py index 194dbc7c..61bb949e 100644 --- a/vrtManager/tests/test_migration.py +++ b/vrtManager/tests/test_migration.py @@ -209,6 +209,11 @@ class ShutOffMigrationTestCase(unittest.TestCase): """libvirt's offline migration fails on some builds (RHEL-156800); a shut-off VM is only its definition, so the app moves that itself.""" + def setUp(self): + # a libvirtError built here takes the message of an earlier real error + # in this thread (an earlier live test) instead of its own + libvirt.virResetLastError() + def test_the_definition_moves_to_the_destination(self): host = FakeHost() source = FakeSource(5, xml="vm") @@ -434,6 +439,7 @@ class NvramCopyTestCase(unittest.TestCase): PATH = "/var/lib/libvirt/qemu/nvram/vm_VARS.fd" def setUp(self): + libvirt.virResetLastError() # see ShutOffMigrationTestCase.setUp self.source = FakeSource(5, nvram=self.PATH, xml="vm") self.source.wvm = mock.MagicMock() self.source.wvm.newStream.return_value.recvAll.side_effect = lambda fn, out: fn(None, b"vars", out)