Netperf does not properly handle confidence calculation when measured throughput is 0. E.g. when firewall blocks the data stream. When this happens netperf reports -nan for confidence level instead of some reasonable number. This patch adds exception check while parsing confidence levels.
Fixes #170.
Signed-off-by: Jan Tluka jtluka@redhat.com --- test_modules/Netperf.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/test_modules/Netperf.py b/test_modules/Netperf.py index 7b9d7f7..5f00d54 100644 --- a/test_modules/Netperf.py +++ b/test_modules/Netperf.py @@ -223,7 +223,14 @@ class Netperf(TestGeneric): def _parse_confidence_omni(self, output): pattern_throughput_confid = "THROUGHPUT_CONFID=([-]?\d+.\d+)" pattern_confidence_level = "CONFIDENCE_LEVEL=(\d+)" - throughput_confid = float(re.search(pattern_throughput_confid, output).group(1)) + try: + throughput_confid = float(re.search(pattern_throughput_confid, output).group(1)) + except AttributeError: + # when netperf measures throughput=0 it tries to divide by 0 and + # prints THROUGHPUT_CONFID=-nan + logging.warning("Could not parse THROUGHPUT_CONFID") + return (0, 0.0) + confidence_level = int(re.search(pattern_confidence_level, output).group(1))
real_confidence = (confidence_level, throughput_confid/2)
lnst-developers@lists.fedorahosted.org