aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/PapiExecutor.py
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2019-09-17 13:00:39 +0200
committerVratko Polak <vrpolak@cisco.com>2019-09-17 12:30:19 +0000
commit8b1bead7b4b70e3ff4e7d4cb82940695d763ed2d (patch)
tree2471e40a115e6bc8ea38f5e2ad79834992f1ad0c /resources/libraries/python/PapiExecutor.py
parentb61e34657e58cbe6c8476f6708d62168ffd80775 (diff)
Update CRC list and support 21997/7
- Attempt to repair IPsec LispGpe perf suite. + Collection name to reflect the current stable vpp. + Add messages found in CSIT L1 keywords. - Uncommented (instead of deleted) untestable messages. Reasons: - Honeycomb. - Messages used by unused keywords. + Listed reasons. Honeycomb not mentioned if both reasons apply. + Delete CRC items for commands not found in keywords anymore. + Add CRCs from .json.api files (as teardown is hard to execute). + Define and restore alphabetical order. + Add hints to find used API commands (not entirely reliable). + Move used commands to "cmd = " form so hints find them. + Argument to run_cli_command changed from "cmd" to "cli_cmd". + Except also struct.error where IOError is excepted. Change-Id: I61058dbe1e33296908aabd0c13433bb16cfa6adf Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/python/PapiExecutor.py')
-rw-r--r--resources/libraries/python/PapiExecutor.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/resources/libraries/python/PapiExecutor.py b/resources/libraries/python/PapiExecutor.py
index aec43b6694..d651e78cca 100644
--- a/resources/libraries/python/PapiExecutor.py
+++ b/resources/libraries/python/PapiExecutor.py
@@ -19,6 +19,7 @@ import copy
import glob
import json
import shutil
+import struct # vpp-papi can raise struct.error
import subprocess
import sys
import tempfile
@@ -95,8 +96,9 @@ class PapiSocketExecutor(object):
Note: Use only with "with" statement, e.g.:
+ cmd = 'show_version'
with PapiSocketExecutor(node) as papi_exec:
- reply = papi_exec.add('show_version').get_reply(err_msg)
+ reply = papi_exec.add(cmd).get_reply(err_msg)
This class processes two classes of VPP PAPI methods:
1. Simple request / reply: method='request'.
@@ -110,8 +112,9 @@ class PapiSocketExecutor(object):
a. One request with no arguments:
+ cmd = 'show_version'
with PapiSocketExecutor(node) as papi_exec:
- reply = papi_exec.add('show_version').get_reply(err_msg)
+ reply = papi_exec.add(cmd).get_reply(err_msg)
b. Three requests with arguments, the second and the third ones are the same
but with different arguments.
@@ -293,7 +296,7 @@ class PapiSocketExecutor(object):
for _ in xrange(2):
try:
vpp_instance.connect_sync("csit_socket")
- except IOError as err:
+ except (IOError, struct.error) as err:
logger.warn("Got initial connect error {err!r}".format(err=err))
vpp_instance.disconnect()
else:
@@ -419,29 +422,29 @@ class PapiSocketExecutor(object):
return self._execute(err_msg)
@staticmethod
- def run_cli_cmd(node, cmd, log=True,
+ def run_cli_cmd(node, cli_cmd, log=True,
remote_vpp_socket=Constants.SOCKSVR_PATH):
"""Run a CLI command as cli_inband, return the "reply" field of reply.
Optionally, log the field value.
:param node: Node to run command on.
- :param cmd: The CLI command to be run on the node.
+ :param cli_cmd: The CLI command to be run on the node.
:param remote_vpp_socket: Path to remote socket to tunnel to.
:param log: If True, the response is logged.
:type node: dict
:type remote_vpp_socket: str
- :type cmd: str
+ :type cli_cmd: str
:type log: bool
:returns: CLI output.
:rtype: str
"""
- cli = 'cli_inband'
- args = dict(cmd=cmd)
+ cmd = 'cli_inband'
+ args = dict(cmd=cli_cmd)
err_msg = "Failed to run 'cli_inband {cmd}' PAPI command on host " \
"{host}".format(host=node['host'], cmd=cmd)
with PapiSocketExecutor(node, remote_vpp_socket) as papi_exec:
- reply = papi_exec.add(cli, **args).get_reply(err_msg)["reply"]
+ reply = papi_exec.add(cmd, **args).get_reply(err_msg)["reply"]
if log:
logger.info(
"{cmd} ({host} - {remote_vpp_socket}):\n{reply}".
@@ -450,21 +453,21 @@ class PapiSocketExecutor(object):
return reply
@staticmethod
- def run_cli_cmd_on_all_sockets(node, cmd, log=True):
+ def run_cli_cmd_on_all_sockets(node, cli_cmd, log=True):
"""Run a CLI command as cli_inband, on all sockets in topology file.
:param node: Node to run command on.
- :param cmd: The CLI command to be run on the node.
+ :param cli_cmd: The CLI command to be run on the node.
:param log: If True, the response is logged.
:type node: dict
- :type cmd: str
+ :type cli_cmd: str
:type log: bool
"""
sockets = Topology.get_node_sockets(node, socket_type=SocketType.PAPI)
if sockets:
for socket in sockets.values():
PapiSocketExecutor.run_cli_cmd(
- node, cmd, log=log, remote_vpp_socket=socket)
+ node, cli_cmd, log=log, remote_vpp_socket=socket)
@staticmethod
def dump_and_log(node, cmds):
@@ -511,7 +514,7 @@ class PapiSocketExecutor(object):
try:
try:
reply = papi_fn(**command["api_args"])
- except IOError as err:
+ except (IOError, struct.error) as err:
# Ocassionally an error happens, try reconnect.
logger.warn("Reconnect after error: {err!r}".format(
err=err))
@@ -521,7 +524,7 @@ class PapiSocketExecutor(object):
self.vpp_instance.connect_sync("csit_socket")
logger.trace("Reconnected.")
reply = papi_fn(**command["api_args"])
- except (AttributeError, IOError) as err:
+ except (AttributeError, IOError, struct.error) as err:
raise_from(AssertionError(err_msg), err, level="INFO")
# *_dump commands return list of objects, convert, ordinary reply.
if not isinstance(reply, list):