From 30d21c198bed86a81b8b5756e04e2a65d84d415c Mon Sep 17 00:00:00 2001 From: pbharathbhu Date: Tue, 21 Apr 2020 08:40:56 +0000 Subject: [PATCH] NSXV octavia cases Change-Id: I4a7e51e30bf7b017c4f4203a2639f172b3f9ec27 --- .../scenario/test_octavia_loadbalancers.py | 788 ++++++++++++++++++ 1 file changed, 788 insertions(+) create mode 100644 vmware_nsx_tempest_plugin/tests/nsxv/scenario/test_octavia_loadbalancers.py diff --git a/vmware_nsx_tempest_plugin/tests/nsxv/scenario/test_octavia_loadbalancers.py b/vmware_nsx_tempest_plugin/tests/nsxv/scenario/test_octavia_loadbalancers.py new file mode 100644 index 0000000..6d6bc6b --- /dev/null +++ b/vmware_nsx_tempest_plugin/tests/nsxv/scenario/test_octavia_loadbalancers.py @@ -0,0 +1,788 @@ +# Copyright 2019 VMware Inc +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from tempest import config +from tempest.lib.common.utils import test_utils +from tempest.lib import decorators +from tempest import test + +from vmware_nsx_tempest_plugin.common import constants +from vmware_nsx_tempest_plugin.lib import feature_manager + + +LOG = constants.log.getLogger(__name__) +CONF = config.CONF + + +class OctaviaRoundRobin(feature_manager.FeatureManager): + + """Base class to support LBaaS ROUND-ROBIN test. + + It provides the methods to create loadbalancer network, and + start web servers. + + Default lb_algorithm is ROUND_ROBIND. + """ + @classmethod + def setup_clients(cls): + super(OctaviaRoundRobin, cls).setup_clients() + cls.cmgr_adm = cls.get_client_manager('admin') + cls.cmgr_alt = cls.get_client_manager('alt') + cls.cmgr_adm = cls.get_client_manager('admin') + + @classmethod + def skip_checks(cls): + super(OctaviaRoundRobin, cls).skip_checks() + cfg = CONF.network + if not test.is_extension_enabled('lbaasv2', 'network'): + msg = 'lbaasv2 extension is not enabled.' + raise cls.skipException(msg) + if not (cfg.project_networks_reachable or cfg.public_network_id): + msg = ('Either project_networks_reachable must be "true", or ' + 'public_network_id must be defined.') + raise cls.skipException(msg) + + @classmethod + def resource_setup(cls): + super(OctaviaRoundRobin, cls).resource_setup() + + @classmethod + def setup_credentials(cls): + # Ask framework to not create network resources for these tests. + cls.set_network_resources() + super(OctaviaRoundRobin, cls).setup_credentials() + + def setUp(self): + super(OctaviaRoundRobin, self).setUp() + CONF.validation.ssh_shell_prologue = '' + self.vip_ip_address = '' + self.namestart = 'lbaas-ops' + self.poke_counters = 12 + self.hm_delay = 4 + self.hm_max_retries = 3 + self.hm_timeout = 10 + self.server_names = [] + self.loadbalancer = None + self.vip_fip = None + self.web_service_start_delay = 2.5 + + def tearDown(self): + if self.vip_fip: + LOG.debug("tearDown lbass vip fip") + self.disassociate_floatingip(self.vip_fip, and_delete=True) + if self.loadbalancer: + LOG.debug("tearDown lbass") + lb_id = self.loadbalancer['id'] + self.delete_octavia_lb_resources(lb_id) + + LOG.debug("tearDown lbaas exiting...") + super(OctaviaRoundRobin, self).tearDown() + + def deploy_octavia_topology(self, no_of_servers=2, image_id=None): + kwargs = {'name': "router_lbaas", + 'external_gateway_info': + {"network_id": CONF.network.public_network_id}} + router_lbaas = self.cmgr_adm.routers_client.create_router(**kwargs) + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.routers_client.delete_router, + router_lbaas['router']['id']) + networks_client = self.cmgr_adm.networks_client + name = "network_lbaas_1" + network_lbaas_1 = self.\ + create_topology_network(name, + networks_client=networks_client) + sec_rule_client = self.cmgr_adm.security_group_rules_client + sec_client = self.cmgr_adm.security_groups_client + kwargs = dict(tenant_id=network_lbaas_1['tenant_id'], + security_group_rules_client=sec_rule_client, + security_groups_client=sec_client) + self.sg = self.create_topology_security_group(**kwargs) + lbaas_rules = [dict(direction='ingress', protocol='tcp', + port_range_min=constants.HTTP_PORT, + port_range_max=constants.HTTP_PORT, ), + dict(direction='ingress', protocol='tcp', + port_range_min=443, port_range_max=443, )] + t_id = network_lbaas_1['tenant_id'] + for rule in lbaas_rules: + self.add_security_group_rule(self.sg, rule, + secclient=sec_client, + ruleclient=sec_rule_client, + tenant_id=t_id) + body = {"network_id": network_lbaas_1['id'], + "allocation_pools": [{"start": "2.0.0.2", "end": "2.0.0.254"}], + "ip_version": 4, "cidr": "2.0.0.0/24"} + subnet_client = self.cmgr_adm.subnets_client + subnet_lbaas = subnet_client.create_subnet(**body) + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + subnet_client.delete_subnet, + subnet_lbaas['subnet']['id']) + self.cmgr_adm.routers_client.\ + add_router_interface(router_lbaas['router']['id'], + subnet_id=subnet_lbaas['subnet']['id']) + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.routers_client.remove_router_interface, + router_lbaas['router']['id'], + subnet_id=subnet_lbaas['subnet']['id']) + for instance in range(0, no_of_servers): + self.create_topology_instance( + "server_lbaas_%s" % instance, [network_lbaas_1], + security_groups=[{'name': self.sg['name']}], + image_id=image_id, clients=self.cmgr_adm) + return dict(router=router_lbaas, subnet=subnet_lbaas, + network=network_lbaas_1) + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a30') + def test_create_verify_octavia_lb_with_vip_subnet_id_rr(self): + """ + This testcase creates an octavia Loadbalancer with vip-subnet-ip + option, and verifies the traffic on the loadbalancer vip + ROUND_ROBIN algorithm + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + subnet_id = diction['subnet']['subnet']['id'] + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_subnet_id=subnet_id) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a31') + def test_create_verify_octavia_lb_with_vip_subnet_id_lc(self): + """ + This testcase creates an octavia Loadbalancer with vip-subnet-ip + option, and verifies the traffic on the loadbalancer vip, + LEAST_CONNECTIONS algorithm + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + subnet_id = diction['subnet']['subnet']['id'] + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="LEAST_CONNECTIONS", + vip_subnet_id=subnet_id) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a32') + def test_create_verify_octavia_lb_with_vip_subnet_id_si(self): + """ + This testcase creates an octavia Loadbalancer with vip-subnet-ip + option, and verifies the traffic on the loadbalancer vip, + SOURCE_IP algorithm + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + subnet_id = diction['subnet']['subnet']['id'] + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="SOURCE_IP", + vip_subnet_id=subnet_id) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a33') + def test_create_verify_octavia_lb_with_vip_subnet_id_rr_tcp(self): + """ + This testcase creates an octavia Loadbalancer with vip-subnet-ip + option, and verifies the traffic on the loadbalancer vip + ROUND_ROBIN algorithm + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + subnet_id = diction['subnet']['subnet']['id'] + self.create_project_octavia(protocol_type="TCP", protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_subnet_id=subnet_id) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a34') + def test_create_verify_octavia_lb_with_vip_subnet_id_lc_tcp(self): + """ + This testcase creates an octavia Loadbalancer with vip-subnet-ip + option, and verifies the traffic on the loadbalancer vip, + LEAST_CONNECTIONS algorithm + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + subnet_id = diction['subnet']['subnet']['id'] + self.create_project_octavia(protocol_type="TCP", protocol_port="80", + lb_algorithm="LEAST_CONNECTIONS", + vip_subnet_id=subnet_id) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a35') + def test_create_verify_octavia_lb_with_vip_subnet_id_si_tcp(self): + """ + This testcase creates an octavia Loadbalancer with vip-subnet-ip + option, and verifies the traffic on the loadbalancer vip, + SOURCE_IP algorithm + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + subnet_id = diction['subnet']['subnet']['id'] + self.create_project_octavia(protocol_type="TCP", protocol_port="80", + lb_algorithm="SOURCE_IP", + vip_subnet_id=subnet_id) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a36') + def test_create_verify_octavia_lb_with_vip_net_id_rr(self): + """ + This testcase creates an octavia Loadbalancer with vip-net-ip + option, and verifies the traffic on the loadbalancer vip + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_net_id=net_id) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a37') + def test_create_verify_octavia_lb_with_vip_net_id_lc(self): + """ + This testcase creates an octavia Loadbalancer with vip-net-ip + option, and verifies the traffic on the loadbalancer vip + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="LEAST_CONNECTIONS", + vip_net_id=net_id) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a38') + def test_create_verify_octavia_lb_with_vip_net_id_si(self): + """ + This testcase creates an octavia Loadbalancer with vip-net-ip + option, and verifies the traffic on the loadbalancer vip + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="SOURCE_IP", + vip_net_id=net_id) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a39') + def test_create_verify_octavia_lb_with_vip_net_id_rr_tcp(self): + """ + This testcase creates an octavia Loadbalancer with vip-net-ip + option, and verifies the traffic on the loadbalancer vip + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + self.create_project_octavia(protocol_type="TCP", protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_net_id=net_id) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a40') + def test_create_verify_octavia_lb_with_vip_net_id_lc_tcp(self): + """ + This testcase creates an octavia Loadbalancer with vip-net-ip + option, and verifies the traffic on the loadbalancer vip + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + self.create_project_octavia(protocol_type="TCP", protocol_port="80", + lb_algorithm="LEAST_CONNECTIONS", + vip_net_id=net_id) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a41') + def test_create_verify_octavia_lb_with_vip_net_id_si_tcp(self): + """ + This testcase creates an octavia Loadbalancer with vip-net-ip + option, and verifies the traffic on the loadbalancer vip + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + self.create_project_octavia(protocol_type="TCP", protocol_port="80", + lb_algorithm="SOURCE_IP", + vip_net_id=net_id) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-5677-4b7a-8704-3843a12b1a42') + def test_verify_octavia_http_lb_port_id_round_robin(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + source_ip algorithm, http protocol. + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-5677-4b7a-8704-3843a12b1a43') + def test_verify_octavia_http_lb_port_id_lc(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + source_ip algorithm, http protocol. + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="LEAST_CONNECTIONS", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-5677-4b7a-8704-3843a12b1a44') + def test_verify_octavia_http_lb_port_id_si(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + source_ip algorithm, http protocol. + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="SOURCE_IP", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-5677-4b7a-8704-3843a12b1a47') + def test_verify_octavia_http_lb_port_id_rr(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + source_ip algorithm, http protocol. + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="TCP", protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay) + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a48') + def test_verify_octavia_https_lb_port_id_rr_default_pool(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + with default-pool option, https traffic + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay, default_pool=True) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a49') + def test_verify_octavia_https_lb_port_id_lc_default_pool(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + with default-pool option, https traffic + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="LEAST_CONNECTIONS", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay, default_pool=True) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a50') + def test_verify_octavia_https_lb_port_id_si_default_pool(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + with default-pool option, https traffic + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="SOURCE_IP", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay, default_pool=True) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a51') + def test_verify_octavia_https_lb_port_id_rr_default_pool_tcp(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + with default-pool option, tcp traffic + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="TCP", protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay, default_pool=True) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a52') + def test_verify_octavia_https_lb_port_id_lc_default_pool_tcp(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + with default-pool option, tcp traffic + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="TCP", protocol_port="80", + lb_algorithm="LEAST_CONNECTIONS", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay, default_pool=True) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a55') + def test_verify_octavia_https_lb_port_id_lc_default_pool_qos(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + with default-pool option,least connections https traffic + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + policy = self.cmgr_adm.qos_client.create_qos_policy( + name='test-policy', description='test policy desc1', + shared=False) + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.qos_client.delete_qos_policy, + policy['policy']['id']) + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="LEAST_CONNECTIONS", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay, default_pool=True, + qos_policy_id=policy['policy']['id']) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a56') + def test_verify_octavia_https_lb_port_id_rr_default_pool_qos(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + with default-pool option,least connections https traffic + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + policy = self.cmgr_adm.qos_client.create_qos_policy( + name='test-policy', description='test policy desc1', + shared=False) + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.qos_client.delete_qos_policy, + policy['policy']['id']) + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay, default_pool=True, + qos_policy_id=policy['policy']['id']) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a57') + def test_verify_octavia_https_lb_port_id_lc_default_pool_qos_tcp(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + with default-pool option,least connections https traffic + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + policy = self.cmgr_adm.qos_client.create_qos_policy( + name='test-policy', description='test policy desc1', + shared=False) + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.qos_client.delete_qos_policy, + policy['policy']['id']) + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="TCP", protocol_port="80", + lb_algorithm="LEAST_CONNECTIONS", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay, default_pool=True, + qos_policy_id=policy['policy']['id']) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3843a11b1a58') + def test_verify_octavia_lb_port_id_rr_default_pool_https(self): + """ + This testcase is for verifying the loadbalancer with port-id and + the pool is created using lb option and attached to a listener + with default-pool option + + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTPS_PORT) + net_id = diction['network']['id'] + port_id = self.cmgr_adm.ports_client.create_port( + network_id=net_id)['port']['id'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.cmgr_adm.ports_client.delete_port, port_id) + self.create_project_octavia(protocol_type="HTTPS", protocol_port="443", + lb_algorithm="ROUND_ROBIN", + vip_port_id=port_id, hm_type='PING', + timeout=self.hm_timeout, + max_retries=self.hm_max_retries, + delay=self.hm_delay, default_pool=True) + self.check_project_lbaas() + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a61') + def test_create_verify_octavia_lb_with_vip_subnet_id(self): + """ + This testcase creates an octavia Loadbalancer with vip-subnet-ip + option, and verifies the traffic on the loadbalancer vip + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + subnet_id = diction['subnet']['subnet']['id'] + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="LEAST_CONNECTIONS", + vip_subnet_id=subnet_id) + self.check_project_lbaas() + get_lb = self.octavia_admin_client.list_octavia_load_balancers() + lb_id = get_lb['loadbalancers'][0]['id'] + stat = self.octavia_admin_client.\ + show_octavia_load_balancer_stats(lb_id) + assert (stat['stats']['bytes_in'] == 0 and + stat['stats']['bytes_out'] == 0) + self.check_lbaas_project_weight_values(constants.NO_OF_VMS_2) + stat = self.octavia_admin_client.\ + show_octavia_load_balancer_stats(lb_id) + assert (stat['stats']['bytes_in'] >= 0 and + stat['stats']['bytes_out'] >= 0) + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('60e9ecaf-b8d6-48a9-b0d2-942e5bb38f62') + def test_octavia_http_round_robin_with_session_persistence(self): + """ + To verify the server count for LB pool with SOURCE_IP + session persistence and ROUND_ROBIN lb-algorithm + expected outcome is only one server responds to the + client requests + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + subnet_id = diction['subnet']['subnet']['id'] + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_subnet_id=subnet_id, persistence=True, + persistence_type="SOURCE_IP") + self.check_lbaas_project_weight_values(constants.NO_OF_VMS_2, + hash_persistence=True) + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('60e9ecaf-b8d6-48a9-b0d2-942e5bb38f63') + def test_octavia_http_round_robin_with_net_id_session_persistence(self): + """ + To verify the server count for LB pool with SOURCE_IP + session persistence and ROUND_ROBIN lb-algorithm, + expected outcome is only one server responds to the + client requests. + """ + diction = self.deploy_octavia_topology() + self.start_web_servers(constants.HTTP_PORT) + net_id = diction['network']['id'] + self.create_project_octavia(protocol_type="HTTP", protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_net_id=net_id, persistence=True, + persistence_type="SOURCE_IP") + self.check_lbaas_project_weight_values(constants.NO_OF_VMS_2, + hash_persistence=True) + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('ca5c5468-6768-4b7a-8704-3844b11b1a64') + def test_create_REJECT_l7policies_listeneres(self): + """ + The Loadbalancer listener is created with allowed_cidrs specified + """ + diction = self.deploy_octavia_topology() + if not CONF.nsxv3.ens: + self.start_web_servers(constants.HTTP_PORT) + subnet_id = diction['subnet']['subnet']['id'] + self.create_project_octavia(protocol_type="HTTP", + protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_subnet_id=subnet_id, + l7policy=True, action='REJECT') + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('ca5c4368-6768-4b7a-8704-3844b11b1a65') + def test_create_REDIRECT_TO_URL_l7policies_listeneres(self): + """ + The Loadbalancer listener is created with redirect_url l7policy + with no url specified. + """ + diction = self.deploy_octavia_topology() + if not CONF.nsxv3.ens: + self.start_web_servers(constants.HTTP_PORT) + subnet_id = diction['subnet']['subnet']['id'] + self.create_project_octavia(protocol_type="HTTP", + protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_subnet_id=subnet_id, + l7policy=True, + action='REDIRECT_TO_URL') + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('ca5c4368-6768-4a7b-8704-3844b11b1b66') + def test_create_REDIRECT_TO_POOL_l7policies_listeneres(self): + """ + The Loadbalancer listener is created with redirect_pool l7policy + with url specified. + """ + diction = self.deploy_octavia_topology() + if not CONF.nsxv3.ens: + self.start_web_servers(constants.HTTP_PORT) + subnet_id = diction['subnet']['subnet']['id'] + lb = self.create_project_octavia(protocol_type="HTTP", + protocol_port="80", + lb_algorithm="ROUND_ROBIN", + vip_subnet_id=subnet_id) + listener = lb['listener_id'] + self.octavia_admin_l7policies_client.create_octavia_l7policies( + listener_id=listener, action='REDIRECT_TO_POOL', + redirect_pool_id=lb['pool_id']) + self.octavia_admin_client.wait_for_load_balancer_status(lb['lb_id']) + l7p = self.octavia_admin_l7policies_client.list_octavia_l7policies( + lb['listener_id']) + for i in l7p['l7policies']: + if lb['listener_id'] == i['listener_id']: + l7p_id = i['id'] + self.octavia_admin_l7policies_client.delete_octavia_l7policy( + l7p_id)