Skip to contentSkip to conversation

Acceptance test: Extension of migration tests

PATCH Superseded Oksana Vohchana 2 participants 8 messages Mar 20, 2020 – Mar 23, 2020

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 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

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 | 46 +++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)
Signature · 1 line
2.21.1
#1 lore raw

PATCH v3 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 v3 1/3
#2 lore raw

Re: [PATCH v3 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 3 lines

2.21.1

#3 lore raw

PATCH v3 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 | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
tests/acceptance/migration.py +30 -0
index e4c39b85a1..a783f3915b 100644
@@ -11,12 +11,17 @@
 
 
 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
 
 
 class Migration(Test):
@@ -58,6 +63,31 @@ 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_interface_rdma(self):
+        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 None
+
+    def _get_ip_rdma(self, 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:
+            self.cancel("Incorrect interface configuration or device name")
+
 
     def test_migration_with_tcp_localhost(self):
         dest_uri = 'tcp:localhost:%u' % self._get_free_port()
Signature · 1 line
2.21.1
#4 lore raw

Re: [PATCH v3 2/3] Acceptance test: provides new functions

Hi Oksana,

Quoted 33 lines · 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 | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
tests/acceptance/migration.py +5 -0
index e4c39b85a1..a783f3915b 100644
@@ -11,12 +11,17 @@
 
 
 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
 
 
 class Migration(Test):

tests/acceptance/migration.py class Migration(Test): · line 69

Quoted 7 lines
tests/acceptance/migration.py +4 -0
@@ -58,6 +63,31 @@ 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

You can just return rdma_stat.status('rdma') here! Also, as you are not using any of the class attributes or methods, if you make this method static, you don't need to call it with None as you did on patch 3 of this series.

tests/acceptance/migration.py class Migration(Test): · line 79

Quoted 10 lines
tests/acceptance/migration.py +10 -0
+
+    def _get_interface_rdma(self):
+        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 None

Same comment about making this method static.

Actually, if you are not using any of the attributes or methods from the Migration class on these two methods, I think you can define them as functions, outside of the Class. Does it make sense?

tests/acceptance/migration.py class Migration(Test): · line 90

Quoted 11 lines
tests/acceptance/migration.py +11 -0
+
+    def _get_ip_rdma(self, 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:
+            self.cancel("Incorrect interface configuration or device name")
+

If you change the logic a bit and raise an exception here, instead of doing a self.cancel, you can also make this method static, or move it outside of the class. The cancel can be handled in the test, with the exception raised here.

Quoted 7 lines
tests/acceptance/migration.py +0 -1
     def test_migration_with_tcp_localhost(self):
         dest_uri = 'tcp:localhost:%u' % self._get_free_port()
--

2.21.1

Let me know if the comments do not make sense.

Willian

#5 lore raw

Re: [PATCH v3 2/3] Acceptance test: provides new functions

Hi Willian
I totally agree with your comments
I'll move those functions outside the class
Let me update and repost the patch
Thanks

Quoted 99 lines · Willian Rampazzo

Hi Oksana,

Review

Quoted 11 lines · 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 | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
(quoted diff) +0 -0

b/tests/acceptance/migration.py

Quoted 22 lines

index e4c39b85a1..a783f3915b 100644

tests/acceptance/migration.py +5 -0
@@ -11,12 +11,17 @@
 
 
 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
 
 
 class Migration(Test):

tests/acceptance/migration.py class Migration(Test): · line 69

Quoted 7 lines
tests/acceptance/migration.py +4 -0
@@ -58,6 +63,31 @@ 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

You can just return rdma_stat.status('rdma') here! Also, as you are not using any of the class attributes or methods, if you make this method static, you don't need to call it with None as you did on patch 3 of this series.

tests/acceptance/migration.py class Migration(Test): · line 79

Quoted 10 lines
tests/acceptance/migration.py +10 -0
+
+    def _get_interface_rdma(self):
+        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 None

Same comment about making this method static.

Actually, if you are not using any of the attributes or methods from the Migration class on these two methods, I think you can define them as functions, outside of the Class. Does it make sense?

tests/acceptance/migration.py class Migration(Test):

Quoted 10 lines
tests/acceptance/migration.py +10 -0
+
+    def _get_ip_rdma(self, 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:
+            self.cancel("Incorrect interface configuration or device

name")

tests/acceptance/migration.py class Migration(Test): · line 90

Quoted 1 line
tests/acceptance/migration.py +1 -0
+

If you change the logic a bit and raise an exception here, instead of doing a self.cancel, you can also make this method static, or move it outside of the class. The cancel can be handled in the test, with the exception raised here.

Quoted 7 lines
tests/acceptance/migration.py +0 -1
     def test_migration_with_tcp_localhost(self):
         dest_uri = 'tcp:localhost:%u' % self._get_free_port()
--

2.21.1

Let me know if the comments do not make sense.

Willian

#6 lore raw

PATCH v3 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 a783f3915b..c8673114a9 100644
@@ -105,3 +105,15 @@ class Migration(Test):
         """
         free_port = self._get_free_port()
         dest_uri = 'exec:nc -l localhost %u' % free_port
+
+    @skipUnless(_if_rdma_enable(None), "Unit rdma.service could not be found")
+    @skipUnless(_get_interface_rdma(None), 'RDMA service or interface not configured')
+    def test_migration_with_rdma_localhost(self):
+        iface = self._get_interface_rdma()
+        ip = self._get_ip_rdma(iface)
+        if ip:
+            free_port = self._get_free_port(address=ip)
+        else:
+            self.cancel("Ip address isn't configured")
+        dest_uri = 'rdma:%s:%u' % (ip, free_port)
+        self.do_migrate(dest_uri)
Signature · 1 line
2.21.1
#7 lore raw

Re: [PATCH v3 3/3] Acceptance test: provides to use RDMA transport for migration test

Hi Oksana,

Quoted 13 lines · Oksana Vohchana

Adds test for RDMA migration check

---
 tests/acceptance/migration.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tests/acceptance/migration.py +0 -0
index a783f3915b..c8673114a9 100644

tests/acceptance/migration.py class Migration(Test): · line 110

Quoted 6 lines
tests/acceptance/migration.py +3 -0
@@ -105,3 +105,15 @@ class Migration(Test):
         """
         free_port = self._get_free_port()
         dest_uri = 'exec:nc -l localhost %u' % free_port
+
+    @skipUnless(_if_rdma_enable(None), "Unit rdma.service could not be found")
+    @skipUnless(_get_interface_rdma(None), 'RDMA service or interface not configured')

If you change these two methods to be static, you will not need to use the None parameter, as I mentioned in patch 2 of this series.

Quoted 13 lines
tests/acceptance/migration.py +9 -1
+    def test_migration_with_rdma_localhost(self):
+        iface = self._get_interface_rdma()
+        ip = self._get_ip_rdma(iface)
+        if ip:
+            free_port = self._get_free_port(address=ip)
+        else:
+            self.cancel("Ip address isn't configured")
+        dest_uri = 'rdma:%s:%u' % (ip, free_port)
+        self.do_migrate(dest_uri)
--

2.21.1