mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
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.
This commit is contained in:
parent
38ff195a27
commit
ade47c08af
2 changed files with 8 additions and 2 deletions
|
|
@ -47,12 +47,12 @@ class LiveSerialConsoleTestCase(TransactionTestCase):
|
||||||
self.server, self.port = start_socketiod(self)
|
self.server, self.port = start_socketiod(self)
|
||||||
|
|
||||||
def token(self, host, login, password, conn_type):
|
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)
|
conn = connection_manager.get_connection(host, login, password, conn_type)
|
||||||
before = livetest.inventory(conn)
|
before = livetest.inventory(conn)
|
||||||
self.addCleanup(lambda: self.assertEqual(livetest.inventory(conn), before))
|
self.addCleanup(lambda: self.assertEqual(livetest.inventory(conn), before))
|
||||||
self.addCleanup(livetest.cleanup, conn)
|
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())
|
vm = Instance.objects.create(compute=compute, name=dom.name(), uuid=dom.UUIDString())
|
||||||
UserInstance.objects.create(user=self.user, instance=vm)
|
UserInstance.objects.create(user=self.user, instance=vm)
|
||||||
return tokens.SIGNER.sign(f"{compute.id}:{vm.uuid}:{self.user.id}"), dom
|
return tokens.SIGNER.sign(f"{compute.id}:{vm.uuid}:{self.user.id}"), dom
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,11 @@ class ShutOffMigrationTestCase(unittest.TestCase):
|
||||||
"""libvirt's offline migration fails on some builds (RHEL-156800); a
|
"""libvirt's offline migration fails on some builds (RHEL-156800); a
|
||||||
shut-off VM is only its definition, so the app moves that itself."""
|
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):
|
def test_the_definition_moves_to_the_destination(self):
|
||||||
host = FakeHost()
|
host = FakeHost()
|
||||||
source = FakeSource(5, xml="<domain><name>vm</name></domain>")
|
source = FakeSource(5, xml="<domain><name>vm</name></domain>")
|
||||||
|
|
@ -434,6 +439,7 @@ class NvramCopyTestCase(unittest.TestCase):
|
||||||
PATH = "/var/lib/libvirt/qemu/nvram/vm_VARS.fd"
|
PATH = "/var/lib/libvirt/qemu/nvram/vm_VARS.fd"
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
libvirt.virResetLastError() # see ShutOffMigrationTestCase.setUp
|
||||||
self.source = FakeSource(5, nvram=self.PATH, xml="<domain><name>vm</name></domain>")
|
self.source = FakeSource(5, nvram=self.PATH, xml="<domain><name>vm</name></domain>")
|
||||||
self.source.wvm = mock.MagicMock()
|
self.source.wvm = mock.MagicMock()
|
||||||
self.source.wvm.newStream.return_value.recvAll.side_effect = lambda fn, out: fn(None, b"vars", out)
|
self.source.wvm.newStream.return_value.recvAll.side_effect = lambda fn, out: fn(None, b"vars", out)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue