aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/benchmark/contexts/test_heat.py25
-rw-r--r--yardstick/benchmark/contexts/heat.py6
-rw-r--r--yardstick/benchmark/scenarios/networking/vnf_generic.py11
3 files changed, 28 insertions, 14 deletions
diff --git a/tests/unit/benchmark/contexts/test_heat.py b/tests/unit/benchmark/contexts/test_heat.py
index d1b5855f9..2e546805d 100644
--- a/tests/unit/benchmark/contexts/test_heat.py
+++ b/tests/unit/benchmark/contexts/test_heat.py
@@ -227,19 +227,20 @@ class HeatContextTestCase(unittest.TestCase):
mock_os.path.exists.return_value = True
self.assertIsNone(self.test_context.undeploy())
- def test__get_server_found_dict(self):
+ @mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
+ def test__get_server_found_dict(self, mock_pkg_resources):
"""
Use HeatContext._get_server to get a server that matches
based on a dictionary input.
"""
foo2_server = mock.Mock()
- foo2_server.key_filename = 'key_file'
+ foo2_server.key_filename = None
foo2_server.private_ip = '10.0.0.2'
foo2_server.public_ip = '127.0.0.2'
foo2_server.context.user = 'oof'
baz3_server = mock.Mock()
- baz3_server.key_filename = 'key_filename'
+ baz3_server.key_filename = None
baz3_server.private_ip = '10.0.0.3'
baz3_server.public_ip = '127.0.0.3'
baz3_server.context.user = 'zab'
@@ -264,11 +265,11 @@ class HeatContextTestCase(unittest.TestCase):
}
result = self.test_context._get_server(attr_name)
self.assertEqual(result['user'], 'bot')
- self.assertIsNotNone(result['key_filename'])
self.assertEqual(result['ip'], '127.0.0.1')
self.assertEqual(result['private_ip'], '10.0.0.1')
- def test__get_server_found_dict_no_attrs(self):
+ @mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
+ def test__get_server_found_dict_no_attrs(self, mock_pkg_resources):
"""
Use HeatContext._get_server to get a server that matches
based on a dictionary input.
@@ -301,13 +302,13 @@ class HeatContextTestCase(unittest.TestCase):
}
result = self.test_context._get_server(attr_name)
self.assertEqual(result['user'], 'bot')
- self.assertIsNotNone(result['key_filename'])
# no private ip attr mapping in the map results in None value in the result
self.assertIsNone(result['private_ip'])
# no public ip attr mapping in the map results in no value in the result
self.assertNotIn('ip', result)
- def test__get_server_found_not_dict(self):
+ @mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
+ def test__get_server_found_not_dict(self, mock_pkg_resources):
"""
Use HeatContext._get_server to get a server that matches
based on a non-dictionary input
@@ -339,12 +340,12 @@ class HeatContextTestCase(unittest.TestCase):
attr_name = 'baz3'
result = self.test_context._get_server(attr_name)
self.assertEqual(result['user'], 'zab')
- self.assertIsNotNone(result['key_filename'])
self.assertEqual(result['private_ip'], '10.0.0.3')
# no public_ip on the server results in no value in the result
self.assertNotIn('public_ip', result)
- def test__get_server_none_found_not_dict(self):
+ @mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
+ def test__get_server_none_found_not_dict(self, mock_pkg_resources):
"""
Use HeatContext._get_server to not get a server due to
None value associated with the match to a non-dictionary
@@ -377,7 +378,8 @@ class HeatContextTestCase(unittest.TestCase):
result = self.test_context._get_server(attr_name)
self.assertIsNone(result)
- def test__get_server_not_found_dict(self):
+ @mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
+ def test__get_server_not_found_dict(self, mock_pkg_resources):
"""
Use HeatContext._get_server to not get a server for lack
of a match to a dictionary input
@@ -412,7 +414,8 @@ class HeatContextTestCase(unittest.TestCase):
result = self.test_context._get_server(attr_name)
self.assertIsNone(result)
- def test__get_server_not_found_not_dict(self):
+ @mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
+ def test__get_server_not_found_not_dict(self, mock_pkg_resources):
"""
Use HeatContext._get_server to not get a server for lack
of a match to a non-dictionary input
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py
index c7586abf4..374be0b1b 100644
--- a/yardstick/benchmark/contexts/heat.py
+++ b/yardstick/benchmark/contexts/heat.py
@@ -413,9 +413,9 @@ class HeatContext(Context):
attr_name: either a name for a server created by yardstick or a dict
with attribute name mapping when using external heat templates
"""
- key_filename = pkg_resources.resource_filename(
+ pkey = pkg_resources.resource_string(
'yardstick.resources',
- h_join('files/yardstick_key', get_short_key_uuid(self.key_uuid)))
+ h_join('files/yardstick_key', get_short_key_uuid(self.key_uuid))).decode('utf-8')
if isinstance(attr_name, collections.Mapping):
node_name, cname = self.split_name(attr_name['name'])
@@ -436,7 +436,7 @@ class HeatContext(Context):
result = {
"user": server.context.user,
- "key_filename": key_filename,
+ "pkey": pkey,
"private_ip": server.private_ip,
"interfaces": server.interfaces,
"routing_table": self.generate_routing_table(server),
diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py
index 905f1f4c5..479206952 100644
--- a/yardstick/benchmark/scenarios/networking/vnf_generic.py
+++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py
@@ -470,6 +470,10 @@ printf "%s/driver:" $1 ; basename $(readlink -s $1/device/driver); } \
ext_intfs = vnfd["vdu"][0]["external-interface"] = []
# have to sort so xe0 goes first
for intf_name, intf in sorted(node['interfaces'].items()):
+ # only interfaces with vld_id are added.
+ # Thus there are two layers of filters, only intefaces with vld_id
+ # show up in interfaces, and only interfaces with traffic profiles
+ # are used by the generators
if intf.get('vld_id'):
# force dpkd_port_num to int so we can do reverse lookup
try:
@@ -511,6 +515,13 @@ printf "%s/driver:" $1 ; basename $(readlink -s $1/device/driver); } \
vnfd = vnfdgen.generate_vnfd(vnf_model, node)
# TODO: here add extra context_cfg["nodes"] regardless of template
vnfd = vnfd["vnfd:vnfd-catalog"]["vnfd"][0]
+ # force inject pkey if it exists
+ # we want to standardize Heat using pkey as a string so we don't rely
+ # on the filesystem
+ try:
+ vnfd['mgmt-interface']['pkey'] = node['pkey']
+ except KeyError:
+ pass
self.create_interfaces_from_node(vnfd, node)
vnf_impl = self.get_vnf_impl(vnfd['id'])
vnf_instance = vnf_impl(node_name, vnfd)