From dc8719279af043cd3678ef08965a07f7c023b4df Mon Sep 17 00:00:00 2001 From: Yichen Wang Date: Tue, 3 Mar 2015 14:55:49 -0800 Subject: [PATCH] Workaround for negative packet count bug in nuttcp Change to 1024 based unit conversion; Automatically fetch version string from vmtp.py; Change-Id: I473a2a03eb4153326c8ee7394b2a71a2815622b8 --- doc/source/conf.py | 9 ++++++--- doc/source/usage.rst | 2 +- nuttcp_tool.py | 12 ++++++++---- vmtp.py | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 6f93aff..02ab26d 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -13,8 +13,9 @@ # serve to show the default. import datetime -import sys import os +import re +import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -57,9 +58,11 @@ copyright = u"%d, OpenStack Foundation" % datetime.datetime.now().year # built documents. # # The short X.Y version. -version = '2.0.0' +vmtp_file = open("../../vmtp.py") +raw_text = vmtp_file.read() +version = re.search(r"__version__\s=\s'(\d+\.\d+\.\d+)'", raw_text).group(1) # The full version, including alpha/beta/rc tags. -release = '2.0.0' +release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/source/usage.rst b/doc/source/usage.rst index 13b933a..1ee8aab 100644 --- a/doc/source/usage.rst +++ b/doc/source/usage.rst @@ -19,7 +19,7 @@ VMTP Usage [--udpbuf ] [--no-env] [-d] [-v] [--stop-on-error] [--vm_image_url ] - OpenStack VM Throughput V2.0.0 + OpenStack VM Throughput V2.0.1 optional arguments: -h, --help show this help message and exit diff --git a/nuttcp_tool.py b/nuttcp_tool.py index eab3029..b3f1a33 100644 --- a/nuttcp_tool.py +++ b/nuttcp_tool.py @@ -166,15 +166,19 @@ class NuttcpTool(PerfTool): # UDP output (unicast and multicast): # megabytes=1.1924 real_seconds=10.01 rate_Mbps=0.9997 tx_cpu=99 rx_cpu=0 # drop=0 pkt=1221 data_loss=0.00000 - re_udp = r'rate_Mbps=([\d\.]*) tx_cpu=\d* rx_cpu=\d* drop=(\d*) pkt=(\d*)' + re_udp = r'rate_Mbps=([\d\.]*) tx_cpu=\d* rx_cpu=\d* drop=(\-*\d*) pkt=(\d*)' match = re.search(re_udp, cmd_out) if match: rate_mbps = float(match.group(1)) drop = float(match.group(2)) pkt = int(match.group(3)) - # nuttcp uses multiple of 1000 for Kbps - not 1024 + # Workaround for a bug of nuttcp that sometimes it will return a + # negative number for drop. + if drop < 0: + drop = 0 + return [self.parse_results('UDP', - int(rate_mbps * 1000), + int(rate_mbps * 1024), lossrate=round(drop * 100 / pkt, 2), reverse_dir=reverse_dir, msg_size=length, @@ -190,7 +194,7 @@ class NuttcpTool(PerfTool): retrans = int(match.group(2)) rtt_ms = float(match.group(3)) return [self.parse_results('TCP', - int(rate_mbps * 1000), + int(rate_mbps * 1024), retrans=retrans, rtt_ms=rtt_ms, reverse_dir=reverse_dir, diff --git a/vmtp.py b/vmtp.py index 537bb83..78f5d67 100755 --- a/vmtp.py +++ b/vmtp.py @@ -39,7 +39,7 @@ from neutronclient.v2_0 import client as neutronclient from novaclient.client import Client from novaclient.exceptions import ClientException -__version__ = '2.0.0' +__version__ = '2.0.1' from perf_instance import PerfInstance as PerfInstance