CSIT-1451: PapiHistory 15/18015/13
authorTibor Frank <tifrank@cisco.com>
Tue, 5 Mar 2019 09:08:30 +0000 (10:08 +0100)
committerTibor Frank <tifrank@cisco.com>
Wed, 6 Mar 2019 15:08:55 +0000 (16:08 +0100)
Change-Id: Idb51f377fe0c196fbe24aab21c294dad595adcd2
Signed-off-by: Tibor Frank <tifrank@cisco.com>
12 files changed:
resources/libraries/python/PapiExecutor.py
resources/libraries/python/PapiHistory.py [new file with mode: 0644]
resources/libraries/python/VatExecutor.py
resources/libraries/python/VatHistory.py [deleted file]
resources/libraries/robot/performance/performance_setup.robot
resources/libraries/robot/shared/default.robot
tests/nsh_sfc/func/classifier/eth2p-ethip4-sfc-classifier-func.robot
tests/nsh_sfc/func/proxy/eth2p-ethip4-nsh-proxy-inbound-func.robot
tests/nsh_sfc/func/proxy/eth2p-ethip4-nsh-proxy-outbound-func.robot
tests/nsh_sfc/func/sff/eth2p-ethip4-sfc-sff-func.robot
tests/vpp/func/ip4/eth2p-ethip4-ip4base-func.robot
tests/vpp/func/ip6/eth2p-ethip6-ip6base-func.robot

index 0313284..928144e 100644 (file)
@@ -20,12 +20,10 @@ from robot.api import logger
 
 from resources.libraries.python.Constants import Constants
 from resources.libraries.python.ssh import SSH, SSHTimeout
+from resources.libraries.python.PapiHistory import PapiHistory
 
 __all__ = ["PapiExecutor", "PapiResponse"]
 
-# TODO: Implement Papi History
-# from resources.libraries.python.PapiHistory import PapiHistory
-
 
 class PapiResponse(object):
     """Class for metadata specifying the Papi reply, stdout, stderr and return
@@ -148,6 +146,7 @@ class PapiExecutor(object):
         :returns: self, so that method chaining is possible.
         :rtype: PapiExecutor
         """
+        PapiHistory.add_to_papi_history(self._node, command, **kwargs)
         self._api_command_list.append(dict(api_name=command, api_args=kwargs))
         return self
 
diff --git a/resources/libraries/python/PapiHistory.py b/resources/libraries/python/PapiHistory.py
new file mode 100644 (file)
index 0000000..13c483b
--- /dev/null
@@ -0,0 +1,102 @@
+# Copyright (c) 2019 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 PAPI command history setup library."""
+
+from robot.api import logger
+
+from resources.libraries.python.topology import NodeType, DICT__nodes
+
+__all__ = ["DICT__DUTS_PAPI_HISTORY", "PapiHistory"]
+
+
+DICT__DUTS_PAPI_HISTORY = dict()
+
+
+class PapiHistory(object):
+    """Contains methods to set up DUT PAPI command history.
+    """
+
+    @staticmethod
+    def reset_papi_history(node):
+        """Reset PAPI command history for DUT node.
+
+        :param node: DUT node to reset PAPI command history for.
+        :type node: dict
+        """
+        DICT__DUTS_PAPI_HISTORY[node['host']] = list()
+
+    @staticmethod
+    def reset_papi_history_on_all_duts(nodes):
+        """Reset PAPI command history for all DUT nodes.
+
+        :param nodes: Nodes to reset PAPI command history for.
+        :type nodes: dict
+        """
+        for node in nodes.values():
+            if node['type'] == NodeType.DUT:
+                PapiHistory.reset_papi_history(node)
+
+    @staticmethod
+    def add_to_papi_history(node, cmd, papi=True, **kwargs):
+        """Add command to PAPI command history on DUT node.
+
+        :param node: DUT node to add command to PAPI command history for.
+        :param cmd: Command to be added to PAPI command history.
+        :param papi: Says if the command to store is PAPi or VAT. Remove when
+            VAT executor is completely removed.
+        :param kwargs: Optional key-value arguments.
+        :type node: dict
+        :type cmd: str
+        :type papi: bool
+        :type kwargs: dict
+        """
+        if papi:
+            args = list()
+            for key, val in kwargs.iteritems():
+                args.append("{key}={val}".format(key=key, val=val))
+            item = "{cmd}({args})".format(cmd=cmd, args=",".join(args))
+        else:
+            # This else part is here to store VAT commands.
+            # VAT history is not used.
+            # TODO: Remove when VatExecutor is completely removed.
+            item = "{cmd}".format(cmd=cmd)
+        DICT__DUTS_PAPI_HISTORY[node['host']].append(item)
+
+    @staticmethod
+    def show_papi_history(node):
+        """Show PAPI command history for DUT node.
+
+        :param node: DUT node to show PAPI command history for.
+        :type node: dict
+        """
+        history = "\nNo PAPI command executed"
+        if DICT__DUTS_PAPI_HISTORY[node['host']]:
+            history = "".join(["\n{}".format(
+                cmd) for cmd in DICT__DUTS_PAPI_HISTORY[node['host']]])
+        logger.trace(
+            "{0} PAPI command history:\n{1}\n".format(node['host'], history))
+
+    @staticmethod
+    def show_papi_history_on_all_duts(nodes):
+        """Show PAPI command history for all DUT nodes.
+
+        :param nodes: Nodes to show PAPI command history for.
+        :type nodes: dict
+        """
+        for node in nodes.values():
+            if node['type'] == NodeType.DUT:
+                PapiHistory.show_papi_history(node)
+
+
+PapiHistory.reset_papi_history_on_all_duts(DICT__nodes)
index 0e40266..c13e990 100644 (file)
@@ -21,7 +21,7 @@ from robot.api import logger
 
 from resources.libraries.python.ssh import SSH, SSHTimeout
 from resources.libraries.python.Constants import Constants
-from resources.libraries.python.VatHistory import VatHistory
+from resources.libraries.python.PapiHistory import PapiHistory
 
 __all__ = ['VatExecutor']
 
@@ -109,7 +109,9 @@ class VatExecutor(object):
             remote_file_path = vat_name
             with open(vat_name, 'r') as vat_file:
                 for line in vat_file:
-                    VatHistory.add_to_vat_history(node, line.replace('\n', ''))
+                    PapiHistory.add_to_papi_history(node,
+                                                    line.replace('\n', ''),
+                                                    papi=False)
         else:
             remote_file_path = '{0}/{1}/{2}'.format(Constants.REMOTE_FW_DIR,
                                                     Constants.RESOURCES_TPL_VAT,
@@ -283,7 +285,7 @@ class VatTerminal(object):
         :returns: Command output in python representation of JSON format or
             None if not in JSON mode.
         """
-        VatHistory.add_to_vat_history(self._node, cmd)
+        PapiHistory.add_to_papi_history(self._node, cmd, papi=False)
         logger.debug("Executing command in VAT terminal: {0}".format(cmd))
         try:
             out = self._ssh.interactive_terminal_exec_command(self._tty, cmd,
diff --git a/resources/libraries/python/VatHistory.py b/resources/libraries/python/VatHistory.py
deleted file mode 100644 (file)
index ffc1644..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-# 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):
-    """Setup VAT history for DUT nodes.
-
-    :param nodes: DUT nodes to setup VAT history for.
-    :type nodes: dict
-    """
-    duts_vat_history = {}
-    try:
-        for node in nodes.values():
-            if node['type'] == NodeType.DUT:
-                duts_vat_history[node['host']] = []
-        return duts_vat_history
-    except AttributeError:
-        # Necessary for the generation of source code documentation.
-        pass
-
-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 DICT__DUTS_VAT_HISTORY[node['host']]:
-                sequence = "".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)
index 1264d44..c155b07 100644 (file)
 | Set up performance test
 | | [Documentation] | Common test setup for performance tests.
 | | ...
-| | Reset VAT History On All DUTs | ${nodes}
+| | Reset PAPI History On All DUTs | ${nodes}
 | | Create base startup configuration of VPP on all DUTs
 
 | Set up tcp performance test
 | | [Documentation] | Common test setup for TCP performance tests.
 | | ...
-| | Reset VAT History On All DUTs | ${nodes}
+| | Reset PAPI History On All DUTs | ${nodes}
 | | Create base startup configuration of VPP for TCP tests on all DUTs
 
 | Set up performance test with Ligato Kubernetes
 | | [Documentation] | Common test teardown for performance tests.
 | | ...
 | | Remove All Added Ports On All DUTs From Topology | ${nodes}
-| | Show VAT History On All DUTs | ${nodes}
+| | Show PAPI History On All DUTs | ${nodes}
 | | Get Core Files on All Nodes | ${nodes}
 | | Set Test Variable | ${pkt_trace} | ${True}
 
index b5242bd..91fde22 100644 (file)
@@ -13,7 +13,7 @@
 
 *** Settings ***
 | Variables | resources/libraries/python/topology.py
-| Variables | resources/libraries/python/VatHistory.py
+| Variables | resources/libraries/python/PapiHistory.py
 | ...
 | Library | Collections
 | Library | OperatingSystem
@@ -26,7 +26,7 @@
 | Library | resources.libraries.python.SchedUtils
 | Library | resources.libraries.python.Tap
 | Library | resources.libraries.python.TGSetup
-| Library | resources.libraries.python.VatHistory
+| Library | resources.libraries.python.PapiHistory
 | Library | resources.libraries.python.VppCounters
 | Library | resources.libraries.python.VPPUtil
 | Library | resources.libraries.python.Trace
 | | Save VPP PIDs
 | | Configure all TGs for traffic script
 | | Update All Interface Data On All Nodes | ${nodes}
-| | Reset VAT History On All DUTs | ${nodes}
+| | Reset PAPI History On All DUTs | ${nodes}
 
 | Tear down functional test
 | | [Documentation] | Common test teardown for functional tests.
 | | ...
 | | Remove All Added Ports On All DUTs From Topology | ${nodes}
 | | Show Packet Trace on All DUTs | ${nodes}
-| | Show VAT History On All DUTs | ${nodes}
+| | Show PAPI History On All DUTs | ${nodes}
 | | Vpp Show Errors On All DUTs | ${nodes}
 | | Verify VPP PID in Teardown
 
 | | Save VPP PIDs
 | | Configure all TGs for traffic script
 | | Update All Interface Data On All Nodes | ${nodes} | skip_tg_udev=${True}
-| | Reset VAT History On All DUTs | ${nodes}
+| | Reset PAPI History On All DUTs | ${nodes}
 
 | Tear down VPP device test
 # TODO: Generalize this KW if it will not diverge from Functional derivate too
 | | ...
 | | Remove All Added Ports On All DUTs From Topology | ${nodes}
 | | Show Packet Trace on All DUTs | ${nodes}
-| | Show VAT History On All DUTs | ${nodes}
+| | Show PAPI History On All DUTs | ${nodes}
 | | Vpp Show Errors On All DUTs | ${nodes}
 | | Verify VPP PID in Teardown
 
 | | ...
 | | Remove All Added Ports On All DUTs From Topology | ${nodes}
 | | Show Packet Trace on All DUTs | ${nodes}
-| | Show VAT History On All DUTs | ${nodes}
+| | Show PAPI History On All DUTs | ${nodes}
 | | Show Vpp Settings | ${nodes['DUT1']}
 | | Show Vpp Settings | ${nodes['DUT2']}
 | | Vpp Show Errors On All DUTs | ${nodes}
 | | ...
 | | Remove All Added Ports On All DUTs From Topology | ${nodes}
 | | Show Packet Trace on All DUTs | ${nodes}
-| | Show VAT History On All DUTs | ${nodes}
+| | Show PAPI History On All DUTs | ${nodes}
 | | Show Vpp Settings | ${nodes['DUT1']}
 | | Show Vpp Settings | ${nodes['DUT2']}
 | | Vpp Show Errors On All DUTs | ${nodes}
index 5bf5934..184715e 100644 (file)
 | ... | Update All Interface Data On All Nodes | ${nodes} | AND
 | ... | Setup DUT nodes for 'Classifier' functional testing
 | Test Setup | Run Keywords | Save VPP PIDs | AND
-| ... | Reset VAT History On All DUTs | ${nodes} | AND
+| ... | Reset PAPI History On All DUTs | ${nodes} | AND
 | ... | Clear interface counters on all vpp nodes in topology | ${nodes}
 | Test Teardown | Run Keywords
 | ... | Show packet trace on all DUTs | ${nodes} | AND
-| ... | Show VAT History On All DUTs | ${nodes} | AND
+| ... | Show PAPI History On All DUTs | ${nodes} | AND
 | ... | Verify VPP PID in Teardown
 | Documentation | *NSH SFC Classifier test cases*
 | ...
index fd34690..9733576 100644 (file)
 | ... | Update All Interface Data On All Nodes | ${nodes} | AND
 | ... | Setup DUT nodes for 'Proxy Inbound' functional testing
 | Test Setup | Run Keywords | Save VPP PIDs | AND
-| ... | Reset VAT History On All DUTs | ${nodes} | AND
+| ... | Reset PAPI History On All DUTs | ${nodes} | AND
 | ... | Clear interface counters on all vpp nodes in topology | ${nodes}
 | Test Teardown | Run Keywords
 | ... | Show packet trace on all DUTs | ${nodes} | AND
-| ... | Show VAT History On All DUTs | ${nodes} | AND
+| ... | Show PAPI History On All DUTs | ${nodes} | AND
 | ... | Verify VPP PID in Teardown
 | Documentation | *NSH SFC Proxy Inbound test cases*
 | ...
index b5f167a..8bddfc9 100644 (file)
 | ... | Update All Interface Data On All Nodes | ${nodes} | AND
 | ... | Setup DUT nodes for 'Proxy Outbound' functional testing
 | Test Setup | Run Keywords | Save VPP PIDs | AND
-| ... | Reset VAT History On All DUTs | ${nodes} | AND
+| ... | Reset PAPI History On All DUTs | ${nodes} | AND
 | ... | Clear interface counters on all vpp nodes in topology | ${nodes}
 | Test Teardown | Run Keywords
 | ... | Show packet trace on all DUTs | ${nodes} | AND
-| ... | Show VAT History On All DUTs | ${nodes} | AND
+| ... | Show PAPI History On All DUTs | ${nodes} | AND
 | ... | Verify VPP PID in Teardown
 | Documentation | *NSH SFC Proxy Outbound test cases*
 | ...
index 77a1d0e..382436a 100644 (file)
 | ... | Update All Interface Data On All Nodes | ${nodes} | AND
 | ... | Setup DUT nodes for 'SFF' functional testing
 | Test Setup | Run Keywords | Save VPP PIDs | AND
-| ... | Reset VAT History On All DUTs | ${nodes} | AND
+| ... | Reset PAPI History On All DUTs | ${nodes} | AND
 | ... | Clear interface counters on all vpp nodes in topology | ${nodes}
 | Test Teardown | Run Keywords
 | ... | Show packet trace on all DUTs | ${nodes} | AND
-| ... | Show VAT History On All DUTs | ${nodes} | AND
+| ... | Show PAPI History On All DUTs | ${nodes} | AND
 | ... | Verify VPP PID in Teardown
 | Documentation | *NSH SFC SFF test cases*
 | ...
index a8fb58d..5262fa1 100644 (file)
 | ... | Update All Interface Data On All Nodes | ${nodes} | AND
 | ... | Configure DUT nodes for IPv4 testing
 | Test Setup | Run Keywords | Save VPP PIDs | AND
-| ... | Reset VAT History On All DUTs | ${nodes} | AND
+| ... | Reset PAPI History On All DUTs | ${nodes} | AND
 | ... | Clear interface counters on all vpp nodes in topology | ${nodes}
 | Test Teardown | Run Keywords
 | ... | Show packet trace on all DUTs | ${nodes} | AND
-| ... | Show VAT History On All DUTs | ${nodes} | AND
+| ... | Show PAPI History On All DUTs | ${nodes} | AND
 | ... | Verify VPP PID in Teardown
 | Documentation | *IPv4 routing test cases*
 | ...
index bd0b2a6..d4b7939 100644 (file)
 | ... | Configure IPv6 routing on all DUTs | ${nodes} | ${nodes_ipv6_addr} | AND
 | ... | Configure all TGs for traffic script
 | Test Setup | Run Keywords | Save VPP PIDs | AND
-| ... | Reset VAT History On All DUTs | ${nodes} | AND
+| ... | Reset PAPI History On All DUTs | ${nodes} | AND
 | ... | Clear interface counters on all vpp nodes in topology | ${nodes}
 | Test Teardown | Run Keywords
 | ... | Show packet trace on all DUTs | ${nodes} | AND
-| ... | Show VAT History On All DUTs | ${nodes}  | AND
+| ... | Show PAPI History On All DUTs | ${nodes} | AND
 | ... | Verify VPP PID in Teardown
 | Documentation | *IPv6 routing test cases*
 | ...