From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
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 [thread overview]
Message-ID: <20241204071911.664057-4-thuth@redhat.com> (raw)
In-Reply-To: <20241204071911.664057-1-thuth@redhat.com>
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
next prev parent reply other threads:[~2024-12-04 7:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 7:19 [PATCH for-10.0 0/5] tests/functional: Convert tests with find_free_ports() Thomas Huth
2024-12-04 7:19 ` [PATCH 1/5] tests/functional: Convert the vnc test Thomas Huth
2024-12-04 7:19 ` [PATCH 2/5] tests/functional: Extract the find_free_ports() function into a helper file Thomas Huth
2024-12-04 10:41 ` Daniel P. Berrangé
2024-12-06 15:53 ` Thomas Huth
2024-12-04 10:46 ` Daniel P. Berrangé
2024-12-06 15:56 ` Thomas Huth
2024-12-04 7:19 ` Thomas Huth [this message]
2024-12-04 7:19 ` [PATCH 4/5] tests/functional/test_vnc: Remove the test_no_vnc test Thomas Huth
2024-12-04 10:42 ` Daniel P. Berrangé
2024-12-04 7:19 ` [PATCH 5/5] tests/functional: Convert the migration avocado test Thomas Huth
2024-12-04 8:27 ` Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241204071911.664057-4-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=berrange@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).