All test modules in test_modules directory are deprecated.
Some of the modules have been already ported, the rest
can be ported later.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
test_modules/Custom.py | 31 --
test_modules/DummyFailing.py | 19 --
test_modules/LinkNeg.py | 59 ----
test_modules/Multicast.py | 134 --------
test_modules/NetCat.py | 69 ----
test_modules/Netperf.py | 579 ----------------------------------
test_modules/PktCounter.py | 89 ------
test_modules/PktgenTx.py | 93 ------
test_modules/TCPConnection.py | 60 ----
9 files changed, 1133 deletions(-)
delete mode 100644 test_modules/Custom.py
delete mode 100644 test_modules/DummyFailing.py
delete mode 100644 test_modules/LinkNeg.py
delete mode 100644 test_modules/Multicast.py
delete mode 100644 test_modules/NetCat.py
delete mode 100644 test_modules/Netperf.py
delete mode 100644 test_modules/PktCounter.py
delete mode 100644 test_modules/PktgenTx.py
delete mode 100644 test_modules/TCPConnection.py
diff --git a/test_modules/Custom.py b/test_modules/Custom.py
deleted file mode 100644
index ac3c742..0000000
--- a/test_modules/Custom.py
+++ /dev/null
@@ -1,31 +0,0 @@
-"""
-This module defines custom test
-
-Copyright 2016 Mellanox Technologies. All rights reserved.
-Licensed under the GNU General Public License, version 2 as
-published by the Free Software Foundation; see COPYING for details.
-"""
-
-__author__ = """
-jiri(a)mellanox.com (Jiri Pirko)
-"""
-
-from lnst.Common.TestsCommon import TestGeneric
-from lnst.Common.Utils import bool_it
-
-class Custom(TestGeneric):
- def run(self):
- fail_str = self.get_opt("fail")
- if not fail_str:
- fail = False
- else:
- fail = bool_it(fail_str)
-
- res_data = self.get_single_opts()
- if "fail" in res_data:
- del(res_data["fail"])
-
- if fail:
- return self.set_fail(res_data)
-
- return self.set_pass(res_data)
diff --git a/test_modules/DummyFailing.py b/test_modules/DummyFailing.py
deleted file mode 100644
index fed9fe4..0000000
--- a/test_modules/DummyFailing.py
+++ /dev/null
@@ -1,19 +0,0 @@
-"""
-This module defines dummy failing test
-
-Copyright 2011 Red Hat, Inc.
-Licensed under the GNU General Public License, version 2 as
-published by the Free Software Foundation; see COPYING for details.
-"""
-
-__author__ = """
-jpirko(a)redhat.com (Jiri Pirko)
-"""
-
-import logging
-from lnst.Common.TestsCommon import TestGeneric
-
-class DummyFailing(TestGeneric):
- def run(self):
- res_data = {"msg": "what else did you expect?"}
- return self.set_fail(res_data)
diff --git a/test_modules/LinkNeg.py b/test_modules/LinkNeg.py
deleted file mode 100644
index 97bcf4c..0000000
--- a/test_modules/LinkNeg.py
+++ /dev/null
@@ -1,59 +0,0 @@
-"""
-This module defines the link negotiation test
-"""
-
-__author__ = """
-idosch(a)mellanox.com (Ido Schimmel)
-"""
-
-import logging
-import re
-from lnst.Common.TestsCommon import TestGeneric
-from lnst.Common.Utils import bool_it
-from lnst.Common.ExecCmd import exec_cmd
-from pyroute2 import IPDB
-
-
-class LinkNeg(TestGeneric):
- def get_speed(self, iface):
- data_stdout = exec_cmd("ethtool %s" % iface)[0]
- match = re.search('Speed: ([0-9]*)', data_stdout)
- return 0 if match is None else int(match.group(1))
-
- def _cb(self, ipdb, msg, action):
- if action == 'RTM_NEWLINK':
- self.oper_state = msg.get_attr('IFLA_OPERSTATE', '')
-
- def run(self):
- logging.info('Started LinkNeg...')
- iface = self.get_mopt('iface')
- state = bool_it(self.get_mopt('state'))
- admin_speed = self.get_opt('speed', default=0)
- timeout = self.get_opt('timeout', default=10)
-
- ip = IPDB()
- self.oper_state = ip.interfaces[iface]['operstate']
- wd = ip.watchdog(ifname=iface)
- cuid = ip.register_callback(self._cb)
-
- wd.wait(timeout=timeout)
- ip.unregister_callback(cuid)
- ip.release()
-
- admin_state = 'UP' if state else 'DOWN'
- oper_state = self.oper_state
-
- if admin_state == oper_state and admin_speed:
- oper_speed = self.get_speed(iface)
- else:
- oper_speed = 0
-
- res_data = {'admin_state': admin_state, 'oper_state':
oper_state}
- if admin_speed:
- res_data['admin_speed'] = "%s Mb/s" % admin_speed
- res_data['oper_speed'] = "%s Mb/s" % oper_speed
-
- if admin_state == oper_state and admin_speed == oper_speed:
- self.set_pass(res_data)
- else:
- self.set_fail(res_data)
diff --git a/test_modules/Multicast.py b/test_modules/Multicast.py
deleted file mode 100644
index b366c9b..0000000
--- a/test_modules/Multicast.py
+++ /dev/null
@@ -1,134 +0,0 @@
-"""
-Wrapper for executing the multicast test tools in LNST
-
-Copyright 2012 Red Hat, Inc.
-Licensed under the GNU General Public License, version 2 as
-published by the Free Software Foundation; see COPYING for details.
-"""
-
-__author__ = """
-rpazdera(a)redhat.com (Radek Pazdera)
-"""
-
-import logging
-import re
-from lnst.Common.TestsCommon import TestGeneric
-from lnst.Common.NetTestCommand import CommandException
-from lnst.Common.ExecCmd import exec_cmd
-
-class Multicast(TestGeneric):
- """ Wrapper for executing the multicast test tools in LNST
-
- Running this test executes specified test setup from
- multicast tools and evaluates the results. The behavior
- is defined entirely by behavior of the selected setup.
-
- """
-
- _conditions = {}
-
- @staticmethod
- def _remove_mask(address_in_string):
- """ Remove mask suffix from the IP address """
- if address_in_string != None:
- return address_in_string.split('/')[0]
- else:
- return address_in_string
-
- def _compose_cmd(self):
- """ Setup a command from the recipe options """
- cmd = ""
- opts = {}
-
- setup = self.get_mopt("setup")
- opts["multicast_address"] =
self._remove_mask(self.get_opt("address"))
- opts["port"] = self.get_opt("port")
- opts["interface"] =
self._remove_mask(self.get_opt("interface"))
- opts["duration"] = self.get_opt("duration")
-
- # sender-specific
- opts["loop"] = self.get_opt("loop")
- opts["ttl"] = self.get_opt("ttl")
- opts["delay"] = self.get_opt("delay")
-
- # receiver-specific
- opts["source_address"] =
self._remove_mask(self.get_opt("source"))
-
- # igmp-specific
- opts["query_type"] = self.get_opt("query_type")
- opts["dest_address"] = self.get_opt("dest_address")
- opts["max_resp_time"] = self.get_opt("max_resp_time")
-
- cmd = "./{0} ".format(setup)
-
- for optname, optval in opts.iteritems():
- if optval != None:
- cmd += "--{0} \"{1}\" ".format(optname, optval)
-
- return cmd
-
- def _evaluate_result(self, name, value):
- """ Check if the result meets required conditions
"""
- if name in self._conditions:
- try:
- float(value)
- except ValueError:
- value = '"' + value + '"'
-
- result = eval(value + self._conditions[name])
- logging.info("Condition evaluated {2}: {0}{1}".format(name,
- self._conditions[name], str(result)))
-
- return result
- else:
- return True
-
- def _prepare_conditions(self):
- """ Search for var names in conditions """
- varname_r = r"[a-zA-Z_][a-zA-Z0-9_]*"
-
- conds = self.get_multi_opt("condition")
- logging.debug(conds)
- for cond in conds:
- if cond == None:
- continue
- logging.debug(cond)
- match = re.match(varname_r, cond)
- if match:
- name = match.group(0)
- self._conditions[name] = cond.replace(name, "")
- else:
- raise CommandException(self)
-
-
- def run(self):
- self._prepare_conditions()
-
- setup_name = self.get_mopt("setup")
- logging.info("Started Multicast test setup {0}".format(setup_name))
-
- cmd = self._compose_cmd()
- data_stdout = self.exec_from("multicast", cmd, die_on_err=False,
- log_outputs=False)[0]
-
- res = {}
-
- # line format matches name=value pairs with optional
- # double quotes around the value
- line_format_r = r"([a-zA-Z0-9_ \-.]+)=\"?([a-zA-Z0-9_
]*)\"?"
-
- for line in data_stdout.split("\n"):
- match = re.search(line_format_r, line)
- if match:
- name = match.group(1).strip()
- value = match.group(2).strip()
-
- logging.info("Test result: {0} = {1}".format(name, value))
-
- name = name.replace(' ', '_')
- res[name] = value
- if not self._evaluate_result(name, value):
- res["msg"] = "Conditions not met!"
- return self.set_fail(res)
-
- return self.set_pass(res)
diff --git a/test_modules/NetCat.py b/test_modules/NetCat.py
deleted file mode 100644
index ffa4c9f..0000000
--- a/test_modules/NetCat.py
+++ /dev/null
@@ -1,69 +0,0 @@
-"""
-This module defines netcat stream test
-
-Copyright 2011 Red Hat, Inc.
-Licensed under the GNU General Public License, version 2 as
-published by the Free Software Foundation; see COPYING for details.
-"""
-
-__author__ = """
-jtluka(a)redhat.com (Jan Tluka)
-"""
-
-import re
-import time
-import logging
-from lnst.Common.TestsCommon import TestGeneric
-from lnst.Common.ShellProcess import ShellProcess
-
-class NetCat(TestGeneric):
- def _get_stream(self):
- return self.get_opt("stream", default="tcp")
-
- def _compose_nc_cmd(self):
- cmd = "yes | nc -v"
-
- if self._get_stream() == "udp":
- cmd += " -u"
-
- ipv = self.get_opt("ipv") # IP protocol version - 4 or 6
- if ipv:
- cmd += " -%s" % ipv
-
- addr = self.get_mopt("addr", opt_type="addr")
- port = self.get_mopt("port")
- cmd += " %s %s" % (addr, port)
-
- return cmd
-
- def _compose_tcpdump_cmd(self):
- cmd = ("tcpdump -c 10 -i any %s port %s and host %s" %
- (self._get_stream(),
- self.get_mopt("port"),
- self.get_mopt("addr", opt_type="addr")))
- return cmd
-
- def run(self):
- nc = ShellProcess(self._compose_nc_cmd())
-
- # check whether anything is being sent over the line
- td = ShellProcess(self._compose_tcpdump_cmd())
-
- try:
- td.read_until_output_matches("10 packets captured", timeout=5)
- except ShellProcess.ProcessTerminatedError:
- res_data = {"msg": "tcpdump process died unexpectedly!"}
- return self.set_fail(res_data)
- except ShellProcess.ProcessTimeoutError:
- res_data = {"msg": "No stream detected!"}
- return self.set_fail(res_data)
-
- td.kill()
-
- duration = self.get_opt("duration", default=30)
- time.sleep(duration)
-
- nc.kill()
-
- logging.info("nc stream with duration of %s secs" % duration)
- return self.set_pass()
diff --git a/test_modules/Netperf.py b/test_modules/Netperf.py
deleted file mode 100644
index 0c3c8d0..0000000
--- a/test_modules/Netperf.py
+++ /dev/null
@@ -1,579 +0,0 @@
-"""
-Netperf test module
-"""
-
-__author__ = """
-jprochaz(a)redhat.com (Jiri Prochazka)
-"""
-
-import logging
-import errno
-import re
-from lnst.Common.TestsCommon import TestGeneric
-from lnst.Common.ShellProcess import ShellProcess
-from lnst.Common.Utils import std_deviation, is_installed, int_it
-
-class Netperf(TestGeneric):
-
- supported_tests = ["TCP_STREAM", "TCP_RR",
"UDP_STREAM", "UDP_RR",
- "SCTP_STREAM", "SCTP_STREAM_MANY",
"SCTP_RR"]
-
- omni_tests = ["TCP_STREAM", "TCP_RR", "UDP_STREAM",
"UDP_RR"]
-
- def __init__(self, command):
- super(Netperf, self).__init__(command)
-
- self._role = self.get_mopt("role")
-
- if self._role == "client":
- self._netperf_server = self.get_mopt("netperf_server",
- opt_type="addr")
-
- self._netperf_opts = self.get_opt("netperf_opts")
- self._duration = self.get_opt("duration")
- self._port = self.get_opt("port")
- self._testname = self.get_opt("testname",
default="TCP_STREAM")
- self._testoptions = self.get_opt("testoptions")
- self._confidence = self.get_opt("confidence")
- self._bind = self.get_opt("bind", opt_type="addr")
- self._cpu_util = self.get_opt("cpu_util")
- self._num_parallel = int(self.get_opt("num_parallel", default=1))
- self._runs = self.get_opt("runs", default=1)
- self._debug = int_it(self.get_opt("debug", default=0))
-
- self._threshold = self._parse_threshold(self.get_opt("threshold"))
- self._threshold_deviation = self._parse_threshold(
- self.get_opt("threshold_deviation"))
- if self._threshold_deviation is None:
- self._threshold_deviation = {"rate" : 0.0,
- "unit" : "bps"}
-
- if self._threshold is not None:
- rate = self._threshold["rate"]
- deviation = self._threshold_deviation["rate"]
- self._threshold_interval = (rate - deviation,
- rate + deviation)
- else:
- self._threshold_interval = None
-
- self._max_deviation = self._parse_max_deviation(
- self.get_opt("max_deviation", default=None))
-
- def _is_omni(self):
- return self._testname in self.omni_tests
-
- def _compose_cmd(self):
- """
- composes commands for netperf and netserver based on xml recipe
- """
- if self._role == "client":
- cmd = "netperf -H %s -f k" % self._netperf_server
- if self._is_omni():
- # -P 0 disables banner header of output
- cmd += " -P 0"
- if self._bind is not None:
- """
- application is bound to this address
- """
- cmd += " -L %s" % self._bind
- if self._port is not None:
- """
- client connects on this port
- """
- cmd += " -p %s" % self._port
- if self._duration is not None:
- """
- test will last this duration
- """
- cmd += " -l %s" % self._duration
- if self._testname is not None:
- """
- test that will be performed
- """
- if self._testname not in self.supported_tests:
- logging.warning("Only TCP_STREAM, TCP_RR, UDP_STREAM, "
- "UDP_RR, SCTP_STREAM, SCTP_STREAM_MANY and SCTP_RR tests "
- "are now officialy supported by LNST. You "
- "can use other tests, but test result may not be
correct.")
- cmd += " -t %s" % self._testname
-
- if self._confidence is not None and self._num_parallel <= 1:
- """
- confidence level that Netperf should try to achieve
- """
- cmd += " -I %s" % self._confidence
- if self._runs >= 3:
- cmd += " -i %d,%d" % (self._runs, self._runs)
- self._runs = 1
-
- if self._cpu_util is not None:
- if self._cpu_util.lower() == "both":
- cmd += " -c -C"
- elif self._cpu_util.lower() == "local":
- cmd += " -c"
- elif self._cpu_util.lower() == "remote":
- cmd += " -C"
-
- if self._debug > 0:
- cmd += " -%s" % ('d' * self._debug)
-
- if self._netperf_opts is not None:
- """
- custom options for netperf
- """
- cmd += " %s" % self._netperf_opts
-
- if self._num_parallel > 1:
- """
- wait 1 second before starting the data transfer
- taken from the super_netperf script, can be removed if it
- doesn't make sense
- """
- cmd += " -s 1"
-
- # Print only relevant output
- if self._is_omni():
- cmd += ' -- -k "THROUGHPUT, LOCAL_CPU_UTIL, REMOTE_CPU_UTIL,
CONFIDENCE_LEVEL, THROUGHPUT_CONFID"'
-
- if self._testoptions:
- if self._is_omni():
- cmd += " %s" % self._testoptions
- else:
- cmd += " -- %s" % self._testoptions
-
- elif self._role == "server":
- cmd = "netserver -D"
- if self._bind is not None:
- """
- server is bound to this address
- """
- cmd += " -L %s" % self._bind
- if self._port is not None:
- """
- server listens on this port
- """
- cmd += " -p %s" % self._port
- if self._netperf_opts is not None:
- """
- custom options for netperf
- """
- cmd += " %s" % self._netperf_opts
- return cmd
-
- def _parse_output(self, output):
- res_val = None
-
- if self._is_omni():
- res_val = self._parse_omni_output(output)
- else:
- res_val = self._parse_non_omni_output(output)
-
- if self._confidence is not None:
- confidence = self._parse_confidence(output)
- res_val["confidence"] = confidence
-
- return res_val
-
- def _parse_omni_output(self, output):
- res_val = {}
-
- pattern_throughput = "THROUGHPUT=(\d+\.\d+)"
- throughput = re.search(pattern_throughput, output)
-
- if throughput is None:
- rate_in_kb = 0.0
- else:
- rate_in_kb = float(throughput.group(1))
-
- res_val["rate"] = rate_in_kb*1000
- res_val["unit"] = "bps"
-
- if self._cpu_util is not None:
- if self._cpu_util == "local" or self._cpu_util ==
"both":
- pattern_loc_cpu_util = "LOCAL_CPU_UTIL=([-]?\d+\.\d+)"
- loc_cpu_util = re.search(pattern_loc_cpu_util, output)
- res_val["LOCAL_CPU_UTIL"] = float(loc_cpu_util.group(1))
-
- if self._cpu_util == "remote" or self._cpu_util ==
"both":
- pattern_rem_cpu_util = "REMOTE_CPU_UTIL=([-]?\d+\.\d+)"
- rem_cpu_util = re.search(pattern_rem_cpu_util, output)
- res_val["REMOTE_CPU_UTIL"] = float(rem_cpu_util.group(1))
-
- return res_val
-
- def _parse_non_omni_output(self, output):
- res_val = {}
-
- # pattern for SCTP streams and other tests
- # decimal decimal decimal float (float)
- pattern = "\d+\s+\d+\s+\d+\s+\d+\.\d+\s+(\d+(?:\.\d+){0,1})"
- if self._cpu_util:
- # cpu utilization data in format: float float
- pattern += "\s+(\d+(?:\.\d+){0,1})\s+(\d+(?:\.\d+){0,1})"
-
- r2 = re.search(pattern, output.lower())
-
- if r2 is None:
- rate_in_kb = 0.0
- else:
- rate_in_kb = float(r2.group(1))
- if self._cpu_util:
- res_val["LOCAL_CPU_UTIL"] = float(r2.group(2))
- res_val["REMOTE_CPU_UTIL"] = float(r2.group(3))
-
- res_val["rate"] = rate_in_kb*1000
- res_val["unit"] = "bps"
-
- return res_val
-
- def _parse_confidence(self, output):
- if self._is_omni():
- return self._parse_confidence_omni(output)
- else:
- return self._parse_confidence_non_omni(output)
-
- def _parse_confidence_omni(self, output):
- pattern_throughput_confid = "THROUGHPUT_CONFID=([-]?\d+\.\d+)"
- pattern_confidence_level = "CONFIDENCE_LEVEL=(\d+)"
-
- throughput_confid = re.search(pattern_throughput_confid, output)
- confidence_level = re.search(pattern_confidence_level, output)
-
- if throughput_confid is not None and confidence_level is not None:
- throughput_confid = float(throughput_confid.group(1))
- confidence_level = int(confidence_level.group(1))
- real_confidence = (confidence_level, throughput_confid/2)
- return real_confidence
- else:
- return (0, 0.0)
-
- def _parse_confidence_non_omni(self, output):
- normal_pattern = r'\+/-(\d+\.\d*)% @ (\d+)% conf\.'
- warning_pattern = r'!!! Confidence intervals: Throughput\s+:
(\d+\.\d*)%'
- normal_confidence = re.search(normal_pattern, output)
- warning_confidence = re.search(warning_pattern, output)
-
- if normal_confidence is None:
- logging.error("Failed to parse confidence!!")
- return (0, 0.0)
-
- if warning_confidence is None:
- real_confidence = (float(normal_confidence.group(2)),
- float(normal_confidence.group(1)))
- else:
- real_confidence = (float(normal_confidence.group(2)),
- float(warning_confidence.group(1))/2)
-
- return real_confidence
-
- def _parse_threshold(self, threshold):
- res_data = {}
-
- if threshold is None:
- return None
- # pattern for threshold
- # group(1) ... threshold value
- # group(3) ... threshold units
- # group(4) ... bytes/bits
- if (self._testname == "TCP_STREAM" or
- self._testname == "UDP_STREAM" or
- self._testname == "SCTP_STREAM" or
- self._testname == "SCTP_STREAM_MANY"):
- pattern_stream = "(\d*(\.\d*)?)\s*([ kmgtKMGT])(bits|bytes)\/sec"
- r1 = re.search(pattern_stream, threshold)
- if r1 is None:
- res_data["msg"] = "Invalid unit type in the "\
- "throughput option"
- return (False, res_data)
- threshold_rate = float(r1.group(1))
- threshold_unit_size = r1.group(3)
- threshold_unit_type = r1.group(4)
- if threshold_unit_size == 'k':
- threshold_rate *= 1000
- elif threshold_unit_size == 'K':
- threshold_rate *= 1024
- elif threshold_unit_size == 'm':
- threshold_rate *= 1000*1000
- elif threshold_unit_size == 'M':
- threshold_rate *= 1024*1024
- elif threshold_unit_size == 'g':
- threshold_rate *= 1000*1000*1000
- elif threshold_unit_size == 'G':
- threshold_rate *= 1024*1024*1024
- elif threshold_unit_size == 't':
- threshold_rate *= 1000 * 1000 * 1000 * 1000
- elif threshold_unit_size == 'T':
- threshold_rate *= 1024 * 1024 * 1024 * 1024
- if threshold_unit_type == "bytes":
- threshold_rate *= 8
- threshold_unit_type = "bps"
- elif (self._testname == "TCP_RR" or self._testname ==
"UDP_RR" or
- self._testname == "SCTP_RR"):
- pattern_rr = "(\d*(\.\d*)?)\s*trans\.\/sec"
- r1 = re.search(pattern_rr, threshold.lower())
- if r1 is None:
- res_data["msg"] = "Invalid unit type in the "\
- "throughput option"
- return (False, res_data)
- threshold_rate = float(r1.group(1))
- threshold_unit_type = "tps"
-
- return {"rate": threshold_rate,
- "unit": threshold_unit_type}
-
- def _parse_max_deviation(self, deviation):
- if deviation is None:
- return None
- percentual_deviation = r"(\d+(.\d+)?)\s*%"
- match = re.match(percentual_deviation, deviation)
- if match:
- return {"type": "percent",
- "value": float(match.group(1))}
- else:
- val = self._parse_threshold(deviation)
- if val is not None:
- return {"type": "absolute",
- "value": val}
- return None
-
- def _sum_results(self, first, second):
- result = {}
-
- #add rates
- if first["unit"] == second["unit"]:
- result["unit"] = first["unit"]
- result["rate"] = first["rate"] +
second["rate"]
-
- # netperf measures the complete cpu utilization of the machine,
- # so both second and first should be +- the same number
- if "LOCAL_CPU_UTIL" in first and "LOCAL_CPU_UTIL" in second:
- result["LOCAL_CPU_UTIL"] = first["LOCAL_CPU_UTIL"]
-
- if "REMOTE_CPU_UTIL" in first and "REMOTE_CPU_UTIL" in
second:
- result["REMOTE_CPU_UTIL"] = first["REMOTE_CPU_UTIL"]
-
- #ignoring confidence because it doesn't make sense to sum those
- return result
-
- def _run_server(self, cmd):
- logging.debug("running as server...")
- server = ShellProcess(cmd)
- try:
- server.wait()
- except OSError as e:
- if e.errno == errno.EINTR:
- server.kill()
-
- def _pretty_rate(self, rate, unit=None):
- pretty_rate = {}
- if unit is None:
- if rate < 1000:
- pretty_rate["unit"] = "bits/sec"
- pretty_rate["rate"] = rate
- elif rate < 1000 * 1000:
- pretty_rate["unit"] = "kbits/sec"
- pretty_rate["rate"] = rate / 1000
- elif rate < 1000 * 1000 * 1000:
- pretty_rate["unit"] = "mbits/sec"
- pretty_rate["rate"] = rate / (1000 * 1000)
- elif rate < 1000 * 1000 * 1000 * 1000:
- pretty_rate["unit"] = "gbits/sec"
- pretty_rate["rate"] = rate / (1000 * 1000 * 1000)
- elif rate < 1000 * 1000 * 1000 * 1000 * 1000:
- pretty_rate["unit"] = "tbits/sec"
- pretty_rate["rate"] = rate / (1000 * 1000 * 1000 * 1000)
- else:
- if unit == "bits/sec":
- pretty_rate["unit"] = "bits/sec"
- pretty_rate["rate"] = rate
- elif unit == "Kbits/sec":
- pretty_rate["unit"] = "Kbits/sec"
- pretty_rate["rate"] = rate / 1024
- elif unit == "kbits/sec":
- pretty_rate["unit"] = "kbits/sec"
- pretty_rate["rate"] = rate / 1000
- elif unit == "Mbits/sec":
- pretty_rate["unit"] = "Mbits/sec"
- pretty_rate["rate"] = rate / (1024 * 1024)
- elif unit == "mbits/sec":
- pretty_rate["unit"] = "mbits/sec"
- pretty_rate["rate"] = rate / (1000 * 1000)
- elif unit == "Gbits/sec":
- pretty_rate["unit"] = "Gbits/sec"
- pretty_rate["rate"] = rate / (1024 * 1024 * 1024)
- elif unit == "gbits/sec":
- pretty_rate["unit"] = "gbits/sec"
- pretty_rate["rate"] = rate / (1000 * 1000 * 1000)
- elif unit == "Tbits/sec":
- pretty_rate["unit"] = "Tbits/sec"
- pretty_rate["rate"] = rate / (1024 * 1024 * 1024 * 1024)
- elif unit == "tbits/sec":
- pretty_rate["unit"] = "tbits/sec"
- pretty_rate["rate"] = rate / (1000 * 1000 * 1000 * 1000)
-
- return pretty_rate
-
- def _run_client(self, cmd):
- logging.debug("running as client...")
-
- res_data = {}
- res_data["testname"] = self._testname
-
- rv = 0
- results = []
- rates = []
- for i in range(1, self._runs+1):
- if self._runs > 1:
- logging.info("Netperf starting run %d" % i)
- clients = []
- client_results = []
- for i in range(0, self._num_parallel):
- clients.append(ShellProcess(cmd))
-
- for client in clients:
- ret_code = None
- try:
- ret_code = client.wait()
- rv += ret_code
- except OSError as e:
- if e.errno == errno.EINTR:
- client.kill()
-
- output = client.read_nonblocking()
- logging.debug(output)
-
- if ret_code is not None and ret_code == 0:
- client_results.append(self._parse_output(output))
-
- if len(client_results) > 0:
- #accumulate all the parallel results into one
- result = client_results[0]
- for res in client_results[1:]:
- result = self._sum_results(result, res)
-
- results.append(result)
- rates.append(results[-1]["rate"])
-
- if results > 1:
- res_data["results"] = results
-
- if len(rates) > 0:
- rate = sum(rates)/len(rates)
- else:
- rate = 0.0
-
- if len(rates) > 1:
- # setting deviation to 2xstd_deviation because of the 68-95-99.7
- # rule this seems comparable to the -I 99 netperf setting
- res_data["std_deviation"] = std_deviation(rates)
- rate_deviation = 2*res_data["std_deviation"]
- elif len(rates) == 1 and self._confidence is not None:
- result = results[0]
- rate_deviation = rate * (float(result["confidence"][1]) / 100)
- else:
- rate_deviation = 0.0
-
- res_data["rate"] = rate
- res_data["rate_deviation"] = rate_deviation
-
- rate_pretty = self._pretty_rate(rate)
- rate_dev_pretty = self._pretty_rate(rate_deviation,
unit=rate_pretty["unit"])
-
- if rv != 0 and self._runs == 1:
- res_data["msg"] = "Could not get performance
throughput!"
- logging.info(res_data["msg"])
- return (False, res_data)
- elif rv != 0 and self._runs > 1:
- res_data["msg"] = "At least one of the Netperf runs failed,
"\
- "check the logs and result data for more "\
- "information."
- logging.info(res_data["msg"])
- return (False, res_data)
-
- res_val = False
- if self._max_deviation is not None:
- if self._max_deviation["type"] == "percent":
- percentual_deviation = (rate_deviation / rate) * 100
- if percentual_deviation > self._max_deviation["value"]:
- res_val = False
- res_data["msg"] = "Measured rate %.2f +-%.2f %s has
bigger "\
- "deviation than allowed (+-%.2f %%)" %\
- (rate_pretty["rate"],
- rate_dev_pretty["rate"],
- rate_pretty["unit"],
- self._max_deviation["value"])
- return (res_val, res_data)
- elif self._max_deviation["type"] == "absolute":
- if rate_deviation >
self._max_deviation["value"]["rate"]:
- pretty_deviation =
self._pretty_rate(self._max_deviation["value"]["rate"])
- res_val = False
- res_data["msg"] = "Measured rate %.2f +-%.2f %s has
bigger "\
- "deviation than allowed (+-%.2f %s)" %\
- (rate_pretty["rate"],
- rate_dev_pretty["rate"],
- rate_pretty["unit"],
- pretty_deviation["rate"],
- pretty_deviation["unit"])
- return (res_val, res_data)
- if self._threshold_interval is not None:
- result_interval = (rate - rate_deviation,
- rate + rate_deviation)
-
- threshold_pretty = self._pretty_rate(self._threshold["rate"])
- threshold_dev_pretty =
self._pretty_rate(self._threshold_deviation["rate"],
- unit =
threshold_pretty["unit"])
-
- if self._threshold_interval[0] > result_interval[1]:
- res_val = False
- res_data["msg"] = "Measured rate %.2f +-%.2f %s is lower
"\
- "than threshold %.2f +-%.2f %s" %\
- (rate_pretty["rate"],
- rate_dev_pretty["rate"],
- rate_pretty["unit"],
- threshold_pretty["rate"],
- threshold_dev_pretty["rate"],
- threshold_pretty["unit"])
- return (res_val, res_data)
- else:
- res_val = True
- res_data["msg"] = "Measured rate %.2f +-%.2f %s is higher
"\
- "than threshold %.2f +-%.2f %s" %\
- (rate_pretty["rate"],
- rate_dev_pretty["rate"],
- rate_pretty["unit"],
- threshold_pretty["rate"],
- threshold_dev_pretty["rate"],
- threshold_pretty["unit"])
- return (res_val, res_data)
- else:
- if rate > 0.0:
- res_val = True
- else:
- res_val = False
- res_data["msg"] = "Measured rate was %.2f +-%.2f %s" %\
- (rate_pretty["rate"],
- rate_dev_pretty["rate"],
- rate_pretty["unit"])
- return (res_val, res_data)
-
- def run(self):
- cmd = self._compose_cmd()
- logging.debug("compiled command: %s" % cmd)
- if self._role == "client":
- if not is_installed("netperf"):
- res_data = {}
- res_data["msg"] = "Netperf is not installed on this
machine!"
- logging.error(res_data["msg"])
- return self.set_fail(res_data)
-
- (rv, res_data) = self._run_client(cmd)
- if rv == False:
- return self.set_fail(res_data)
- return self.set_pass(res_data)
- elif self._role == "server":
- if not is_installed("netserver"):
- res_data = {}
- res_data["msg"] = "Netserver is not installed on this
machine!"
- logging.error(res_data["msg"])
- return self.set_fail(res_data)
- self._run_server(cmd)
diff --git a/test_modules/PktCounter.py b/test_modules/PktCounter.py
deleted file mode 100644
index 52a1c30..0000000
--- a/test_modules/PktCounter.py
+++ /dev/null
@@ -1,89 +0,0 @@
-"""
-This module defines packet counter implemented by iptables
-
-Copyright 2011 Red Hat, Inc.
-Licensed under the GNU General Public License, version 2 as
-published by the Free Software Foundation; see COPYING for details.
-"""
-
-__author__ = """
-jpirko(a)redhat.com (Jiri Pirko)
-"""
-
-import logging
-import re
-import os
-from lnst.Common.TestsCommon import TestGeneric
-from lnst.Common.ExecCmd import exec_cmd, ExecCmdFail
-from lnst.Common.Utils import bool_it
-
-class PktCounter(TestGeneric):
- def _iptables_exec(self, param_str):
- if self._is_ipv6:
- cmd = "ip6tables"
- else:
- cmd = "iptables"
- return exec_cmd("%s %s" % (cmd, param_str))
-
- def _get_pttr(self, p_proto, p_indev_name, p_protodport):
- if self._is_ipv6:
- return r'\s*(\d+)\s+\d+\s+%s\s+%s\s+\*\s+::\/0\s+::\/0\s*%s' %
(p_proto, p_indev_name, p_protodport)
- else:
- return
r'\s*(\d+)\s+\d+\s+%s\s+\-\-\s+%s\s+\*\s+0\.0\.0\.0\/0\s+0\.0\.0\.0\/0\s*%s' %
(p_proto, p_indev_name, p_protodport)
-
- def _get_pkt_count(self, indev_name, dport, proto):
- if indev_name:
- p_indev_name = indev_name
- else:
- p_indev_name = "\*"
- if proto:
- p_proto = proto
- if dport:
- p_protodport = "%s dpt:%s" % (proto, dport)
- else:
- p_protodport = ""
- else:
- p_proto = "all"
- p_protodport = ""
- pttr = self._get_pttr(p_proto, p_indev_name, p_protodport)
- data_stdout = self._iptables_exec("-L -v -x -n")[0]
- match = re.search(pttr, data_stdout)
- if not match:
- return None
- return match.groups()[0]
-
- def run(self):
- indev_name = self.get_opt("input_netdev_name")
- dport = self.get_opt("dport")
- proto = self.get_opt("proto")
- ipv6 = self.get_opt("ipv6")
- self._is_ipv6 = False
- if ipv6 and bool_it(ipv6):
- self._is_ipv6 = True
- params = ""
- if indev_name:
- params += " -i %s" % indev_name
-
- if proto:
- params += " -p %s" % proto
-
- if dport:
- params += " --dport %s" % dport
-
- '''
- Remove all same already existing rules
- '''
- while True:
- if self._get_pkt_count(indev_name, dport, proto) == None:
- break
- self._iptables_exec("-D INPUT%s" % params)
-
- self._iptables_exec("-I INPUT%s" % params)
-
- self.wait_on_interrupt()
-
- count = self._get_pkt_count(indev_name, dport, proto)
-
- self._iptables_exec("-D INPUT%s" % params)
-
- return self.set_pass(res_data={"pkt_count": count})
diff --git a/test_modules/PktgenTx.py b/test_modules/PktgenTx.py
deleted file mode 100644
index cf35b5f..0000000
--- a/test_modules/PktgenTx.py
+++ /dev/null
@@ -1,93 +0,0 @@
-"""
-This module defines pktgen test, Tx side
-
-Copyright 2011 Red Hat, Inc.
-Licensed under the GNU General Public License, version 2 as
-published by the Free Software Foundation; see COPYING for details.
-"""
-
-__author__ = """
-jpirko(a)redhat.com (Jiri Pirko)
-"""
-
-import logging
-import re
-import os
-from lnst.Common.TestsCommon import TestGeneric
-from lnst.Common.ExecCmd import exec_cmd, ExecCmdFail
-
-class Pktgen:
- def __init__(self, dev):
- self._dev = dev
-
- def set(self, val):
- exec_cmd("echo \"%s\" > %s" % (val, self._dev))
-
-class PktgenWorkers:
- def __init__(self):
- self._current = 0
- self._cpunum = int(os.sysconf('SC_NPROCESSORS_ONLN'))
- self._wrkrs = {}
-
- def _init_current_wrkr(self):
- num = self._current
- wrkr = Pktgen("/proc/net/pktgen/kpktgend_%d" % (num))
- wrkr.set("rem_device_all")
- wrkr.set("max_before_softirq 5000")
- self._wrkrs[num] = wrkr
-
- def _get_wrkr(self):
- num = self._current
- if not num in self._wrkrs:
- self._init_current_wrkr()
- wrkr = self._wrkrs[num]
- num += 1
- if num == self._cpunum:
- num = 0
- self._current = num
- return wrkr
-
- def add_device(self, dev_name):
- wrkr = self._get_wrkr()
- wrkr.set("add_device %s" % dev_name)
-
-def pktget_options_merge(pktgen_options, default_pktgen_options):
- opts = [re.split('\s+', opt) for opt in pktgen_options]
- def_opts = [re.split('\s+', opt) for opt in default_pktgen_options]
- res = []
- for def_opt in def_opts:
- if not def_opt[0] in [opt[0] for opt in opts]:
- res.append(def_opt)
- res = res + opts
- return [" ".join(opt) for opt in res]
-
-class PktgenTx(TestGeneric):
- def run(self):
- dev_names = self.get_multi_mopt("netdev_name")
- pktgen_options = self.get_multi_mopt("pktgen_option")
-
- default_pktgen_options = [
- "count 10000000",
- "clone_skb 100000",
- "pkt_size 60",
- ]
- pktgen_options = pktget_options_merge(pktgen_options,
- default_pktgen_options)
-
- exec_cmd("modprobe pktgen")
-
- pgctl = Pktgen("/proc/net/pktgen/pgctrl")
- pgwrkr = PktgenWorkers()
-
- try:
- for dev_name in dev_names:
- pgwrkr.add_device(dev_name)
- pg = Pktgen("/proc/net/pktgen/%s" % dev_name)
- for pktgen_option in pktgen_options:
- pg.set(pktgen_option)
- pgctl.set("start")
- except ExecCmdFail:
- res_data = {"msg": "pktgen failed"}
- return self.set_fail(res_data)
-
- return self.set_pass()
diff --git a/test_modules/TCPConnection.py b/test_modules/TCPConnection.py
deleted file mode 100644
index 43b88a9..0000000
--- a/test_modules/TCPConnection.py
+++ /dev/null
@@ -1,60 +0,0 @@
-"""
-This module defines TCPConnection test,
-a python wrapper for LNST's tcp_conn test tool
-"""
-
-__author__ = """
-jtluka(a)redhat.com (Jan Tluka)
-"""
-
-import re
-import errno
-import logging
-from lnst.Common.TestsCommon import TestGeneric
-from lnst.Common.Utils import bool_it
-
-class TCPConnection(TestGeneric):
- def run(self):
- mode = self.get_mopt("mode")
- address = self.get_mopt("address")
- portrange = self.get_mopt("portrange")
-
- continuous = self.get_opt("continuous")
- debug = self.get_opt("debug")
- ipv6 = self.get_opt("ipv6")
-
- cmd = ""
- if (mode == "server"):
- logging.debug("TCPConnection: running as server")
- cmd += "./tcp_listen"
- elif (mode == "client"):
- logging.debug("TCPConnection: running as client")
- cmd += "./tcp_connect"
- else:
- raise Exception("Invalid mode value for TCPConnection test
module!")
-
- cmd += " -a %s -p %s" % (address, portrange)
-
- if continuous and bool_it(continuous):
- cmd += " -c"
-
- if debug and bool_it(debug):
- cmd += " -d"
-
- if ipv6 and bool_it(ipv6):
- cmd += " -6"
-
- output = self.exec_from("tcp_conn", cmd, die_on_err=False,
log_outputs=True)[0]
-
- logging.debug("TCPConnection done, inspecting logs ...")
-
- m = None
- if (mode == "client"):
- m = re.search("made [0-9]* connections", output)
- elif (mode == "server"):
- m = re.search("handled [0-9]* connections", output)
-
- if m is None:
- return self.set_fail({'msg': "Unexpected error"})
- else:
- return self.set_pass({'msg': m.group(0)})
--
2.21.1