From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:39125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxGi3-0003vU-Fd for qemu-devel@nongnu.org; Fri, 22 Feb 2019 14:42:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gxGi2-0008EW-JW for qemu-devel@nongnu.org; Fri, 22 Feb 2019 14:42:11 -0500 From: Cleber Rosa Date: Fri, 22 Feb 2019 14:41:44 -0500 Message-Id: <20190222194146.13102-6-crosa@redhat.com> In-Reply-To: <20190222194146.13102-1-crosa@redhat.com> References: <20190222194146.13102-1-crosa@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 5/7] tests.acceptance: adds simple migration test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , qemu-devel@nongnu.org Cc: Eduardo Habkost , Fam Zheng , qemu-block@nongnu.org, Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Cleber Rosa , Markus Armbruster , Caio Carrara , Wainer dos Santos Moschetta From: Caio Carrara This change adds the simplest possible migration test. Beyond the test purpose itself it's also useful to exercise the multi virtual machines capabilities from base avocado qemu test class. Signed-off-by: Cleber Rosa Signed-off-by: Caio Carrara Reviewed-by: Cleber Rosa Reviewed-by: Wainer dos Santos Moschetta Message-Id: <20190212193855.13223-3-ccarrara@redhat.com> Signed-off-by: Cleber Rosa --- tests/acceptance/migration.py | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/acceptance/migration.py diff --git a/tests/acceptance/migration.py b/tests/acceptance/migration.p= y new file mode 100644 index 0000000000..6115cf6c24 --- /dev/null +++ b/tests/acceptance/migration.py @@ -0,0 +1,53 @@ +# 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. + + +from avocado_qemu import Test + +from avocado.utils import network +from avocado.utils import wait + + +class Migration(Test): + """ + :avocado: enable + """ + + timeout =3D 10 + + @staticmethod + def migration_finished(vm): + return vm.command('query-migrate')['status'] in ('completed', 'f= ailed') + + def _get_free_port(self): + port =3D network.find_free_port() + if port is None: + self.cancel('Failed to find a free port') + return port + + + def test_migration_with_tcp_localhost(self): + source_vm =3D self.get_vm() + dest_uri =3D 'tcp:localhost:%u' % self._get_free_port() + dest_vm =3D self.get_vm('-incoming', dest_uri) + dest_vm.launch() + source_vm.launch() + source_vm.qmp('migrate', uri=3Ddest_uri) + wait.wait_for( + self.migration_finished, + timeout=3Dself.timeout, + step=3D0.1, + args=3D(source_vm,) + ) + self.assertEqual(dest_vm.command('query-migrate')['status'], 'co= mpleted') + self.assertEqual(source_vm.command('query-migrate')['status'], '= completed') + self.assertEqual(dest_vm.command('query-status')['status'], 'run= ning') + self.assertEqual(source_vm.command('query-status')['status'], 'p= ostmigrate') --=20 2.20.1