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/cmd | |
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/cmd')
-rw-r--r-- | yardstick/cmd/__init__.py | 5 | ||||
-rw-r--r-- | yardstick/cmd/cli.py | 1 | ||||
-rw-r--r-- | yardstick/cmd/commands/__init__.py | 1 | ||||
-rw-r--r-- | yardstick/cmd/commands/env.py | 11 | ||||
-rw-r--r-- | yardstick/cmd/commands/plugin.py | 3 | ||||
-rw-r--r-- | yardstick/cmd/commands/runner.py | 3 | ||||
-rw-r--r-- | yardstick/cmd/commands/scenario.py | 2 | ||||
-rw-r--r-- | yardstick/cmd/commands/task.py | 4 | ||||
-rw-r--r-- | yardstick/cmd/commands/testcase.py | 3 |
9 files changed, 27 insertions, 6 deletions
diff --git a/yardstick/cmd/__init__.py b/yardstick/cmd/__init__.py index df891e304..6b7d65792 100644 --- a/yardstick/cmd/__init__.py +++ b/yardstick/cmd/__init__.py @@ -6,10 +6,11 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import print_function def print_hbar(barlen): '''print to stdout a horizontal bar''' - print("+"), - print("-" * barlen), + print(("+"), end=' ') + print(("-" * barlen), end=' ') print("+") diff --git a/yardstick/cmd/cli.py b/yardstick/cmd/cli.py index beaa187aa..05bf8f06f 100644 --- a/yardstick/cmd/cli.py +++ b/yardstick/cmd/cli.py @@ -11,6 +11,7 @@ Command-line interface to yardstick ''' +from __future__ import absolute_import import logging import os import sys diff --git a/yardstick/cmd/commands/__init__.py b/yardstick/cmd/commands/__init__.py index ba229d481..5c5356736 100644 --- a/yardstick/cmd/commands/__init__.py +++ b/yardstick/cmd/commands/__init__.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import from yardstick.benchmark.core import Param diff --git a/yardstick/cmd/commands/env.py b/yardstick/cmd/commands/env.py index d0fc75dd3..dfcb63727 100644 --- a/yardstick/cmd/commands/env.py +++ b/yardstick/cmd/commands/env.py @@ -6,13 +6,17 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import from __future__ import print_function -import time + import os import sys +import time + +from six.moves import range -from yardstick.common.httpClient import HttpClient from yardstick.common import constants as consts +from yardstick.common.httpClient import HttpClient class EnvCommand(object): @@ -20,6 +24,7 @@ class EnvCommand(object): Set of commands to prepare environment ''' + def do_influxdb(self, args): data = {'action': 'createInfluxDBContainer'} task_id = self._start_async_task(data) @@ -52,7 +57,7 @@ class EnvCommand(object): CHECK_STATUS_RETRY = 20 CHECK_STATUS_DELAY = 5 - for retry in xrange(CHECK_STATUS_RETRY): + for retry in range(CHECK_STATUS_RETRY): response = HttpClient().get(url) status = response['status'] diff --git a/yardstick/cmd/commands/plugin.py b/yardstick/cmd/commands/plugin.py index 94095665a..c3e951e8c 100644 --- a/yardstick/cmd/commands/plugin.py +++ b/yardstick/cmd/commands/plugin.py @@ -9,6 +9,9 @@ """ Handler for yardstick command 'plugin' """ +from __future__ import print_function + +from __future__ import absolute_import from yardstick.benchmark.core.plugin import Plugin from yardstick.common.utils import cliargs from yardstick.cmd.commands import change_osloobj_to_paras diff --git a/yardstick/cmd/commands/runner.py b/yardstick/cmd/commands/runner.py index 62a2082c4..02176aba3 100644 --- a/yardstick/cmd/commands/runner.py +++ b/yardstick/cmd/commands/runner.py @@ -9,6 +9,9 @@ """ Handler for yardstick command 'runner' """ +from __future__ import print_function + +from __future__ import absolute_import from yardstick.benchmark.core.runner import Runners from yardstick.common.utils import cliargs from yardstick.cmd.commands import change_osloobj_to_paras diff --git a/yardstick/cmd/commands/scenario.py b/yardstick/cmd/commands/scenario.py index 6aa3a451a..5a6d04f55 100644 --- a/yardstick/cmd/commands/scenario.py +++ b/yardstick/cmd/commands/scenario.py @@ -9,6 +9,8 @@ """ Handler for yardstick command 'scenario' """ +from __future__ import print_function +from __future__ import absolute_import from yardstick.benchmark.core.scenario import Scenarios from yardstick.common.utils import cliargs from yardstick.cmd.commands import change_osloobj_to_paras diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py index bd018bcab..fa82f078f 100644 --- a/yardstick/cmd/commands/task.py +++ b/yardstick/cmd/commands/task.py @@ -8,11 +8,13 @@ ############################################################################## """ Handler for yardstick command 'task' """ +from __future__ import print_function + +from __future__ import absolute_import from yardstick.benchmark.core.task import Task from yardstick.common.utils import cliargs from yardstick.cmd.commands import change_osloobj_to_paras - output_file_default = "/tmp/yardstick.out" diff --git a/yardstick/cmd/commands/testcase.py b/yardstick/cmd/commands/testcase.py index 6ff796238..92831ad2f 100644 --- a/yardstick/cmd/commands/testcase.py +++ b/yardstick/cmd/commands/testcase.py @@ -8,6 +8,9 @@ ############################################################################## """ Handler for yardstick command 'testcase' """ +from __future__ import print_function + +from __future__ import absolute_import from yardstick.benchmark.core.testcase import Testcase from yardstick.common.utils import cliargs from yardstick.cmd.commands import change_osloobj_to_paras |