summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Pisarski <s.pisarski@cablelabs.com>2017-07-18 13:48:52 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-07-18 13:48:52 +0000
commitacda399def76b37345f298c7df14ae2594cdc147 (patch)
tree61cf4d96349f800aa807898523b6a9346ef585d2
parentf2fc55fc622b57c078615d847443023fea0799e2 (diff)
parent34623d35ba81b5d8290b87e469af784be746f78f (diff)
Merge "Added proper assertion config NIC test."
-rw-r--r--snaps/openstack/create_instance.py5
-rw-r--r--snaps/openstack/tests/create_instance_tests.py56
2 files changed, 27 insertions, 34 deletions
diff --git a/snaps/openstack/create_instance.py b/snaps/openstack/create_instance.py
index 189ea57..97f04f3 100644
--- a/snaps/openstack/create_instance.py
+++ b/snaps/openstack/create_instance.py
@@ -405,7 +405,7 @@ class OpenStackVmInstance:
"""
Responsible for configuring NICs on RPM systems where the instance has
more than one configured port
- :return: None
+ :return: the value returned by ansible_utils.apply_ansible_playbook()
"""
if len(self.__ports) > 1 and len(self.__floating_ips) > 0:
if self.vm_active(block=True) and self.vm_ssh_active(block=True):
@@ -413,11 +413,12 @@ class OpenStackVmInstance:
port_index = self.__ports.index((key, port))
if port_index > 0:
nic_name = 'eth' + repr(port_index)
- self.__config_nic(
+ retval = self.__config_nic(
nic_name, port,
self.__get_first_provisioning_floating_ip().ip)
logger.info('Configured NIC - %s on VM - %s',
nic_name, self.instance_settings.name)
+ return retval
def __get_first_provisioning_floating_ip(self):
"""
diff --git a/snaps/openstack/tests/create_instance_tests.py b/snaps/openstack/tests/create_instance_tests.py
index aef8e6e..ebdb76a 100644
--- a/snaps/openstack/tests/create_instance_tests.py
+++ b/snaps/openstack/tests/create_instance_tests.py
@@ -1276,9 +1276,9 @@ class CreateInstancePubPrivNetTests(OSIntegrationTestCase):
SecurityGroupSettings(name=sec_grp_name,
rule_settings=[rule1, rule2]))
self.sec_grp_creator.create()
- except Exception as e:
+ except:
self.tearDown()
- raise Exception(str(e))
+ raise
def tearDown(self):
"""
@@ -1400,15 +1400,7 @@ class CreateInstancePubPrivNetTests(OSIntegrationTestCase):
# Effectively blocks until VM's ssh port has been opened
self.assertTrue(self.inst_creator.vm_ssh_active(block=True))
- # TODO - Refactor config_nics() to return a status that can be
- # validated here.
- self.inst_creator.config_nics()
-
- # TODO - *** ADD VALIDATION HERE ***
- # TODO - Add validation that both floating IPs work
- # TODO - Add tests where only one NIC has a floating IP
- # TODO - Add tests where one attempts to place a floating IP on a
- # network/router without an external gateway
+ self.assertEqual(0, self.inst_creator.config_nics())
class InstanceSecurityGroupTests(OSIntegrationTestCase):
@@ -2079,11 +2071,11 @@ class CreateInstanceMockOfflineTests(OSComponentTestCase):
self.image_creator.create()
metadata = {
- 'cirros':
- {'config':
- {'name': os_image_settings.name,
- 'image_user': os_image_settings.image_user,
- 'exists': True}}}
+ 'cirros': {
+ 'config': {
+ 'name': os_image_settings.name,
+ 'image_user': os_image_settings.image_user,
+ 'exists': True}}}
test_image_settings = openstack_tests.cirros_image_settings(
image_metadata=metadata)
test_image = OpenStackImage(self.os_creds, test_image_settings)
@@ -2114,22 +2106,22 @@ class CreateInstanceMockOfflineTests(OSComponentTestCase):
openstack_tests.CIRROS_DEFAULT_RAMDISK_IMAGE_URL, self.tmpDir)
metadata = {
- 'cirros':
- {'config':
- {'name': self.image_name,
- 'image_user': openstack_tests.CIRROS_USER,
- 'image_file': self.image_file.name,
- 'format': openstack_tests.DEFAULT_IMAGE_FORMAT,
- 'kernel_image_settings':
- {'name': self.image_name + '-kernel',
- 'image_user': openstack_tests.CIRROS_USER,
- 'image_file': kernel_file.name,
- 'format': openstack_tests.DEFAULT_IMAGE_FORMAT},
- 'ramdisk_image_settings':
- {'name': self.image_name + '-ramdisk',
- 'image_user': openstack_tests.CIRROS_USER,
- 'image_file': ramdisk_file.name,
- 'format': openstack_tests.DEFAULT_IMAGE_FORMAT}}}}
+ 'cirros': {
+ 'config': {
+ 'name': self.image_name,
+ 'image_user': openstack_tests.CIRROS_USER,
+ 'image_file': self.image_file.name,
+ 'format': openstack_tests.DEFAULT_IMAGE_FORMAT,
+ 'kernel_image_settings': {
+ 'name': self.image_name + '-kernel',
+ 'image_user': openstack_tests.CIRROS_USER,
+ 'image_file': kernel_file.name,
+ 'format': openstack_tests.DEFAULT_IMAGE_FORMAT},
+ 'ramdisk_image_settings': {
+ 'name': self.image_name + '-ramdisk',
+ 'image_user': openstack_tests.CIRROS_USER,
+ 'image_file': ramdisk_file.name,
+ 'format': openstack_tests.DEFAULT_IMAGE_FORMAT}}}}
os_image_settings = openstack_tests.cirros_image_settings(
name=self.image_name, image_metadata=metadata)