summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/network_services/test_utils.py13
-rw-r--r--yardstick/network_services/utils.py10
2 files changed, 16 insertions, 7 deletions
diff --git a/tests/unit/network_services/test_utils.py b/tests/unit/network_services/test_utils.py
index ecacac7c3..8d9e74adf 100644
--- a/tests/unit/network_services/test_utils.py
+++ b/tests/unit/network_services/test_utils.py
@@ -16,6 +16,8 @@
# Unittest for yardstick.network_services.utils
from __future__ import absolute_import
+
+import os
import unittest
import mock
@@ -25,19 +27,24 @@ from yardstick.network_services import utils
class UtilsTestCase(unittest.TestCase):
"""Test all VNF helper methods."""
- DPDK_PATH = "/opt/nsb_bin/dpdk_nic_bind.py"
+ DPDK_PATH = os.path.join(utils.NSB_ROOT, "dpdk_nic_bind.py")
def setUp(self):
super(UtilsTestCase, self).setUp()
def test_get_nsb_options(self):
result = utils.get_nsb_option("bin_path", None)
- self.assertEqual(result, "/opt/nsb_bin")
+ self.assertEqual(result, utils.NSB_ROOT)
- def test_get_nsb_optionsi_invalid_key(self):
+ def test_get_nsb_option_is_invalid_key(self):
result = utils.get_nsb_option("bin", None)
self.assertEqual(result, None)
+ def test_get_nsb_option_default(self):
+ default = object()
+ result = utils.get_nsb_option("nosuch", default)
+ self.assertIs(result, default)
+
def test_provision_tool(self):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
diff --git a/yardstick/network_services/utils.py b/yardstick/network_services/utils.py
index b75091326..cb71a6029 100644
--- a/yardstick/network_services/utils.py
+++ b/yardstick/network_services/utils.py
@@ -15,18 +15,21 @@
from __future__ import absolute_import
import logging
+import os
from oslo_config import cfg
from oslo_config.cfg import NoSuchOptError
from oslo_utils import encodeutils
+NSB_ROOT = "/opt/nsb_bin"
+
CONF = cfg.CONF
OPTS = [
cfg.StrOpt('bin_path',
- default='/opt/nsb_bin',
+ default=NSB_ROOT,
help='bin_path for VNFs location.'),
cfg.StrOpt('trex_path',
- default='/opt/nsb_bin/trex/scripts',
+ default=os.path.join(NSB_ROOT, 'trex/scripts'),
help='trex automation lib pathh.'),
]
CONF.register_opts(OPTS, group="nsb")
@@ -39,8 +42,7 @@ def get_nsb_option(option, default=None):
return CONF.nsb.__getitem__(option)
except NoSuchOptError:
logging.debug("Invalid key %s", option)
- else:
- return default
+ return default
def provision_tool(connection, tool_path):