1 # Copyright (c) 2018 Huawei Technologies Co.,Ltd.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
16 This module exists to provide the vs_epoll ping test for DMM on topology nodes.
20 from resources.libraries.python.ssh import SSH
21 from resources.libraries.python.DMM.DMMConstants import DMMConstants as con
22 from resources.libraries.python.topology import Topology
23 from robot.api import logger
25 class SingleCliSer(object):
26 """Test the DMM vs_epoll ping function."""
29 def exec_the_base_vs_epoll_test(dut1_node, dut2_node):
30 """Execute the vs_epoll on the dut1_node.
32 :param dut1_node: Will execute the vs_epoll on this node.
33 :param dut2_node: Will execute the vc_epoll on this node.
36 :returns: positive value if packets are sent and received
37 :raises RuntimeError:If failed to execute vs_epoll test on dut1_node.
39 dut1_ip = Topology.get_node_hostname(dut1_node)
40 dut2_ip = Topology.get_node_hostname(dut2_node)
43 ssh.connect(dut1_node)
45 cmd = 'cd {0}/{1} && ./run_dmm.sh {2} {3} {4} ' \
46 .format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS, dut1_ip, dut2_ip, 0)
48 cmd += '2>&1 | tee log_run_dmm.txt &'
50 (ret_code, _, _) = ssh.exec_command(cmd, timeout=6000)
52 raise RuntimeError('Failed to execute vs_epoll test at node {0}'
53 .format(dut1_node['host']))
58 ssh.connect(dut2_node)
60 cmd = 'cd {0}/{1} && ./run_dmm.sh {2} {3} {4} ' \
61 .format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS, dut1_ip, dut2_ip, 1)
63 cmd += '2>&1 | tee log_run_dmm.txt'
65 (ret_code, stdout_cli, _) = ssh.exec_command(cmd, timeout=6000)
67 raise RuntimeError('Failed to execute vs_epoll test at node {0}'
68 .format(dut1_node['host']))
70 return stdout_cli.find("send 50000")
73 def get_the_test_result(dut_node):
75 After executing exec_the_base_vs_epoll_test, use this
76 to get the test result
78 :param dut_node: will get the test result in this dut node
82 :raises RuntimeError: If failed to get the test result.
86 cmd = 'cat {0}/{1}/log_run_dmm.txt | grep "send 50000" | wc -l' \
87 .format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS)
89 (ret_code, stdout, _) = ssh.exec_command(cmd, timeout=100)
91 raise RuntimeError('Failed to get test result at node {0}'
92 .format(dut_node['host']))
97 def echo_dmm_logs(dut_node):
103 ssh.connect(dut_node)
104 cmd = 'cat {0}/{1}/log_install_dmm.txt' \
105 .format(con.REMOTE_FW_DIR, con.DMM_SCRIPTS)
107 (ret_code, stdout, _) = ssh.exec_command(cmd, timeout=100)
109 raise RuntimeError('Failed to get log_install_dmm at node {0}'
110 .format(dut_node['host']))
112 logger.console('....log_install_dmm on node {1}.... {0}'
113 .format(stdout, dut_node['host']))