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/runners | |
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/runners')
-rwxr-xr-x | yardstick/benchmark/runners/arithmetic.py | 21 | ||||
-rwxr-xr-x | yardstick/benchmark/runners/base.py | 1 | ||||
-rw-r--r-- | yardstick/benchmark/runners/duration.py | 1 | ||||
-rw-r--r-- | yardstick/benchmark/runners/iteration.py | 1 | ||||
-rw-r--r-- | yardstick/benchmark/runners/sequence.py | 1 |
5 files changed, 17 insertions, 8 deletions
diff --git a/yardstick/benchmark/runners/arithmetic.py b/yardstick/benchmark/runners/arithmetic.py index 69ea915a1..956c3ffd1 100755 --- a/yardstick/benchmark/runners/arithmetic.py +++ b/yardstick/benchmark/runners/arithmetic.py @@ -24,12 +24,17 @@ until the end of the shortest list is reached (optimally all lists should be defined with the same number of values when using such iter_type). ''' -import os -import multiprocessing +from __future__ import absolute_import + +import itertools import logging -import traceback +import multiprocessing +import os import time -import itertools +import traceback + +import six +from six.moves import range from yardstick.benchmark.runners import base @@ -71,8 +76,8 @@ def _worker_process(queue, cls, method_name, scenario_cfg, return -1 if start > stop else 1 param_iters = \ - [xrange(d['start'], d['stop'] + margin(d['start'], d['stop']), - d['step']) for d in runner_cfg['iterators']] + [range(d['start'], d['stop'] + margin(d['start'], d['stop']), + d['step']) for d in runner_cfg['iterators']] param_names = [d['name'] for d in runner_cfg['iterators']] iter_type = runner_cfg.get("iter_type", "nested_for_loops") @@ -82,10 +87,10 @@ def _worker_process(queue, cls, method_name, scenario_cfg, loop_iter = itertools.product(*param_iters) elif iter_type == 'tuple_loops': # Combine each i;th index of respective parameter list - loop_iter = itertools.izip(*param_iters) + loop_iter = six.moves.zip(*param_iters) else: LOG.warning("iter_type unrecognized: %s", iter_type) - raise + raise TypeError("iter_type unrecognized: %s", iter_type) # Populate options and run the requested method for each value combination for comb_values in loop_iter: diff --git a/yardstick/benchmark/runners/base.py b/yardstick/benchmark/runners/base.py index 8f3f75fa1..0e0292713 100755 --- a/yardstick/benchmark/runners/base.py +++ b/yardstick/benchmark/runners/base.py @@ -16,6 +16,7 @@ # yardstick comment: this is a modified copy of # rally/rally/benchmark/runners/base.py +from __future__ import absolute_import import importlib import logging import multiprocessing diff --git a/yardstick/benchmark/runners/duration.py b/yardstick/benchmark/runners/duration.py index 1412c0caa..89cac7db8 100644 --- a/yardstick/benchmark/runners/duration.py +++ b/yardstick/benchmark/runners/duration.py @@ -19,6 +19,7 @@ '''A runner that runs a specific time before it returns ''' +from __future__ import absolute_import import os import multiprocessing import logging diff --git a/yardstick/benchmark/runners/iteration.py b/yardstick/benchmark/runners/iteration.py index 3a839b65f..930f883e9 100644 --- a/yardstick/benchmark/runners/iteration.py +++ b/yardstick/benchmark/runners/iteration.py @@ -19,6 +19,7 @@ '''A runner that runs a configurable number of times before it returns ''' +from __future__ import absolute_import import os import multiprocessing import logging diff --git a/yardstick/benchmark/runners/sequence.py b/yardstick/benchmark/runners/sequence.py index 3b06e2a36..e6abeab3c 100644 --- a/yardstick/benchmark/runners/sequence.py +++ b/yardstick/benchmark/runners/sequence.py @@ -20,6 +20,7 @@ The input value in the sequence is specified in a list in the input file. ''' +from __future__ import absolute_import import os import multiprocessing import logging |