diff options
author | spisarski <s.pisarski@cablelabs.com> | 2017-07-24 11:27:59 -0600 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2017-07-24 11:27:59 -0600 |
commit | 3d6ec1eeaf70ae4e46042946f8bd35d5b5380401 (patch) | |
tree | 9d2881a2f73de6e779d266ceb6798ec3930d42ea /snaps/openstack/tests/create_router_tests.py | |
parent | feae63d11f8295a0d9327496f42949ad5b67fca4 (diff) |
Fixed problems when setting the OpenStack project ID.
There were several calls to retrieve the project ID that required
named parameters which was causing the utility function to always
return None. Additionally, when creating the dict() required by the
Neutron create API 'body' parameter key 'project_id' is not supported
and still uses 'tenant_id'.
As these problems should have been found earlier, this patch also
extends the tests for networks, subnets, ports, and security groups
to use 'tenant_id' rather than 'project_id'.
JIRA: SNAPS-143
Change-Id: Ic69e56145ea6070718d821edd22a1d0f9970995d
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/tests/create_router_tests.py')
-rw-r--r-- | snaps/openstack/tests/create_router_tests.py | 86 |
1 files changed, 69 insertions, 17 deletions
diff --git a/snaps/openstack/tests/create_router_tests.py b/snaps/openstack/tests/create_router_tests.py index efa0993..6e10d66 100644 --- a/snaps/openstack/tests/create_router_tests.py +++ b/snaps/openstack/tests/create_router_tests.py @@ -21,7 +21,7 @@ from snaps.openstack.create_network import ( NetworkSettings, PortSettings) from snaps.openstack.create_network import OpenStackNetwork from snaps.openstack.create_router import ( - RouterSettings, RouterSettingsError, RouterCreationError) + RouterSettings, RouterSettingsError) from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase from snaps.openstack.utils import neutron_utils @@ -169,6 +169,46 @@ class CreateRouterSuccessTests(OSIntegrationTestCase): self.assertTrue(verify_router_attributes( router, self.router_creator, ext_gateway=self.ext_net_name)) + def test_create_router_admin_user_to_new_project(self): + """ + Test creation of a most basic router with the admin user pointing + to the new project. + """ + router_settings = RouterSettings( + name=self.guid + '-pub-router', external_gateway=self.ext_net_name, + project_name=self.os_creds.project_name) + + self.router_creator = create_router.OpenStackRouter( + self.admin_os_creds, router_settings) + self.router_creator.create() + + router = neutron_utils.get_router_by_name(self.neutron, + router_settings.name) + self.assertIsNotNone(router) + + self.assertTrue(verify_router_attributes( + router, self.router_creator, ext_gateway=self.ext_net_name)) + + def test_create_router_new_user_to_admin_project(self): + """ + Test creation of a most basic router with the new user pointing + to the admin project. + """ + router_settings = RouterSettings( + name=self.guid + '-pub-router', external_gateway=self.ext_net_name, + project_name=self.admin_os_creds.project_name) + + self.router_creator = create_router.OpenStackRouter( + self.os_creds, router_settings) + self.router_creator.create() + + router = neutron_utils.get_router_by_name(self.neutron, + router_settings.name) + self.assertIsNotNone(router) + + self.assertTrue(verify_router_attributes( + router, self.router_creator, ext_gateway=self.ext_net_name)) + def test_create_delete_router(self): """ Test that clean() will not raise an exception if the router is deleted @@ -257,14 +297,23 @@ class CreateRouterSuccessTests(OSIntegrationTestCase): self.network_creator2.create() port_settings = [ - create_network.PortSettings(name=self.guid + '-port1', ip_addrs=[ - {'subnet_name': network_settings1.subnet_settings[0].name, - 'ip': static_gateway_ip1}], - network_name=network_settings1.name), - create_network.PortSettings(name=self.guid + '-port2', ip_addrs=[ - {'subnet_name': network_settings2.subnet_settings[0].name, - 'ip': static_gateway_ip2}], - network_name=network_settings2.name)] + create_network.PortSettings( + name=self.guid + '-port1', + ip_addrs=[{ + 'subnet_name': + network_settings1.subnet_settings[0].name, + 'ip': static_gateway_ip1 + }], + network_name=network_settings1.name, + project_name=self.os_creds.project_name), + create_network.PortSettings( + name=self.guid + '-port2', + ip_addrs=[{ + 'subnet_name': network_settings2.subnet_settings[0].name, + 'ip': static_gateway_ip2 + }], + network_name=network_settings2.name, + project_name=self.os_creds.project_name)] router_settings = RouterSettings(name=self.guid + '-pub-router', port_settings=port_settings) @@ -293,14 +342,17 @@ class CreateRouterSuccessTests(OSIntegrationTestCase): self.network_creator1.create() port_settings = [ - create_network.PortSettings(name=self.guid + '-port1', ip_addrs=[ - {'subnet_name': network_settings.subnet_settings[0].name, - 'ip': static_gateway_ip1}], - network_name=network_settings.name)] - - router_settings = RouterSettings(name=self.guid + '-pub-router', - external_gateway=self.ext_net_name, - port_settings=port_settings) + create_network.PortSettings( + name=self.guid + '-port1', + ip_addrs=[{ + 'subnet_name': network_settings.subnet_settings[0].name, + 'ip': static_gateway_ip1}], + network_name=network_settings.name, + project_name=self.os_creds.project_name)] + + router_settings = RouterSettings( + name=self.guid + '-pub-router', external_gateway=self.ext_net_name, + port_settings=port_settings) self.router_creator = create_router.OpenStackRouter(self.os_creds, router_settings) self.router_creator.create() |