summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2017-03-09 08:59:29 +0000
committerchenjiankun <chenjiankun1@huawei.com>2017-03-13 08:19:16 +0000
commita416a8f615be4555dbfe15951c7b414c0daa6d34 (patch)
tree09c48e671f646e1b75859ef2d515e5baf59ae6a3
parent106eae2d19ca59e27262a7d8c3cd4501507697ff (diff)
Bugfix: network_utilization: parse error
JIRA: YARDSTICK-586 When run tc072, there is a bug: network_utilization: parse error, see the log: ERROR ('network_utilization: parse error', [], [u'05:10:46', u'IFACE', u'rxpck/s', u'txpck/s', u'rxkB/s', u'txkB/s', u'rxcmp/s', u'txcmp/s', u'rxmcst/s', u'%ifutil']) Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/yardstick/benchmark/runners/duration.py", line 69, in _worker_process method(data) File "/usr/local/lib/python2.7/dist-packages/yardstick/benchmark/scenarios/networking/netutilization.py", line 191, in run result.update(self._get_network_utilization()) File "/usr/local/lib/python2.7/dist-packages/yardstick/benchmark/scenarios/networking/netutilization.py", line 182, in _get_network_utilization result = self._filtrate_result(raw_result) File "/usr/local/lib/python2.7/dist-packages/yardstick/benchmark/scenarios/networking/netutilization.py", line 146, in _filtrate_result fields, line) RuntimeError: ('network_utilization: parse error', [], [u'05:10:46', u'IFACE', u'rxpck/s', u'txpck/s', u'rxkB/s', u'txkB/s', u'rxcmp/s', u'txcmp/s', u'rxmcst/s', u'%ifutil']) Maybe the tool has some changes. Change-Id: I6c4fe3fe9f749ec942fb5fbd799b8f4ab9a5c16c Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
-rw-r--r--yardstick/benchmark/scenarios/networking/netutilization.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/yardstick/benchmark/scenarios/networking/netutilization.py b/yardstick/benchmark/scenarios/networking/netutilization.py
index 1ba6f1ec3..37da7f895 100644
--- a/yardstick/benchmark/scenarios/networking/netutilization.py
+++ b/yardstick/benchmark/scenarios/networking/netutilization.py
@@ -100,30 +100,22 @@ class NetUtilization(base.Scenario):
average = {}
time_marker = re.compile("^([0-9]+):([0-9]+):([0-9]+)$")
- ampm_marker = re.compile("(AM|PM)$")
# Parse network utilization stats
- for row in raw_result.split('\n'):
+ for row in raw_result.splitlines():
line = row.split()
if line and re.match(time_marker, line[0]):
- if re.match(ampm_marker, line[1]):
- del line[:2]
- if line[0] == 'IFACE':
- # header fields
- fields = line[1:]
- if len(fields) != NetUtilization.\
- NET_UTILIZATION_FIELD_SIZE:
- raise RuntimeError("network_utilization: unexpected\
- field size", fields)
- else:
- # value fields
+ try:
+ index = line.index('IFACE')
+ except ValueError:
+ del line[:index]
net_interface = line[0]
values = line[1:]
if values and len(values) == len(fields):
- temp_dict = dict(list(zip(fields, values)))
+ temp_dict = dict(zip(fields, values))
if net_interface not in maximum:
maximum[net_interface] = temp_dict
else:
@@ -144,6 +136,13 @@ class NetUtilization(base.Scenario):
else:
raise RuntimeError("network_utilization: parse error",
fields, line)
+ else:
+ del line[:index]
+ fields = line[1:]
+ if len(fields) != NetUtilization.\
+ NET_UTILIZATION_FIELD_SIZE:
+ raise RuntimeError("network_utilization: unexpected\
+ field size", fields)
elif line and line[0] == 'Average:':
del line[:1]
@@ -161,7 +160,7 @@ class NetUtilization(base.Scenario):
values = line[1:]
if values and len(values) == len(fields):
average[net_interface] = dict(
- list(zip(fields, values)))
+ zip(fields, values))
else:
raise RuntimeError("network_utilization average: \
parse error", fields, line)