diff mbox series

[v2,3/4] Acceptance test: provides new functions

Message ID 20200225131302.4792-4-ovoshcha@redhat.com
State New
Headers show
Series Acceptance test: Extension of migration tests | expand

Commit Message

Oksana Vohchana Feb. 25, 2020, 1:13 p.m. UTC
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

Signed-off-by: Oksana Vohchana <ovoshcha@redhat.com>
---
 tests/acceptance/migration.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/tests/acceptance/migration.py b/tests/acceptance/migration.py
index 8209dcf71d..5632d74f14 100644
--- a/tests/acceptance/migration.py
+++ b/tests/acceptance/migration.py
@@ -11,12 +11,22 @@ 
 
 
 import tempfile
+import re
 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 import service
+from avocado.utils import process
+
+
+NET_AVAILABLE = True
+try:
+    import netifaces
+except ImportError:
+    NET_AVAILABLE = False
 
 
 class Migration(Test):
@@ -58,6 +68,22 @@  class Migration(Test):
             self.cancel('Failed to find a free port')
         return port
 
+    def _if_rdma_enable(self):
+        rdma_stat = service.ServiceManager()
+        rdma = rdma_stat.status('rdma')
+        return rdma
+
+    def _get_ip_rdma(self):
+        get_ip_rdma = process.run('rdma link show').stdout.decode()
+        for line in get_ip_rdma.split('\n'):
+            if re.search(r"ACTIVE", line):
+                interface = line.split(" ")[-2]
+                try:
+                     return netifaces.ifaddresses(interface)[netifaces \
+                                                 .AF_INET][0]['addr']
+                except (IndexError, KeyError):
+                    return None
+
 
     def test_migration_with_tcp_localhost(self):
         dest_uri = 'tcp:localhost:%u' % self._get_free_port()