commit 77bbc7d8f19984670ebe4113b84048b72f396234
Author: Jiri Prochazka <jprochaz(a)redhat.com>
Date: Tue Jan 27 15:42:50 2015 +0100
Extended netperf test support
Added support for TCP_RR, UDP_RR, SCTP_STREAM, SCTP_STREAM_MANY and SCTP_RR tests.
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
test_modules/Netperf.py | 98 ++++++++++++++++++++++++++++++++---------------
1 files changed, 67 insertions(+), 31 deletions(-)
---
diff --git a/test_modules/Netperf.py b/test_modules/Netperf.py
index fba6213..1994412 100644
--- a/test_modules/Netperf.py
+++ b/test_modules/Netperf.py
@@ -14,6 +14,9 @@ from lnst.Common.ShellProcess import ShellProcess
class Netperf(TestGeneric):
+ supported_tests = ["TCP_STREAM", "TCP_RR", "UDP_STREAM", "UDP_RR",
+ "SCTP_STREAM", "SCTP_STREAM_MANY", "SCTP_RR"]
+
def _compose_cmd(self, role):
"""
composes commands for netperf and netserver based on xml recipe
@@ -39,10 +42,11 @@ class Netperf(TestGeneric):
"""
test that will be performed
"""
- if testname != "TCP_STREAM" and testname != "UDP_STREAM":
- logging.warning("Only TCP_STREAM and UDP_STREAM tests are "\
- "now officialy supported by LNST. You can use other tests,"\
- " but test result may not be correct.")
+ if 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" % testname
if netperf_opts is not None:
@@ -73,40 +77,68 @@ class Netperf(TestGeneric):
return cmd
def _parse_output(self, threshold, output):
- # pattern for tcp throughput output
- pattern_tcp = "\d+\s+\d+\s+\d+\s+\d+\.\d+\s+(\d+(\.\d+){0,1})"
- # pattern for udp throughput output
- pattern_udp = "\d+\s+\d+\s+\d+\.\d+\s+\d+\s+\d+\s+(\d+(\.\d+){0,1})"
- if self.get_opt("testname") == "UDP_STREAM":
- r2 = re.search(pattern_udp, output.lower())
+ testname = self.get_opt("testname")
+ if testname == "UDP_STREAM":
+ # pattern for UDP_STREAM throughput output
+ # decimal decimal float decimal decimal (float)
+ pattern_udp_stream = "\d+\s+\d+\s+\d+\.\d+\s+\d+\s+\d+\s+(\d+(\.\d+){0,1})"
+ r2 = re.search(pattern_udp_stream, output.lower())
+ elif testname == "TCP_STREAM":
+ # pattern for TCP_STREAM throughput output
+ # decimal decimal decimal float (float)
+ pattern_tcp_stream = "\d+\s+\d+\s+\d+\s+\d+\.\d+\s+(\d+(\.\d+){0,1})"
+ r2 = re.search(pattern_tcp_stream, output.lower())
+ elif testname == "TCP_RR" or testname == "UDP_RR" or testname == "SCTP_RR":
+ # pattern for TCP_RR, UDP_RR and SCTP_RR throughput output
+ # decimal decimal decimal decimal float (float)
+ pattern_tcp_rr = "\d+\s+\d+\s+\d+\s+\d+\s+\d+\.\d+\s+(\d+(\.\d+){0,1})"
+ r2 = re.search(pattern_tcp_rr, output.lower())
else:
- r2 = re.search(pattern_tcp, output.lower())
+ # pattern for SCTP streams and other tests
+ # decimal decimal decimal float (float)
+ pattern_sctp = "\d+\s+\d+\s+\d+\s+\d+\.\d+\s+(\d+(\.\d+){0,1})"
+ r2 = re.search(pattern_sctp, output.lower())
if threshold is not None:
# pattern for threshold
# group(1) ... threshold value
# group(3) ... threshold units
# group(4) ... bytes/bits
- pattern1 = "(\d*(\.\d*){0,1})\s*([ kmgt])(bits|bytes)\/sec"
- r1 = re.search(pattern1, threshold.lower())
- threshold_rate = float(r1.group(1))
- threshold_unit_size = r1.group(3)
- threshold_unit_type = r1.group(4)
+ if (testname == "TCP_STREAM" or testname == "UDP_STREAM" or
+ testname == "SCTP_STREAM" or testname == "SCTP_STREAM_MANY"):
+ pattern_stream = "(\d*(\.\d*){0,1})\s*([ kmgt])(bits|bytes)\/sec"
+ r1 = re.search(pattern_stream, threshold.lower())
+ if r1 is None:
+ return (False, "Invalid unit type in the throughput option")
+ threshold_rate = float(r1.group(1))
+ threshold_unit_size = r1.group(3)
+ threshold_unit_type = r1.group(4)
+ elif (testname == "TCP_RR" or testname == "UDP_RR" or
+ testname == "SCTP_RR"):
+ pattern_rr = "(\d*(\.\d*){0,1})\s*trans\.\/sec"
+ r1 = re.search(pattern_rr, threshold.lower())
+ if r1 is None:
+ return (False, "Invalid unit type in the throughput option")
+ threshold_rate = float(r1.group(1))
+ threshold_unit_size = ""
+ threshold_unit_type = "Trans./sec"
throughput_rate = float(r2.group(1))
"""
this part converts threshold and throughput rates to same format
user will get output in format specified in threshold option
if no threshold option is put in, default format is Mbits
"""
- if threshold_unit_size == 'k':
- throughput_rate *= 1000
- elif threshold_unit_size == 'g':
- throughput_rate /= 1000
- elif threshold_unit_size == 't':
- throughput_rate /= 1000 * 1000
- if threshold_unit_type == "bytes":
- throughput_rate /= 8
+ if (testname == "UDP_STREAM" or testname == "TCP_STREAM" or
+ testname == "SCTP_STREAM" or testname == "SCTP_STREAM_MANY"):
+ if threshold_unit_size == 'k':
+ throughput_rate *= 1000
+ elif threshold_unit_size == 'g':
+ throughput_rate /= 1000
+ elif threshold_unit_size == 't':
+ throughput_rate /= 1000 * 1000
+ if threshold_unit_type == "bytes":
+ throughput_rate /= 8
if threshold_rate > throughput_rate:
- return (False, "Measured rate (%s %s%s) is below threshold "\
+ return (False, "Measured rate (%s %s%s) is below threshold "
"(%s %s%s)!" % (throughput_rate,
threshold_unit_size.upper(),
threshold_unit_type,
@@ -114,7 +146,7 @@ class Netperf(TestGeneric):
threshold_unit_size.upper(),
threshold_unit_type))
else:
- return (True, "Measured rate (%s %s%s) is over threshold "\
+ return (True, "Measured rate (%s %s%s) is over threshold "
"(%s %s%s)." % (throughput_rate,
threshold_unit_size.upper(),
threshold_unit_type,
@@ -122,7 +154,11 @@ class Netperf(TestGeneric):
threshold_unit_size.upper(),
threshold_unit_type))
else:
- return (True, "Measured rate: %s Mbits" % r2.group(1))
+ if (testname == "TCP_RR" or testname == "UDP_RR" or
+ testname == "SCTP_RR"):
+ return (True, "Measured rate: %s Trans./sec" % r2.group(1))
+ else:
+ return (True, "Measured rate: %s Mbits/sec" % r2.group(1))
@@ -145,11 +181,11 @@ class Netperf(TestGeneric):
client.kill()
output = client.read_nonblocking()
if rv != 0:
- logging.info("Could not get performance throughput! Are you sure "\
- "netperf is installed on both machines and machines "\
+ logging.info("Could not get performance throughput! Are you sure "
+ "netperf is installed on both machines and machines "
"are mutually accessible?")
- return (False, "Could not get performance throughput! Are you "\
- "sure netperf is installed on both machines and "\
+ return (False, "Could not get performance throughput! Are you "
+ "sure netperf is installed on both machines and "
"machines are mutually accessible?")
return self._parse_output(self.get_opt("threshold"), output)