diff options
author | Martin Klozik <martinx.klozik@intel.com> | 2017-12-19 08:58:43 +0000 |
---|---|---|
committer | Martin Klozik <martinx.klozik@intel.com> | 2018-01-11 11:28:02 +0000 |
commit | a2d97b05fb3b7ff62f62bcb16d36c51e3df6ca77 (patch) | |
tree | 8cb4e2cd7a463275416d8ac2422b6907166f2a94 /tools/tasks.py | |
parent | 58d53561bad01ae7829fdeee0c67f5dae4a9dc34 (diff) |
capture: Traffic capture examples
Traffic can be captured also at DUT side. Two options are supported by
vsperf:
1) Traffic is captured inside VM after it has been processed
by vSwitch. This can be used for verification of vSwitch frame
modification functionality, including HW offloading at ingress side.
2) Another NIC under the test (NIC2) is added into standard VSPERF DUT
setup. Traffic is then forwarded from TGen through NIC and vSwitch
to NIC2 and then over patch cable back to NIC2, the vSwitch, NIC and
to the traffic generator. This setup supports also verification of HW
offloading at egress side of NIC2 and thus it can be used for validation
of smart NICS.
Both options above are traffic generator agnostic if compared to direct
support of traffic capture by traffic generator. This patch introduces
example testcases for both options.
Detailed documentation will be pushed as a standalone patch.
JIRA: VSPERF-556
Change-Id: I23e12e45768ae4dbe9442f74d8391c3d5b2c7895
Signed-off-by: Martin Klozik <martinx.klozik@intel.com>
Reviewed-by: Richard Elias <richardx.elias@intel.com>
Reviewed-by: Al Morton <acmorton@att.com>
Reviewed-by: Christian Trautman <ctrautma@redhat.com>
Reviewed-by: Sridhar Rao <sridhar.rao@spirent.com>
Reviewed-by: Trevor Cooper <trevor.cooper@intel.com>
Diffstat (limited to 'tools/tasks.py')
-rw-r--r-- | tools/tasks.py | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/tools/tasks.py b/tools/tasks.py index 4179291f..18f4d712 100644 --- a/tools/tasks.py +++ b/tools/tasks.py @@ -114,6 +114,16 @@ def run_task(cmd, logger, msg=None, check_error=False): return ('\n'.join(sout.decode(my_encoding).strip() for sout in stdout), ('\n'.join(sout.decode(my_encoding).strip() for sout in stderr))) +def update_pids(pid): + """update list of running pids, so they can be terminated at the end + """ + try: + pids = settings.getValue('_EXECUTED_PIDS') + pids.append(pid) + except AttributeError: + pids = [pid] + settings.setValue('_EXECUTED_PIDS', pids) + def run_background_task(cmd, logger, msg): """Run task in background and log when started. @@ -132,6 +142,8 @@ def run_background_task(cmd, logger, msg): proc = subprocess.Popen(map(os.path.expanduser, cmd), stdout=_get_stdout(), bufsize=0) + update_pids(proc.pid) + return proc.pid @@ -174,14 +186,13 @@ def terminate_task_subtree(pid, signal='-15', sleep=10, logger=None): :param logger: Logger to write details to """ try: - output = subprocess.check_output("pgrep -P " + str(pid), shell=True).decode().rstrip('\n') + children = subprocess.check_output("pgrep -P " + str(pid), shell=True).decode().rstrip('\n').split() except subprocess.CalledProcessError: - output = "" + children = [] terminate_task(pid, signal, sleep, logger) # just for case children were kept alive - children = output.split('\n') for child in children: terminate_task(child, signal, sleep, logger) @@ -208,6 +219,22 @@ def terminate_task(pid, signal='-15', sleep=10, logger=None): if signal.lstrip('-').upper() not in ('9', 'KILL', 'SIGKILL') and systeminfo.pid_isalive(pid): terminate_task(pid, '-9', sleep, logger) + pids = settings.getValue('_EXECUTED_PIDS') + if pid in pids: + pids.remove(pid) + settings.setValue('_EXECUTED_PIDS', pids) + +def terminate_all_tasks(logger): + """Terminate all processes executed by vsperf, just for case they were not + terminated by standard means. + """ + pids = settings.getValue('_EXECUTED_PIDS') + if pids: + logger.debug('Following processes will be terminated: %s', pids) + for pid in pids: + terminate_task_subtree(pid, logger=logger) + settings.setValue('_EXECUTED_PIDS', []) + class Process(object): """Control an instance of a long-running process. |