From patchwork Fri Jun 7 15:22:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cleber Rosa X-Patchwork-Id: 10982369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C921213AD for ; Fri, 7 Jun 2019 16:29:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B780026222 for ; Fri, 7 Jun 2019 16:29:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB366289EB; Fri, 7 Jun 2019 16:29:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96F6726222 for ; Fri, 7 Jun 2019 16:29:20 +0000 (UTC) Received: from localhost ([::1]:49386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZHjz-0007bc-PI for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 12:29:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48818) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZGht-00057j-UN for qemu-devel@nongnu.org; Fri, 07 Jun 2019 11:23:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZGhs-0006Fv-FZ for qemu-devel@nongnu.org; Fri, 07 Jun 2019 11:23:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34488) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hZGhq-0006BS-FX for qemu-devel@nongnu.org; Fri, 07 Jun 2019 11:23:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7104830F1BA9; Fri, 7 Jun 2019 15:22:56 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-122-62.rdu2.redhat.com [10.10.122.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7A71842A8; Fri, 7 Jun 2019 15:22:50 +0000 (UTC) From: Cleber Rosa To: qemu-devel@nongnu.org Date: Fri, 7 Jun 2019 11:22:20 -0400 Message-Id: <20190607152223.9467-6-crosa@redhat.com> In-Reply-To: <20190607152223.9467-1-crosa@redhat.com> References: <20190607152223.9467-1-crosa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 07 Jun 2019 15:23:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 5/8] VNC Acceptance test: use UNIX domain sockets to avoid port collisions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Cleber Rosa , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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)