fb6f4dc79176300fb4b437d8bef58977259a2337
[csit.git] / resources / libraries / python / DPDK / TestpmdCheck.py
1 # Copyright (c) 2022 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 from resources.libraries.python.Constants import Constants
15 from resources.libraries.python.ssh import exec_cmd_no_error
16 from resources.libraries.python.topology import NodeType
17
18
19 class TestpmdCheck:
20     """Test the DPDK testpmd is ready."""
21
22     @staticmethod
23     def check_testpmd(node):
24         """
25         Execute the testpmd check on the DUT node.
26
27         :param node: DUT node.
28         :type node: dict
29         :raises RuntimeError: If the script "check_testpmd.sh" fails.
30         """
31         if node[u"type"] == NodeType.DUT:
32             command = f"{Constants.REMOTE_FW_DIR}/{Constants.RESOURCES_LIB_SH}"\
33                 f"/entry/check_testpmd.sh"
34             message = f"Failed to check testpmd state at node {node['host']}"
35             exec_cmd_no_error(node, command, timeout=1800, message=message)