diff options
Diffstat (limited to 'snaps/openstack/utils/tests/heat_utils_tests.py')
-rw-r--r-- | snaps/openstack/utils/tests/heat_utils_tests.py | 103 |
1 files changed, 72 insertions, 31 deletions
diff --git a/snaps/openstack/utils/tests/heat_utils_tests.py b/snaps/openstack/utils/tests/heat_utils_tests.py index 67fbdec..fa240bd 100644 --- a/snaps/openstack/utils/tests/heat_utils_tests.py +++ b/snaps/openstack/utils/tests/heat_utils_tests.py @@ -31,7 +31,7 @@ from snaps.openstack.tests import openstack_tests from snaps.openstack.tests.os_source_file_test import OSComponentTestCase from snaps.openstack.utils import ( heat_utils, neutron_utils, nova_utils, settings_utils, glance_utils, - cinder_utils) + cinder_utils, keystone_utils) __author__ = 'spisarski' @@ -47,12 +47,12 @@ class HeatSmokeTests(OSComponentTestCase): """ Tests to ensure that the proper credentials can connect. """ - heat = heat_utils.heat_client(self.os_creds) + heat = heat_utils.heat_client(self.os_creds, self.os_session) # This should not throw an exception stacks = heat.stacks.list() for stack in stacks: - print stack + logger.info('Stack - %s', stack) def test_heat_connect_fail(self): """ @@ -70,7 +70,7 @@ class HeatSmokeTests(OSComponentTestCase): # This should throw an exception with self.assertRaises(Exception): for stack in stacks: - print stack + logger.info('Stack - %s', stack) class HeatUtilsCreateSimpleStackTests(OSComponentTestCase): @@ -115,7 +115,8 @@ class HeatUtilsCreateSimpleStackTests(OSComponentTestCase): env_values=env_values) self.stack1 = None self.stack2 = None - self.heat_client = heat_utils.heat_client(self.os_creds) + self.heat_client = heat_utils.heat_client( + self.os_creds, self.os_session) def tearDown(self): """ @@ -145,6 +146,8 @@ class HeatUtilsCreateSimpleStackTests(OSComponentTestCase): except: pass + super(self.__class__, self).__clean__() + def test_create_stack(self): """ Tests the creation of an OpenStack Heat stack1 that does not exist. @@ -174,7 +177,7 @@ class HeatUtilsCreateSimpleStackTests(OSComponentTestCase): self.assertTrue(stack_active(self.heat_client, self.stack1)) - neutron = neutron_utils.neutron_client(self.os_creds) + neutron = neutron_utils.neutron_client(self.os_creds, self.os_session) networks = heat_utils.get_stack_networks( self.heat_client, neutron, self.stack1) self.assertIsNotNone(networks) @@ -185,9 +188,12 @@ class HeatUtilsCreateSimpleStackTests(OSComponentTestCase): self.assertEqual(1, len(subnets)) self.assertEqual(self.subnet_name, subnets[0].name) - nova = nova_utils.nova_client(self.os_creds) + nova = nova_utils.nova_client(self.os_creds, self.os_session) + keystone = keystone_utils.keystone_client( + self.os_creds, self.os_session) servers = heat_utils.get_stack_servers( - self.heat_client, nova, neutron, self.stack1) + self.heat_client, nova, neutron, keystone, self.stack1, + self.os_creds.project_name) self.assertIsNotNone(servers) self.assertEqual(1, len(servers)) self.assertEqual(self.vm_inst_name, servers[0].name) @@ -275,7 +281,8 @@ class HeatUtilsCreateComplexStackTests(OSComponentTestCase): stack_settings = StackConfig( name=stack_name, template_path=heat_tmplt_path, env_values=env_values) - self.heat_client = heat_utils.heat_client(self.os_creds) + self.heat_client = heat_utils.heat_client( + self.os_creds, self.os_session) self.stack = heat_utils.create_stack(self.heat_client, stack_settings) self.assertTrue(stack_active(self.heat_client, self.stack)) @@ -307,14 +314,22 @@ class HeatUtilsCreateComplexStackTests(OSComponentTestCase): time.sleep(3) if not is_deleted: - nova = nova_utils.nova_client(self.os_creds) - neutron = neutron_utils.neutron_client(self.os_creds) - glance = glance_utils.glance_client(self.os_creds) + nova = nova_utils.nova_client( + self.os_creds, self.os_session) + keystone = keystone_utils.keystone_client( + self.os_creds, self.os_session) + neutron = neutron_utils.neutron_client( + self.os_creds, self.os_session) + glance = glance_utils.glance_client( + self.os_creds, self.os_session) + servers = heat_utils.get_stack_servers( - self.heat_client, nova, neutron, self.stack) + self.heat_client, nova, neutron, keystone, self.stack, + self.os_creds.project_name) for server in servers: vm_settings = settings_utils.create_vm_inst_config( - nova, neutron, server) + nova, keystone, neutron, server, + self.os_creds.project_name) img_settings = settings_utils.determine_image_config( glance, server, [self.image_creator1.image_settings, @@ -354,6 +369,8 @@ class HeatUtilsCreateComplexStackTests(OSComponentTestCase): os.chmod(expanded_path, 0o755) os.remove(expanded_path) + super(self.__class__, self).__clean__() + def test_get_settings_from_stack(self): """ Tests that a heat template with floating IPs and can have the proper @@ -361,13 +378,13 @@ class HeatUtilsCreateComplexStackTests(OSComponentTestCase): """ resources = heat_utils.get_resources(self.heat_client, self.stack.id) self.assertIsNotNone(resources) - self.assertEqual(12, len(resources)) + self.assertEqual(13, len(resources)) options = heat_utils.get_outputs(self.heat_client, self.stack) self.assertIsNotNone(options) self.assertEqual(1, len(options)) - neutron = neutron_utils.neutron_client(self.os_creds) + neutron = neutron_utils.neutron_client(self.os_creds, self.os_session) networks = heat_utils.get_stack_networks( self.heat_client, neutron, self.stack) self.assertIsNotNone(networks) @@ -379,11 +396,13 @@ class HeatUtilsCreateComplexStackTests(OSComponentTestCase): self.assertIsNotNone(network_settings) self.assertEqual(self.network_name, network_settings.name) - nova = nova_utils.nova_client(self.os_creds) - glance = glance_utils.glance_client(self.os_creds) - + nova = nova_utils.nova_client(self.os_creds, self.os_session) + glance = glance_utils.glance_client(self.os_creds, self.os_session) + keystone = keystone_utils.keystone_client( + self.os_creds, self.os_session) servers = heat_utils.get_stack_servers( - self.heat_client, nova, neutron, self.stack) + self.heat_client, nova, neutron, keystone, self.stack, + self.os_creds.project_name) self.assertIsNotNone(servers) self.assertEqual(2, len(servers)) @@ -452,8 +471,10 @@ class HeatUtilsRouterTests(OSComponentTestCase): name=stack_name, template_path=heat_tmplt_path, env_values=env_values) self.stack = None - self.heat_client = heat_utils.heat_client(self.os_creds) - self.neutron = neutron_utils.neutron_client(self.os_creds) + self.heat_client = heat_utils.heat_client( + self.os_creds, self.os_session) + self.neutron = neutron_utils.neutron_client( + self.os_creds, self.os_session) def tearDown(self): """ @@ -465,6 +486,8 @@ class HeatUtilsRouterTests(OSComponentTestCase): except: pass + super(self.__class__, self).__clean__() + def test_create_router_with_stack(self): """ Tests the creation of an OpenStack router with Heat and the retrieval @@ -498,8 +521,10 @@ class HeatUtilsRouterTests(OSComponentTestCase): router = routers[0] self.assertEqual(self.router_name, router.name) + keystone = keystone_utils.keystone_client( + self.os_creds, self.os_session) ext_net = neutron_utils.get_network( - self.neutron, network_name=self.ext_net_name) + self.neutron, keystone, network_name=self.ext_net_name) self.assertEqual(ext_net.id, router.external_network_id) @@ -527,8 +552,10 @@ class HeatUtilsVolumeTests(OSComponentTestCase): name=stack_name, template_path=heat_tmplt_path, env_values=env_values) self.stack = None - self.heat_client = heat_utils.heat_client(self.os_creds) - self.cinder = cinder_utils.cinder_client(self.os_creds) + self.heat_client = heat_utils.heat_client( + self.os_creds, self.os_session) + self.cinder = cinder_utils.cinder_client( + self.os_creds, self.os_session) def tearDown(self): """ @@ -540,6 +567,8 @@ class HeatUtilsVolumeTests(OSComponentTestCase): except: pass + super(self.__class__, self).__clean__() + def test_create_vol_with_stack(self): """ Tests the creation of an OpenStack volume with Heat. @@ -607,8 +636,10 @@ class HeatUtilsFlavorTests(OSComponentTestCase): self.stack_settings = StackConfig( name=stack_name, template_path=heat_tmplt_path) self.stack = None - self.heat_client = heat_utils.heat_client(self.os_creds) - self.nova = nova_utils.nova_client(self.os_creds) + self.heat_client = heat_utils.heat_client( + self.os_creds, self.os_session) + self.nova = nova_utils.nova_client( + self.os_creds, self.os_session) def tearDown(self): """ @@ -620,6 +651,8 @@ class HeatUtilsFlavorTests(OSComponentTestCase): except: pass + super(self.__class__, self).__clean__() + def test_create_flavor_with_stack(self): """ Tests the creation of an OpenStack volume with Heat. @@ -666,8 +699,10 @@ class HeatUtilsKeypairTests(OSComponentTestCase): name=stack_name, template_path=heat_tmplt_path, env_values=env_values) self.stack = None - self.heat_client = heat_utils.heat_client(self.os_creds) - self.nova = nova_utils.nova_client(self.os_creds) + self.heat_client = heat_utils.heat_client( + self.os_creds, self.os_session) + self.nova = nova_utils.nova_client( + self.os_creds, self.os_session) def tearDown(self): """ @@ -679,6 +714,8 @@ class HeatUtilsKeypairTests(OSComponentTestCase): except: pass + super(self.__class__, self).__clean__() + def test_create_keypair_with_stack(self): """ Tests the creation of an OpenStack keypair with Heat. @@ -729,8 +766,10 @@ class HeatUtilsSecurityGroupTests(OSComponentTestCase): name=stack_name, template_path=heat_tmplt_path, env_values=env_values) self.stack = None - self.heat_client = heat_utils.heat_client(self.os_creds) - self.neutron = neutron_utils.neutron_client(self.os_creds) + self.heat_client = heat_utils.heat_client( + self.os_creds, self.os_session) + self.neutron = neutron_utils.neutron_client( + self.os_creds, self.os_session) def tearDown(self): """ @@ -742,6 +781,8 @@ class HeatUtilsSecurityGroupTests(OSComponentTestCase): except: pass + super(self.__class__, self).__clean__() + def test_create_security_group_with_stack(self): """ Tests the creation of an OpenStack SecurityGroup with Heat. |