summaryrefslogtreecommitdiffstats
path: root/snaps/openstack/utils/tests
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
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')
-rw-r--r--snaps/openstack/utils/tests/cinder_utils_tests.py28
-rw-r--r--snaps/openstack/utils/tests/glance_utils_tests.py7
-rw-r--r--snaps/openstack/utils/tests/heat_utils_tests.py84
-rw-r--r--snaps/openstack/utils/tests/keystone_utils_tests.py11
-rw-r--r--snaps/openstack/utils/tests/magnum_utils_tests.py8
-rw-r--r--snaps/openstack/utils/tests/neutron_utils_tests.py52
-rw-r--r--snaps/openstack/utils/tests/nova_utils_tests.py55
-rw-r--r--snaps/openstack/utils/tests/settings_utils_tests.py19
8 files changed, 187 insertions, 77 deletions
diff --git a/snaps/openstack/utils/tests/cinder_utils_tests.py b/snaps/openstack/utils/tests/cinder_utils_tests.py
index 3004c0f..073d574 100644
--- a/snaps/openstack/utils/tests/cinder_utils_tests.py
+++ b/snaps/openstack/utils/tests/cinder_utils_tests.py
@@ -43,7 +43,7 @@ class CinderSmokeTests(OSComponentTestCase):
"""
Tests to ensure that the proper credentials can connect.
"""
- cinder = cinder_utils.cinder_client(self.os_creds)
+ cinder = cinder_utils.cinder_client(self.os_creds, self.os_session)
volumes = cinder.volumes.list()
self.assertIsNotNone(volumes)
self.assertTrue(isinstance(volumes, list))
@@ -74,8 +74,10 @@ class CinderUtilsVolumeTests(OSComponentTestCase):
guid = uuid.uuid4()
self.volume_name = self.__class__.__name__ + '-' + str(guid)
self.volume = None
- self.cinder = cinder_utils.cinder_client(self.os_creds)
- self.keystone = keystone_utils.keystone_client(self.os_creds)
+ self.cinder = cinder_utils.cinder_client(
+ self.os_creds, self.os_session)
+ self.keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
def tearDown(self):
"""
@@ -186,7 +188,8 @@ class CinderUtilsQoSTests(OSComponentTestCase):
self.qos_name = self.__class__.__name__ + '-' + str(guid)
self.specs = {'foo': 'bar '}
self.qos = None
- self.cinder = cinder_utils.cinder_client(self.os_creds)
+ self.cinder = cinder_utils.cinder_client(
+ self.os_creds, self.os_session)
def tearDown(self):
"""
@@ -198,6 +201,8 @@ class CinderUtilsQoSTests(OSComponentTestCase):
except NotFound:
pass
+ super(self.__class__, self).__clean__()
+
def test_create_qos_both(self):
"""
Tests the cinder_utils.create_qos()
@@ -283,7 +288,8 @@ class CinderUtilsSimpleVolumeTypeTests(OSComponentTestCase):
volume_type_name = self.__class__.__name__ + '-' + str(guid)
self.volume_type_settings = VolumeTypeConfig(name=volume_type_name)
self.volume_type = None
- self.cinder = cinder_utils.cinder_client(self.os_creds)
+ self.cinder = cinder_utils.cinder_client(
+ self.os_creds, self.os_session)
def tearDown(self):
"""
@@ -295,6 +301,8 @@ class CinderUtilsSimpleVolumeTypeTests(OSComponentTestCase):
except NotFound:
pass
+ super(self.__class__, self).__clean__()
+
def test_create_simple_volume_type(self):
"""
Tests the cinder_utils.create_volume_type(), get_volume_type(), and
@@ -351,7 +359,8 @@ class CinderUtilsAddEncryptionTests(OSComponentTestCase):
self.encryption_name = self.__class__.__name__ + '-' + str(guid)
self.encryption = None
- self.cinder = cinder_utils.cinder_client(self.os_creds)
+ self.cinder = cinder_utils.cinder_client(
+ self.os_creds, self.os_session)
volume_type_name = self.__class__.__name__ + '-' + str(guid) + '-type'
self.volume_type = cinder_utils.create_volume_type(
@@ -374,6 +383,8 @@ class CinderUtilsAddEncryptionTests(OSComponentTestCase):
except NotFound:
pass
+ super(self.__class__, self).__clean__()
+
def test_create_simple_encryption(self):
"""
Tests the cinder_utils.create_volume_encryption(),
@@ -468,7 +479,8 @@ class CinderUtilsVolumeTypeCompleteTests(OSComponentTestCase):
self.qos_name = self.__class__.__name__ + '-' + str(guid) + '-qos'
self.vol_type_name = self.__class__.__name__ + '-' + str(guid)
self.specs = {'foo': 'bar'}
- self.cinder = cinder_utils.cinder_client(self.os_creds)
+ self.cinder = cinder_utils.cinder_client(
+ self.os_creds, self.os_session)
qos_settings = QoSConfig(
name=self.qos_name, specs=self.specs, consumer=Consumer.both)
self.qos = cinder_utils.create_qos(self.cinder, qos_settings)
@@ -496,6 +508,8 @@ class CinderUtilsVolumeTypeCompleteTests(OSComponentTestCase):
except NotFound:
pass
+ super(self.__class__, self).__clean__()
+
def test_create_with_encryption(self):
"""
Tests the cinder_utils.create_volume_type() where encryption has been
diff --git a/snaps/openstack/utils/tests/glance_utils_tests.py b/snaps/openstack/utils/tests/glance_utils_tests.py
index e61b795..e761ed8 100644
--- a/snaps/openstack/utils/tests/glance_utils_tests.py
+++ b/snaps/openstack/utils/tests/glance_utils_tests.py
@@ -39,7 +39,7 @@ class GlanceSmokeTests(OSComponentTestCase):
"""
Tests to ensure that the proper credentials can connect.
"""
- glance = glance_utils.glance_client(self.os_creds)
+ glance = glance_utils.glance_client(self.os_creds, self.os_session)
image = glance_utils.get_image(glance, image_name='foo')
self.assertIsNone(image)
@@ -69,7 +69,8 @@ class GlanceUtilsTests(OSComponentTestCase):
guid = uuid.uuid4()
self.image_name = self.__class__.__name__ + '-' + str(guid)
self.image = None
- self.glance = glance_utils.glance_client(self.os_creds)
+ self.glance = glance_utils.glance_client(
+ self.os_creds, self.os_session)
if self.image_metadata:
self.glance_test_meta = self.image_metadata.get('glance_tests')
else:
@@ -89,6 +90,8 @@ class GlanceUtilsTests(OSComponentTestCase):
if os.path.exists(self.tmp_dir) and os.path.isdir(self.tmp_dir):
shutil.rmtree(self.tmp_dir)
+ super(self.__class__, self).__clean__()
+
def test_create_image_minimal_url(self):
"""
Tests the glance_utils.create_image() function with a URL unless the
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.
diff --git a/snaps/openstack/utils/tests/keystone_utils_tests.py b/snaps/openstack/utils/tests/keystone_utils_tests.py
index 7ce7a61..cc3a8ad 100644
--- a/snaps/openstack/utils/tests/keystone_utils_tests.py
+++ b/snaps/openstack/utils/tests/keystone_utils_tests.py
@@ -31,7 +31,8 @@ class KeystoneSmokeTests(OSComponentTestCase):
"""
Tests to ensure that the proper credentials can connect.
"""
- keystone = keystone_utils.keystone_client(self.os_creds)
+ keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
users = keystone.users.list()
self.assertIsNotNone(users)
@@ -66,14 +67,16 @@ class KeystoneUtilsTests(OSComponentTestCase):
self.project_name = self.guid + '-projName'
self.project = None
self.role = None
- self.keystone = keystone_utils.keystone_client(self.os_creds)
+ self.keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
def tearDown(self):
"""
Cleans the remote OpenStack objects
"""
if self.project:
- neutron = neutron_utils.neutron_client(self.os_creds)
+ neutron = neutron_utils.neutron_client(
+ self.os_creds, self.os_session)
default_sec_grp = neutron_utils.get_security_group(
neutron, self.keystone, sec_grp_name='default',
project_name=self.os_creds.project_name)
@@ -92,6 +95,8 @@ class KeystoneUtilsTests(OSComponentTestCase):
if self.role:
keystone_utils.delete_role(self.keystone, self.role)
+ super(self.__class__, self).__clean__()
+
def test_create_user_minimal(self):
"""
Tests the keystone_utils.create_user() function
diff --git a/snaps/openstack/utils/tests/magnum_utils_tests.py b/snaps/openstack/utils/tests/magnum_utils_tests.py
index f841c48..d87d97a 100644
--- a/snaps/openstack/utils/tests/magnum_utils_tests.py
+++ b/snaps/openstack/utils/tests/magnum_utils_tests.py
@@ -44,7 +44,8 @@ class MagnumSmokeTests(OSComponentTestCase):
"""
Tests to ensure that the proper credentials can connect.
"""
- magnum = magnum_utils.magnum_client(self.os_creds)
+ magnum = magnum_utils.magnum_client(
+ self.os_creds, self.os_session)
# This should not throw an exception
self.assertIsNotNone(magnum.clusters.list())
@@ -70,7 +71,8 @@ class MagnumUtilsClusterTypeTests(OSComponentTestCase):
def setUp(self):
self.guid = self.__class__.__name__ + '-' + str(uuid.uuid4())
self.cluster_type_name = self.guid + '-cluster-type'
- self.magnum = magnum_utils.magnum_client(self.os_creds)
+ self.magnum = magnum_utils.magnum_client(
+ self.os_creds, self.os_session)
metadata = self.image_metadata
if not metadata:
@@ -130,6 +132,8 @@ class MagnumUtilsClusterTypeTests(OSComponentTestCase):
except:
pass
+ super(self.__class__, self).__clean__()
+
def test_create_cluster_template_simple(self):
config = ClusterTemplateConfig(
name=self.cluster_type_name,
diff --git a/snaps/openstack/utils/tests/neutron_utils_tests.py b/snaps/openstack/utils/tests/neutron_utils_tests.py
index 2583a96..cd293ca 100644
--- a/snaps/openstack/utils/tests/neutron_utils_tests.py
+++ b/snaps/openstack/utils/tests/neutron_utils_tests.py
@@ -41,7 +41,7 @@ class NeutronSmokeTests(OSComponentTestCase):
"""
Tests to ensure that the proper credentials can connect.
"""
- neutron = neutron_utils.neutron_client(self.os_creds)
+ neutron = neutron_utils.neutron_client(self.os_creds, self.os_session)
networks = neutron.list_networks()
@@ -70,7 +70,7 @@ class NeutronSmokeTests(OSComponentTestCase):
configured self.ext_net_name is contained within the returned list
:return:
"""
- neutron = neutron_utils.neutron_client(self.os_creds)
+ neutron = neutron_utils.neutron_client(self.os_creds, self.os_session)
ext_networks = neutron_utils.get_external_networks(neutron)
found = False
for network in ext_networks:
@@ -88,8 +88,10 @@ class NeutronUtilsNetworkTests(OSComponentTestCase):
def setUp(self):
guid = self.__class__.__name__ + '-' + str(uuid.uuid4())
self.port_name = str(guid) + '-port'
- self.neutron = neutron_utils.neutron_client(self.os_creds)
- self.keystone = keystone_utils.keystone_client(self.os_creds)
+ self.neutron = neutron_utils.neutron_client(
+ self.os_creds, self.os_session)
+ self.keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
self.network = None
self.net_config = openstack_tests.get_pub_net_config(
net_name=guid + '-pub-net')
@@ -101,6 +103,8 @@ class NeutronUtilsNetworkTests(OSComponentTestCase):
if self.network:
neutron_utils.delete_network(self.neutron, self.network)
+ super(self.__class__, self).__clean__()
+
def test_create_network(self):
"""
Tests the neutron_utils.create_network() function
@@ -145,8 +149,10 @@ class NeutronUtilsSubnetTests(OSComponentTestCase):
def setUp(self):
guid = self.__class__.__name__ + '-' + str(uuid.uuid4())
self.port_name = str(guid) + '-port'
- self.neutron = neutron_utils.neutron_client(self.os_creds)
- self.keystone = keystone_utils.keystone_client(self.os_creds)
+ self.neutron = neutron_utils.neutron_client(
+ self.os_creds, self.os_session)
+ self.keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
self.network = None
self.net_config = openstack_tests.get_pub_net_config(
net_name=guid + '-pub-net', subnet_name=guid + '-pub-subnet',
@@ -162,6 +168,8 @@ class NeutronUtilsSubnetTests(OSComponentTestCase):
except:
pass
+ super(self.__class__, self).__clean__()
+
def test_create_subnet(self):
"""
Tests the neutron_utils.create_network() function
@@ -264,7 +272,8 @@ class NeutronUtilsIPv6Tests(OSComponentTestCase):
def setUp(self):
self.guid = self.__class__.__name__ + '-' + str(uuid.uuid4())
- self.neutron = neutron_utils.neutron_client(self.os_creds)
+ self.neutron = neutron_utils.neutron_client(
+ self.os_creds, self.os_session)
self.network = None
def tearDown(self):
@@ -277,6 +286,8 @@ class NeutronUtilsIPv6Tests(OSComponentTestCase):
except:
pass
+ super(self.__class__, self).__clean__()
+
def test_create_network_slaac(self):
"""
Tests the neutron_utils.create_network() with an IPv6 subnet where DHCP
@@ -497,8 +508,10 @@ class NeutronUtilsRouterTests(OSComponentTestCase):
def setUp(self):
guid = self.__class__.__name__ + '-' + str(uuid.uuid4())
self.port_name = str(guid) + '-port'
- self.neutron = neutron_utils.neutron_client(self.os_creds)
- self.keystone = keystone_utils.keystone_client(self.os_creds)
+ self.neutron = neutron_utils.neutron_client(
+ self.os_creds, self.os_session)
+ self.keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
self.network = None
self.port = None
self.router = None
@@ -533,6 +546,8 @@ class NeutronUtilsRouterTests(OSComponentTestCase):
if self.network:
neutron_utils.delete_network(self.neutron, self.network)
+ super(self.__class__, self).__clean__()
+
def test_create_router_simple(self):
"""
Tests the neutron_utils.create_router()
@@ -856,8 +871,10 @@ class NeutronUtilsSecurityGroupTests(OSComponentTestCase):
self.security_groups = list()
self.security_group_rules = list()
- self.neutron = neutron_utils.neutron_client(self.os_creds)
- self.keystone = keystone_utils.keystone_client(self.os_creds)
+ self.neutron = neutron_utils.neutron_client(
+ self.os_creds, self.os_session)
+ self.keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
def tearDown(self):
"""
@@ -873,6 +890,8 @@ class NeutronUtilsSecurityGroupTests(OSComponentTestCase):
except:
pass
+ super(self.__class__, self).__clean__()
+
def test_create_delete_simple_sec_grp(self):
"""
Tests the neutron_utils.create_security_group() function
@@ -944,7 +963,8 @@ class NeutronUtilsSecurityGroupTests(OSComponentTestCase):
for free_rule in free_rules:
self.security_group_rules.append(free_rule)
- keystone = keystone_utils.keystone_client(self.os_creds)
+ keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
self.security_group_rules.append(
neutron_utils.create_security_group_rule(
self.neutron, keystone, sec_grp_settings.rule_settings[0],
@@ -1001,8 +1021,10 @@ class NeutronUtilsFloatingIpTests(OSComponentTestCase):
Instantiates the CreateImage object that is responsible for downloading
and creating an OS image file within OpenStack
"""
- self.neutron = neutron_utils.neutron_client(self.os_creds)
- self.keystone = keystone_utils.keystone_client(self.os_creds)
+ self.neutron = neutron_utils.neutron_client(
+ self.os_creds, self.os_session)
+ self.keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
self.floating_ip = None
def tearDown(self):
@@ -1016,6 +1038,8 @@ class NeutronUtilsFloatingIpTests(OSComponentTestCase):
except:
pass
+ super(self.__class__, self).__clean__()
+
def test_floating_ips(self):
"""
Tests the creation of a floating IP
diff --git a/snaps/openstack/utils/tests/nova_utils_tests.py b/snaps/openstack/utils/tests/nova_utils_tests.py
index 910684c..f5df865 100644
--- a/snaps/openstack/utils/tests/nova_utils_tests.py
+++ b/snaps/openstack/utils/tests/nova_utils_tests.py
@@ -49,7 +49,7 @@ class NovaSmokeTests(OSComponentTestCase):
"""
Tests to ensure that the proper credentials can connect.
"""
- nova = nova_utils.nova_client(self.os_creds)
+ nova = nova_utils.nova_client(self.os_creds, self.os_session)
# This should not throw an exception
nova.flavors.list()
@@ -58,7 +58,7 @@ class NovaSmokeTests(OSComponentTestCase):
"""
Tests to ensure that get_hypervisors() function works.
"""
- nova = nova_utils.nova_client(self.os_creds)
+ nova = nova_utils.nova_client(self.os_creds, self.os_session)
hosts = nova_utils.get_hypervisor_hosts(nova)
# This should not throw an exception
@@ -95,7 +95,7 @@ class NovaUtilsKeypairTests(OSComponentTestCase):
self.priv_key_file_path = 'tmp/' + guid
self.pub_key_file_path = self.priv_key_file_path + '.pub'
- self.nova = nova_utils.nova_client(self.os_creds)
+ self.nova = nova_utils.nova_client(self.os_creds, self.os_session)
self.keys = nova_utils.create_keys()
self.public_key = nova_utils.public_key_openssh(self.keys)
self.keypair_name = guid
@@ -123,6 +123,8 @@ class NovaUtilsKeypairTests(OSComponentTestCase):
except:
pass
+ super(self.__class__, self).__clean__()
+
def test_create_keypair(self):
"""
Tests the creation of an OpenStack keypair that does not exist.
@@ -176,7 +178,7 @@ class NovaUtilsFlavorTests(OSComponentTestCase):
self.flavor_settings = FlavorConfig(
name=guid + '-name', flavor_id=guid + '-id', ram=1, disk=1,
vcpus=1, ephemeral=1, swap=2, rxtx_factor=3.0, is_public=False)
- self.nova = nova_utils.nova_client(self.os_creds)
+ self.nova = nova_utils.nova_client(self.os_creds, self.os_session)
self.flavor = None
def tearDown(self):
@@ -189,6 +191,8 @@ class NovaUtilsFlavorTests(OSComponentTestCase):
except:
pass
+ super(self.__class__, self).__clean__()
+
def test_create_flavor(self):
"""
Tests the creation of an OpenStack keypair that does not exist.
@@ -242,10 +246,14 @@ class NovaUtilsInstanceTests(OSComponentTestCase):
guid = self.__class__.__name__ + '-' + str(uuid.uuid4())
- self.nova = nova_utils.nova_client(self.os_creds)
- self.keystone = keystone_utils.keystone_client(self.os_creds)
- self.neutron = neutron_utils.neutron_client(self.os_creds)
- self.glance = glance_utils.glance_client(self.os_creds)
+ self.nova = nova_utils.nova_client(
+ self.os_creds, self.os_session)
+ self.keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
+ self.neutron = neutron_utils.neutron_client(
+ self.os_creds, self.os_session)
+ self.glance = glance_utils.glance_client(
+ self.os_creds, self.os_session)
self.image_creator = None
self.network_creator = None
@@ -316,6 +324,8 @@ class NovaUtilsInstanceTests(OSComponentTestCase):
except:
pass
+ super(self.__class__, self).__clean__()
+
def test_create_instance(self):
"""
Tests the nova_utils.create_server() method
@@ -363,8 +373,9 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
guid = self.__class__.__name__ + '-' + str(uuid.uuid4())
- self.nova = nova_utils.nova_client(self.os_creds)
- self.cinder = cinder_utils.cinder_client(self.os_creds)
+ self.nova = nova_utils.nova_client(self.os_creds, self.os_session)
+ self.cinder = cinder_utils.cinder_client(
+ self.os_creds, self.os_session)
self.image_creator = None
self.network_creator = None
@@ -442,6 +453,8 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
except:
pass
+ super(self.__class__, self).__clean__()
+
def test_add_remove_volume(self):
"""
Tests the nova_utils.attach_volume() and detach_volume functions with
@@ -453,8 +466,10 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
self.assertEqual(0, len(self.volume_creator.get_volume().attachments))
# Attach volume to VM
- neutron = neutron_utils.neutron_client(self.os_creds)
- keystone = keystone_utils.keystone_client(self.os_creds)
+ neutron = neutron_utils.neutron_client(
+ self.os_creds, self.os_session)
+ keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
self.assertIsNotNone(nova_utils.attach_volume(
self.nova, neutron, keystone, self.instance_creator.get_vm_inst(),
self.volume_creator.get_volume(), self.os_creds.project_name))
@@ -476,7 +491,8 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
self.assertTrue(attached)
self.assertIsNotNone(vol_attach)
- keystone = keystone_utils.keystone_client(self.os_creds)
+ keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
vm_attach = nova_utils.get_server_object_by_id(
self.nova, neutron, keystone,
self.instance_creator.get_vm_inst().id, self.os_creds.project_name)
@@ -528,8 +544,9 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
self.assertEqual(0, len(self.volume_creator.get_volume().attachments))
# Attach volume to VM
- neutron = neutron_utils.neutron_client(self.os_creds)
- keystone = keystone_utils.keystone_client(self.os_creds)
+ neutron = neutron_utils.neutron_client(self.os_creds, self.os_session)
+ keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
with self.assertRaises(NovaException):
nova_utils.attach_volume(
self.nova, neutron, keystone,
@@ -548,14 +565,16 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
self.assertEqual(0, len(self.volume_creator.get_volume().attachments))
# Attach volume to VM
- neutron = neutron_utils.neutron_client(self.os_creds)
- keystone = keystone_utils.keystone_client(self.os_creds)
+ neutron = neutron_utils.neutron_client(self.os_creds, self.os_session)
+ keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
nova_utils.attach_volume(
self.nova, neutron, keystone, self.instance_creator.get_vm_inst(),
self.volume_creator.get_volume(), self.os_creds.project_name)
# Check VmInst for attachment
- keystone = keystone_utils.keystone_client(self.os_creds)
+ keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
latest_vm = nova_utils.get_server_object_by_id(
self.nova, neutron, keystone,
self.instance_creator.get_vm_inst().id, self.os_creds.project_name)
diff --git a/snaps/openstack/utils/tests/settings_utils_tests.py b/snaps/openstack/utils/tests/settings_utils_tests.py
index 7dc59b5..14af990 100644
--- a/snaps/openstack/utils/tests/settings_utils_tests.py
+++ b/snaps/openstack/utils/tests/settings_utils_tests.py
@@ -58,7 +58,8 @@ class SettingsUtilsNetworkingTests(OSComponentTestCase):
self.network_name = guid + '-net'
self.subnet_name = guid + '-subnet'
self.net_creator = None
- self.neutron = neutron_utils.neutron_client(self.os_creds)
+ self.neutron = neutron_utils.neutron_client(
+ self.os_creds, self.os_session)
def tearDown(self):
"""
@@ -70,6 +71,8 @@ class SettingsUtilsNetworkingTests(OSComponentTestCase):
except:
pass
+ super(self.__class__, self).__clean__()
+
def test_derive_net_settings_no_subnet(self):
"""
Validates the utility function settings_utils#create_network_config
@@ -154,10 +157,14 @@ class SettingsUtilsVmInstTests(OSComponentTestCase):
Instantiates the CreateImage object that is responsible for downloading
and creating an OS image file within OpenStack
"""
- self.nova = nova_utils.nova_client(self.os_creds)
- self.keystone = keystone_utils.keystone_client(self.os_creds)
- self.glance = glance_utils.glance_client(self.os_creds)
- self.neutron = neutron_utils.neutron_client(self.os_creds)
+ self.nova = nova_utils.nova_client(
+ self.os_creds, self.os_session)
+ self.keystone = keystone_utils.keystone_client(
+ self.os_creds, self.os_session)
+ self.glance = glance_utils.glance_client(
+ self.os_creds, self.os_session)
+ self.neutron = neutron_utils.neutron_client(
+ self.os_creds, self.os_session)
guid = self.__class__.__name__ + '-' + str(uuid.uuid4())
self.keypair_priv_filepath = 'tmp/' + guid
@@ -315,7 +322,7 @@ class SettingsUtilsVmInstTests(OSComponentTestCase):
if os.path.isfile(self.test_file_local_path):
os.remove(self.test_file_local_path)
- # super(self.__class__, self).__clean__()
+ super(self.__class__, self).__clean__()
def test_derive_vm_inst_config(self):
"""