summaryrefslogtreecommitdiffstats
path: root/snaps/openstack/utils/tests/heat_utils_tests.py
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2018-03-09 14:42:34 -0700
committerspisarski <s.pisarski@cablelabs.com>2018-03-12 08:28:45 -0600
commit9e9e09590cce321f55996c1a31370ffdf28251b0 (patch)
treea0e031d0365604f4a299ad8f748fe10d09a75a8a /snaps/openstack/utils/tests/heat_utils_tests.py
parentfb0ab37c323717ca10ac3f3bda24ae390635495e (diff)
Closing keystone sessions after done with them.
By not closing all of the keystone sessions being created when running all of the tests, this may be the root cause to the IOError occasionally being observed: IOError: [Errno 24] Too many open files JIRA: SNAPS-285 Change-Id: I7fc7ab0c6cdd02f1ae32bb3ae4f121cb465d5693 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/utils/tests/heat_utils_tests.py')
-rw-r--r--snaps/openstack/utils/tests/heat_utils_tests.py84
1 files changed, 59 insertions, 25 deletions
diff --git a/snaps/openstack/utils/tests/heat_utils_tests.py b/snaps/openstack/utils/tests/heat_utils_tests.py
index cad3fc2..081736a 100644
--- a/snaps/openstack/utils/tests/heat_utils_tests.py
+++ b/snaps/openstack/utils/tests/heat_utils_tests.py
@@ -47,7 +47,7 @@ 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()
@@ -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,8 +188,9 @@ class HeatUtilsCreateSimpleStackTests(OSComponentTestCase):
self.assertEqual(1, len(subnets))
self.assertEqual(self.subnet_name, subnets[0].name)
- nova = nova_utils.nova_client(self.os_creds)
- keystone = keystone_utils.keystone_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, keystone, self.stack1,
self.os_creds.project_name)
@@ -277,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))
@@ -309,10 +314,15 @@ class HeatUtilsCreateComplexStackTests(OSComponentTestCase):
time.sleep(3)
if not is_deleted:
- nova = nova_utils.nova_client(self.os_creds)
- keystone = keystone_utils.keystone_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, keystone, self.stack,
self.os_creds.project_name)
@@ -359,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
@@ -372,7 +384,7 @@ class HeatUtilsCreateComplexStackTests(OSComponentTestCase):
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)
@@ -384,9 +396,10 @@ 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)
- keystone = keystone_utils.keystone_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, keystone, self.stack,
self.os_creds.project_name)
@@ -458,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):
"""
@@ -471,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
@@ -504,7 +521,8 @@ class HeatUtilsRouterTests(OSComponentTestCase):
router = routers[0]
self.assertEqual(self.router_name, router.name)
- keystone = keystone_utils.keystone_client(self.os_creds)
+ keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
ext_net = neutron_utils.get_network(
self.neutron, keystone, network_name=self.ext_net_name)
self.assertEqual(ext_net.id, router.external_network_id)
@@ -534,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):
"""
@@ -547,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.
@@ -614,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):
"""
@@ -627,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.
@@ -673,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):
"""
@@ -686,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.
@@ -736,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):
"""
@@ -749,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.