Skip to contentSkip to conversation

Add acceptance test for migration

PATCH New Balamuruhan S 1 participant 4 messages Aug 5, 2019

lore
Share & tools
lore
#0 lore raw

cover Add acceptance test for migration

Add new test for migration that bringup vm with different machine types and migrate it, introduce new API in avocado_qemu to query all the machine types supported by qemu.

Test run:

# avocado run migration.py
JOB ID     : ef54f57a073eb267d2347e32225f2adbe27969de
JOB LOG    : /home/bala/avocado-fvt-wrapper/results/job-2019-08-05T13.54-ef54f57/job.log
 (1/2) migration.py:Migration.test_migration_with_tcp_localhost: PASS (0.54 s)
 (2/2) migration.py:Migration.test_migration_with_machine_types: PASS (5.21 s)
RESULTS    : PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 5.86 s

Currently acceptance test for migration error out as we check query-migrate in target after migration which is not appropriate.

Balamuruhan S (3):
tests/acceptance/migration: fix post migration check tests/acceptance/avocado_qemu: add method to get supported machine
types
tests/acceptance/migration: test to migrate will all machine types

 tests/acceptance/avocado_qemu/__init__.py |  6 ++++++
 tests/acceptance/migration.py             | 27 ++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)
Signature · 1 line
2.14.5
#1 lore raw

PATCH 1/3 tests/acceptance/migration: fix post migration check

assert query-migrate in target doesn't give migration status and test errors even if migration succeeds.

In target:
{'execute': 'query-migrate'}
{"return": {}}

---
 tests/acceptance/migration.py | 1 -
 1 file changed, 1 deletion(-)
tests/acceptance/migration.py +0 -1
index 6115cf6c24..66941db3b3 100644
@@ -47,7 +47,6 @@ class Migration(Test):
             step=0.1,
             args=(source_vm,)
         )
-        self.assertEqual(dest_vm.command('query-migrate')['status'], 'completed')
         self.assertEqual(source_vm.command('query-migrate')['status'], 'completed')
         self.assertEqual(dest_vm.command('query-status')['status'], 'running')
         self.assertEqual(source_vm.command('query-status')['status'], 'postmigrate')
Signature · 1 line
2.14.5
#2 lore raw

PATCH 2/3 tests/acceptance/avocado_qemu: add method to get supported machine types

In reply to Balamuruhan S

add get_machine_types() to return list of supported machine types by the qemu binary.

---
 tests/acceptance/avocado_qemu/__init__.py | 6 ++++++
 1 file changed, 6 insertions(+)
tests/acceptance/avocado_qemu/__init__.py +6 -0
index aee5d820ed..df18561e97 100644
@@ -82,6 +82,12 @@ class Test(avocado.Test):
             self._vms[name] = self._new_vm(*args)
         return self._vms[name]
 
+    def get_machine_types(self):
+        cmd = "%s -machine ?" % self.qemu_bin
+        output = avocado.utils.process.getoutput(cmd).split("\n")
+        output.remove("Supported machines are:")
+        return [each.split()[0] for each in output]
+
     def tearDown(self):
         for vm in self._vms.values():
             vm.shutdown()
Signature · 1 line
2.14.5
#3 lore raw

PATCH 3/3 tests/acceptance/migration: test to migrate will all machine types

In reply to Balamuruhan S

add migration test to query machine types supported by qemu binary and migrate vm will all supported type.

---
 tests/acceptance/migration.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
tests/acceptance/migration.py +26 -0
index 66941db3b3..a598b54718 100644
@@ -50,3 +50,29 @@ class Migration(Test):
         self.assertEqual(source_vm.command('query-migrate')['status'], 'completed')
         self.assertEqual(dest_vm.command('query-status')['status'], 'running')
         self.assertEqual(source_vm.command('query-status')['status'], 'postmigrate')
+
+
+    def test_migration_with_machine_types(self):
+        migration_port = self._get_free_port()
+        for machine in self.get_machine_types():
+            if 'pseries' in machine:
+                print("migrating with machine type - {}".format(machine))
+                source_vm = self.get_vm('-M', '{},cap-htm=off'.format(machine))
+                dest_uri = 'tcp:localhost:%u' % migration_port
+                dest_vm = self.get_vm('-M', '{},cap-htm=off'.format(machine),
+                                      '-incoming', dest_uri)
+                dest_vm.launch()
+                source_vm.launch()
+                source_vm.qmp('migrate', uri=dest_uri)
+                wait.wait_for(
+                    self.migration_finished,
+                    timeout=self.timeout,
+                    step=0.1,
+                    args=(source_vm,)
+                )
+                self.assertEqual(source_vm.command('query-migrate')['status'],
+                                                   'completed')
+                self.assertEqual(dest_vm.command('query-status')['status'],
+                                                 'running')
+                self.assertEqual(source_vm.command('query-status')['status'],
+                                                   'postmigrate')
Signature · 1 line
2.14.5