fa2f879492f701732f0130a44c1c8817b14edf7d
[csit.git] / resources / libraries / python / DPDK / L2fwdTest.py
1 # Copyright (c) 2016 Cisco and/or its affiliates.
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:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
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.
13
14
15 """
16 This module exists to provide the l2fwd test for DPDK on topology nodes.
17 """
18
19 from resources.libraries.python.ssh import SSH
20 from resources.libraries.python.constants import Constants as con
21
22 class L2fwdTest(object):
23     """Test the DPDK l2fwd performance."""
24
25     @staticmethod
26     def start_the_l2fwd_test(dut_node, cpu_coremask, nb_cores, queue_nums,
27                              jumbo_frames):
28         """
29         Execute the l2fwd on the dut_node.
30
31         :param dut_node: Will execute the l2fwd on this node.
32         :param cpu_coremask: The DPDK run core mask.
33         :param nb_cores: The cores number for the forwarding.
34         :param queue_nums: The queues number for the NIC.
35         :param jumbo_frames: Is jumbo frames or not.
36         :type dut_node: dict
37         :type cpu_coremask: str
38         :type nb_cores: str
39         :type queue_nums: str
40         :type jumbo_frames: str
41         :returns: none
42         """
43         ssh = SSH()
44         ssh.connect(dut_node)
45
46         cmd = 'cd {0}/dpdk-tests/dpdk_scripts/ && sudo ./run_l2fwd.sh ' \
47               '{1} {2} {3} {4}'.format(con.REMOTE_FW_DIR, cpu_coremask, \
48               nb_cores, queue_nums, jumbo_frames)
49
50         (ret_code, _, _) = ssh.exec_command(cmd, timeout=600)
51         if ret_code != 0:
52             raise Exception('Failed to execute l2fwd test at node {0}'
53                             .format(dut_node['host']))
54