Return value of client netperf is checked instead of output parsing and looking for error there.
Signed-off-by: Jiri Prochazka jprochaz@redhat.com --- test_modules/Netperf.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/test_modules/Netperf.py b/test_modules/Netperf.py index 09bb8f0..fba6213 100644 --- a/test_modules/Netperf.py +++ b/test_modules/Netperf.py @@ -73,24 +73,14 @@ class Netperf(TestGeneric): return cmd
def _parse_output(self, threshold, output): - # pattern for throughput output - pattern2 = "\d+\s+\d+\s+\d+\s+\d+.\d+\s+(\d+(.\d+){0,1})" + # 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 - pattern3 = "\d+\s+\d+\s+\d+.\d+\s+\d+\s+\d+\s+(\d+(.\d+){0,1})" + 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(pattern3, output.lower()) + r2 = re.search(pattern_udp, output.lower()) else: - r2 = re.search(pattern2, output.lower()) - if r2 is None: - """ - throughput was not found, end test with failure - """ - 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 "\ - "machines are mutually accessible?") + r2 = re.search(pattern_tcp, output.lower()) if threshold is not None: # pattern for threshold # group(1) ... threshold value @@ -149,11 +139,18 @@ class Netperf(TestGeneric): logging.debug("running as client...") client = ShellProcess(cmd) try: - client.wait() + rv = client.wait() except OSError as e: if e.errno == errno.EINTR: 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 "\ + "are mutually accessible?") + 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)
def run(self):
Added support for TCP_RR, UDP_RR, SCTP_STREAM, SCTP_STREAM_MANY and SCTP_RR tests.
Signed-off-by: Jiri Prochazka jprochaz@redhat.com --- test_modules/Netperf.py | 86 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 25 deletions(-)
diff --git a/test_modules/Netperf.py b/test_modules/Netperf.py index fba6213..bf6821f 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,38 +77,66 @@ 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 "\ "(%s %s%s)!" % (throughput_rate, @@ -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))
Added netperf test recipes for each test variation.
Signed-off-by: Jiri Prochazka jprochaz@redhat.com --- recipes/examples/quick_guides/netperf.xml | 39 -------------------- .../quick_guides/netperf/netperf_sctp_rr.xml | 41 ++++++++++++++++++++++ .../quick_guides/netperf/netperf_sctp_stream.xml | 41 ++++++++++++++++++++++ .../netperf/netperf_sctp_stream_many.xml | 41 ++++++++++++++++++++++ .../quick_guides/netperf/netperf_tcp_rr.xml | 41 ++++++++++++++++++++++ .../quick_guides/netperf/netperf_tcp_stream.xml | 41 ++++++++++++++++++++++ .../quick_guides/netperf/netperf_udp_rr.xml | 41 ++++++++++++++++++++++ .../quick_guides/netperf/netperf_udp_stream.xml | 41 ++++++++++++++++++++++ 8 files changed, 287 insertions(+), 39 deletions(-) delete mode 100644 recipes/examples/quick_guides/netperf.xml create mode 100644 recipes/examples/quick_guides/netperf/netperf_sctp_rr.xml create mode 100644 recipes/examples/quick_guides/netperf/netperf_sctp_stream.xml create mode 100644 recipes/examples/quick_guides/netperf/netperf_sctp_stream_many.xml create mode 100644 recipes/examples/quick_guides/netperf/netperf_tcp_rr.xml create mode 100644 recipes/examples/quick_guides/netperf/netperf_tcp_stream.xml create mode 100644 recipes/examples/quick_guides/netperf/netperf_udp_rr.xml create mode 100644 recipes/examples/quick_guides/netperf/netperf_udp_stream.xml
diff --git a/recipes/examples/quick_guides/netperf.xml b/recipes/examples/quick_guides/netperf.xml deleted file mode 100644 index dd339a5..0000000 --- a/recipes/examples/quick_guides/netperf.xml +++ /dev/null @@ -1,39 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <interfaces> - <eth label="tnet" id="testifc1"> - <addresses> - <address value="192.168.200.2/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="testmachine2"> - <interfaces> - <eth label="tnet" id="testifc2"> - <addresses> - <address value="192.168.200.3/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - <task> - <run module="Netperf" host="testmachine2" bg_id="server"> - <options> - <option name="role" value="server"/> - <option name="bind" value="{ip(testmachine2, testifc2)}"/> - </options> - </run> - <run module="Netperf" host="testmachine1"> - <options> - <option name="role" value="client"/> - <option name="netperf_server" value="{ip(testmachine2, testifc2)}"/> - </options> - </run> - - <kill host="testmachine2" bg_id="server"/> - - </task> -</lnstrecipe> diff --git a/recipes/examples/quick_guides/netperf/netperf_sctp_rr.xml b/recipes/examples/quick_guides/netperf/netperf_sctp_rr.xml new file mode 100644 index 0000000..06c2607 --- /dev/null +++ b/recipes/examples/quick_guides/netperf/netperf_sctp_rr.xml @@ -0,0 +1,41 @@ +<lnstrecipe> + <network> + <host id="testmachine1"> + <interfaces> + <eth label="tnet" id="testifc1"> + <addresses> + <address value="192.168.200.2/24"/> + </addresses> + </eth> + </interfaces> + </host> + <host id="testmachine2"> + <interfaces> + <eth label="tnet" id="testifc2"> + <addresses> + <address value="192.168.200.3/24"/> + </addresses> + </eth> + </interfaces> + </host> + </network> + <task> + <run module="Netperf" host="testmachine2" bg_id="server"> + <options> + <option name="role" value="server"/> + <option name="bind" value="{ip(testmachine2, testifc2)}"/> + </options> + </run> + <run module="Netperf" host="testmachine1"> + <options> + <option name="role" value="client"/> + <option name="netperf_server" value="{ip(testmachine2, testifc2)}"/> + <option name="testname" value="SCTP_RR" /> + <option name="threshold" value="0 Trans./sec" /> + </options> + </run> + + <kill host="testmachine2" bg_id="server"/> + + </task> +</lnstrecipe> diff --git a/recipes/examples/quick_guides/netperf/netperf_sctp_stream.xml b/recipes/examples/quick_guides/netperf/netperf_sctp_stream.xml new file mode 100644 index 0000000..3e53843 --- /dev/null +++ b/recipes/examples/quick_guides/netperf/netperf_sctp_stream.xml @@ -0,0 +1,41 @@ +<lnstrecipe> + <network> + <host id="testmachine1"> + <interfaces> + <eth label="tnet" id="testifc1"> + <addresses> + <address value="192.168.200.2/24"/> + </addresses> + </eth> + </interfaces> + </host> + <host id="testmachine2"> + <interfaces> + <eth label="tnet" id="testifc2"> + <addresses> + <address value="192.168.200.3/24"/> + </addresses> + </eth> + </interfaces> + </host> + </network> + <task> + <run module="Netperf" host="testmachine2" bg_id="server"> + <options> + <option name="role" value="server"/> + <option name="bind" value="{ip(testmachine2, testifc2)}"/> + </options> + </run> + <run module="Netperf" host="testmachine1"> + <options> + <option name="role" value="client"/> + <option name="netperf_server" value="{ip(testmachine2, testifc2)}"/> + <option name="testname" value="SCTP_STREAM" /> + <option name="threshold" value="0 Mbits/sec" /> + </options> + </run> + + <kill host="testmachine2" bg_id="server"/> + + </task> +</lnstrecipe> diff --git a/recipes/examples/quick_guides/netperf/netperf_sctp_stream_many.xml b/recipes/examples/quick_guides/netperf/netperf_sctp_stream_many.xml new file mode 100644 index 0000000..175cb36 --- /dev/null +++ b/recipes/examples/quick_guides/netperf/netperf_sctp_stream_many.xml @@ -0,0 +1,41 @@ +<lnstrecipe> + <network> + <host id="testmachine1"> + <interfaces> + <eth label="tnet" id="testifc1"> + <addresses> + <address value="192.168.200.2/24"/> + </addresses> + </eth> + </interfaces> + </host> + <host id="testmachine2"> + <interfaces> + <eth label="tnet" id="testifc2"> + <addresses> + <address value="192.168.200.3/24"/> + </addresses> + </eth> + </interfaces> + </host> + </network> + <task> + <run module="Netperf" host="testmachine2" bg_id="server"> + <options> + <option name="role" value="server"/> + <option name="bind" value="{ip(testmachine2, testifc2)}"/> + </options> + </run> + <run module="Netperf" host="testmachine1"> + <options> + <option name="role" value="client"/> + <option name="netperf_server" value="{ip(testmachine2, testifc2)}"/> + <option name="testname" value="SCTP_STREAM_MANY" /> + <option name="threshold" value="0 Mbits/sec" /> + </options> + </run> + + <kill host="testmachine2" bg_id="server"/> + + </task> +</lnstrecipe> diff --git a/recipes/examples/quick_guides/netperf/netperf_tcp_rr.xml b/recipes/examples/quick_guides/netperf/netperf_tcp_rr.xml new file mode 100644 index 0000000..98bd279 --- /dev/null +++ b/recipes/examples/quick_guides/netperf/netperf_tcp_rr.xml @@ -0,0 +1,41 @@ +<lnstrecipe> + <network> + <host id="testmachine1"> + <interfaces> + <eth label="tnet" id="testifc1"> + <addresses> + <address value="192.168.200.2/24"/> + </addresses> + </eth> + </interfaces> + </host> + <host id="testmachine2"> + <interfaces> + <eth label="tnet" id="testifc2"> + <addresses> + <address value="192.168.200.3/24"/> + </addresses> + </eth> + </interfaces> + </host> + </network> + <task> + <run module="Netperf" host="testmachine2" bg_id="server"> + <options> + <option name="role" value="server"/> + <option name="bind" value="{ip(testmachine2, testifc2)}"/> + </options> + </run> + <run module="Netperf" host="testmachine1"> + <options> + <option name="role" value="client"/> + <option name="netperf_server" value="{ip(testmachine2, testifc2)}"/> + <option name="testname" value="TCP_RR" /> + <option name="threshold" value="0 Trans./sec" /> + </options> + </run> + + <kill host="testmachine2" bg_id="server"/> + + </task> +</lnstrecipe> diff --git a/recipes/examples/quick_guides/netperf/netperf_tcp_stream.xml b/recipes/examples/quick_guides/netperf/netperf_tcp_stream.xml new file mode 100644 index 0000000..bcbfdcd --- /dev/null +++ b/recipes/examples/quick_guides/netperf/netperf_tcp_stream.xml @@ -0,0 +1,41 @@ +<lnstrecipe> + <network> + <host id="testmachine1"> + <interfaces> + <eth label="tnet" id="testifc1"> + <addresses> + <address value="192.168.200.2/24"/> + </addresses> + </eth> + </interfaces> + </host> + <host id="testmachine2"> + <interfaces> + <eth label="tnet" id="testifc2"> + <addresses> + <address value="192.168.200.3/24"/> + </addresses> + </eth> + </interfaces> + </host> + </network> + <task> + <run module="Netperf" host="testmachine2" bg_id="server"> + <options> + <option name="role" value="server"/> + <option name="bind" value="{ip(testmachine2, testifc2)}"/> + </options> + </run> + <run module="Netperf" host="testmachine1"> + <options> + <option name="role" value="client"/> + <option name="netperf_server" value="{ip(testmachine2, testifc2)}"/> + <option name="testname" value="TCP_STREAM" /> + <option name="threshold" value="0 Mbits/sec" /> + </options> + </run> + + <kill host="testmachine2" bg_id="server"/> + + </task> +</lnstrecipe> diff --git a/recipes/examples/quick_guides/netperf/netperf_udp_rr.xml b/recipes/examples/quick_guides/netperf/netperf_udp_rr.xml new file mode 100644 index 0000000..0c6621d --- /dev/null +++ b/recipes/examples/quick_guides/netperf/netperf_udp_rr.xml @@ -0,0 +1,41 @@ +<lnstrecipe> + <network> + <host id="testmachine1"> + <interfaces> + <eth label="tnet" id="testifc1"> + <addresses> + <address value="192.168.200.2/24"/> + </addresses> + </eth> + </interfaces> + </host> + <host id="testmachine2"> + <interfaces> + <eth label="tnet" id="testifc2"> + <addresses> + <address value="192.168.200.3/24"/> + </addresses> + </eth> + </interfaces> + </host> + </network> + <task> + <run module="Netperf" host="testmachine2" bg_id="server"> + <options> + <option name="role" value="server"/> + <option name="bind" value="{ip(testmachine2, testifc2)}"/> + </options> + </run> + <run module="Netperf" host="testmachine1"> + <options> + <option name="role" value="client"/> + <option name="netperf_server" value="{ip(testmachine2, testifc2)}"/> + <option name="testname" value="UDP_RR" /> + <option name="threshold" value="0 Trans./sec" /> + </options> + </run> + + <kill host="testmachine2" bg_id="server"/> + + </task> +</lnstrecipe> diff --git a/recipes/examples/quick_guides/netperf/netperf_udp_stream.xml b/recipes/examples/quick_guides/netperf/netperf_udp_stream.xml new file mode 100644 index 0000000..aa1964c --- /dev/null +++ b/recipes/examples/quick_guides/netperf/netperf_udp_stream.xml @@ -0,0 +1,41 @@ +<lnstrecipe> + <network> + <host id="testmachine1"> + <interfaces> + <eth label="tnet" id="testifc1"> + <addresses> + <address value="192.168.200.2/24"/> + </addresses> + </eth> + </interfaces> + </host> + <host id="testmachine2"> + <interfaces> + <eth label="tnet" id="testifc2"> + <addresses> + <address value="192.168.200.3/24"/> + </addresses> + </eth> + </interfaces> + </host> + </network> + <task> + <run module="Netperf" host="testmachine2" bg_id="server"> + <options> + <option name="role" value="server"/> + <option name="bind" value="{ip(testmachine2, testifc2)}"/> + </options> + </run> + <run module="Netperf" host="testmachine1"> + <options> + <option name="role" value="client"/> + <option name="netperf_server" value="{ip(testmachine2, testifc2)}"/> + <option name="testname" value="UDP_STREAM" /> + <option name="threshold" value="0 Mbits/sec" /> + </options> + </run> + + <kill host="testmachine2" bg_id="server"/> + + </task> +</lnstrecipe>
lnst-developers@lists.fedorahosted.org