aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/DMM/SingleCliSer.py
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries/python/DMM/SingleCliSer.py')
-rw-r--r--resources/libraries/python/DMM/SingleCliSer.py213
1 files changed, 153 insertions, 60 deletions
diff --git a/resources/libraries/python/DMM/SingleCliSer.py b/resources/libraries/python/DMM/SingleCliSer.py
index 9bf18bb9eb..e96843ac36 100644
--- a/resources/libraries/python/DMM/SingleCliSer.py
+++ b/resources/libraries/python/DMM/SingleCliSer.py
@@ -17,98 +17,191 @@ This module exists to provide the vs_epoll ping test for DMM on topology nodes.
"""
import time
-from resources.libraries.python.ssh import SSH
+from resources.libraries.python.ssh import exec_cmd_no_error
from resources.libraries.python.DMM.DMMConstants import DMMConstants as con
from resources.libraries.python.topology import Topology
-from robot.api import logger
class SingleCliSer(object):
"""Test the DMM vs_epoll ping function."""
@staticmethod
- def exec_the_base_vs_epoll_test(dut1_node, dut2_node):
- """Execute the vs_epoll on the dut1_node.
-
- :param dut1_node: Will execute the vs_epoll on this node.
- :param dut2_node: Will execute the vc_epoll on this node.
+ def exec_the_base_vs_epoll_test(dut1_node, dut2_node,
+ dut1_if_name, dut2_if_name,
+ dut1_if_ip, dut2_if_ip):
+ """
+ Perform base vs_epoll test on DUT's.
+
+ :param dut1_node: Node to execute vs_epoll on.
+ :param dut2_node: Node to execute vc_common on.
+ :param dut1_if_name: DUT1 to DUT2 interface name.
+ :param dut2_if_name: DUT2 to DUT1 interface name.
+ :param dut1_if_ip: DUT1 to DUT2 interface ip.
+ :param dut2_if_ip: DUT2 to DUT1 interface ip.
:type dut1_node: dict
:type dut2_node: dict
- :returns: positive value if packets are sent and received
- :raises RuntimeError:If failed to execute vs_epoll test on dut1_node.
+ :type dut1_if_name: str
+ :type dut2_if_name: str
+ :type dut1_if_ip: str
+ :type dut2_if_ip: str
"""
- dut1_ip = Topology.get_node_hostname(dut1_node)
- dut2_ip = Topology.get_node_hostname(dut2_node)
-
- ssh = SSH()
- ssh.connect(dut1_node)
-
- cmd = 'cd {0}/{1} && ./run_dmm.sh {2} {3} {4} ' \
- .format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS, dut1_ip, dut2_ip, 0)
+ cmd = 'cd {0}/{1} && ./run_dmm.sh {2} {3} {4} {5} ' \
+ .format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS, 0, dut1_if_name,
+ dut1_if_ip, dut2_if_ip)
cmd += '2>&1 | tee log_run_dmm.txt &'
-
- (ret_code, _, _) = ssh.exec_command(cmd, timeout=6000)
- if ret_code != 0:
- raise RuntimeError('Failed to execute vs_epoll test at node {0}'
- .format(dut1_node['host']))
-
+ exec_cmd_no_error(dut1_node, cmd)
time.sleep(10)
- ssh = SSH()
- ssh.connect(dut2_node)
-
- cmd = 'cd {0}/{1} && ./run_dmm.sh {2} {3} {4} ' \
- .format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS, dut1_ip, dut2_ip, 1)
+ cmd = 'cd {0}/{1} && ./run_dmm.sh {2} {3} {4} {5} ' \
+ .format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS, 1, dut2_if_name,
+ dut1_if_ip, dut2_if_ip)
cmd += '2>&1 | tee log_run_dmm.txt'
-
- (ret_code, stdout_cli, _) = ssh.exec_command(cmd, timeout=6000)
- if ret_code != 0:
- raise RuntimeError('Failed to execute vs_epoll test at node {0}'
- .format(dut1_node['host']))
-
- return stdout_cli.find("send 50000")
+ exec_cmd_no_error(dut2_node, cmd)
@staticmethod
def get_the_test_result(dut_node):
"""
After executing exec_the_base_vs_epoll_test, use this
- to get the test result
+ to get the test result.
- :param dut_node: will get the test result in this dut node
+ :param dut_node: Node to get the test result on.
:type dut_node: dict
- :returns: str.
- :rtype: str.
- :raises RuntimeError: If failed to get the test result.
+ :returns: Word count of "send 50000" in the log.
+ :rtype: str
"""
- ssh = SSH()
- ssh.connect(dut_node)
cmd = 'cat {0}/{1}/log_run_dmm.txt | grep "send 50000" | wc -l' \
.format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS)
-
- (ret_code, stdout, _) = ssh.exec_command(cmd, timeout=100)
- if ret_code != 0:
- raise RuntimeError('Failed to get test result at node {0}'
- .format(dut_node['host']))
-
+ (stdout, _) = exec_cmd_no_error(dut_node, cmd)
return stdout
@staticmethod
def echo_dmm_logs(dut_node):
"""
- :param dut_node:
- :return:
+ Get the prerequisites installation log from DUT.
+
+ :param dut_node: Node to get the installation log on.
+ :type dut_node: dict
"""
- ssh = SSH()
- ssh.connect(dut_node)
- cmd = 'cat {0}/{1}/log_install_dmm.txt' \
+ cmd = 'cat {0}/{1}/log_install_prereq.txt' \
.format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS)
+ exec_cmd_no_error(dut_node, cmd)
+
+ @staticmethod
+ def exec_the_base_lwip_test(dut1_node, dut2_node,
+ dut1_if_name, dut2_if_name,
+ dut1_if_ip, dut2_if_ip):
+ """Test DMM with LWIP.
+
+ :param dut1_node: Node to execute vs_epoll on.
+ :param dut2_node: Node to execute vc_common on.
+ :param dut1_if_name: DUT1 to DUT2 interface name.
+ :param dut2_if_name: DUT2 to DUT1 interface name.
+ :param dut1_if_ip: DUT1 to DUT2 interface ip.
+ :param dut2_if_ip: DUT2 to DUT1 interface ip.
+ :type dut1_node: dict
+ :type dut2_node: dict
+ :type dut1_if_name: str
+ :type dut2_if_name: str
+ :type dut1_if_ip: str
+ :type dut2_if_ip: str
+ """
+ cmd = 'cd {0}/{1} && ./run_dmm_with_lwip.sh {2} {3} {4} {5} ' \
+ .format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS, 0, dut1_if_name,
+ dut1_if_ip, dut2_if_ip)
+
+ cmd += '2>&1 | tee log_run_dmm_with_lwip.txt &'
+ exec_cmd_no_error(dut1_node, cmd)
+ time.sleep(10)
+
+ cmd = 'cd {0}/{1} && ./run_dmm_with_lwip.sh {2} {3} {4} {5} ' \
+ .format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS, 1, dut2_if_name,
+ dut1_if_ip, dut2_if_ip)
- (ret_code, stdout, _) = ssh.exec_command(cmd, timeout=100)
- if ret_code != 0:
- raise RuntimeError('Failed to get log_install_dmm at node {0}'
- .format(dut_node['host']))
- else:
- logger.console('....log_install_dmm on node {1}.... {0}'
- .format(stdout, dut_node['host']))
+ cmd += '2>&1 | tee log_run_dmm_with_lwip.txt'
+ exec_cmd_no_error(dut2_node, cmd)
+
+ @staticmethod
+ def get_lwip_test_result(dut_node):
+ """
+ After executing exec_the_base_lwip_test, use this
+ to get the test result.
+
+ :param dut_node: Node to get the test result on.
+ :type dut_node: dict
+ :returns: Word count of "send 50" in the log.
+ :rtype: str
+ """
+ cmd = 'cat {0}/{1}/log_run_dmm_with_lwip.txt | grep "send 50" | wc -l' \
+ .format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS)
+ (stdout, _) = exec_cmd_no_error(dut_node, cmd)
+ return stdout
+
+ @staticmethod
+ def echo_running_log(dut1_node, dut2_node):
+ """
+ Get the running log.
+
+ :param dut1_node: Node to get the running log on.
+ :param dut2_node: Node to get the running log on.
+ :type dut1_node: dict
+ :type dut2_node: dict
+ """
+ cmd = 'cat /var/log/nStack/running.log'
+ exec_cmd_no_error(dut1_node, cmd)
+ exec_cmd_no_error(dut2_node, cmd)
+
+ @staticmethod
+ def echo_dpdk_log(dut1_node, dut2_node):
+ """
+ Get the dpdk log.
+
+ :param dut1_node: Node to get the DPDK log on.
+ :param dut2_node: Node to get the DPDK log on.
+ :type dut1_node: dict
+ :type dut2_node: dict
+ """
+ cmd = 'cat /var/log/nstack-dpdk/nstack_dpdk.log'
+ exec_cmd_no_error(dut1_node, cmd)
+ exec_cmd_no_error(dut2_node, cmd)
+
+ @staticmethod
+ def dmm_get_interface_name(dut_node, dut_interface):
+ """
+ Get the interface name.
+
+ :param dut_node: Node to get the interface name on.
+ :param dut_interface: Interface key.
+ :type dut_node: dict
+ :type dut_interface: str
+ :returns: Interface name.
+ :rtype: str
+ """
+ mac = Topology.get_interface_mac(dut_node, dut_interface)
+ cmd = 'ifconfig -a | grep {0}'.format(mac)
+ (stdout, _) = exec_cmd_no_error(dut_node, cmd)
+ interface_name = stdout.split(' ', 1)[0]
+ return interface_name
+
+ @staticmethod
+ def set_dmm_interface_address(dut_node, ifname, ip_addr, ip4_prefix):
+ """
+ Flush ip, set ip, set interface up.
+
+ :param dut_node: Node to set the interface address on.
+ :param ifname: Interface name.
+ :param ip_addr: IP address to configure.
+ :param ip4_prefix: Prefix length.
+ :type dut_node: dict
+ :type ifname: str
+ :type ip_addr: str
+ :type ip4_prefix: int
+ """
+ cmd = 'sudo ip -4 addr flush dev {}'.format(ifname)
+ exec_cmd_no_error(dut_node, cmd)
+ cmd = 'sudo ip addr add {}/{} dev {}'\
+ .format(ip_addr, ip4_prefix, ifname)
+ exec_cmd_no_error(dut_node, cmd)
+ cmd = 'sudo ip link set {0} up'.format(ifname)
+ exec_cmd_no_error(dut_node, cmd)