aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorJan Gelety <jgelety@cisco.com>2017-02-08 12:51:31 +0100
committerPeter Mikus <pmikus@cisco.com>2017-02-13 12:45:08 +0000
commit44dc1d4781470b722c5f7d5adb197ace96b96db3 (patch)
treed4eed5a5634d5af73d7d039adff6f3d1816c96a1 /resources
parentc29c69bb91057e4217952602cda71e6a85fd13b6 (diff)
Introduce simple VAT history per test case
- print list of VAT commands executed per DUT node during the test case in the func test teardown Change-Id: I18a750ebfb7560eff9f5c4f0826ef84c3f64b4a8 Signed-off-by: Jan Gelety <jgelety@cisco.com>
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/python/VatExecutor.py7
-rw-r--r--resources/libraries/python/VatHistory.py93
-rw-r--r--resources/libraries/robot/default.robot5
3 files changed, 102 insertions, 3 deletions
diff --git a/resources/libraries/python/VatExecutor.py b/resources/libraries/python/VatExecutor.py
index bbce83d1ad..5f7e188b7f 100644
--- a/resources/libraries/python/VatExecutor.py
+++ b/resources/libraries/python/VatExecutor.py
@@ -19,6 +19,7 @@ from robot.api import logger
from resources.libraries.python.ssh import SSH
from resources.libraries.python.constants import Constants
+from resources.libraries.python.VatHistory import VatHistory
__all__ = ['VatExecutor']
@@ -162,8 +163,9 @@ class VatTerminal(object):
def __init__(self, node, json_param=True):
json_text = ' json' if json_param else ''
self.json = json_param
+ self._node = node
self._ssh = SSH()
- self._ssh.connect(node)
+ self._ssh.connect(self._node)
self._tty = self._ssh.interactive_terminal_open()
self._ssh.interactive_terminal_exec_command(
self._tty,
@@ -185,6 +187,7 @@ class VatTerminal(object):
:return: Command output in python representation of JSON format or
None if not in JSON mode.
"""
+ VatHistory.add_to_vat_history(self._node, cmd)
logger.debug("Executing command in VAT terminal: {}".format(cmd))
try:
out = self._ssh.interactive_terminal_exec_command(self._tty, cmd,
@@ -217,7 +220,7 @@ class VatTerminal(object):
def vat_terminal_close(self):
"""Close VAT terminal."""
- #interactive terminal is dead, we only need to close session
+ # interactive terminal is dead, we only need to close session
if not self._exec_failure:
self._ssh.interactive_terminal_exec_command(self._tty,
'quit',
diff --git a/resources/libraries/python/VatHistory.py b/resources/libraries/python/VatHistory.py
new file mode 100644
index 0000000000..caa3de50f2
--- /dev/null
+++ b/resources/libraries/python/VatHistory.py
@@ -0,0 +1,93 @@
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""DUT VAT command history setup library."""
+
+from robot.api import logger
+
+from resources.libraries.python.topology import NodeType, DICT__nodes
+
+__all__ = ["DICT__duts_vat_history", "VatHistory"]
+
+
+def setup_vat_history(nodes):
+ duts_vat_history = {}
+ for node in nodes.values():
+ if node['type'] == NodeType.DUT:
+ duts_vat_history[node['host']] = []
+ return duts_vat_history
+
+DICT__duts_vat_history = setup_vat_history(DICT__nodes)
+
+
+class VatHistory(object):
+ """Contains methods to set up DUT VAT command history."""
+
+ @staticmethod
+ def reset_vat_history(node):
+ """Reset VAT command history for DUT node.
+
+ :param node: DUT node to reset VAT command history for.
+ :type node: dict
+ """
+ if node['type'] == NodeType.DUT:
+ DICT__duts_vat_history[node['host']] = []
+
+ @staticmethod
+ def reset_vat_history_on_all_duts(nodes):
+ """Reset VAT command history for all DUT nodes.
+
+ :param nodes: Nodes to reset VAT command history for.
+ :type nodes: dict
+ """
+ for node in nodes.values():
+ if node['type'] == NodeType.DUT:
+ VatHistory.reset_vat_history(node)
+
+ @staticmethod
+ def show_vat_history(node):
+ """Show VAT command history for DUT node.
+
+ :param node: DUT node to show VAT command history for.
+ :type node: dict
+ """
+ if node['type'] == NodeType.DUT:
+ sequence = "\nno VAT command executed"\
+ if len(DICT__duts_vat_history[node['host']]) == 0\
+ else "".join("\n{}".format(cmd)
+ for cmd in DICT__duts_vat_history[node['host']])
+ logger.trace("{0} VAT command history:{1}\n".
+ format(node['host'], sequence))
+
+ @staticmethod
+ def show_vat_history_on_all_duts(nodes):
+ """Show VAT command history for all DUT nodes.
+
+ :param nodes: Nodes to show VAT command history for.
+ :type nodes: dict
+ """
+ for node in nodes.values():
+ if node['type'] == NodeType.DUT:
+ VatHistory.show_vat_history(node)
+
+ @staticmethod
+ def add_to_vat_history(node, cmd):
+ """Add command to VAT command history on DUT node.
+
+ :param node: DUT node to add command to VAT command history for.
+ :param cmd: Command to be added to VAT command history.
+ :type node: dict
+ :type cmd: str
+ """
+ if node['type'] == NodeType.DUT:
+ DICT__duts_vat_history[node['host']].append(cmd)
diff --git a/resources/libraries/robot/default.robot b/resources/libraries/robot/default.robot
index 29934ade2d..f8dda1721e 100644
--- a/resources/libraries/robot/default.robot
+++ b/resources/libraries/robot/default.robot
@@ -13,7 +13,9 @@
*** Settings ***
| Variables | resources/libraries/python/topology.py
+| Variables | resources/libraries/python/VatHistory.py
| Library | resources.libraries.python.topology.Topology
+| Library | resources.libraries.python.VatHistory
| Library | resources.libraries.python.CpuUtils
| Library | resources.libraries.python.DUTSetup
| Library | resources.libraries.python.SchedUtils
@@ -234,11 +236,12 @@
| | Save VPP PIDs
| | Setup all TGs before traffic script
| | Update All Interface Data On All Nodes | ${nodes}
+| | Reset VAT History On All DUTs | ${nodes}
| Func Test Teardown
| | [Documentation] | Common test teardown for functional tests.
| | ...
| | Show Packet Trace on All DUTs | ${nodes}
-| | Show vpp trace dump on all DUTs
+| | Show VAT History On All DUTs | ${nodes}
| | Vpp Show Errors On All DUTs | ${nodes}
| | Check VPP PID in Teardown