summaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/contexts/test_heat.py
diff options
context:
space:
mode:
authorRex Lee <limingjiang@huawei.com>2017-01-11 03:01:14 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-01-11 03:01:14 +0000
commit205729564104b309058ad011f1daf402a285d7b8 (patch)
tree656dac4b6048469648a0296c0e53cbad85200b95 /tests/unit/benchmark/contexts/test_heat.py
parent9a02ad7f3b9b7eac2bdc226554ca2efba752ad0d (diff)
parent5386de98f7d9e44ab507904d82530fff3a3ae5e4 (diff)
Merge "associate an uuid to yardstick_key and yardstick_key.pub"
Diffstat (limited to 'tests/unit/benchmark/contexts/test_heat.py')
-rw-r--r--tests/unit/benchmark/contexts/test_heat.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/unit/benchmark/contexts/test_heat.py b/tests/unit/benchmark/contexts/test_heat.py
index f891b0a5f..dd830a485 100644
--- a/tests/unit/benchmark/contexts/test_heat.py
+++ b/tests/unit/benchmark/contexts/test_heat.py
@@ -11,6 +11,7 @@
# Unittest for yardstick.benchmark.contexts.heat
+import os
import mock
import unittest
@@ -39,6 +40,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 +58,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")
@@ -69,14 +73,23 @@ class HeatContextTestCase(unittest.TestCase):
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", e.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')
@@ -100,6 +113,7 @@ class HeatContextTestCase(unittest.TestCase):
self.assertTrue(mock_template.delete.called)
+
def test__get_server(self):
self.mock_context.name = 'bar'