diff options
Diffstat (limited to 'tests/unit/benchmark/contexts/test_heat.py')
-rw-r--r-- | tests/unit/benchmark/contexts/test_heat.py | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/tests/unit/benchmark/contexts/test_heat.py b/tests/unit/benchmark/contexts/test_heat.py index f891b0a5f..f8f349205 100644 --- a/tests/unit/benchmark/contexts/test_heat.py +++ b/tests/unit/benchmark/contexts/test_heat.py @@ -11,13 +11,21 @@ # Unittest for yardstick.benchmark.contexts.heat -import mock +from __future__ import absolute_import + +import logging +import os import unittest +import uuid + +import mock -from yardstick.benchmark.contexts import model from yardstick.benchmark.contexts import heat +LOG = logging.getLogger(__name__) + + class HeatContextTestCase(unittest.TestCase): def setUp(self): @@ -39,6 +47,8 @@ class HeatContextTestCase(unittest.TestCase): self.assertIsNone(self.test_context._user) self.assertIsNone(self.test_context.template_file) self.assertIsNone(self.test_context.heat_parameters) + self.assertIsNotNone(self.test_context.key_uuid) + self.assertIsNotNone(self.test_context.key_filename) @mock.patch('yardstick.benchmark.contexts.heat.PlacementGroup') @mock.patch('yardstick.benchmark.contexts.heat.Network') @@ -55,6 +65,7 @@ class HeatContextTestCase(unittest.TestCase): self.test_context.init(attrs) + self.assertEqual(self.test_context.name, "foo") self.assertEqual(self.test_context.keypair_name, "foo-key") self.assertEqual(self.test_context.secgroup_name, "foo-secgroup") @@ -66,17 +77,29 @@ class HeatContextTestCase(unittest.TestCase): 'bar', self.test_context, networks['bar']) self.assertTrue(len(self.test_context.networks) == 1) - mock_server.assert_called_with('baz', self.test_context, servers['baz']) + mock_server.assert_called_with('baz', self.test_context, + servers['baz']) self.assertTrue(len(self.test_context.servers) == 1) + if os.path.exists(self.test_context.key_filename): + try: + os.remove(self.test_context.key_filename) + os.remove(self.test_context.key_filename + ".pub") + except OSError: + LOG.exception("key_filename: %s", + self.test_context.key_filename) + @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate') def test__add_resources_to_template_no_servers(self, mock_template): self.test_context.keypair_name = "foo-key" self.test_context.secgroup_name = "foo-secgroup" + self.test_context.key_uuid = "2f2e4997-0a8e-4eb7-9fa4-f3f8fbbc393b" self.test_context._add_resources_to_template(mock_template) - mock_template.add_keypair.assert_called_with("foo-key") + mock_template.add_keypair.assert_called_with( + "foo-key", + "2f2e4997-0a8e-4eb7-9fa4-f3f8fbbc393b") mock_template.add_security_group.assert_called_with("foo-secgroup") @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate') @@ -105,6 +128,8 @@ class HeatContextTestCase(unittest.TestCase): self.mock_context.name = 'bar' self.mock_context.stack.outputs = {'public_ip': '127.0.0.1', 'private_ip': '10.0.0.1'} + self.mock_context.key_uuid = uuid.uuid4() + attr_name = {'name': 'foo.bar', 'public_ip_attr': 'public_ip', 'private_ip_attr': 'private_ip'} |