[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/5] tests/functional/test_vnc: Do not use a hard-coded VNC port
From: |
Thomas Huth |
Subject: |
[PATCH 3/5] tests/functional/test_vnc: Do not use a hard-coded VNC port |
Date: |
Wed, 4 Dec 2024 08:19:09 +0100 |
Two tests here are using the hard-coded VNC port :0 ... if there
is already a QEMU or other program running that is using this
port, the tests will be failing. Let's better detect a free port
for these tests and use that one instead.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/functional/test_vnc.py | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/tests/functional/test_vnc.py b/tests/functional/test_vnc.py
index 32a81259e4..59c790b1ce 100755
--- a/tests/functional/test_vnc.py
+++ b/tests/functional/test_vnc.py
@@ -46,8 +46,8 @@ def test_no_vnc_change_password(self):
self.assertEqual(set_password_response['error']['desc'],
'Could not set password')
- def test_change_password_requires_a_password(self):
- self.vm.add_args('-nodefaults', '-S', '-vnc', ':0')
+ def do_test_change_password_requires_a_password(self, port):
+ self.vm.add_args('-nodefaults', '-S', '-vnc', f':{port - 5900}')
self.vm.launch()
self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled'])
set_password_response = self.vm.qmp('change-vnc-password',
@@ -58,13 +58,24 @@ def test_change_password_requires_a_password(self):
self.assertEqual(set_password_response['error']['desc'],
'Could not set password')
- def test_change_password(self):
- self.vm.add_args('-nodefaults', '-S', '-vnc', ':0,password=on')
+ def test_change_password_requires_a_password(self):
+ with Ports() as ports:
+ port = ports.find_free_port()
+ self.do_test_change_password_requires_a_password(port)
+
+ def do_test_change_password(self, port):
+ self.vm.add_args('-nodefaults', '-S',
+ '-vnc', f':{port - 5900},password=on')
self.vm.launch()
self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled'])
self.vm.cmd('change-vnc-password',
password='new_password')
+ def test_change_password(self):
+ with Ports() as ports:
+ port = ports.find_free_port()
+ self.do_test_change_password(port)
+
def do_test_change_listen(self, a, b, c):
self.assertFalse(check_connect(a))
self.assertFalse(check_connect(b))
--
2.47.0