diff options
author | Ross Brattain <ross.b.brattain@intel.com> | 2016-12-05 16:11:54 -0500 |
---|---|---|
committer | Ross Brattain <ross.b.brattain@intel.com> | 2017-01-12 18:25:04 -0800 |
commit | f036e9898a69f5041f9cde02e3652c29e2de1643 (patch) | |
tree | 36e5eea75811bb640bb30f442f5a3c617e945909 /yardstick/benchmark/scenarios | |
parent | 5f0b3d417244397b2d5e61c7a6ddd145f1d25046 (diff) |
Add support for Python 3
Porting to Python3 using Openstack guidelines:
https://wiki.openstack.org/wiki/Python3
This passes unittests on Python 3.5 and passes opnfv_smoke suite
Updates:
use six for urlparse and urlopen
fix exception.message attribute removal
run unittests on python3
use unitest.mock on python 3
fix open mock for vsperf
fix float division by using delta/eplison comparison
use unicode in StringIO
use plugin/sample_config.yaml relative path from test case
fixed apexlake unittests
upgraded to mock 2.0.0 to match python3 unittest.mock features
fixed flake8 issues
implement safe JSON decode with oslo_serialization.jsonutils.dump_as_bytes()
implement safe unicode encode/decode with oslo_utils.encodeutils
heat: convert pub key file from bytes to unicode
pkg_resources returns raw bytes, in python3
we have to decode this to utf-8 unicode
so JSON can encode it for heat template
JIRA: YARDSTICK-452
Change-Id: Ib80dd1d0c0eb0592acd832b82f6a7f8f7c20bfda
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Diffstat (limited to 'yardstick/benchmark/scenarios')
48 files changed, 256 insertions, 125 deletions
diff --git a/yardstick/benchmark/scenarios/availability/actionrollbackers.py b/yardstick/benchmark/scenarios/availability/actionrollbackers.py index 38f57d476..28c338d60 100644 --- a/yardstick/benchmark/scenarios/availability/actionrollbackers.py +++ b/yardstick/benchmark/scenarios/availability/actionrollbackers.py @@ -6,6 +6,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging LOG = logging.getLogger(__name__) diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py index e88fed636..7eb93a80f 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py +++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py @@ -6,11 +6,14 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging -import traceback import subprocess +import traceback + import yardstick.ssh as ssh -from baseattacker import BaseAttacker +from yardstick.benchmark.scenarios.availability.attacker.baseattacker import \ + BaseAttacker LOG = logging.getLogger(__name__) diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py index 595067a95..38a966803 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py +++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py @@ -6,11 +6,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging -from baseattacker import BaseAttacker import yardstick.ssh as ssh from yardstick.benchmark.scenarios.availability import util +from yardstick.benchmark.scenarios.availability.attacker.baseattacker import \ + BaseAttacker LOG = logging.getLogger(__name__) @@ -40,7 +42,7 @@ class GeneralAttacker(BaseAttacker): str = util.buildshellparams(actionParameter) LOG.debug("inject parameter is: {0}".format(actionParameter)) LOG.debug("inject parameter values are: {0}" - .format(actionParameter.values())) + .format(list(actionParameter.values()))) l = list(item for item in actionParameter.values()) self.action_param = str.format(*l) @@ -49,7 +51,7 @@ class GeneralAttacker(BaseAttacker): str = util.buildshellparams(rollbackParameter) LOG.debug("recover parameter is: {0}".format(rollbackParameter)) LOG.debug("recover parameter values are: {0}". - format(rollbackParameter.values())) + format(list(rollbackParameter.values()))) l = list(item for item in rollbackParameter.values()) self.rollback_param = str.format(*l) diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py index 1d190a160..521c57931 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py +++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py @@ -6,10 +6,12 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging -from baseattacker import BaseAttacker import yardstick.ssh as ssh +from yardstick.benchmark.scenarios.availability.attacker.baseattacker import \ + BaseAttacker LOG = logging.getLogger(__name__) diff --git a/yardstick/benchmark/scenarios/availability/attacker/baseattacker.py b/yardstick/benchmark/scenarios/availability/attacker/baseattacker.py index f96e57728..f5f74f291 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/baseattacker.py +++ b/yardstick/benchmark/scenarios/availability/attacker/baseattacker.py @@ -6,6 +6,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import pkg_resources import yaml import logging diff --git a/yardstick/benchmark/scenarios/availability/director.py b/yardstick/benchmark/scenarios/availability/director.py index 104c68380..76fcc0e7f 100644 --- a/yardstick/benchmark/scenarios/availability/director.py +++ b/yardstick/benchmark/scenarios/availability/director.py @@ -6,6 +6,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging from yardstick.benchmark.scenarios.availability.monitor import basemonitor diff --git a/yardstick/benchmark/scenarios/availability/monitor/basemonitor.py b/yardstick/benchmark/scenarios/availability/monitor/basemonitor.py index 38d1c4e5c..a11966a12 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/basemonitor.py +++ b/yardstick/benchmark/scenarios/availability/monitor/basemonitor.py @@ -6,6 +6,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import pkg_resources import logging import multiprocessing @@ -23,6 +24,7 @@ monitor_conf_path = pkg_resources.resource_filename( class MonitorMgr(object): """docstring for MonitorMgr""" + def __init__(self): self._monitor_list = [] @@ -130,7 +132,7 @@ class BaseMonitor(multiprocessing.Process): total_time = end_time - begin_time self._queue.put({"total_time": total_time, - "outage_time": last_outage-first_outage, + "outage_time": last_outage - first_outage, "total_count": total_count, "outage_count": outage_count}) diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_command.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_command.py index cd33e6188..6ddb73ea2 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_command.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_command.py @@ -6,11 +6,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging import subprocess import traceback + import yardstick.ssh as ssh -import basemonitor as basemonitor +from yardstick.benchmark.scenarios.availability.monitor import basemonitor LOG = logging.getLogger(__name__) diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py index 461a2ded5..78a603193 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py @@ -6,10 +6,11 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging import yardstick.ssh as ssh -import basemonitor as basemonitor +from yardstick.benchmark.scenarios.availability.monitor import basemonitor from yardstick.benchmark.scenarios.availability.util import buildshellparams diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py index 5f492ad69..10b398e9b 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py @@ -6,10 +6,11 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging import yardstick.ssh as ssh -import basemonitor as basemonitor +from yardstick.benchmark.scenarios.availability.monitor import basemonitor LOG = logging.getLogger(__name__) diff --git a/yardstick/benchmark/scenarios/availability/operation/baseoperation.py b/yardstick/benchmark/scenarios/availability/operation/baseoperation.py index 80efd1b02..709884b6f 100644 --- a/yardstick/benchmark/scenarios/availability/operation/baseoperation.py +++ b/yardstick/benchmark/scenarios/availability/operation/baseoperation.py @@ -6,6 +6,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import pkg_resources import yaml import logging diff --git a/yardstick/benchmark/scenarios/availability/operation/operation_general.py b/yardstick/benchmark/scenarios/availability/operation/operation_general.py index c82df836d..42d70f4da 100644 --- a/yardstick/benchmark/scenarios/availability/operation/operation_general.py +++ b/yardstick/benchmark/scenarios/availability/operation/operation_general.py @@ -6,8 +6,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging -from baseoperation import BaseOperation + +from yardstick.benchmark.scenarios.availability.operation.baseoperation \ + import \ + BaseOperation + import yardstick.ssh as ssh from yardstick.benchmark.scenarios.availability.util import buildshellparams diff --git a/yardstick/benchmark/scenarios/availability/result_checker/baseresultchecker.py b/yardstick/benchmark/scenarios/availability/result_checker/baseresultchecker.py index a24f26e81..70e004012 100644 --- a/yardstick/benchmark/scenarios/availability/result_checker/baseresultchecker.py +++ b/yardstick/benchmark/scenarios/availability/result_checker/baseresultchecker.py @@ -6,6 +6,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import pkg_resources import yaml import logging @@ -46,7 +47,7 @@ class ResultCheckerMgr(object): def verify(self): result = True for obj in self._result_checker_list: - result &= obj.success + result &= obj.success return result diff --git a/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py b/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py index 275aff076..75c433a0e 100644 --- a/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py +++ b/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py @@ -6,9 +6,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging -from baseresultchecker import BaseResultChecker + +from yardstick.benchmark.scenarios.availability.result_checker \ + .baseresultchecker import \ + BaseResultChecker from yardstick.benchmark.scenarios.availability import Condition import yardstick.ssh as ssh from yardstick.benchmark.scenarios.availability.util import buildshellparams diff --git a/yardstick/benchmark/scenarios/availability/scenario_general.py b/yardstick/benchmark/scenarios/availability/scenario_general.py index b064c6724..2d7ce664e 100644 --- a/yardstick/benchmark/scenarios/availability/scenario_general.py +++ b/yardstick/benchmark/scenarios/availability/scenario_general.py @@ -6,8 +6,8 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging -import traceback from yardstick.benchmark.scenarios import base from yardstick.benchmark.scenarios.availability.director import Director @@ -34,8 +34,8 @@ class ScenarioGeneral(base.Scenario): orderedSteps = sorted(steps, key=lambda x: x['index']) for step in orderedSteps: LOG.debug( - "\033[94m running step: {0} .... \033[0m" - .format(orderedSteps.index(step)+1)) + "\033[94m running step: %s .... \033[0m", + orderedSteps.index(step) + 1) try: actionPlayer = self.director.createActionPlayer( step['actionType'], step['actionKey']) @@ -44,9 +44,8 @@ class ScenarioGeneral(base.Scenario): step['actionType'], step['actionKey']) if actionRollbacker: self.director.executionSteps.append(actionRollbacker) - except Exception, e: - LOG.debug(e.message) - traceback.print_exc() + except Exception: + LOG.exception("Exception") LOG.debug( "\033[91m exception when running step: {0} .... \033[0m" .format(orderedSteps.index(step))) diff --git a/yardstick/benchmark/scenarios/availability/serviceha.py b/yardstick/benchmark/scenarios/availability/serviceha.py index 46a197c3b..b981c8cd8 100755 --- a/yardstick/benchmark/scenarios/availability/serviceha.py +++ b/yardstick/benchmark/scenarios/availability/serviceha.py @@ -6,6 +6,8 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import print_function +from __future__ import absolute_import import logging from yardstick.benchmark.scenarios import base from yardstick.benchmark.scenarios.availability.monitor import basemonitor @@ -109,15 +111,16 @@ def _test(): # pragma: no cover sla = {"outage_time": 5} args = {"options": options, "sla": sla} - print "create instance" + print("create instance") terstInstance = ServiceHA(args, ctx) terstInstance.setup() result = {} terstInstance.run(result) - print result + print(result) terstInstance.teardown() + if __name__ == '__main__': # pragma: no cover _test() diff --git a/yardstick/benchmark/scenarios/base.py b/yardstick/benchmark/scenarios/base.py index 33efbcbc4..5f5c07d3b 100644 --- a/yardstick/benchmark/scenarios/base.py +++ b/yardstick/benchmark/scenarios/base.py @@ -19,6 +19,7 @@ """ Scenario base class """ +from __future__ import absolute_import import yardstick.common.utils as utils diff --git a/yardstick/benchmark/scenarios/compute/cachestat.py b/yardstick/benchmark/scenarios/compute/cachestat.py index 20786ff61..0f60d466e 100644 --- a/yardstick/benchmark/scenarios/compute/cachestat.py +++ b/yardstick/benchmark/scenarios/compute/cachestat.py @@ -9,12 +9,14 @@ """cache hit/miss ratio and usage statistics""" +from __future__ import absolute_import import pkg_resources import logging import re import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base +from six.moves import zip LOG = logging.getLogger(__name__) @@ -120,7 +122,7 @@ class CACHEstat(base.Scenario): ite += 1 values = line[:] if values and len(values) == len(fields): - cachestat[cache] = dict(zip(fields, values)) + cachestat[cache] = dict(list(zip(fields, values))) for entry in cachestat: for item in average: diff --git a/yardstick/benchmark/scenarios/compute/computecapacity.py b/yardstick/benchmark/scenarios/compute/computecapacity.py index 7f0c58de1..9d518f7a0 100644 --- a/yardstick/benchmark/scenarios/compute/computecapacity.py +++ b/yardstick/benchmark/scenarios/compute/computecapacity.py @@ -6,9 +6,12 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import pkg_resources +from __future__ import absolute_import + import logging -import json + +import pkg_resources +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -66,4 +69,4 @@ class ComputeCapacity(base.Scenario): if status: raise RuntimeError(stderr) - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) diff --git a/yardstick/benchmark/scenarios/compute/cpuload.py b/yardstick/benchmark/scenarios/compute/cpuload.py index 9d71038ef..121d5a75d 100644 --- a/yardstick/benchmark/scenarios/compute/cpuload.py +++ b/yardstick/benchmark/scenarios/compute/cpuload.py @@ -9,13 +9,16 @@ """Processor statistics and system load.""" +from __future__ import absolute_import + import logging -import time import re -import yardstick.ssh as ssh +import time -from yardstick.benchmark.scenarios import base +from six.moves import map, zip +import yardstick.ssh as ssh +from yardstick.benchmark.scenarios import base LOG = logging.getLogger(__name__) @@ -145,7 +148,7 @@ class CPULoad(base.Scenario): cpu = 'cpu' if line[0] == 'all' else 'cpu' + line[0] values = line[1:] if values and len(values) == len(fields): - temp_dict = dict(zip(fields, values)) + temp_dict = dict(list(zip(fields, values))) if cpu not in maximum: maximum[cpu] = temp_dict else: @@ -177,7 +180,7 @@ class CPULoad(base.Scenario): cpu = 'cpu' if line[0] == 'all' else 'cpu' + line[0] values = line[1:] if values and len(values) == len(fields): - average[cpu] = dict(zip(fields, values)) + average[cpu] = dict(list(zip(fields, values))) else: raise RuntimeError("mpstat average: parse error", fields, line) @@ -210,9 +213,9 @@ class CPULoad(base.Scenario): cpu = cur_list[0] - cur_stats = map(int, cur_list[1:]) + cur_stats = list(map(int, cur_list[1:])) if self.interval > 0: - prev_stats = map(int, prev_list[1:]) + prev_stats = list(map(int, prev_list[1:])) else: prev_stats = [0] * len(cur_stats) @@ -236,9 +239,9 @@ class CPULoad(base.Scenario): else: return "%.2f" % (100.0 * (x - y) / samples) - load = map(_percent, cur_stats, prev_stats) + load = list(map(_percent, cur_stats, prev_stats)) - mpstat[cpu] = dict(zip(fields, load)) + mpstat[cpu] = dict(list(zip(fields, load))) return {'mpstat': mpstat} @@ -278,7 +281,7 @@ class CPULoad(base.Scenario): # p = CPULoad(args, ctx) # p.run(result) # import json -# print json.dumps(result) +# print(oslo_serialization.jsonutils.dump_as_bytes(result)) # if __name__ == '__main__': # _test() diff --git a/yardstick/benchmark/scenarios/compute/cyclictest.py b/yardstick/benchmark/scenarios/compute/cyclictest.py index 568e6e7df..76bafff2b 100644 --- a/yardstick/benchmark/scenarios/compute/cyclictest.py +++ b/yardstick/benchmark/scenarios/compute/cyclictest.py @@ -6,12 +6,16 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import pkg_resources +from __future__ import absolute_import +from __future__ import print_function + import logging -import json +import os import re import time -import os + +import pkg_resources +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -183,7 +187,7 @@ class Cyclictest(base.Scenario): if status: raise RuntimeError(stderr) - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) if "sla" in self.scenario_cfg: sla_error = "" @@ -236,7 +240,8 @@ def _test(): # pragma: no cover cyclictest = Cyclictest(args, ctx) cyclictest.run(result) - print result + print(result) + if __name__ == '__main__': # pragma: no cover _test() diff --git a/yardstick/benchmark/scenarios/compute/lmbench.py b/yardstick/benchmark/scenarios/compute/lmbench.py index 518840c09..6a17ae8a1 100644 --- a/yardstick/benchmark/scenarios/compute/lmbench.py +++ b/yardstick/benchmark/scenarios/compute/lmbench.py @@ -6,9 +6,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import pkg_resources +from __future__ import absolute_import +from __future__ import print_function + import logging -import json + +import pkg_resources +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -130,9 +134,10 @@ class Lmbench(base.Scenario): raise RuntimeError(stderr) if test_type == 'latency': - result.update({"latencies": json.loads(stdout)}) + result.update( + {"latencies": jsonutils.loads(stdout)}) else: - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) if "sla" in self.scenario_cfg: sla_error = "" @@ -185,7 +190,8 @@ def _test(): p = Lmbench(args, ctx) p.run(result) - print result + print(result) + if __name__ == '__main__': _test() diff --git a/yardstick/benchmark/scenarios/compute/memload.py b/yardstick/benchmark/scenarios/compute/memload.py index e1ba93d02..35528d4ef 100644 --- a/yardstick/benchmark/scenarios/compute/memload.py +++ b/yardstick/benchmark/scenarios/compute/memload.py @@ -9,10 +9,12 @@ """Memory load and statistics.""" +from __future__ import absolute_import import logging import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base +from six.moves import zip LOG = logging.getLogger(__name__) @@ -88,7 +90,7 @@ class MEMLoad(base.Scenario): ite += 1 values = line[1:] if values and len(values) == len(fields): - free[memory] = dict(zip(fields, values)) + free[memory] = dict(list(zip(fields, values))) for entry in free: for item in average: diff --git a/yardstick/benchmark/scenarios/compute/perf.py b/yardstick/benchmark/scenarios/compute/perf.py index 8f1a4d630..ae4990688 100644 --- a/yardstick/benchmark/scenarios/compute/perf.py +++ b/yardstick/benchmark/scenarios/compute/perf.py @@ -6,9 +6,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import pkg_resources +from __future__ import absolute_import +from __future__ import print_function + import logging -import json + +import pkg_resources +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -100,7 +104,7 @@ class Perf(base.Scenario): if status: raise RuntimeError(stdout) - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) if "sla" in self.scenario_cfg: metric = self.scenario_cfg['sla']['metric'] @@ -140,7 +144,8 @@ def _test(): p = Perf(args, ctx) p.run(result) - print result + print(result) + if __name__ == '__main__': _test() diff --git a/yardstick/benchmark/scenarios/compute/plugintest.py b/yardstick/benchmark/scenarios/compute/plugintest.py index e7ec91c5c..c9d025964 100644 --- a/yardstick/benchmark/scenarios/compute/plugintest.py +++ b/yardstick/benchmark/scenarios/compute/plugintest.py @@ -6,8 +6,11 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import + import logging -import json + +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -53,4 +56,4 @@ class PluginTest(base.Scenario): if status: raise RuntimeError(stderr) - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) diff --git a/yardstick/benchmark/scenarios/compute/ramspeed.py b/yardstick/benchmark/scenarios/compute/ramspeed.py index db70af90b..4330202de 100644 --- a/yardstick/benchmark/scenarios/compute/ramspeed.py +++ b/yardstick/benchmark/scenarios/compute/ramspeed.py @@ -6,9 +6,12 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import pkg_resources +from __future__ import absolute_import + import logging -import json + +import pkg_resources +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -131,7 +134,7 @@ class Ramspeed(base.Scenario): if status: raise RuntimeError(stderr) - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) if "sla" in self.scenario_cfg: sla_error = "" diff --git a/yardstick/benchmark/scenarios/compute/unixbench.py b/yardstick/benchmark/scenarios/compute/unixbench.py index b22be29c9..4a2eb9766 100644 --- a/yardstick/benchmark/scenarios/compute/unixbench.py +++ b/yardstick/benchmark/scenarios/compute/unixbench.py @@ -6,9 +6,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import pkg_resources +from __future__ import absolute_import +from __future__ import print_function + import logging -import json + +import pkg_resources +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -115,7 +119,7 @@ class Unixbench(base.Scenario): if status: raise RuntimeError(stderr) - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) if "sla" in self.scenario_cfg: sla_error = "" @@ -152,7 +156,7 @@ def _test(): # pragma: no cover p = Unixbench(args, ctx) p.run(result) - print result + print(result) if __name__ == '__main__': diff --git a/yardstick/benchmark/scenarios/dummy/dummy.py b/yardstick/benchmark/scenarios/dummy/dummy.py index de6742c40..95146e0c5 100644 --- a/yardstick/benchmark/scenarios/dummy/dummy.py +++ b/yardstick/benchmark/scenarios/dummy/dummy.py @@ -6,6 +6,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging from yardstick.benchmark.scenarios import base diff --git a/yardstick/benchmark/scenarios/networking/iperf3.py b/yardstick/benchmark/scenarios/networking/iperf3.py index 13fa0155b..b8ec9acdf 100644 --- a/yardstick/benchmark/scenarios/networking/iperf3.py +++ b/yardstick/benchmark/scenarios/networking/iperf3.py @@ -10,9 +10,13 @@ # iperf3 scenario # iperf3 homepage at: http://software.es.net/iperf/ +from __future__ import absolute_import +from __future__ import print_function + import logging -import json + import pkg_resources +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -89,7 +93,7 @@ For more info see http://software.es.net/iperf self.host.close() status, stdout, stderr = self.target.execute("pkill iperf3") if status: - LOG.warn(stderr) + LOG.warning(stderr) self.target.close() def run(self, result): @@ -138,7 +142,8 @@ For more info see http://software.es.net/iperf # Note: convert all ints to floats in order to avoid # schema conflicts in influxdb. We probably should add # a format func in the future. - result.update(json.loads(stdout, parse_int=float)) + result.update( + jsonutils.loads(stdout, parse_int=float)) if "sla" in self.scenario_cfg: sla_iperf = self.scenario_cfg["sla"] @@ -188,7 +193,8 @@ def _test(): p = Iperf(args, ctx) p.run(result) - print result + print(result) + if __name__ == '__main__': _test() diff --git a/yardstick/benchmark/scenarios/networking/netperf.py b/yardstick/benchmark/scenarios/networking/netperf.py index 28f5bea56..80dbed334 100755 --- a/yardstick/benchmark/scenarios/networking/netperf.py +++ b/yardstick/benchmark/scenarios/networking/netperf.py @@ -7,9 +7,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## # bulk data test and req/rsp test are supported -import pkg_resources +from __future__ import absolute_import +from __future__ import print_function + import logging -import json + +import pkg_resources +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -129,7 +133,7 @@ class Netperf(base.Scenario): if status: raise RuntimeError(stderr) - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) if result['mean_latency'] == '': raise RuntimeError(stdout) @@ -175,7 +179,7 @@ def _test(): netperf = Netperf(args, ctx) netperf.run(result) - print result + print(result) if __name__ == '__main__': diff --git a/yardstick/benchmark/scenarios/networking/netperf_node.py b/yardstick/benchmark/scenarios/networking/netperf_node.py index a76982b6f..0cf52b8dd 100755 --- a/yardstick/benchmark/scenarios/networking/netperf_node.py +++ b/yardstick/benchmark/scenarios/networking/netperf_node.py @@ -7,9 +7,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## # bulk data test and req/rsp test are supported -import pkg_resources +from __future__ import absolute_import +from __future__ import print_function + import logging -import json + +import pkg_resources +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -152,7 +156,7 @@ class NetperfNode(base.Scenario): if status: raise RuntimeError(stderr) - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) if result['mean_latency'] == '': raise RuntimeError(stdout) @@ -200,7 +204,8 @@ def _test(): # pragma: no cover netperf = NetperfNode(args, ctx) netperf.run(result) - print result + print(result) + if __name__ == '__main__': _test() diff --git a/yardstick/benchmark/scenarios/networking/netutilization.py b/yardstick/benchmark/scenarios/networking/netutilization.py index 1ea92cca3..1ba6f1ec3 100644 --- a/yardstick/benchmark/scenarios/networking/netutilization.py +++ b/yardstick/benchmark/scenarios/networking/netutilization.py @@ -6,11 +6,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging import re import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base +from six.moves import zip LOG = logging.getLogger(__name__) @@ -121,7 +123,7 @@ class NetUtilization(base.Scenario): values = line[1:] if values and len(values) == len(fields): - temp_dict = dict(zip(fields, values)) + temp_dict = dict(list(zip(fields, values))) if net_interface not in maximum: maximum[net_interface] = temp_dict else: @@ -158,7 +160,8 @@ class NetUtilization(base.Scenario): net_interface = line[0] values = line[1:] if values and len(values) == len(fields): - average[net_interface] = dict(zip(fields, values)) + average[net_interface] = dict( + list(zip(fields, values))) else: raise RuntimeError("network_utilization average: \ parse error", fields, line) diff --git a/yardstick/benchmark/scenarios/networking/networkcapacity.py b/yardstick/benchmark/scenarios/networking/networkcapacity.py index 250f7eaf0..e7ce83570 100644 --- a/yardstick/benchmark/scenarios/networking/networkcapacity.py +++ b/yardstick/benchmark/scenarios/networking/networkcapacity.py @@ -6,9 +6,12 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import pkg_resources +from __future__ import absolute_import + import logging -import json + +import pkg_resources +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -67,4 +70,4 @@ class NetworkCapacity(base.Scenario): if status: raise RuntimeError(stderr) - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) diff --git a/yardstick/benchmark/scenarios/networking/ping.py b/yardstick/benchmark/scenarios/networking/ping.py index 6e49a1437..eb173f1df 100644 --- a/yardstick/benchmark/scenarios/networking/ping.py +++ b/yardstick/benchmark/scenarios/networking/ping.py @@ -9,6 +9,8 @@ # ping scenario +from __future__ import print_function +from __future__ import absolute_import import pkg_resources import logging @@ -122,7 +124,8 @@ def _test(): # pragma: no cover p = Ping(args, ctx) p.run(result) - print result + print(result) + if __name__ == '__main__': # pragma: no cover _test() diff --git a/yardstick/benchmark/scenarios/networking/ping6.py b/yardstick/benchmark/scenarios/networking/ping6.py index f4d23ce7b..dd4272236 100644 --- a/yardstick/benchmark/scenarios/networking/ping6.py +++ b/yardstick/benchmark/scenarios/networking/ping6.py @@ -7,6 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import pkg_resources import logging diff --git a/yardstick/benchmark/scenarios/networking/pktgen.py b/yardstick/benchmark/scenarios/networking/pktgen.py index e2df706a2..69663ec5f 100644 --- a/yardstick/benchmark/scenarios/networking/pktgen.py +++ b/yardstick/benchmark/scenarios/networking/pktgen.py @@ -6,9 +6,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import pkg_resources +from __future__ import absolute_import +from __future__ import print_function + import logging -import json + +import pkg_resources +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -130,7 +134,7 @@ class Pktgen(base.Scenario): if status: raise RuntimeError(stderr) - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) result['packets_received'] = self._iptables_get_result() @@ -170,7 +174,7 @@ def _test(): p = Pktgen(args, ctx) p.run(result) - print result + print(result) if __name__ == '__main__': diff --git a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py index 503ea97e1..2bdb91abb 100644 --- a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py +++ b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py @@ -6,6 +6,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import pkg_resources import logging import time diff --git a/yardstick/benchmark/scenarios/networking/sfc.py b/yardstick/benchmark/scenarios/networking/sfc.py index 1bd99b957..87fea4f95 100644 --- a/yardstick/benchmark/scenarios/networking/sfc.py +++ b/yardstick/benchmark/scenarios/networking/sfc.py @@ -1,9 +1,14 @@ -import pkg_resources +from __future__ import absolute_import + import logging import subprocess -import sfc_openstack + +import pkg_resources +from six.moves import range + import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base +from yardstick.benchmark.scenarios.networking import sfc_openstack LOG = logging.getLogger(__name__) @@ -199,7 +204,7 @@ class Sfc(base.Scenario): # pragma: no cover sfc = Sfc(scenario_cfg, context_cfg) sfc.setup() sfc.run(result) - print result + print(result) sfc.teardown() if __name__ == '__main__': # pragma: no cover diff --git a/yardstick/benchmark/scenarios/networking/sfc_openstack.py b/yardstick/benchmark/scenarios/networking/sfc_openstack.py index d1d45d8e4..caaf10060 100644 --- a/yardstick/benchmark/scenarios/networking/sfc_openstack.py +++ b/yardstick/benchmark/scenarios/networking/sfc_openstack.py @@ -1,3 +1,5 @@ +from __future__ import print_function +from __future__ import absolute_import import os from novaclient import client as novaclient from neutronclient.v2_0 import client as neutronclient @@ -40,8 +42,8 @@ def get_credentials(service): # pragma: no cover "ca_file": cacert}) creds.update({"insecure": "True", "https_insecure": "True"}) if not os.path.isfile(cacert): - print ("WARNING: The 'OS_CACERT' environment variable is " + - "set to %s but the file does not exist." % cacert) + print(("WARNING: The 'OS_CACERT' environment variable is " + + "set to %s but the file does not exist." % cacert)) return creds @@ -49,8 +51,8 @@ def get_instances(nova_client): # pragma: no cover try: instances = nova_client.servers.list(search_opts={'all_tenants': 1}) return instances - except Exception, e: - print "Error [get_instances(nova_client)]:", e + except Exception as e: + print("Error [get_instances(nova_client)]:", e) return None @@ -62,8 +64,8 @@ def get_SFs(nova_client): # pragma: no cover if "sfc_test" not in instance.name: SFs.append(instance) return SFs - except Exception, e: - print "Error [get_SFs(nova_client)]:", e + except Exception as e: + print("Error [get_SFs(nova_client)]:", e) return None @@ -83,8 +85,8 @@ def create_floating_ips(neutron_client): # pragma: no cover ip_json = neutron_client.create_floatingip({'floatingip': props}) fip_addr = ip_json['floatingip']['floating_ip_address'] ips.append(fip_addr) - except Exception, e: - print "Error [create_floating_ip(neutron_client)]:", e + except Exception as e: + print("Error [create_floating_ip(neutron_client)]:", e) return None return ips @@ -96,9 +98,9 @@ def floatIPtoSFs(SFs, floatips): # pragma: no cover SF.add_floating_ip(floatips[i]) i = i + 1 return True - except Exception, e: - print ("Error [add_floating_ip(nova_client, '%s', '%s')]:" % - (SF, floatips[i]), e) + except Exception as e: + print(("Error [add_floating_ip(nova_client, '%s', '%s')]:" % + (SF, floatips[i]), e)) return False @@ -113,5 +115,6 @@ def get_an_IP(): # pragma: no cover floatIPtoSFs(SFs, floatips) return floatips + if __name__ == '__main__': # pragma: no cover get_an_IP() diff --git a/yardstick/benchmark/scenarios/networking/vsperf.py b/yardstick/benchmark/scenarios/networking/vsperf.py index 4f4ef21eb..9d6db7c1d 100644 --- a/yardstick/benchmark/scenarios/networking/vsperf.py +++ b/yardstick/benchmark/scenarios/networking/vsperf.py @@ -13,6 +13,7 @@ # limitations under the License. """ Vsperf specific scenario definition """ +from __future__ import absolute_import import logging import os import subprocess @@ -211,7 +212,7 @@ class Vsperf(base.Scenario): # convert result.csv to JSON format reader = csv.DictReader(stdout.split('\r\n')) - result.update(reader.next()) + result.update(next(reader)) # sla check; go through all defined SLAs and check if values measured # by VSPERF are higher then those defined by SLAs diff --git a/yardstick/benchmark/scenarios/networking/vtc_instantiation_validation.py b/yardstick/benchmark/scenarios/networking/vtc_instantiation_validation.py index bec23fc52..bf42d9a9a 100644 --- a/yardstick/benchmark/scenarios/networking/vtc_instantiation_validation.py +++ b/yardstick/benchmark/scenarios/networking/vtc_instantiation_validation.py @@ -7,6 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging import os @@ -81,7 +82,7 @@ class VtcInstantiationValidation(base.Scenario): heat_template_parameters, deployment_configuration, openstack_credentials) - except Exception as e: - LOG.info('Exception: {}'.format(e.message)) - LOG.info('Got output: {}'.format(res)) + except Exception: + LOG.exception('Exception') + LOG.info('Got output: %s', res) result.update(res) diff --git a/yardstick/benchmark/scenarios/networking/vtc_instantiation_validation_noisy.py b/yardstick/benchmark/scenarios/networking/vtc_instantiation_validation_noisy.py index 8d9bf0962..fb6e762d1 100644 --- a/yardstick/benchmark/scenarios/networking/vtc_instantiation_validation_noisy.py +++ b/yardstick/benchmark/scenarios/networking/vtc_instantiation_validation_noisy.py @@ -7,6 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging import os @@ -92,7 +93,7 @@ class VtcInstantiationValidationNoisy(base.Scenario): heat_template_parameters, deployment_configuration, openstack_credentials) - except Exception as e: - LOG.info('Exception: {}'.format(e.message)) - LOG.info('Got output: {}'.format(res)) + except Exception: + LOG.exception('Exception') + LOG.info('Got output: %s', res) result.update(res) diff --git a/yardstick/benchmark/scenarios/networking/vtc_throughput.py b/yardstick/benchmark/scenarios/networking/vtc_throughput.py index ff20279ff..0754d3782 100644 --- a/yardstick/benchmark/scenarios/networking/vtc_throughput.py +++ b/yardstick/benchmark/scenarios/networking/vtc_throughput.py @@ -7,6 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging import os @@ -81,7 +82,7 @@ class VtcThroughput(base.Scenario): heat_template_parameters, deployment_configuration, openstack_credentials) - except Exception as e: - LOG.info('Exception: {}'.format(e.message)) - LOG.info('Got output: {}'.format(res)) + except Exception: + LOG.exception("Exception") + LOG.info('Got output: %s', res) result.update(res) diff --git a/yardstick/benchmark/scenarios/networking/vtc_throughput_noisy.py b/yardstick/benchmark/scenarios/networking/vtc_throughput_noisy.py index f03226732..552ef8090 100644 --- a/yardstick/benchmark/scenarios/networking/vtc_throughput_noisy.py +++ b/yardstick/benchmark/scenarios/networking/vtc_throughput_noisy.py @@ -7,6 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging import os @@ -91,7 +92,7 @@ class VtcThroughputNoisy(base.Scenario): heat_template_parameters, deployment_configuration, openstack_credentials) - except Exception as e: - LOG.info('Exception: {}'.format(e.message)) - LOG.info('Got output: {}'.format(res)) + except Exception: + LOG.exception('Exception') + LOG.info('Got output: %s', res) result.update(res) diff --git a/yardstick/benchmark/scenarios/parser/parser.py b/yardstick/benchmark/scenarios/parser/parser.py index bb16e7c89..6d39733c6 100644 --- a/yardstick/benchmark/scenarios/parser/parser.py +++ b/yardstick/benchmark/scenarios/parser/parser.py @@ -6,6 +6,8 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import print_function +from __future__ import absolute_import import pkg_resources import logging import subprocess @@ -61,7 +63,7 @@ class Parser(base.Scenario): p = subprocess.Popen(cmd1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.communicate() - print "yangtotosca finished" + print("yangtotosca finished") result['yangtotosca'] = "success" if p.returncode == 0 else "fail" @@ -78,5 +80,6 @@ def _test(): '''internal test function''' pass + if __name__ == '__main__': _test() diff --git a/yardstick/benchmark/scenarios/storage/fio.py b/yardstick/benchmark/scenarios/storage/fio.py index 4e004235d..2a8738e88 100644 --- a/yardstick/benchmark/scenarios/storage/fio.py +++ b/yardstick/benchmark/scenarios/storage/fio.py @@ -6,9 +6,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import pkg_resources +from __future__ import absolute_import +from __future__ import print_function + import logging -import json + +import pkg_resources +from oslo_serialization import jsonutils import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -114,7 +118,7 @@ class Fio(base.Scenario): if status: raise RuntimeError(stderr) - raw_data = json.loads(stdout) + raw_data = jsonutils.loads(stdout) # The bandwidth unit is KB/s, and latency unit is us if rw in ["read", "randread", "rw", "randrw"]: @@ -175,7 +179,8 @@ def _test(): fio = Fio(args, ctx) fio.run(result) - print result + print(result) + if __name__ == '__main__': _test() diff --git a/yardstick/benchmark/scenarios/storage/storagecapacity.py b/yardstick/benchmark/scenarios/storage/storagecapacity.py index bf5bc2810..c437f22c0 100644 --- a/yardstick/benchmark/scenarios/storage/storagecapacity.py +++ b/yardstick/benchmark/scenarios/storage/storagecapacity.py @@ -6,9 +6,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import pkg_resources +from __future__ import absolute_import + import logging -import json + +import pkg_resources +from oslo_serialization import jsonutils +from six.moves import range import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base @@ -131,4 +135,4 @@ class StorageCapacity(base.Scenario): if status: raise RuntimeError(stderr) - result.update(json.loads(stdout)) + result.update(jsonutils.loads(stdout)) diff --git a/yardstick/benchmark/scenarios/storage/storperf.py b/yardstick/benchmark/scenarios/storage/storperf.py index 72ceff7ce..6ea035133 100644 --- a/yardstick/benchmark/scenarios/storage/storperf.py +++ b/yardstick/benchmark/scenarios/storage/storperf.py @@ -6,11 +6,14 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import + import logging -import json -import requests import time +import requests +from oslo_serialization import jsonutils + from yardstick.benchmark.scenarios import base LOG = logging.getLogger(__name__) @@ -73,7 +76,8 @@ class StorPerf(base.Scenario): setup_query = requests.get('http://%s:5000/api/v1.0/configurations' % self.target) - setup_query_content = json.loads(setup_query.content) + setup_query_content = jsonutils.loads( + setup_query.content) if setup_query_content["stack_created"]: self.setup_done = True LOG.debug("stack_created: %s", @@ -96,7 +100,8 @@ class StorPerf(base.Scenario): setup_res = requests.post('http://%s:5000/api/v1.0/configurations' % self.target, json=env_args) - setup_res_content = json.loads(setup_res.content) + setup_res_content = jsonutils.loads( + setup_res.content) if setup_res.status_code != 200: raise RuntimeError("Failed to create a stack, error message:", @@ -114,7 +119,8 @@ class StorPerf(base.Scenario): report_res = requests.get('http://{}:5000/api/v1.0/jobs'.format (self.target), params={'id': job_id}) - report_res_content = json.loads(report_res.content) + report_res_content = jsonutils.loads( + report_res.content) if report_res.status_code != 200: raise RuntimeError("Failed to fetch report, error message:", @@ -154,7 +160,7 @@ class StorPerf(base.Scenario): job_res = requests.post('http://%s:5000/api/v1.0/jobs' % self.target, json=job_args) - job_res_content = json.loads(job_res.content) + job_res_content = jsonutils.loads(job_res.content) if job_res.status_code != 200: raise RuntimeError("Failed to start a job, error message:", @@ -171,7 +177,8 @@ class StorPerf(base.Scenario): self.target) if terminate_res.status_code != 200: - terminate_res_content = json.loads(terminate_res.content) + terminate_res_content = jsonutils.loads( + terminate_res.content) raise RuntimeError("Failed to start a job, error message:", terminate_res_content["message"]) @@ -190,7 +197,8 @@ class StorPerf(base.Scenario): result_res = requests.get('http://%s:5000/api/v1.0/jobs?id=%s' % (self.target, job_id)) - result_res_content = json.loads(result_res.content) + result_res_content = jsonutils.loads( + result_res.content) result.update(result_res_content) @@ -200,7 +208,8 @@ class StorPerf(base.Scenario): configurations' % self.target) if teardown_res.status_code == 400: - teardown_res_content = json.loads(teardown_res.content) + teardown_res_content = jsonutils.loads( + teardown_res.content) raise RuntimeError("Failed to reset environment, error message:", teardown_res_content['message']) |