aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional')
-rwxr-xr-xtests/functional/test_cli_scenario.py20
-rwxr-xr-xtests/functional/utils.py44
2 files changed, 20 insertions, 44 deletions
diff --git a/tests/functional/test_cli_scenario.py b/tests/functional/test_cli_scenario.py
index 4741e8244..63b533b85 100755
--- a/tests/functional/test_cli_scenario.py
+++ b/tests/functional/test_cli_scenario.py
@@ -32,31 +32,25 @@ class ScenarioTestCase(unittest.TestCase):
def test_scenario_show_Lmbench(self):
res = self.yardstick("scenario show Lmbench")
- lmbench = "Execute lmbench memory read latency"
- "or memory bandwidth benchmark in a host" in res
- self.assertTrue(lmbench)
+ self.assertIn("Execute lmbench memory read latency or memory "
+ "bandwidth benchmark in a hos", res)
def test_scenario_show_Perf(self):
res = self.yardstick("scenario show Perf")
- perf = "Execute perf benchmark in a host" in res
- self.assertTrue(perf)
+ self.assertIn("Execute perf benchmark in a host", res)
def test_scenario_show_Fio(self):
res = self.yardstick("scenario show Fio")
- fio = "Execute fio benchmark in a host" in res
- self.assertTrue(fio)
+ self.assertIn("Execute fio benchmark in a host", res)
def test_scenario_show_Ping(self):
res = self.yardstick("scenario show Ping")
- ping = "Execute ping between two hosts" in res
- self.assertTrue(ping)
+ self.assertIn("Execute ping between two hosts", res)
def test_scenario_show_Iperf3(self):
res = self.yardstick("scenario show Iperf3")
- iperf3 = "Execute iperf3 between two hosts" in res
- self.assertTrue(iperf3)
+ self.assertIn("Execute iperf3 between two hosts", res)
def test_scenario_show_Pktgen(self):
res = self.yardstick("scenario show Pktgen")
- pktgen = "Execute pktgen between two hosts" in res
- self.assertTrue(pktgen)
+ self.assertIn("Execute pktgen between two hosts", res)
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