aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/python/PapiExecutor.py5
-rw-r--r--resources/libraries/python/PapiHistory.py102
-rw-r--r--resources/libraries/python/VatExecutor.py8
-rw-r--r--resources/libraries/python/VatHistory.py102
-rw-r--r--resources/libraries/robot/performance/performance_setup.robot6
-rw-r--r--resources/libraries/robot/shared/default.robot16
6 files changed, 120 insertions, 119 deletions
diff --git a/resources/libraries/python/PapiExecutor.py b/resources/libraries/python/PapiExecutor.py
index 0313284405..928144e058 100644
--- a/resources/libraries/python/PapiExecutor.py
+++ b/resources/libraries/python/PapiExecutor.py
@@ -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
index 0000000000..13c483b4bc
--- /dev/null
+++ b/resources/libraries/python/PapiHistory.py
@@ -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)
diff --git a/resources/libraries/python/VatExecutor.py b/resources/libraries/python/VatExecutor.py
index 0e40266f1c..c13e990b63 100644
--- a/resources/libraries/python/VatExecutor.py
+++ b/resources/libraries/python/VatExecutor.py
@@ -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
index ffc1644f1b..0000000000
--- a/resources/libraries/python/VatHistory.py
+++ /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)
diff --git a/resources/libraries/robot/performance/performance_setup.robot b/resources/libraries/robot/performance/performance_setup.robot
index 1264d440ed..c155b07d3e 100644
--- a/resources/libraries/robot/performance/performance_setup.robot
+++ b/resources/libraries/robot/performance/performance_setup.robot
@@ -607,13 +607,13 @@
| 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
@@ -670,7 +670,7 @@
| | [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}
diff --git a/resources/libraries/robot/shared/default.robot b/resources/libraries/robot/shared/default.robot
index b5242bd113..91fde22038 100644
--- a/resources/libraries/robot/shared/default.robot
+++ b/resources/libraries/robot/shared/default.robot
@@ -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
@@ -470,14 +470,14 @@
| | 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
@@ -490,7 +490,7 @@
| | 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
@@ -499,7 +499,7 @@
| | ...
| | 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
@@ -508,7 +508,7 @@
| | ...
| | 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}
@@ -529,7 +529,7 @@
| | ...
| | 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}