aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliang gao <jean.gaoliang@huawei.com>2016-10-17 06:30:16 +0000
committerGerrit Code Review <gerrit@opnfv.org>2016-10-17 06:30:16 +0000
commitf889d6136e7a23d3db678c53ed0da3eea421cd68 (patch)
tree8f9e1c2c0549bf18369e6701c61208683ba5871a
parentc5c9a48610bb587f25135f1d0758472c1fbe876c (diff)
parent1065e856c9dc938652556fc535a0ec47f8a0dc08 (diff)
Merge "Bugfix: no pod.yaml file error when run test case not in the root path"
-rw-r--r--etc/__init__.py0
-rwxr-xr-xsetup.py6
-rw-r--r--yardstick/benchmark/contexts/node.py6
-rw-r--r--yardstick/cmd/commands/testcase.py10
-rw-r--r--yardstick/definitions.py5
5 files changed, 22 insertions, 5 deletions
diff --git a/etc/__init__.py b/etc/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/etc/__init__.py
diff --git a/setup.py b/setup.py
index a2131cf0b..ba7316d80 100755
--- a/setup.py
+++ b/setup.py
@@ -23,6 +23,12 @@ setup(
'resources/files/*',
'resources/scripts/install/*.bash',
'resources/scripts/remove/*.bash'
+ ],
+ 'etc': [
+ 'yardstick/nodes/*/*.yaml'
+ ],
+ 'tests': [
+ 'opnfv/*/*.yaml'
]
},
url="https://www.opnfv.org",
diff --git a/yardstick/benchmark/contexts/node.py b/yardstick/benchmark/contexts/node.py
index c3d652119..c4e603a46 100644
--- a/yardstick/benchmark/contexts/node.py
+++ b/yardstick/benchmark/contexts/node.py
@@ -8,10 +8,12 @@
##############################################################################
import sys
+import os
import yaml
import logging
from yardstick.benchmark.contexts.base import Context
+from yardstick.definitions import YARDSTICK_ROOT_PATH
LOG = logging.getLogger(__name__)
@@ -33,7 +35,9 @@ class NodeContext(Context):
def init(self, attrs):
'''initializes itself from the supplied arguments'''
self.name = attrs["name"]
- self.file_path = attrs.get("file", "/etc/yardstick/nodes/pod.yaml")
+ self.file_path = attrs.get("file", "")
+ if not os.path.exists(self.file_path):
+ self.file_path = YARDSTICK_ROOT_PATH + self.file_path
LOG.info("Parsing pod file: %s", self.file_path)
diff --git a/yardstick/cmd/commands/testcase.py b/yardstick/cmd/commands/testcase.py
index 5205eb93e..cb76c7ae3 100644
--- a/yardstick/cmd/commands/testcase.py
+++ b/yardstick/cmd/commands/testcase.py
@@ -8,13 +8,15 @@
##############################################################################
""" Handler for yardstick command 'testcase' """
-from yardstick.cmd import print_hbar
-from yardstick.common.task_template import TaskTemplate
-from yardstick.common.utils import cliargs
import os
import yaml
import sys
+from yardstick.cmd import print_hbar
+from yardstick.common.task_template import TaskTemplate
+from yardstick.common.utils import cliargs
+from yardstick.definitions import YARDSTICK_ROOT_PATH
+
class TestcaseCommands(object):
'''Testcase commands.
@@ -22,7 +24,7 @@ class TestcaseCommands(object):
Set of commands to discover and display test cases.
'''
def __init__(self):
- self.test_case_path = 'tests/opnfv/test_cases/'
+ self.test_case_path = YARDSTICK_ROOT_PATH + 'tests/opnfv/test_cases/'
self.testcase_list = []
def do_list(self, args):
diff --git a/yardstick/definitions.py b/yardstick/definitions.py
new file mode 100644
index 000000000..300a78e58
--- /dev/null
+++ b/yardstick/definitions.py
@@ -0,0 +1,5 @@
+import os
+
+dirname = os.path.dirname
+YARDSTICK_ROOT_PATH = dirname(dirname(os.path.abspath(__file__)))
+YARDSTICK_ROOT_PATH += os.path.sep