summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJing Lu <lvjing5@huawei.com>2017-01-20 01:09:36 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-01-20 01:09:36 +0000
commit8f4cc883d89e997320d68c653a12d59f8fba308b (patch)
tree8411d57e47cb402914e348e1d83d7178fd43dac9
parent8f91b0a5c1f47953dd1a14541b71505dbf8f869a (diff)
parent65e1ffbabbbfafd03de817e1c4606e5e0382b98d (diff)
Merge "Bugfix:can not run a test suite if not under yardstick root path"
-rw-r--r--tests/unit/benchmark/core/test_task.py36
-rw-r--r--yardstick/benchmark/core/task.py2
2 files changed, 22 insertions, 16 deletions
diff --git a/tests/unit/benchmark/core/test_task.py b/tests/unit/benchmark/core/test_task.py
index 5dd32ea17..c56e21047 100644
--- a/tests/unit/benchmark/core/test_task.py
+++ b/tests/unit/benchmark/core/test_task.py
@@ -24,6 +24,7 @@ except ImportError:
from yardstick.benchmark.core import task
+from yardstick.common import constants as consts
class TaskTestCase(unittest.TestCase):
@@ -92,10 +93,10 @@ class TaskTestCase(unittest.TestCase):
task_files, task_args, task_args_fnames = t.parse_suite()
print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
task_args_fnames))
- self.assertEqual(task_files[0],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
- self.assertEqual(task_files[1],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
+ self.assertEqual(task_files[0], self.change_to_abspath(
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml'))
+ self.assertEqual(task_files[1], self.change_to_abspath(
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml'))
self.assertEqual(task_args[0], None)
self.assertEqual(task_args[1], None)
self.assertEqual(task_args_fnames[0], None)
@@ -109,10 +110,10 @@ class TaskTestCase(unittest.TestCase):
task_files, task_args, task_args_fnames = t.parse_suite()
print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
task_args_fnames))
- self.assertEqual(task_files[0],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
- self.assertEqual(task_files[1],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
+ self.assertEqual(task_files[0], self.change_to_abspath(
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml'))
+ self.assertEqual(task_files[1], self.change_to_abspath(
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml'))
self.assertEqual(task_args[0], None)
self.assertEqual(task_args[1],
'{"host": "node1.LF","target": "node2.LF"}')
@@ -127,10 +128,10 @@ class TaskTestCase(unittest.TestCase):
task_files, task_args, task_args_fnames = t.parse_suite()
print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
task_args_fnames))
- self.assertEqual(task_files[0],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
- self.assertEqual(task_files[1],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
+ self.assertEqual(task_files[0], self.change_to_abspath(
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml'))
+ self.assertEqual(task_files[1], self.change_to_abspath(
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml'))
self.assertEqual(task_args[0], None)
self.assertEqual(task_args[1], None)
self.assertEqual(task_args_fnames[0], None)
@@ -144,10 +145,10 @@ class TaskTestCase(unittest.TestCase):
task_files, task_args, task_args_fnames = t.parse_suite()
print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
task_args_fnames))
- self.assertEqual(task_files[0],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
- self.assertEqual(task_files[1],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
+ self.assertEqual(task_files[0], self.change_to_abspath(
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml'))
+ self.assertEqual(task_files[1], self.change_to_abspath(
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml'))
self.assertEqual(task_args[0], None)
self.assertEqual(task_args[1],
'{"host": "node1.LF","target": "node2.LF"}')
@@ -159,6 +160,9 @@ class TaskTestCase(unittest.TestCase):
file_path = os.path.join(curr_path, filename)
return file_path
+ def change_to_abspath(self, filepath):
+ return os.path.join(consts.YARDSTICK_ROOT_PATH, filepath)
+
def main():
unittest.main()
diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py
index 6cfec7b13..14b46867c 100644
--- a/yardstick/benchmark/core/task.py
+++ b/yardstick/benchmark/core/task.py
@@ -195,6 +195,8 @@ class TaskParser(object): # pragma: no cover
LOG.info("\nStarting scenario:%s", cfg["name"])
test_cases_dir = cfg.get("test_cases_dir", test_cases_dir_default)
+ test_cases_dir = os.path.join(constants.YARDSTICK_ROOT_PATH,
+ test_cases_dir)
if test_cases_dir[-1] != os.sep:
test_cases_dir += os.sep