qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cleber Rosa <crosa@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: [Qemu-devel] [PATCH 5/8] VNC Acceptance test: use UNIX domain sockets to avoid port collisions
Date: Fri,  7 Jun 2019 11:22:20 -0400	[thread overview]
Message-ID: <20190607152223.9467-6-crosa@redhat.com> (raw)
In-Reply-To: <20190607152223.9467-1-crosa@redhat.com>

While running in parallel, the VNC tests that use a TCP port easily
collide.  There's a number of possibilities to reduce the probability
of collisions, but none that completely prevents it from happening.

So, to avoid those collisions, and given that the scope of the tests
are really not related to nature of the socket type, let's switch to
UNIX domain sockets created in temporary directories.

Note: the amount of boiler plate code is far from the ideal, but it's
related to the fact that a test "workdir"[1] attribute can not be used
here, because of the 108 bytes limitation of the UNIX socket path (see
ad9579aaa16). There's a fair assumption here that the temporary
directory returned by Python's tempfile.mkdtemp() won't be anywhere
close to 100 bytes.

[1] https://avocado-framework.readthedocs.io/en/68.0/api/test/avocado.html#avocado.Test.workdir

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 tests/acceptance/vnc.py | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/tests/acceptance/vnc.py b/tests/acceptance/vnc.py
index 064ceabcc1..675fd507ed 100644
--- a/tests/acceptance/vnc.py
+++ b/tests/acceptance/vnc.py
@@ -8,6 +8,10 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later.  See the COPYING file in the top-level directory.
 
+import os
+import tempfile
+import shutil
+
 from avocado_qemu import Test
 
 
@@ -34,8 +38,16 @@ class Vnc(Test):
         self.assertEqual(set_password_response['error']['desc'],
                          'Could not set password')
 
+class VncUnixSocket(Test):
+
+    def setUp(self):
+        super(VncUnixSocket, self).setUp()
+        self.socket_dir = tempfile.mkdtemp()
+        self.socket_path = os.path.join(self.socket_dir, 'vnc-socket')
+
     def test_vnc_change_password_requires_a_password(self):
-        self.vm.add_args('-nodefaults', '-S', '-vnc', ':0')
+        self.vm.add_args('-nodefaults', '-S',
+                         '-vnc', 'unix:%s' % self.socket_path)
         self.vm.launch()
         self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled'])
         set_password_response = self.vm.qmp('change',
@@ -49,7 +61,8 @@ class Vnc(Test):
                          'Could not set password')
 
     def test_vnc_change_password(self):
-        self.vm.add_args('-nodefaults', '-S', '-vnc', ':0,password')
+        self.vm.add_args('-nodefaults', '-S',
+                         '-vnc', 'unix:%s,password' % self.socket_path)
         self.vm.launch()
         self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled'])
         set_password_response = self.vm.qmp('change',
@@ -57,3 +70,6 @@ class Vnc(Test):
                                             target='password',
                                             arg='new_password')
         self.assertEqual(set_password_response['return'], {})
+
+    def tearDown(self):
+        shutil.rmtree(self.socket_dir)
-- 
2.21.0



  parent reply	other threads:[~2019-06-07 16:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-07 15:22 [Qemu-devel] [PATCH 0/8] Miscellaneous acceptance test and Travis CI improvements Cleber Rosa
2019-06-07 15:22 ` [Qemu-devel] [PATCH 1/8] Travis: print acceptance tests logs in case of job failure Cleber Rosa
2019-06-10 19:46   ` Wainer dos Santos Moschetta
2019-06-14 14:14   ` Alex Bennée
2019-06-07 15:22 ` [Qemu-devel] [PATCH 2/8] tests/requirements.txt: pin paramiko version requirement Cleber Rosa
2019-06-10 19:47   ` Wainer dos Santos Moschetta
2019-06-14 14:17   ` Philippe Mathieu-Daudé
2019-06-07 15:22 ` [Qemu-devel] [PATCH 3/8] Acceptance tests: drop left over usage of ":avocado: enable" Cleber Rosa
2019-06-10 19:48   ` Wainer dos Santos Moschetta
2019-06-14 14:17   ` Philippe Mathieu-Daudé
2019-06-07 15:22 ` [Qemu-devel] [PATCH 4/8] Boot Linux Console Test: add a test for ppc64 + pseries Cleber Rosa
2019-06-10 20:02   ` Wainer dos Santos Moschetta
2019-06-07 15:22 ` Cleber Rosa [this message]
2019-06-10 20:27   ` [Qemu-devel] [PATCH 5/8] VNC Acceptance test: use UNIX domain sockets to avoid port collisions Wainer dos Santos Moschetta
2019-06-07 15:22 ` [Qemu-devel] [PATCH 6/8] VNC Acceptance test: simplify test names Cleber Rosa
2019-06-10 20:28   ` Wainer dos Santos Moschetta
2019-06-14 14:18   ` Philippe Mathieu-Daudé
2019-06-07 15:22 ` [Qemu-devel] [PATCH 7/8] VNC Acceptance test: check protocol version Cleber Rosa
2019-06-07 17:29   ` Daniel P. Berrangé
2019-06-07 18:12     ` Cleber Rosa
2019-06-10  8:58       ` Daniel P. Berrangé
2019-06-10 20:43   ` Wainer dos Santos Moschetta
2019-06-07 15:22 ` [Qemu-devel] [PATCH 8/8] Migration acceptance test: reduce the possibility of port collisions Cleber Rosa
2019-06-07 15:26 ` [Qemu-devel] [PATCH 0/8] Miscellaneous acceptance test and Travis CI improvements Cleber Rosa

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=20190607152223.9467-6-crosa@redhat.com \
    --to=crosa@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=ehabkost@redhat.com \
    --cc=fam@euphon.net \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wainersm@redhat.com \
    /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).