From nobody Thu Dec 18 17:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1733296814; cv=none; d=zohomail.com; s=zohoarc; b=IixUgcMwjEieg7kKyn5Kinh9xWzReMZR2ZgCISf3qpWHUeDm7fV5XjuPvLJtPZWAOaZHIZI+XYXPdy3/n1exIC68XfjfKl5J1KvGiRY8yCKLwkRP8aOdWRDLaGj2EQh944h+vIuvPe3nkDJJR6V88sM/qVUWMy/Ow/Bs18T+9Mk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733296814; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PGOrDdYWaOef4MfQEkI3GVDOqwz8+MMlsUiqjHR4ua0=; b=XpRaeWP9LVdQzsn2LtiriOEioz+vO2EfY6GgoQ8xo9NMzTeRIylBMAKLUiElg/H+KopE/GuQ2YwE3VcqEYQ8+1q9SqHTsWl+Tl5eD4OVhVNOoiRoPOdhNzXvp2H2JSATJJ/LWstWD32oDglhyHSF3U9l6+K5mlhIuh4qLIzmKc0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733296814605984.7465690554678; Tue, 3 Dec 2024 23:20:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIjfk-0006Zf-11; Wed, 04 Dec 2024 02:19:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIjfV-0006Si-Iu for qemu-devel@nongnu.org; Wed, 04 Dec 2024 02:19:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIjfU-0005Gs-39 for qemu-devel@nongnu.org; Wed, 04 Dec 2024 02:19:29 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-13-60-95wvhMVyjKU8Wr9B4VQ-1; Wed, 04 Dec 2024 02:19:19 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 14FAC1956095; Wed, 4 Dec 2024 07:19:18 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.192.155]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E978B1956060; Wed, 4 Dec 2024 07:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733296766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PGOrDdYWaOef4MfQEkI3GVDOqwz8+MMlsUiqjHR4ua0=; b=EZbx8n1z9HhWGckNuADJKYyZwqGNC6iZgrWSjzv6vSPDRiBzonaZOUCB88vSrxXKN0O1Vl oNigzS9VoQd6ohSFPcyaQrFOo0kueMsCKUrx9Am4ZLLfawD6+1pBv4jFAusrXavHDEkAD6 IOmPhlzsB4TxFvUGP2VKx5ToCRlHyWs= X-MC-Unique: 60-95wvhMVyjKU8Wr9B4VQ-1 X-Mimecast-MFC-AGG-ID: 60-95wvhMVyjKU8Wr9B4VQ From: Thomas Huth To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/5] tests/functional: Convert the vnc test Date: Wed, 4 Dec 2024 08:19:07 +0100 Message-ID: <20241204071911.664057-2-thuth@redhat.com> In-Reply-To: <20241204071911.664057-1-thuth@redhat.com> References: <20241204071911.664057-1-thuth@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.996, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1733296816098116600 Nothing thrilling in here, it's just a straight forward conversion. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Thomas Huth --- tests/functional/meson.build | 1 + tests/{avocado/vnc.py =3D> functional/test_vnc.py} | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) rename tests/{avocado/vnc.py =3D> functional/test_vnc.py} (97%) mode change 100644 =3D> 100755 diff --git a/tests/functional/meson.build b/tests/functional/meson.build index f50bf61a50..3d29b8245a 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -206,6 +206,7 @@ tests_x86_64_system_quick =3D [ 'pc_cpu_hotplug_props', 'virtio_version', 'x86_cpu_model_versions', + 'vnc', ] =20 tests_x86_64_system_thorough =3D [ diff --git a/tests/avocado/vnc.py b/tests/functional/test_vnc.py old mode 100644 new mode 100755 similarity index 97% rename from tests/avocado/vnc.py rename to tests/functional/test_vnc.py index 862c8996a8..b769d3b268 --- a/tests/avocado/vnc.py +++ b/tests/functional/test_vnc.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Simple functional tests for VNC functionality # # Copyright (c) 2018 Red Hat, Inc. @@ -11,7 +13,7 @@ import socket from typing import List =20 -from avocado_qemu import QemuSystemTest +from qemu_test import QemuSystemTest =20 =20 VNC_ADDR =3D '127.0.0.1' @@ -51,10 +53,7 @@ def find_free_ports(count: int) -> List[int]: =20 =20 class Vnc(QemuSystemTest): - """ - :avocado: tags=3Dvnc,quick - :avocado: tags=3Dmachine:none - """ + def test_no_vnc(self): self.vm.add_args('-nodefaults', '-S') self.vm.launch() @@ -113,3 +112,6 @@ def test_change_listen(self): self.assertFalse(check_connect(a)) self.assertTrue(check_connect(b)) self.assertTrue(check_connect(c)) + +if __name__ =3D=3D '__main__': + QemuSystemTest.main() --=20 2.47.0 From nobody Thu Dec 18 17:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1733296842; cv=none; d=zohomail.com; s=zohoarc; b=en43adLkpqJItCOe+43p5RlalEFds0NhiX7SiB+SpU/PeiHLT+XnuG9MABZWypQO0wFsHPgLIRm3G12ZcIkcNqRY+hSlDjRWuBr0iKrZMTcIEBeYJpqD0ZXHzLX0CVHd4YO95nHw9ZfeFBhbyIA6Ua+yN0Icxoq5LYjgBngE+1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733296842; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=g1uRF7EjvJkJnu1ajWbogr7mymnhMvyRYTvzFBcCrcs=; b=WqB8/8vq8hyjrBaFhn5WwsyQJ++49K2o5SQaIbOtV1+tcDnx4ctyV8w4fUMtVaG+zpyvFObz1nthQ0IY9AfOtzc/4yT30zt+iQOMi8j3SniQhZjC09+dz30YaUdrYd1T/uJERUbmEexqvuA64mAsxrACPpskqNvojDDEhi4Wgp0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733296842527365.99629633648715; Tue, 3 Dec 2024 23:20:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIjfe-0006XT-9r; Wed, 04 Dec 2024 02:19:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIjfS-0006RT-Sy for qemu-devel@nongnu.org; Wed, 04 Dec 2024 02:19:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIjfQ-0005GZ-Nk for qemu-devel@nongnu.org; Wed, 04 Dec 2024 02:19:26 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-377-ahhJYH1tPKKPZl5MqCTGOg-1; Wed, 04 Dec 2024 02:19:21 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7898A1956058; Wed, 4 Dec 2024 07:19:20 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.192.155]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C076C1956054; Wed, 4 Dec 2024 07:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733296763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g1uRF7EjvJkJnu1ajWbogr7mymnhMvyRYTvzFBcCrcs=; b=JW6xjaf2CY40L5zzTM71HRO6vOP6BrquyuQbP1wB/NniLORnNTftyDAkrbdz9OJtAlQl6x ebGebOnI3oRQJMlQASqbCRRG00LAAxH/CRj1WXeu4FTx3nK2AXnqv7qv39qA5lZJdzp2Jm zxZpbIGRMxg5I/cznKpIliwXm45OSq4= X-MC-Unique: ahhJYH1tPKKPZl5MqCTGOg-1 X-Mimecast-MFC-AGG-ID: ahhJYH1tPKKPZl5MqCTGOg From: Thomas Huth To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 2/5] tests/functional: Extract the find_free_ports() function into a helper file Date: Wed, 4 Dec 2024 08:19:08 +0100 Message-ID: <20241204071911.664057-3-thuth@redhat.com> In-Reply-To: <20241204071911.664057-1-thuth@redhat.com> References: <20241204071911.664057-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.996, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1733296844354116600 Content-Type: text/plain; charset="utf-8" We'll need this functionality in other functional tests, too, so let's extract it into the qemu_test module. Also add an __enter__ and __exit__ function that can be used for using this functionality in a locked context, so that tests that are running in parallel don't try to compete for the same ports later. Signed-off-by: Thomas Huth --- tests/functional/qemu_test/ports.py | 53 +++++++++++++++++++++++++++++ tests/functional/test_vnc.py | 36 +++++--------------- 2 files changed, 61 insertions(+), 28 deletions(-) create mode 100644 tests/functional/qemu_test/ports.py diff --git a/tests/functional/qemu_test/ports.py b/tests/functional/qemu_te= st/ports.py new file mode 100644 index 0000000000..d235d3432b --- /dev/null +++ b/tests/functional/qemu_test/ports.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +# +# Simple functional tests for VNC functionality +# +# Copyright 2018, 2024 Red Hat, Inc. +# +# 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 fcntl +import os +import socket +import sys +import tempfile +from typing import List + +class Ports(): + + PORTS_ADDR =3D '127.0.0.1' + PORTS_START =3D 32768 + PORTS_END =3D PORTS_START + 1024 + + def __enter__(self): + lock_file =3D os.path.join(tempfile.gettempdir(), "qemu_port_lock") + self.lock_fh =3D os.open(lock_file, os.O_CREAT) + fcntl.flock(self.lock_fh, fcntl.LOCK_EX) + return self + + def __exit__(self, exc_type, exc_value, traceback): + fcntl.flock(self.lock_fh, fcntl.LOCK_UN) + os.close(self.lock_fh) + + def check_bind(self, port: int) -> bool: + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: + try: + sock.bind((self.PORTS_ADDR, port)) + except OSError: + return False + + return True + + def find_free_ports(self, count: int) -> List[int]: + result =3D [] + for port in range(self.PORTS_START, self.PORTS_END): + if self.check_bind(port): + result.append(port) + if len(result) >=3D count: + break + assert len(result) =3D=3D count + return result + + def find_free_port(self) -> int: + return self.find_free_ports(1)[0] diff --git a/tests/functional/test_vnc.py b/tests/functional/test_vnc.py index b769d3b268..32a81259e4 100755 --- a/tests/functional/test_vnc.py +++ b/tests/functional/test_vnc.py @@ -14,22 +14,9 @@ from typing import List =20 from qemu_test import QemuSystemTest - +from qemu_test.ports import Ports =20 VNC_ADDR =3D '127.0.0.1' -VNC_PORT_START =3D 32768 -VNC_PORT_END =3D VNC_PORT_START + 1024 - - -def check_bind(port: int) -> bool: - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: - try: - sock.bind((VNC_ADDR, port)) - except OSError: - return False - - return True - =20 def check_connect(port: int) -> bool: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: @@ -40,18 +27,6 @@ def check_connect(port: int) -> bool: =20 return True =20 - -def find_free_ports(count: int) -> List[int]: - result =3D [] - for port in range(VNC_PORT_START, VNC_PORT_END): - if check_bind(port): - result.append(port) - if len(result) >=3D count: - break - assert len(result) =3D=3D count - return result - - class Vnc(QemuSystemTest): =20 def test_no_vnc(self): @@ -90,8 +65,7 @@ def test_change_password(self): self.vm.cmd('change-vnc-password', password=3D'new_password') =20 - def test_change_listen(self): - a, b, c =3D find_free_ports(3) + def do_test_change_listen(self, a, b, c): self.assertFalse(check_connect(a)) self.assertFalse(check_connect(b)) self.assertFalse(check_connect(c)) @@ -113,5 +87,11 @@ def test_change_listen(self): self.assertTrue(check_connect(b)) self.assertTrue(check_connect(c)) =20 + def test_change_listen(self): + with Ports() as ports: + a, b, c =3D ports.find_free_ports(3) + self.do_test_change_listen(a, b, c) + + if __name__ =3D=3D '__main__': QemuSystemTest.main() --=20 2.47.0 From nobody Thu Dec 18 17:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1733296867; cv=none; d=zohomail.com; s=zohoarc; b=R6Ubu0S9SSuvR61slOR0fwz+dkDXoFg9V0914kpKzrcQBOblXl9bUN3BYNOp2O8pqaNasOcku88IDj9/bNEvNefIzl0IRYi6F1XUU0aNrbVk4UnyqVj4KVPb4NgdJcvHPvxCVe1RDzzLwJbJE9gZTIvo5c50HcC/mX8Q7fFMi/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733296867; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DPc/TAIvpVYP9UaXsmRy/Dwk2j1lH5elMxHmRHmk/FQ=; b=c1SNLt47ST8TxF7Am4I/rxTD535amcptYslXpgUBdrJSj67yP9CbMpuptvR0R8gCCe2wr38XrCLTGwTLyDtSDTvZF1v2mWHWUnBw1p9AzEAQ/Vf3Lp2Lk2qYMklh46/HyivYOD2DrCCVGAv6BFQSyK84+doBeIdrRZA3PrHdLmg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173329686762363.835299011947086; Tue, 3 Dec 2024 23:21:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIjft-0006dI-4J; Wed, 04 Dec 2024 02:19:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIjfW-0006TJ-1l for qemu-devel@nongnu.org; Wed, 04 Dec 2024 02:19:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIjfU-0005H6-Ih for qemu-devel@nongnu.org; Wed, 04 Dec 2024 02:19:29 -0500 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-i4JJG92dNBOyGZnTiKZ37Q-1; Wed, 04 Dec 2024 02:19:26 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6795219560BD; Wed, 4 Dec 2024 07:19:23 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.192.155]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 563371956054; Wed, 4 Dec 2024 07:19:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733296767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DPc/TAIvpVYP9UaXsmRy/Dwk2j1lH5elMxHmRHmk/FQ=; b=IC96RA33UDb6X1quV/IKylNcjEyK9zY2FXuhsOfUvsYqcYvfTsxnKckWPglQma4eAM6xWA xfLNzx4o+ZNhWwegsYZDXBDDQXWoE3/D5BBVCByMsKQaZRWvfw4cgo7onZRV65I0xzqT/j CKyqYQGWdkscdhZ4cvM8YDdRJf/8UtM= X-MC-Unique: i4JJG92dNBOyGZnTiKZ37Q-1 X-Mimecast-MFC-AGG-ID: i4JJG92dNBOyGZnTiKZ37Q From: Thomas Huth To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Message-ID: <20241204071911.664057-4-thuth@redhat.com> In-Reply-To: <20241204071911.664057-1-thuth@redhat.com> References: <20241204071911.664057-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.996, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1733296868601116600 Content-Type: text/plain; charset="utf-8" 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 --- 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') =20 - 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 =3D 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') =20 - def test_change_password(self): - self.vm.add_args('-nodefaults', '-S', '-vnc', ':0,password=3Don') + def test_change_password_requires_a_password(self): + with Ports() as ports: + port =3D 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=3Don') self.vm.launch() self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled']) self.vm.cmd('change-vnc-password', password=3D'new_password') =20 + def test_change_password(self): + with Ports() as ports: + port =3D 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)) --=20 2.47.0 From nobody Thu Dec 18 17:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1733296874; cv=none; d=zohomail.com; s=zohoarc; b=g2kErbCMFIAMyXloqHidUvf0lwguF4g4bDmEa3I3xK9XliwzO3+POnRG0C+pu83iT2yLBrcgl5sCXO9Dax7LhakxicqRqANqdU+N/ETrP77CcNDbaN9t03mzpgEWPsHLZuMF16rmOtraI+NXp79x4IGPu6+KjMV3H/0VR2V2pSE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733296874; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=B54FAB3CP/bJZqXPMqPwx8hP05VEGeBqgY/lzGJ3b58=; b=PwW9Oz6xYXFP0uYYB6FpeiXCoA1O45XEoncg/hlpEfK6ZaeiBg37FKQRu24YQY2++h+20AAfD2jXRuXia1wb+40ffgfsDHUfjLpqQNTQvYsd14tqO5HjKexsYdjV9yhoqh+uIoKcln4kAJn7LRGDq4wU2sm/CAGP7Xbzkk7v9Vc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733296874036780.4272805609933; Tue, 3 Dec 2024 23:21:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIjfm-0006b4-2I; Wed, 04 Dec 2024 02:19:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIjfe-0006Y4-VG for qemu-devel@nongnu.org; Wed, 04 Dec 2024 02:19:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIjfc-0005IJ-KA for qemu-devel@nongnu.org; Wed, 04 Dec 2024 02:19:38 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-wvGXdlE7NOmIaEwqQHVpbQ-1; Wed, 04 Dec 2024 02:19:28 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 49D2619560A3; Wed, 4 Dec 2024 07:19:26 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.192.155]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E02531956054; Wed, 4 Dec 2024 07:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733296775; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B54FAB3CP/bJZqXPMqPwx8hP05VEGeBqgY/lzGJ3b58=; b=H73t3ZZanir+yGru6eavbbsy8hVygowRXGTQNKsWbPcqg7uUUav28vCNgnCSEOK9IUMIqC VpR2JzaIaeQVYDkEZ0CU6nps0lM60ExSAB3aEBotFnMm/MjVi0rPTgDNTOg/H+/b9SwNrG iibWCH2Xh9/pEyBdxi7zx8095HzZ8HM= X-MC-Unique: wvGXdlE7NOmIaEwqQHVpbQ-1 X-Mimecast-MFC-AGG-ID: wvGXdlE7NOmIaEwqQHVpbQ From: Thomas Huth To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 4/5] tests/functional/test_vnc: Remove the test_no_vnc test Date: Wed, 4 Dec 2024 08:19:10 +0100 Message-ID: <20241204071911.664057-5-thuth@redhat.com> In-Reply-To: <20241204071911.664057-1-thuth@redhat.com> References: <20241204071911.664057-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.996, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1733296876251116600 Content-Type: text/plain; charset="utf-8" This test matches exactly the first three lines of the following test_no_vnc_change_password test, so there is exactly zero additional test coverage in here. Signed-off-by: Thomas Huth Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/functional/test_vnc.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/functional/test_vnc.py b/tests/functional/test_vnc.py index 59c790b1ce..96267707ff 100755 --- a/tests/functional/test_vnc.py +++ b/tests/functional/test_vnc.py @@ -29,11 +29,6 @@ def check_connect(port: int) -> bool: =20 class Vnc(QemuSystemTest): =20 - def test_no_vnc(self): - self.vm.add_args('-nodefaults', '-S') - self.vm.launch() - self.assertFalse(self.vm.qmp('query-vnc')['return']['enabled']) - def test_no_vnc_change_password(self): self.vm.add_args('-nodefaults', '-S') self.vm.launch() --=20 2.47.0 From nobody Thu Dec 18 17:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1733296867; cv=none; d=zohomail.com; s=zohoarc; b=S5aPnie+v/K+LDha+FLh/ns0/JWfVgcuupPvBPuat1FtpxYkZ6gLKUqEmtboS6U39uJE5K2iwJLSZKTjnpvL8dcWZSlqlgwmozKizwK19pOyjj2HIGa/of73zmw1DXt9YkcCguNuYkSLmyLAgPTbTlRn+M9MXdEmJ8a8Ci4tmVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733296867; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ge4TGd+pIUVhg9BTGjgOHWXEMpXP8I6MCMpCMX9GCEg=; b=m9ZPyOUxOUCVdIREeCA+Bl5wTxav9JXvDldMQtk408tMlOVastX8b2KdAVCLd6yOSDbsv34BG/NX2c7fZK+5HHcH7JASm96Msc3RNmaeOipi2mrq2mvcRLtTqdDZgvSOPbl5DNk27JnsYIMlmNxE0uzV1uGiuQFwWNIUSOyjyCg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733296867097921.7819624458722; Tue, 3 Dec 2024 23:21:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIjfv-0006eI-P9; Wed, 04 Dec 2024 02:19:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIjfg-0006Ye-A9 for qemu-devel@nongnu.org; Wed, 04 Dec 2024 02:19:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIjfb-0005I5-HW for qemu-devel@nongnu.org; Wed, 04 Dec 2024 02:19:39 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-8-KKUHrXcQM4OY_ZS2cWfsnA-1; Wed, 04 Dec 2024 02:19:30 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 54D291956058; Wed, 4 Dec 2024 07:19:29 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.192.155]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F1C621956054; Wed, 4 Dec 2024 07:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733296773; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ge4TGd+pIUVhg9BTGjgOHWXEMpXP8I6MCMpCMX9GCEg=; b=cGNqlmCkfBcDFJ5xhZWFvWe28Hv3Ww3aFXFvFS/H9s5o7EuSJ5w4h42vkQDMoU9WOx61CL 99PmXe7kpe11Y3k0nvXn3BLlw/JzQgnFkTVNrpJdDZ8IOysxBZS49MlqYLD5iJtbUZtILA xF0c8xLYVqE/WEghzvheRrKkkW8Ptec= X-MC-Unique: KKUHrXcQM4OY_ZS2cWfsnA-1 X-Mimecast-MFC-AGG-ID: KKUHrXcQM4OY_ZS2cWfsnA From: Thomas Huth To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 5/5] tests/functional: Convert the migration avocado test Date: Wed, 4 Dec 2024 08:19:11 +0100 Message-ID: <20241204071911.664057-6-thuth@redhat.com> In-Reply-To: <20241204071911.664057-1-thuth@redhat.com> References: <20241204071911.664057-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.996, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1733296868457116600 Content-Type: text/plain; charset="utf-8" Now that we've got a find_free_port() function in the functional test framework, we can convert the migration test, too. While the original avocado test was only meant to run on aarch64, ppc64 and x86, we can turn this into a more generic test by now and run it on all architectures that have a default machine that ships with a working firmware. Signed-off-by: Thomas Huth --- tests/avocado/migration.py | 135 ----------------------------- tests/functional/meson.build | 19 ++++ tests/functional/test_migration.py | 83 ++++++++++++++++++ 3 files changed, 102 insertions(+), 135 deletions(-) delete mode 100644 tests/avocado/migration.py create mode 100755 tests/functional/test_migration.py diff --git a/tests/avocado/migration.py b/tests/avocado/migration.py deleted file mode 100644 index be6234b3c2..0000000000 --- a/tests/avocado/migration.py +++ /dev/null @@ -1,135 +0,0 @@ -# Migration test -# -# Copyright (c) 2019 Red Hat, Inc. -# -# Authors: -# Cleber Rosa -# Caio Carrara -# -# 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 tempfile -import os - -from avocado_qemu import QemuSystemTest -from avocado import skipUnless - -from avocado.utils.network import ports -from avocado.utils import wait -from avocado.utils.path import find_command - - -class MigrationTest(QemuSystemTest): - """ - :avocado: tags=3Dmigration - """ - - timeout =3D 10 - - @staticmethod - def migration_finished(vm): - return vm.cmd('query-migrate')['status'] in ('completed', 'failed') - - def assert_migration(self, src_vm, dst_vm): - wait.wait_for(self.migration_finished, - timeout=3Dself.timeout, - step=3D0.1, - args=3D(src_vm,)) - wait.wait_for(self.migration_finished, - timeout=3Dself.timeout, - step=3D0.1, - args=3D(dst_vm,)) - self.assertEqual(src_vm.cmd('query-migrate')['status'], 'completed= ') - self.assertEqual(dst_vm.cmd('query-migrate')['status'], 'completed= ') - self.assertEqual(dst_vm.cmd('query-status')['status'], 'running') - self.assertEqual(src_vm.cmd('query-status')['status'],'postmigrate= ') - - def do_migrate(self, dest_uri, src_uri=3DNone): - dest_vm =3D self.get_vm('-incoming', dest_uri) - dest_vm.add_args('-nodefaults') - dest_vm.launch() - if src_uri is None: - src_uri =3D dest_uri - source_vm =3D self.get_vm() - source_vm.add_args('-nodefaults') - source_vm.launch() - source_vm.qmp('migrate', uri=3Dsrc_uri) - self.assert_migration(source_vm, dest_vm) - - def _get_free_port(self): - port =3D ports.find_free_port() - if port is None: - self.cancel('Failed to find a free port') - return port - - def migration_with_tcp_localhost(self): - dest_uri =3D 'tcp:localhost:%u' % self._get_free_port() - self.do_migrate(dest_uri) - - def migration_with_unix(self): - with tempfile.TemporaryDirectory(prefix=3D'socket_') as socket_pat= h: - dest_uri =3D 'unix:%s/qemu-test.sock' % socket_path - self.do_migrate(dest_uri) - - @skipUnless(find_command('nc', default=3DFalse), "'nc' command not fou= nd") - def migration_with_exec(self): - """The test works for both netcat-traditional and netcat-openbsd p= ackages.""" - free_port =3D self._get_free_port() - dest_uri =3D 'exec:nc -l localhost %u' % free_port - src_uri =3D 'exec:nc localhost %u' % free_port - self.do_migrate(dest_uri, src_uri) - - -@skipUnless('aarch64' in os.uname()[4], "host !=3D target") -class Aarch64(MigrationTest): - """ - :avocado: tags=3Darch:aarch64 - :avocado: tags=3Dmachine:virt - :avocado: tags=3Dcpu:max - """ - - def test_migration_with_tcp_localhost(self): - self.migration_with_tcp_localhost() - - def test_migration_with_unix(self): - self.migration_with_unix() - - def test_migration_with_exec(self): - self.migration_with_exec() - - -@skipUnless('x86_64' in os.uname()[4], "host !=3D target") -class X86_64(MigrationTest): - """ - :avocado: tags=3Darch:x86_64 - :avocado: tags=3Dmachine:pc - :avocado: tags=3Dcpu:qemu64 - """ - - def test_migration_with_tcp_localhost(self): - self.migration_with_tcp_localhost() - - def test_migration_with_unix(self): - self.migration_with_unix() - - def test_migration_with_exec(self): - self.migration_with_exec() - - -@skipUnless('ppc64le' in os.uname()[4], "host !=3D target") -class PPC64(MigrationTest): - """ - :avocado: tags=3Darch:ppc64 - :avocado: tags=3Dmachine:pseries - """ - - def test_migration_with_tcp_localhost(self): - self.migration_with_tcp_localhost() - - def test_migration_with_unix(self): - self.migration_with_unix() - - def test_migration_with_exec(self): - self.migration_with_exec() diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 3d29b8245a..0558d0aa4e 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -61,6 +61,10 @@ tests_aarch64_system_thorough =3D [ 'multiprocess', ] =20 +tests_alpha_system_quick =3D [ + 'migration', +] + tests_alpha_system_thorough =3D [ 'alpha_clipper', ] @@ -148,6 +152,10 @@ tests_ppc_system_thorough =3D [ 'ppc_virtex_ml507', ] =20 +tests_ppc64_system_quick =3D [ + 'migration', +] + tests_ppc64_system_thorough =3D [ 'ppc64_e500', 'ppc64_hv', @@ -157,6 +165,7 @@ tests_ppc64_system_thorough =3D [ ] =20 tests_riscv32_system_quick =3D [ + 'migration', 'riscv_opensbi', ] =20 @@ -165,6 +174,7 @@ tests_riscv32_system_thorough =3D [ ] =20 tests_riscv64_system_quick =3D [ + 'migration', 'riscv_opensbi', ] =20 @@ -191,10 +201,18 @@ tests_sh4eb_system_thorough =3D [ 'sh4eb_r2d', ] =20 +tests_sparc_system_quick =3D [ + 'migration', +] + tests_sparc_system_thorough =3D [ 'sparc_sun4m', ] =20 +tests_sparc64_system_quick =3D [ + 'migration', +] + tests_sparc64_system_thorough =3D [ 'sparc64_sun4u', 'sparc64_tuxrun', @@ -203,6 +221,7 @@ tests_sparc64_system_thorough =3D [ tests_x86_64_system_quick =3D [ 'cpu_queries', 'mem_addr_space', + 'migration', 'pc_cpu_hotplug_props', 'virtio_version', 'x86_cpu_model_versions', diff --git a/tests/functional/test_migration.py b/tests/functional/test_mig= ration.py new file mode 100755 index 0000000000..9c78444f80 --- /dev/null +++ b/tests/functional/test_migration.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 +# +# Migration test +# +# Copyright (c) 2019 Red Hat, Inc. +# +# Authors: +# Cleber Rosa +# Caio Carrara +# +# 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 time + +from qemu_test import QemuSystemTest, has_cmd +from qemu_test.ports import Ports +from unittest import skipUnless + +class MigrationTest(QemuSystemTest): + + timeout =3D 10 + + @staticmethod + def migration_finished(vm): + return vm.cmd('query-migrate')['status'] in ('completed', 'failed') + + def assert_migration(self, src_vm, dst_vm): + + end =3D time.monotonic() + self.timeout + while time.monotonic() < end and not self.migration_finished(src_v= m): + time.sleep(0.1) + + end =3D time.monotonic() + self.timeout + while time.monotonic() < end and not self.migration_finished(dst_v= m): + time.sleep(0.1) + + self.assertEqual(src_vm.cmd('query-migrate')['status'], 'completed= ') + self.assertEqual(dst_vm.cmd('query-migrate')['status'], 'completed= ') + self.assertEqual(dst_vm.cmd('query-status')['status'], 'running') + self.assertEqual(src_vm.cmd('query-status')['status'],'postmigrate= ') + + def do_migrate(self, dest_uri, src_uri=3DNone): + dest_vm =3D self.get_vm('-incoming', dest_uri, name=3D"dest-qemu") + dest_vm.add_args('-nodefaults') + dest_vm.launch() + if src_uri is None: + src_uri =3D dest_uri + source_vm =3D self.get_vm(name=3D"source-qemu") + source_vm.add_args('-nodefaults') + source_vm.launch() + source_vm.qmp('migrate', uri=3Dsrc_uri) + self.assert_migration(source_vm, dest_vm) + + def _get_free_port(self, ports): + port =3D ports.find_free_port() + if port is None: + self.skipTest('Failed to find a free port') + return port + + def test_migration_with_tcp_localhost(self): + with Ports() as ports: + dest_uri =3D 'tcp:localhost:%u' % self._get_free_port(ports) + self.do_migrate(dest_uri) + + def test_migration_with_unix(self): + with tempfile.TemporaryDirectory(prefix=3D'socket_') as socket_pat= h: + dest_uri =3D 'unix:%s/qemu-test.sock' % socket_path + self.do_migrate(dest_uri) + + @skipUnless(*has_cmd('nc')) + def test_migration_with_exec(self): + """The test works for both netcat-traditional and netcat-openbsd p= ackages.""" + with Ports() as ports: + free_port =3D self._get_free_port(ports) + dest_uri =3D 'exec:nc -l localhost %u' % free_port + src_uri =3D 'exec:nc localhost %u' % free_port + self.do_migrate(dest_uri, src_uri) + +if __name__ =3D=3D '__main__': + QemuSystemTest.main() --=20 2.47.0