1
# Copyright 2014 Mirantis.inc
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
# not use this file except in compliance with the License. You may obtain
6
# a copy of the License at
8
# http://www.apache.org/licenses/LICENSE-2.0
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
# License for the specific language governing permissions and limitations
16
from tempest_lib.common.utils import data_utils
18
from neutron.tests.tempest.api.network import base
19
from neutron.tests.tempest import test
22
class LoadBalancerAdminTestJSON(base.BaseAdminNetworkTest):
25
Test admin actions for load balancer.
27
Create VIP for another tenant
28
Create health monitor for another tenant
32
def resource_setup(cls):
33
super(LoadBalancerAdminTestJSON, cls).resource_setup()
34
if not test.is_extension_enabled('lbaas', 'network'):
35
msg = "lbaas extension not enabled."
36
raise cls.skipException(msg)
37
cls.force_tenant_isolation = True
38
manager = cls.get_client_manager()
39
cls.client = manager.network_client
40
cls.tenant_id = cls.isolated_creds.get_primary_creds().tenant_id
41
cls.network = cls.create_network()
42
cls.subnet = cls.create_subnet(cls.network)
43
cls.pool = cls.create_pool(data_utils.rand_name('pool-'),
44
"ROUND_ROBIN", "HTTP", cls.subnet)
46
@test.attr(type='smoke')
47
@test.idempotent_id('6b0a20d8-4fcd-455e-b54f-ec4db5199518')
48
def test_create_vip_as_admin_for_another_tenant(self):
49
name = data_utils.rand_name('vip-')
50
body = self.admin_client.create_pool(
51
name=data_utils.rand_name('pool-'),
52
lb_method="ROUND_ROBIN",
54
subnet_id=self.subnet['id'],
55
tenant_id=self.tenant_id)
57
self.addCleanup(self.admin_client.delete_pool, pool['id'])
58
body = self.admin_client.create_vip(name=name,
61
subnet_id=self.subnet['id'],
63
tenant_id=self.tenant_id)
65
self.addCleanup(self.admin_client.delete_vip, vip['id'])
66
self.assertIsNotNone(vip['id'])
67
self.assertEqual(self.tenant_id, vip['tenant_id'])
68
body = self.client.show_vip(vip['id'])
69
show_vip = body['vip']
70
self.assertEqual(vip['id'], show_vip['id'])
71
self.assertEqual(vip['name'], show_vip['name'])
73
@test.attr(type='smoke')
74
@test.idempotent_id('74552cfc-ab78-4fb6-825b-f67bca379921')
75
def test_create_health_monitor_as_admin_for_another_tenant(self):
77
self.admin_client.create_health_monitor(delay=4,
81
tenant_id=self.tenant_id))
82
health_monitor = body['health_monitor']
83
self.addCleanup(self.admin_client.delete_health_monitor,
85
self.assertIsNotNone(health_monitor['id'])
86
self.assertEqual(self.tenant_id, health_monitor['tenant_id'])
87
body = self.client.show_health_monitor(health_monitor['id'])
88
show_health_monitor = body['health_monitor']
89
self.assertEqual(health_monitor['id'], show_health_monitor['id'])
91
@test.attr(type='smoke')
92
@test.idempotent_id('266a192d-3c22-46c4-a8fb-802450301e82')
93
def test_create_pool_from_admin_user_other_tenant(self):
94
body = self.admin_client.create_pool(
95
name=data_utils.rand_name('pool-'),
96
lb_method="ROUND_ROBIN",
98
subnet_id=self.subnet['id'],
99
tenant_id=self.tenant_id)
101
self.addCleanup(self.admin_client.delete_pool, pool['id'])
102
self.assertIsNotNone(pool['id'])
103
self.assertEqual(self.tenant_id, pool['tenant_id'])
105
@test.attr(type='smoke')
106
@test.idempotent_id('158bb272-b9ed-4cfc-803c-661dac46f783')
107
def test_create_member_from_admin_user_other_tenant(self):
108
body = self.admin_client.create_member(address="10.0.9.47",
110
pool_id=self.pool['id'],
111
tenant_id=self.tenant_id)
112
member = body['member']
113
self.addCleanup(self.admin_client.delete_member, member['id'])
114
self.assertIsNotNone(member['id'])
115
self.assertEqual(self.tenant_id, member['tenant_id'])