~ubuntu-branches/ubuntu/wily/neutron-lbaas/wily

« back to all changes in this revision

Viewing changes to neutron_lbaas/tests/tempest/v2/api/test_health_monitor_admin.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-06-29 10:07:38 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20150629100738-yxyfnvo9xl2jhpp9
Tags: 2:7.0.0~b1-0ubuntu1
* New upstream milestone for OpenStack Liberty.
* Align (build)-depends with upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2015 Hewlett-Packard Development Company, L.P.
 
2
#
 
3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
 
4
# not use this file except in compliance with the License. You may obtain
 
5
# a copy of the License at
 
6
#
 
7
# http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
9
# Unless required by applicable law or agreed to in writing, software
 
10
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
12
# License for the specific language governing permissions and limitations
 
13
# under the License.
 
14
 
 
15
from oslo_log import log as logging
 
16
from oslo_utils import uuidutils
 
17
 
 
18
from neutron_lbaas.tests.tempest.lib.common.utils import data_utils
 
19
from neutron_lbaas.tests.tempest.lib import config
 
20
from neutron_lbaas.tests.tempest.lib import test
 
21
from neutron_lbaas.tests.tempest.v2.api import base
 
22
 
 
23
CONF = config.CONF
 
24
 
 
25
LOG = logging.getLogger(__name__)
 
26
 
 
27
 
 
28
class TestHealthMonitors(base.BaseAdminTestCase):
 
29
 
 
30
    """
 
31
    Tests the following operations in the Neutron-LBaaS API using the
 
32
    REST client for Health Monitors with ADMIN role:
 
33
 
 
34
    create health monitor with missing tenant_id
 
35
    create health monitor with empty tenant id
 
36
    create health monitor with another tenant_id
 
37
    """
 
38
 
 
39
    @classmethod
 
40
    def resource_setup(cls):
 
41
        super(TestHealthMonitors, cls).resource_setup()
 
42
        if not test.is_extension_enabled('lbaas', 'network'):
 
43
            msg = "lbaas extension not enabled."
 
44
            raise cls.skipException(msg)
 
45
        network_name = data_utils.rand_name('network-')
 
46
        cls.network = cls.create_network(network_name)
 
47
        cls.subnet = cls.create_subnet(cls.network)
 
48
        cls.load_balancer = cls._create_load_balancer(
 
49
            tenant_id=cls.subnet.get('tenant_id'),
 
50
            vip_subnet_id=cls.subnet.get('id'))
 
51
        cls.listener = cls._create_listener(
 
52
            loadbalancer_id=cls.load_balancer.get('id'),
 
53
            protocol='HTTP', protocol_port=80)
 
54
        cls.pool = cls._create_pool(
 
55
            protocol='HTTP', lb_algorithm='ROUND_ROBIN',
 
56
            listener_id=cls.listener.get('id'))
 
57
 
 
58
    @classmethod
 
59
    def resource_cleanup(cls):
 
60
        super(TestHealthMonitors, cls).resource_cleanup()
 
61
 
 
62
    @test.attr(type='smoke')
 
63
    def test_create_health_monitor_missing_tenant_id_field(self):
 
64
        """
 
65
        Test if admin user can create health monitor with a missing tenant id
 
66
        field.
 
67
        """
 
68
        hm = self._create_health_monitor(type='HTTP', delay=3, max_retries=10,
 
69
                                         timeout=5,
 
70
                                         pool_id=self.pool.get('id'))
 
71
 
 
72
        admin_hm = self.health_monitors_client.get_health_monitor(hm.get('id'))
 
73
        admin_tenant_id = admin_hm.get('tenant_id')
 
74
        hm_tenant_id = hm.get('tenant_id')
 
75
        self.assertEqual(admin_tenant_id, hm_tenant_id)
 
76
 
 
77
        # cleanup test
 
78
        self._delete_health_monitor(hm.get('id'))
 
79
 
 
80
    @test.attr(type='smoke')
 
81
    def test_create_health_monitor_empty_tenant_id_field(self):
 
82
        """
 
83
        Test with admin user create health monitor with an empty tenant id
 
84
        field.
 
85
        """
 
86
        hm = self._create_health_monitor(type='HTTP', delay=3, max_retries=10,
 
87
                                         timeout=5,
 
88
                                         pool_id=self.pool.get('id'),
 
89
                                         tenant_id="")
 
90
 
 
91
        self.assertEqual(hm.get('tenant_id'), "")
 
92
 
 
93
        # cleanup test
 
94
        self._delete_health_monitor(hm.get('id'))
 
95
 
 
96
    @test.attr(type='smoke')
 
97
    def test_create_health_monitor_for_another_tenant_id_field(self):
 
98
        """Test with admin user create health monitor for another tenant id.
 
99
        """
 
100
 
 
101
        tenantid = uuidutils.generate_uuid()
 
102
        hm = self._create_health_monitor(type='HTTP', delay=3, max_retries=10,
 
103
                                         timeout=5,
 
104
                                         pool_id=self.pool.get('id'),
 
105
                                         tenant_id=tenantid)
 
106
 
 
107
        self.assertEqual(hm.get('tenant_id'), tenantid)
 
108
        self.assertNotEqual(hm.get('tenant_id'),
 
109
                            self.subnet.get('tenant_id'))
 
110
        # cleanup test
 
111
        self._delete_health_monitor(hm.get('id'))