Thu, Apr 20, 2017 at 05:21:46PM CEST, jprochaz(a)redhat.com wrote:
This method had two uses. When no param unit was specified it
converted
the rate to highest pretty unit. When param unit was specified, it
converted deviation rate to the same unit as the rate.
This patch splits these methods in two
Why do you need to split it? My guess is that it's related to previous
patch and expectation that you'll have bit/s units by default.
-Jan
>- _pretty_rate takes only rate as param and converts it to highest pretty unit.
>For RR tests it doesn't modify the rate and uses Trans/sec as unit.
>- _pretty_dev_rate takes two arguments, rate (deviation) and unit (which
>is equal to unit of the rate (throughput)) and converts the deviation
>rate to the same unit as the throughput rate. For RR tests it doesn't
>change anything.
>
>Occurences in the code have been updated to match the new layout of the
>functions.
>
>Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
>---
> test_modules/Netperf.py | 78 ++++++++++++++++++++++++++++---------------------
> 1 file changed, 45 insertions(+), 33 deletions(-)
>
>diff --git a/test_modules/Netperf.py b/test_modules/Netperf.py
>index fbc4885..b9227eb 100644
>--- a/test_modules/Netperf.py
>+++ b/test_modules/Netperf.py
>@@ -392,9 +392,13 @@ class Netperf(TestGeneric):
> if e.errno == errno.EINTR:
> server.kill()
>
>- def _pretty_rate(self, rate, unit=None):
>+ def _pretty_rate(self, rate):
> pretty_rate = {}
>- if unit is None:
>+
>+ if "RR" in self._testname:
>+ pretty_rate["unit"] = "Trans/sec"
>+ pretty_rate["rate"] = rate
>+ else:
> if rate < 1000:
> pretty_rate["unit"] = "bits/sec"
> pretty_rate["rate"] = rate
>@@ -410,34 +414,42 @@ class Netperf(TestGeneric):
> 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 _pretty_dev_rate(self, rate, unit):
>+ pretty_rate = {}
>+
>+ 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)
>+ elif unit == "Trans/sec":
>+ pretty_rate["unit"] = "Trans/sec"
>+ pretty_rate["rate"] = rate
>
> return pretty_rate
>
>@@ -505,7 +517,7 @@ class Netperf(TestGeneric):
> res_data["rate_deviation"] = rate_deviation
>
> rate_pretty = self._pretty_rate(rate)
>- rate_dev_pretty = self._pretty_rate(rate_deviation,
unit=rate_pretty["unit"])
>+ rate_dev_pretty = self._pretty_dev_rate(rate_deviation,
unit=rate_pretty["unit"])
>
> if rv != 0 and self._runs == 1:
> res_data["msg"] = "Could not get performance
throughput!"
>@@ -543,7 +555,7 @@ class Netperf(TestGeneric):
> 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"])
>+ pretty_deviation =
self._pretty_dev_rate(self._max_deviation["value"]["rate"])
> res_val = False
> res_data["msg"] = "Measured rate %.2f +-%.2f %s
has bigger "\
> "deviation than allowed (+-%.2f %s)"
%\
>@@ -558,7 +570,7 @@ class Netperf(TestGeneric):
> rate + rate_deviation)
>
> threshold_pretty = self._pretty_rate(self._threshold["rate"])
>- threshold_dev_pretty =
self._pretty_rate(self._threshold_deviation["rate"],
>+ threshold_dev_pretty =
self._pretty_dev_rate(self._threshold_deviation["rate"],
> unit =
threshold_pretty["unit"])
>
> if self._threshold_interval[0] > result_interval[1]:
>--
>2.9.3
>_______________________________________________
>LNST-developers mailing list -- lnst-developers(a)lists.fedorahosted.org
>To unsubscribe send an email to lnst-developers-leave(a)lists.fedorahosted.org