Merge "Add some tests for floating ips"

This commit is contained in:
Jenkins 2015-05-01 23:30:36 +00:00 committed by Gerrit Code Review
commit 195799fb5d
2 changed files with 52 additions and 0 deletions

View File

@ -14,6 +14,7 @@
# under the License.
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from neutron.tests.api import base
from neutron.tests.api import clients
@ -33,6 +34,8 @@ class FloatingIPAdminTestJSON(base.BaseAdminNetworkTest):
cls.ext_net_id = CONF.network.public_network_id
cls.floating_ip = cls.create_floatingip(cls.ext_net_id)
cls.alt_manager = clients.Manager(cls.isolated_creds.get_alt_creds())
admin_manager = clients.AdminManager()
cls.identity_admin_client = admin_manager.identity_client
cls.alt_client = cls.alt_manager.network_client
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
@ -109,3 +112,23 @@ class FloatingIPAdminTestJSON(base.BaseAdminNetworkTest):
floating_ips = self.admin_client.list_floatingips()
floatingip_id_list = [f['id'] for f in floating_ips['floatingips']]
self.assertIn(created_floating_ip['id'], floatingip_id_list)
@test.attr(type=['negative', 'smoke'])
@test.idempotent_id('11116ee9-4e99-5b15-b8e1-aa7df92ca589')
def test_associate_floating_ip_with_port_from_another_tenant(self):
body = self.admin_client.create_floatingip(
floating_network_id=self.ext_net_id)
floating_ip = body['floatingip']
test_tenant = data_utils.rand_name('test_tenant_')
test_description = data_utils.rand_name('desc_')
tenant = self.identity_admin_client.create_tenant(
name=test_tenant, description=test_description)
tenant_id = tenant['id']
self.addCleanup(self.identity_admin_client.delete_tenant, tenant_id)
port = self.admin_client.create_port(network_id=self.network['id'],
tenant_id=tenant_id)
self.addCleanup(self.admin_client.delete_port, port['port']['id'])
self.assertRaises(lib_exc.BadRequest,
self.admin_client.update_floatingip,
floating_ip['id'], port_id=port['port']['id'])

View File

@ -32,6 +32,8 @@ class FloatingIPNegativeTestJSON(base.BaseNetworkTest):
Create floatingip with a port that is unreachable to external network
Create floatingip in private network
Associate floatingip with port that is unreachable to external network
Associate floating ip to port that has already another floating ip
Associate floating ip with port from another tenant
"""
@classmethod
@ -80,3 +82,30 @@ class FloatingIPNegativeTestJSON(base.BaseNetworkTest):
floating_ip['id'], port_id=self.port['id'],
fixed_ip_address=self.port['fixed_ips'][0]
['ip_address'])
@test.attr(type=['negative', 'smoke'])
@test.idempotent_id('0b5b8797-6de7-4191-905c-a48b888eb429')
def test_associate_floatingip_with_port_with_floatingip(self):
net = self.create_network()
subnet = self.create_subnet(net)
r = self.create_router('test')
self.create_router_interface(r['id'], subnet['id'])
self.client.update_router(
r['id'],
external_gateway_info={
'network_id': self.ext_net_id})
self.addCleanup(self.client.update_router, self.router['id'],
external_gateway_info={})
port = self.create_port(net)
body1 = self.client.create_floatingip(
floating_network_id=self.ext_net_id)
floating_ip1 = body1['floatingip']
self.addCleanup(self.client.delete_floatingip, floating_ip1['id'])
body2 = self.client.create_floatingip(
floating_network_id=self.ext_net_id)
floating_ip2 = body2['floatingip']
self.addCleanup(self.client.delete_floatingip, floating_ip2['id'])
self.client.update_floatingip(floating_ip1['id'],
port_id=port['id'])
self.assertRaises(lib_exc.Conflict, self.client.update_floatingip,
floating_ip2['id'], port_id=port['id'])