aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries')
-rw-r--r--resources/libraries/python/DMM/DMMConstants.py5
-rw-r--r--resources/libraries/python/DMM/SetupDMMTest.py6
-rw-r--r--resources/libraries/python/DMM/SingleCliSer.py292
3 files changed, 178 insertions, 125 deletions
diff --git a/resources/libraries/python/DMM/DMMConstants.py b/resources/libraries/python/DMM/DMMConstants.py
index ec6f192bf3..265320a1d8 100644
--- a/resources/libraries/python/DMM/DMMConstants.py
+++ b/resources/libraries/python/DMM/DMMConstants.py
@@ -20,7 +20,10 @@ class DMMConstants(object):
REMOTE_FW_DIR = '/tmp/DMM-testing'
# Shell scripts location
- DMM_SCRIPTS = 'tests/dmm/dmm_scripts'
+ DMM_SCRIPTS = 'dmm/scripts/csit/'
+
+ # Run scripts location
+ DMM_RUN_SCRIPTS = 'dmm/scripts/csit/run'
# Libraries location
DMM_DEPLIBS = 'tests/dmm/dmm_deplibs'
diff --git a/resources/libraries/python/DMM/SetupDMMTest.py b/resources/libraries/python/DMM/SetupDMMTest.py
index 7bb596546c..993e11924e 100644
--- a/resources/libraries/python/DMM/SetupDMMTest.py
+++ b/resources/libraries/python/DMM/SetupDMMTest.py
@@ -95,7 +95,7 @@ def install_dmm_test(node):
"""
arch = Topology.get_node_arch(node)
- logger.console('Install the DMM on {0} ({1})'.format(node['host'], arch))
+ logger.console('Install DMM on {0} ({1})'.format(node['host'], arch))
ssh = SSH()
ssh.connect(node)
@@ -105,10 +105,10 @@ def install_dmm_test(node):
.format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS, arch), timeout=600)
if ret_code != 0:
- logger.error('Install the DMM error: {0}'.format(stderr))
+ logger.error('Install DMM error: {0}'.format(stderr))
raise RuntimeError('Install prereq failed')
else:
- logger.console('Install prereq on {0} success!'.format(node['host']))
+ logger.console('Install DMM on {0} success!'.format(node['host']))
def setup_node(args):
"""Run all set-up methods for a node.
diff --git a/resources/libraries/python/DMM/SingleCliSer.py b/resources/libraries/python/DMM/SingleCliSer.py
index e96843ac36..89ac10f923 100644
--- a/resources/libraries/python/DMM/SingleCliSer.py
+++ b/resources/libraries/python/DMM/SingleCliSer.py
@@ -13,158 +13,230 @@
"""
-This module exists to provide the vs_epoll ping test for DMM on topology nodes.
+This module exists to provide single client-server test for DMM
+on topology nodes.
"""
import time
+import os
+import glob
-from resources.libraries.python.ssh import exec_cmd_no_error
+from resources.libraries.python.ssh import exec_cmd, exec_cmd_no_error
from resources.libraries.python.DMM.DMMConstants import DMMConstants as con
from resources.libraries.python.topology import Topology
class SingleCliSer(object):
- """Test the DMM vs_epoll ping function."""
+ """Test DMM with single client-server topology."""
@staticmethod
- def exec_the_base_vs_epoll_test(dut1_node, dut2_node,
- dut1_if_name, dut2_if_name,
- dut1_if_ip, dut2_if_ip):
+ 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)
+
+ @staticmethod
+ def setup_dmm_dut(dut1_node, dut2_node, dut1_if_name, dut2_if_name,
+ script_name, dut1_ip, dut2_ip, prefix_len):
"""
- Perform base vs_epoll test on DUT's.
+ Setup DMM on DUT nodes.
- :param dut1_node: Node to execute vs_epoll on.
- :param dut2_node: Node to execute vc_common on.
+ :param dut1_node: Node to setup DMM on.
+ :param dut2_node: Node to setup DMM 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.
+ :param script_name: Name of the script to run.
+ :param dut1_ip: IP address to configure on DUT1.
+ :param dut2_ip: IP address to configure on DUT2.
+ :param prefix_len: Prefix length.
: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
+ :type script_name: str
+ :type dut1_ip: str
+ :type dut2_ip: str
+ :type prefix_len: int
"""
- 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 &'
- exec_cmd_no_error(dut1_node, cmd)
- time.sleep(10)
+ SingleCliSer.set_dmm_interface_address(dut1_node, dut1_if_name,
+ dut1_ip, prefix_len)
+ SingleCliSer.set_dmm_interface_address(dut2_node, dut2_if_name,
+ dut2_ip, prefix_len)
+ cmd = 'cd {0}/{1} && ./{2} setup 0 {3} {4} {5}'\
+ .format(con.REMOTE_FW_DIR, con.DMM_RUN_SCRIPTS, script_name,
+ dut1_if_name, dut1_ip, dut2_ip)
+ exec_cmd(dut1_node, cmd)
- 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'
- exec_cmd_no_error(dut2_node, cmd)
+ cmd = 'cd {0}/{1} && ./{2} setup 1 {3} {4} {5}'\
+ .format(con.REMOTE_FW_DIR, con.DMM_RUN_SCRIPTS, script_name,
+ dut2_if_name, dut1_ip, dut2_ip)
+ exec_cmd(dut2_node, cmd)
@staticmethod
- def get_the_test_result(dut_node):
+ def execute_test(dut1_node, dut2_node, dut1_if_name, dut2_if_name,
+ script_name, dut1_ip, dut2_ip):
"""
- After executing exec_the_base_vs_epoll_test, use this
- to get the test result.
+ Run the given test case.
- :param dut_node: Node to get the test result on.
- :type dut_node: dict
- :returns: Word count of "send 50000" in the log.
- :rtype: str
- """
- cmd = 'cat {0}/{1}/log_run_dmm.txt | grep "send 50000" | wc -l' \
- .format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS)
- (stdout, _) = exec_cmd_no_error(dut_node, cmd)
- return stdout
-
- @staticmethod
- def echo_dmm_logs(dut_node):
- """
- Get the prerequisites installation log from DUT.
-
- :param dut_node: Node to get the installation log on.
- :type dut_node: dict
- """
- 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_node: Node to run an app with DMM on.
+ :param dut2_node: Node to run an app with DMM 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.
+ :param script_name: Name of the script to run.
+ :param dut1_ip: DUT1 IP address.
+ :param dut2_ip: DUT2 IP address.
: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
+ :type script_name: str
+ :type dut1_ip: str
+ :type dut2_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)
+ cmd = 'cd {0}/{1} && ./{2} run 0 {3} {4} {5} ' \
+ .format(con.REMOTE_FW_DIR, con.DMM_RUN_SCRIPTS, script_name,
+ dut1_if_name, dut1_ip, dut2_ip)
+ cmd += '2>&1 | tee log_{0}.txt &'.format(script_name)
+ exec_cmd(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)
-
- cmd += '2>&1 | tee log_run_dmm_with_lwip.txt'
- exec_cmd_no_error(dut2_node, cmd)
+ cmd = 'cd {0}/{1} && ./{2} run 1 {3} {4} {5} ' \
+ .format(con.REMOTE_FW_DIR, con.DMM_RUN_SCRIPTS, script_name,
+ dut2_if_name, dut1_ip, dut2_ip)
+ cmd += '2>&1 | tee log_{0}.txt'.format(script_name)
+ exec_cmd(dut2_node, cmd)
@staticmethod
- def get_lwip_test_result(dut_node):
+ def verify_test_result(dut1_node, dut2_node, script_name):
"""
- After executing exec_the_base_lwip_test, use this
- to get the test result.
+ Verify the test and return result.
- :param dut_node: Node to get the test result on.
- :type dut_node: dict
- :returns: Word count of "send 50" in the log.
+ :param dut1_node: Node to verify test result on.
+ :param dut2_node: Node to verify test result on.
+ :param script_name: Name of the script to run.
+ :type dut1_node: dict
+ :type dut2_node: dict
+ :type script_name: str
+ :returns: test result PASS/FAIL.
: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)
+ cmd = 'cd {0}/{1} && ./{2} verify 0' \
+ .format(con.REMOTE_FW_DIR, con.DMM_RUN_SCRIPTS, script_name)
+ (_, stdout_ser, _) = exec_cmd(dut1_node, cmd)
- (stdout, _) = exec_cmd_no_error(dut_node, cmd)
- return stdout
+ cmd = 'cd {0}/{1} && ./{2} verify 1' \
+ .format(con.REMOTE_FW_DIR, con.DMM_RUN_SCRIPTS, script_name)
+ (_, stdout_cli, _) = exec_cmd(dut2_node, cmd)
+
+ if stdout_ser.find('DMM_CSIT_TEST_PASSED') != -1 \
+ and stdout_cli.find('DMM_CSIT_TEST_PASSED') != -1:
+ return "PASS"
+ else:
+ return "FAIL"
@staticmethod
- def echo_running_log(dut1_node, dut2_node):
+ def print_dmm_log(dut1_node, dut2_node, script_name):
"""
- Get the running log.
+ Print DMM logs.
- :param dut1_node: Node to get the running log on.
- :param dut2_node: Node to get the running log on.
+ :param dut1_node: Node to print DMM logs of.
+ :param dut2_node: Node to print DMM logs of.
+ :param script_name: Name of the script to run.
:type dut1_node: dict
:type dut2_node: dict
+ :type script_name: str
"""
- cmd = 'cat /var/log/nStack/running.log'
- exec_cmd_no_error(dut1_node, cmd)
- exec_cmd_no_error(dut2_node, cmd)
+ cmd = 'cd {0}/{1} && ./{2} log 0'\
+ .format(con.REMOTE_FW_DIR, con.DMM_RUN_SCRIPTS, script_name)
+ exec_cmd(dut1_node, cmd)
+
+ cmd = 'cd {0}/{1} && ./{2} log 1'\
+ .format(con.REMOTE_FW_DIR, con.DMM_RUN_SCRIPTS, script_name)
+ exec_cmd(dut2_node, cmd)
@staticmethod
- def echo_dpdk_log(dut1_node, dut2_node):
+ def cleanup_dmm_dut(dut1_node, dut2_node, script_name):
"""
- Get the dpdk log.
+ Cleanup DMM DUT node.
- :param dut1_node: Node to get the DPDK log on.
- :param dut2_node: Node to get the DPDK log on.
+ :param dut1_node: DMM node to be cleaned up.
+ :param dut2_node: DMM node to be cleaned up.
+ :param script_name: Name of the script to run.
:type dut1_node: dict
:type dut2_node: dict
+ :type script_name: str
"""
- cmd = 'cat /var/log/nstack-dpdk/nstack_dpdk.log'
- exec_cmd_no_error(dut1_node, cmd)
- exec_cmd_no_error(dut2_node, cmd)
+ cmd = 'cd {0}/{1} && ./{2} cleanup 0'\
+ .format(con.REMOTE_FW_DIR, con.DMM_RUN_SCRIPTS, script_name)
+ exec_cmd(dut1_node, cmd)
+ exec_cmd(dut2_node, cmd)
+ time.sleep(5)
+
+ @staticmethod
+ def run_dmm_func_test_cases(dut1_node, dut2_node, dut1_if_name,
+ dut2_if_name, dut1_ip, dut2_ip, prefix_len):
+ """
+ Execute all the functional test cases and return result.
+
+ :param dut1_node: Node to run an app with DMM on.
+ :param dut2_node: Node to run an app with DMM on.
+ :param dut1_if_name: DUT1 to DUT2 interface name.
+ :param dut2_if_name: DUT2 to DUT1 interface name.
+ :param dut1_ip: IP address to configure on DUT1.
+ :param dut2_ip: IP address to configure on DUT2.
+ :param prefix_len: Prefix length.
+ :type dut1_node: dict
+ :type dut2_node: dict
+ :type dut1_if_name: str
+ :type dut2_if_name: str
+ :type dut1_ip: str
+ :type dut2_ip: str
+ :type prefix_len: int
+ :returns: Total testcase count, Passed testcase count.
+ :rtype: tuple(int, int)
+ """
+ passed = 0
+ total = 0
+ failed = 0
+ path = '{0}/*'.format(con.DMM_RUN_SCRIPTS)
+ files = [os.path.basename(x) for x in glob.glob(path)]
+ print "list of files : {0}".format(files)
+
+ for name in files:
+ print("file name : {}").format(name)
+ total += 1
+ SingleCliSer.setup_dmm_dut(dut1_node, dut2_node, dut1_if_name,
+ dut2_if_name, name, dut1_ip, dut2_ip,
+ prefix_len)
+ SingleCliSer.execute_test(dut1_node, dut2_node, dut1_if_name,
+ dut2_if_name, name, dut1_ip, dut2_ip)
+ result = SingleCliSer.verify_test_result(dut1_node, dut2_node,
+ '{0}'.format(name))
+ if result == "PASS":
+ passed += 1
+ elif result == "FAIL":
+ failed += 1
+
+ SingleCliSer.print_dmm_log(dut1_node, dut2_node, name)
+ SingleCliSer.cleanup_dmm_dut(dut1_node, dut2_node, name)
+ print("TOTAL :{} PASSED : {} FAILED: {}").format\
+ (total, passed, failed)
+
+ return total, passed
@staticmethod
def dmm_get_interface_name(dut_node, dut_interface):
@@ -183,25 +255,3 @@ class SingleCliSer(object):
(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)