aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/storage/storperf.py
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2016-12-05 16:11:54 -0500
committerRoss Brattain <ross.b.brattain@intel.com>2017-01-12 18:25:04 -0800
commitf036e9898a69f5041f9cde02e3652c29e2de1643 (patch)
tree36e5eea75811bb640bb30f442f5a3c617e945909 /yardstick/benchmark/scenarios/storage/storperf.py
parent5f0b3d417244397b2d5e61c7a6ddd145f1d25046 (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/storage/storperf.py')
-rw-r--r--yardstick/benchmark/scenarios/storage/storperf.py27
1 files changed, 18 insertions, 9 deletions
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'])