From 11802c9ec469ab570dace176c18093bc655561a2 Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Wed, 29 Nov 2017 23:02:43 +0000 Subject: Move tests: functional/ All tests in tests/functional have been moved to yardstick/tests/functional JIRA: YARDSTICK-837 Change-Id: I89276b36635de74dd7b8f70e961c71aa0d2c494e Signed-off-by: Emma Foley --- tests/functional/__init__.py | 0 tests/functional/test_cli_runner.py | 49 ---------------------- tests/functional/test_cli_scenario.py | 56 ------------------------- tests/functional/utils.py | 45 -------------------- tools/run_tests.sh | 1 - yardstick/tests/functional/test_cli_runner.py | 47 +++++++++++++++++++++ yardstick/tests/functional/test_cli_scenario.py | 54 ++++++++++++++++++++++++ yardstick/tests/functional/utils.py | 45 ++++++++++++++++++++ 8 files changed, 146 insertions(+), 151 deletions(-) delete mode 100755 tests/functional/__init__.py delete mode 100755 tests/functional/test_cli_runner.py delete mode 100755 tests/functional/test_cli_scenario.py delete mode 100755 tests/functional/utils.py create mode 100755 yardstick/tests/functional/test_cli_runner.py create mode 100755 yardstick/tests/functional/test_cli_scenario.py create mode 100755 yardstick/tests/functional/utils.py diff --git a/tests/functional/__init__.py b/tests/functional/__init__.py deleted file mode 100755 index e69de29bb..000000000 diff --git a/tests/functional/test_cli_runner.py b/tests/functional/test_cli_runner.py deleted file mode 100755 index 620edc396..000000000 --- a/tests/functional/test_cli_runner.py +++ /dev/null @@ -1,49 +0,0 @@ -############################################################################## -# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from __future__ import absolute_import -import unittest - -from tests.functional import utils - - -class RunnerTestCase(unittest.TestCase): - - def setUp(self): - super(RunnerTestCase, self).setUp() - self.yardstick = utils.Yardstick() - - def test_runner_list(self): - res = self.yardstick("runner list") - - self.assertIn("Duration", res) - self.assertIn("Arithmetic", res) - self.assertIn("Iteration", res) - self.assertIn("Sequence", res) - - def test_runner_show_Duration(self): - res = self.yardstick("runner show Duration") - duration = "duration - amount of time" in res - self.assertTrue(duration) - - def test_runner_show_Arithmetic(self): - res = self.yardstick("runner show Arithmetic") - arithmetic = "Run a scenario arithmetically" in res - self.assertTrue(arithmetic) - - def test_runner_show_Iteration(self): - res = self.yardstick("runner show Iteration") - iteration = "iterations - amount of times" in res - self.assertTrue(iteration) - - def test_runner_show_Sequence(self): - res = self.yardstick("runner show Sequence") - sequence = "sequence - list of values which are executed" in res - self.assertTrue(sequence) diff --git a/tests/functional/test_cli_scenario.py b/tests/functional/test_cli_scenario.py deleted file mode 100755 index 63b533b85..000000000 --- a/tests/functional/test_cli_scenario.py +++ /dev/null @@ -1,56 +0,0 @@ -############################################################################## -# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from __future__ import absolute_import -import unittest - -from tests.functional import utils - - -class ScenarioTestCase(unittest.TestCase): - - def setUp(self): - super(ScenarioTestCase, self).setUp() - self.yardstick = utils.Yardstick() - - def test_scenario_list(self): - res = self.yardstick("scenario list") - - self.assertIn("Lmbench", res) - self.assertIn("Perf", res) - self.assertIn("Fio", res) - self.assertIn("Ping", res) - self.assertIn("Iperf3", res) - self.assertIn("Pktgen", res) - - def test_scenario_show_Lmbench(self): - res = self.yardstick("scenario show 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") - self.assertIn("Execute perf benchmark in a host", res) - - def test_scenario_show_Fio(self): - res = self.yardstick("scenario show Fio") - self.assertIn("Execute fio benchmark in a host", res) - - def test_scenario_show_Ping(self): - res = self.yardstick("scenario show Ping") - self.assertIn("Execute ping between two hosts", res) - - def test_scenario_show_Iperf3(self): - res = self.yardstick("scenario show Iperf3") - self.assertIn("Execute iperf3 between two hosts", res) - - def test_scenario_show_Pktgen(self): - res = self.yardstick("scenario show Pktgen") - self.assertIn("Execute pktgen between two hosts", res) diff --git a/tests/functional/utils.py b/tests/functional/utils.py deleted file mode 100755 index d889c0dfa..000000000 --- a/tests/functional/utils.py +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################## -# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -import copy -import os - -from oslo_serialization import jsonutils - -from yardstick.common import process - - -class Yardstick(object): - """Create and represent separate yardstick installation. - - Usage: - yardstick = yardstick() - output = yardstick("runner list") - - """ - - def __init__(self): - self._args = ["yardstick"] - self.env = copy.deepcopy(os.environ) - - def __call__(self, cmd, getjson=False): - """Call yardstick in the shell - - :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(" ") - cmd = self._args + cmd - output = process.execute(cmd=cmd) - if getjson: - return jsonutils.loads(output) - return output diff --git a/tools/run_tests.sh b/tools/run_tests.sh index ddb5e55af..633c93859 100755 --- a/tools/run_tests.sh +++ b/tools/run_tests.sh @@ -56,7 +56,6 @@ run_functional_test() { mkdir -p .testrepository python -m subunit.run discover yardstick/tests/functional > .testrepository/subunit.log - python -m subunit.run discover tests/functional >> .testrepository/subunit.log subunit2pyunit < .testrepository/subunit.log EXIT_CODE=$? diff --git a/yardstick/tests/functional/test_cli_runner.py b/yardstick/tests/functional/test_cli_runner.py new file mode 100755 index 000000000..2f2d7fef2 --- /dev/null +++ b/yardstick/tests/functional/test_cli_runner.py @@ -0,0 +1,47 @@ +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +import unittest + +from yardstick.tests.functional import utils + + +class RunnerTestCase(unittest.TestCase): + + def setUp(self): + super(RunnerTestCase, self).setUp() + self.yardstick = utils.Yardstick() + + def test_runner_list(self): + res = self.yardstick("runner list") + + self.assertIn("Duration", res) + self.assertIn("Arithmetic", res) + self.assertIn("Iteration", res) + self.assertIn("Sequence", res) + + def test_runner_show_Duration(self): + res = self.yardstick("runner show Duration") + duration = "duration - amount of time" in res + self.assertTrue(duration) + + def test_runner_show_Arithmetic(self): + res = self.yardstick("runner show Arithmetic") + arithmetic = "Run a scenario arithmetically" in res + self.assertTrue(arithmetic) + + def test_runner_show_Iteration(self): + res = self.yardstick("runner show Iteration") + iteration = "iterations - amount of times" in res + self.assertTrue(iteration) + + def test_runner_show_Sequence(self): + res = self.yardstick("runner show Sequence") + sequence = "sequence - list of values which are executed" in res + self.assertTrue(sequence) diff --git a/yardstick/tests/functional/test_cli_scenario.py b/yardstick/tests/functional/test_cli_scenario.py new file mode 100755 index 000000000..7aaacad0a --- /dev/null +++ b/yardstick/tests/functional/test_cli_scenario.py @@ -0,0 +1,54 @@ +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +import unittest + +from yardstick.tests.functional import utils + + +class ScenarioTestCase(unittest.TestCase): + + def setUp(self): + super(ScenarioTestCase, self).setUp() + self.yardstick = utils.Yardstick() + + def test_scenario_list(self): + res = self.yardstick("scenario list") + + self.assertIn("Lmbench", res) + self.assertIn("Perf", res) + self.assertIn("Fio", res) + self.assertIn("Ping", res) + self.assertIn("Iperf3", res) + self.assertIn("Pktgen", res) + + def test_scenario_show_Lmbench(self): + res = self.yardstick("scenario show 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") + self.assertIn("Execute perf benchmark in a host", res) + + def test_scenario_show_Fio(self): + res = self.yardstick("scenario show Fio") + self.assertIn("Execute fio benchmark in a host", res) + + def test_scenario_show_Ping(self): + res = self.yardstick("scenario show Ping") + self.assertIn("Execute ping between two hosts", res) + + def test_scenario_show_Iperf3(self): + res = self.yardstick("scenario show Iperf3") + self.assertIn("Execute iperf3 between two hosts", res) + + def test_scenario_show_Pktgen(self): + res = self.yardstick("scenario show Pktgen") + self.assertIn("Execute pktgen between two hosts", res) diff --git a/yardstick/tests/functional/utils.py b/yardstick/tests/functional/utils.py new file mode 100755 index 000000000..d889c0dfa --- /dev/null +++ b/yardstick/tests/functional/utils.py @@ -0,0 +1,45 @@ +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +import copy +import os + +from oslo_serialization import jsonutils + +from yardstick.common import process + + +class Yardstick(object): + """Create and represent separate yardstick installation. + + Usage: + yardstick = yardstick() + output = yardstick("runner list") + + """ + + def __init__(self): + self._args = ["yardstick"] + self.env = copy.deepcopy(os.environ) + + def __call__(self, cmd, getjson=False): + """Call yardstick in the shell + + :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(" ") + cmd = self._args + cmd + output = process.execute(cmd=cmd) + if getjson: + return jsonutils.loads(output) + return output -- cgit 1.2.3-korg