Skip to contentSkip to conversation

Acceptance test: Extension of migration tests

PATCH Superseded Oksana Vohchana 2 participants 5 messages Mar 23, 2020

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Acceptance test: Extension of migration tests

This series adds a new migration test through RDMA.
To correct uses of migration need to add a new function to work with RDMA service.
And as a part of migration tests, the series makes small updates to EXEC migration and to _get_free_port function

V2:
- improves commit message in Acceptance test: adds param 'address' in _get_free_port
- provides import check for netifaces library
- makes fix to _get_ip_rdma function
- adds skip to test if not upload python module

V3:
- removes unrelated changes
- updates functions with new avocado features

V4:
- moves RDMA's functions outside the Migration class

Oksana Vohchana (3):
Acceptance test: adds param 'address' in _get_free_port Acceptance test: provides new functions
Acceptance test: provides to use RDMA transport for migration test

 tests/acceptance/migration.py | 48 +++++++++++++++++++++++++++++++++--
 1 file changed, 46 insertions(+), 2 deletions(-)
Signature · 1 line
2.21.1
#1 lore raw

PATCH v4 1/3 Acceptance test: adds param 'address' in _get_free_port

In the migration test function _get_free_port works only for localhost, but in the case to use migration through an RDMA we need to get a free port on the configured network RDMA-interface.
This patch is the start for another migration option

---
 tests/acceptance/migration.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/acceptance/migration.py +2 -2
index a8367ca023..e4c39b85a1 100644
@@ -52,8 +52,8 @@ class Migration(Test):
         source_vm.qmp('migrate', uri=src_uri)
         self.assert_migration(source_vm, dest_vm)
 
-    def _get_free_port(self):
-        port = network.find_free_port()
+    def _get_free_port(self, address='localhost'):
+        port = network.find_free_port(address=address)
         if port is None:
             self.cancel('Failed to find a free port')
         return port
Signature · 1 line
2.21.1
Reviewed-by on v4 1/3
#2 lore raw

Re: [PATCH v4 1/3] Acceptance test: adds param 'address' in _get_free_port

Quoted 27 lines · Oksana Vohchana

In the migration test function _get_free_port works only for localhost, but in the case to use migration through an RDMA we need to get a free port on the configured network RDMA-interface.
This patch is the start for another migration option

---
 tests/acceptance/migration.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/acceptance/migration.py +2 -3
index a8367ca023..e4c39b85a1 100644
@@ -52,8 +52,8 @@ class Migration(Test):
         source_vm.qmp('migrate', uri=src_uri)
         self.assert_migration(source_vm, dest_vm)
 
-    def _get_free_port(self):
-        port = network.find_free_port()
+    def _get_free_port(self, address='localhost'):
+        port = network.find_free_port(address=address)
         if port is None:
             self.cancel('Failed to find a free port')
         return port
--
Quoted 2 lines

2.21.1

Just confirming,

#3 lore raw

PATCH v4 2/3 Acceptance test: provides new functions

In reply to Oksana Vohchana

Provides new functions related to the rdma migration test Adds functions to check if service RDMA is enabled and gets the ip address on the interface where it was configured

---
 tests/acceptance/migration.py | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
tests/acceptance/migration.py +32 -0
index e4c39b85a1..59144f18fd 100644
@@ -11,12 +11,44 @@
 
 
 import tempfile
+import json
 from avocado_qemu import Test
 from avocado import skipUnless
 
 from avocado.utils import network
 from avocado.utils import wait
 from avocado.utils.path import find_command
+from avocado.utils.network.interfaces import NetworkInterface
+from avocado.utils.network.hosts import LocalHost
+from avocado.utils import service
+from avocado.utils import process
+
+
+def _if_rdma_enable():
+    rdma_stat = service.ServiceManager()
+    return bool(rdma_stat.status('rdma'))
+
+def _get_interface_rdma():
+    cmd = 'rdma link show -j'
+    out = json.loads(process.getoutput(cmd))
+    try:
+        for i in out:
+            if i['state'] == 'ACTIVE':
+                return i['netdev']
+    except KeyError:
+        return False
+    return False
+
+def _get_ip_rdma(interface):
+    local = LocalHost()
+    network_in = NetworkInterface(interface, local)
+    try:
+        ip = network_in._get_interface_details()
+        if ip:
+            return ip[0]['addr_info'][0]['local']
+    except (KeyError, process.CmdError):
+        return False
+    return False
 
 
 class Migration(Test):
Signature · 1 line
2.21.1
#4 lore raw

PATCH v4 3/3 Acceptance test: provides to use RDMA transport for migration test

In reply to Oksana Vohchana

Adds test for RDMA migration check

---
 tests/acceptance/migration.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tests/acceptance/migration.py +12 -0
index 59144f18fd..c96da1dd4b 100644
@@ -107,3 +107,15 @@ class Migration(Test):
         """
         free_port = self._get_free_port()
         dest_uri = 'exec:nc -l localhost %u' % free_port
+
+    @skipUnless(_if_rdma_enable(), 'Unit rdma.service could not be found')
+    @skipUnless(_get_interface_rdma(), 'RDMA service or interface not configured')
+    def test_migration_with_rdma_localhost(self):
+        iface = _get_interface_rdma()
+        ip = _get_ip_rdma(iface)
+        if ip:
+            free_port = self._get_free_port(address=ip)
+        else:
+            self.cancel("Ip address doesn't configured properly on interface:%s" % iface)
+        dest_uri = 'rdma:%s:%u' % (ip, free_port)
+        self.do_migrate(dest_uri)
Signature · 1 line
2.21.1