diff mbox series

[v5,2/3] Acceptance test: provides new functions

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

Commit Message

Oksana Vohchana April 7, 2020, 3:56 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 | 45 +++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

Comments

Willian Rampazzo April 7, 2020, 5:22 p.m. UTC | #1
On Tue, Apr 7, 2020 at 1:07 PM Oksana Vohchana <ovoshcha@redhat.com> wrote:
>
> 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 | 45 +++++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
>
> diff --git a/tests/acceptance/migration.py b/tests/acceptance/migration.py
> index e4c39b85a1..1c3a684395 100644
> --- a/tests/acceptance/migration.py
> +++ b/tests/acceptance/migration.py
> @@ -11,12 +11,57 @@
>
>
>  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 get_rdma_status():
> +    """Verify the status of RDMA service.
> +
> +    return: True if rdma service is enabled, False otherwise.
> +    """
> +    rdma_stat = service.ServiceManager()
> +    return bool(rdma_stat.status('rdma'))
> +
> +def get_interface_rdma():
> +    """Get the interface name where RDMA is configured.
> +
> +    return: The interface name or False if none is found
> +    """
> +    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:
> +        pass
> +    return False
> +
> +def get_ip_rdma(interface):
> +    """Get the IP address on a specific interface.
> +
> +    :param interface: Network interface name
> +    :return: IP addresses as a list, otherwise will return False
> +    """
> +    local = LocalHost()
> +    network_in = NetworkInterface(interface, local)
> +    try:
> +        ip = network_in.get_ipaddrs()
> +        if ip:
> +            return ip
> +    except:
> +        pass
> +    return False
>
>
>  class Migration(Test):
> --
> 2.21.1
>
>

Reviewed-by: Willian Rampazzo <willianr@redhat.com>
diff mbox series

Patch

diff --git a/tests/acceptance/migration.py b/tests/acceptance/migration.py
index e4c39b85a1..1c3a684395 100644
--- a/tests/acceptance/migration.py
+++ b/tests/acceptance/migration.py
@@ -11,12 +11,57 @@ 
 
 
 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 get_rdma_status():
+    """Verify the status of RDMA service.
+
+    return: True if rdma service is enabled, False otherwise.
+    """
+    rdma_stat = service.ServiceManager()
+    return bool(rdma_stat.status('rdma'))
+
+def get_interface_rdma():
+    """Get the interface name where RDMA is configured.
+
+    return: The interface name or False if none is found
+    """
+    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:
+        pass
+    return False
+
+def get_ip_rdma(interface):
+    """Get the IP address on a specific interface.
+
+    :param interface: Network interface name
+    :return: IP addresses as a list, otherwise will return False
+    """
+    local = LocalHost()
+    network_in = NetworkInterface(interface, local)
+    try:
+        ip = network_in.get_ipaddrs()
+        if ip:
+            return ip
+    except:
+        pass
+    return False
 
 
 class Migration(Test):