summaryrefslogtreecommitdiffstats
path: root/tests/functional
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-12-22 19:35:50 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-12-22 19:35:50 +0000
commit3984c976967e3d697473cd3bb85204577a838dcd (patch)
tree926b123337e6f7e9301ada7a799da31638576073 /tests/functional
parentedb1b87fae318501b853ef02a7aa7dffddfe1e48 (diff)
parent090b1a166bd19bdb98b0311d58b85582bd1676ed (diff)
Merge "Replace subprocess "check_output" with "Popen""
Diffstat (limited to 'tests/functional')
-rwxr-xr-xtests/functional/utils.py44
1 files changed, 13 insertions, 31 deletions
diff --git a/tests/functional/utils.py b/tests/functional/utils.py
index b96d2dd50..d889c0dfa 100755
--- a/tests/functional/utils.py
+++ b/tests/functional/utils.py
@@ -7,14 +7,12 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import absolute_import
-
import copy
import os
-import subprocess
from oslo_serialization import jsonutils
-from oslo_utils import encodeutils
+
+from yardstick.common import process
class Yardstick(object):
@@ -26,38 +24,22 @@ class Yardstick(object):
"""
- def __init__(self, fake=False):
-
- self.args = ["yardstick"]
+ def __init__(self):
+ self._args = ["yardstick"]
self.env = copy.deepcopy(os.environ)
- def __del__(self):
- pass
-
- def __call__(self, cmd, getjson=False, report_path=None, raw=False,
- suffix=None, extension=None, keep_old=False,
- write_report=False):
+ def __call__(self, cmd, getjson=False):
"""Call yardstick in the shell
- :param cmd: yardstick command
- :param getjson: in cases, when yardstick prints JSON, you can catch
- output deserialized
- TO DO:
- :param report_path: if present, yardstick command and its output will
- be written to file with passed file name
- :param raw: don't write command itself to report file. Only output
- will be written
+ :param cmd: Yardstick command.
+ :param getjson: If the output is a JSON object, it's deserialized.
+ :return Command output string.
"""
if not isinstance(cmd, list):
cmd = cmd.split(" ")
- try:
- output = encodeutils.safe_decode(subprocess.check_output(
- self.args + cmd, stderr=subprocess.STDOUT, env=self.env),
- 'utf-8')
-
- if getjson:
- return jsonutils.loads(output)
- return output
- except subprocess.CalledProcessError as e:
- raise e
+ cmd = self._args + cmd
+ output = process.execute(cmd=cmd)
+ if getjson:
+ return jsonutils.loads(output)
+ return output