1
# Copyright 2014 Hewlett-Packard Development Company, L.P.
2
# Copyright 2014 OpenStack Foundation
5
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
# not use this file except in compliance with the License. You may obtain
7
# a copy of the License at
9
# http://www.apache.org/licenses/LICENSE-2.0
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
# License for the specific language governing permissions and limitations
17
from tempest_lib.common.utils import data_utils
18
from tempest_lib import exceptions as lib_exc
20
from neutron.tests.tempest.api.network import base
21
from neutron.tests.tempest import config
22
from neutron.tests.tempest import test
27
class FloatingIPNegativeTestJSON(base.BaseNetworkTest):
30
Test the following negative operations for floating ips:
32
Create floatingip with a port that is unreachable to external network
33
Create floatingip in private network
34
Associate floatingip with port that is unreachable to external network
38
def resource_setup(cls):
39
super(FloatingIPNegativeTestJSON, cls).resource_setup()
40
if not test.is_extension_enabled('router', 'network'):
41
msg = "router extension not enabled."
42
raise cls.skipException(msg)
43
cls.ext_net_id = CONF.network.public_network_id
44
# Create a network with a subnet connected to a router.
45
cls.network = cls.create_network()
46
cls.subnet = cls.create_subnet(cls.network)
47
cls.router = cls.create_router(data_utils.rand_name('router'))
48
cls.create_router_interface(cls.router['id'], cls.subnet['id'])
49
cls.port = cls.create_port(cls.network)
51
@test.attr(type=['negative', 'smoke'])
52
@test.idempotent_id('22996ea8-4a81-4b27-b6e1-fa5df92fa5e8')
53
def test_create_floatingip_with_port_ext_net_unreachable(self):
54
self.assertRaises(lib_exc.NotFound, self.client.create_floatingip,
55
floating_network_id=self.ext_net_id,
56
port_id=self.port['id'],
57
fixed_ip_address=self.port['fixed_ips'][0]
60
@test.attr(type=['negative', 'smoke'])
61
@test.idempotent_id('50b9aeb4-9f0b-48ee-aa31-fa955a48ff54')
62
def test_create_floatingip_in_private_network(self):
63
self.assertRaises(lib_exc.BadRequest,
64
self.client.create_floatingip,
65
floating_network_id=self.network['id'],
66
port_id=self.port['id'],
67
fixed_ip_address=self.port['fixed_ips'][0]
70
@test.attr(type=['negative', 'smoke'])
71
@test.idempotent_id('6b3b8797-6d43-4191-985c-c48b773eb429')
72
def test_associate_floatingip_port_ext_net_unreachable(self):
74
body = self.client.create_floatingip(
75
floating_network_id=self.ext_net_id)
76
floating_ip = body['floatingip']
77
self.addCleanup(self.client.delete_floatingip, floating_ip['id'])
78
# Associate floating IP to the other port
79
self.assertRaises(lib_exc.NotFound, self.client.update_floatingip,
80
floating_ip['id'], port_id=self.port['id'],
81
fixed_ip_address=self.port['fixed_ips'][0]