A Tempest plugin to test Neutron VMware NSX plugin.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

1301 lines
63 KiB

  1. # Copyright 2019 VMware Inc
  2. # All Rights Reserved
  3. #
  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
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  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
  14. # under the License.
  15. import time
  16. from oslo_utils import uuidutils
  17. from tempest import config
  18. from tempest.lib.common.utils import data_utils
  19. from tempest.lib.common.utils import test_utils
  20. from tempest.lib import decorators
  21. from tempest.lib import exceptions
  22. from tempest import test
  23. from vmware_nsx_tempest_plugin.common import constants
  24. from vmware_nsx_tempest_plugin.lib import feature_manager
  25. from vmware_nsx_tempest_plugin.services import nsxp_client
  26. from vmware_nsx_tempest_plugin.services import nsxv3_client
  27. LOG = constants.log.getLogger(__name__)
  28. CONF = config.CONF
  29. class OctaviaRoundRobin(feature_manager.FeatureManager):
  30. """Base class to support LBaaS ROUND-ROBIN test.
  31. It provides the methods to create loadbalancer network, and
  32. start web servers.
  33. Default lb_algorithm is ROUND_ROBIND.
  34. """
  35. @classmethod
  36. def setup_clients(cls):
  37. super(OctaviaRoundRobin, cls).setup_clients()
  38. cls.cmgr_adm = cls.get_client_manager('admin')
  39. cls.cmgr_alt = cls.get_client_manager('alt')
  40. cls.cmgr_adm = cls.get_client_manager('admin')
  41. @classmethod
  42. def skip_checks(cls):
  43. super(OctaviaRoundRobin, cls).skip_checks()
  44. cfg = CONF.network
  45. if not test.is_extension_enabled('lbaasv2', 'network'):
  46. msg = 'lbaasv2 extension is not enabled.'
  47. raise cls.skipException(msg)
  48. if not (cfg.project_networks_reachable or cfg.public_network_id):
  49. msg = ('Either project_networks_reachable must be "true", or '
  50. 'public_network_id must be defined.')
  51. raise cls.skipException(msg)
  52. @classmethod
  53. def resource_setup(cls):
  54. super(OctaviaRoundRobin, cls).resource_setup()
  55. cls.nsx = nsxv3_client.NSXV3Client(CONF.nsxv3.nsx_manager,
  56. CONF.nsxv3.nsx_user,
  57. CONF.nsxv3.nsx_password)
  58. cls.nsxp = nsxp_client.NSXPClient(CONF.nsxv3.nsx_manager,
  59. CONF.nsxv3.nsx_user,
  60. CONF.nsxv3.nsx_password)
  61. @classmethod
  62. def setup_credentials(cls):
  63. # Ask framework to not create network resources for these tests.
  64. cls.set_network_resources()
  65. super(OctaviaRoundRobin, cls).setup_credentials()
  66. def setUp(self):
  67. super(OctaviaRoundRobin, self).setUp()
  68. CONF.validation.ssh_shell_prologue = ''
  69. self.vip_ip_address = ''
  70. self.namestart = 'lbaas-ops'
  71. self.poke_counters = 12
  72. self.hm_delay = 4
  73. self.hm_max_retries = 3
  74. self.hm_timeout = 10
  75. self.server_names = []
  76. self.loadbalancer = None
  77. self.vip_fip = None
  78. self.web_service_start_delay = 2.5
  79. def tearDown(self, clean=None):
  80. if self.vip_fip:
  81. LOG.debug("tearDown lbass vip fip")
  82. self.disassociate_floatingip(self.vip_fip, and_delete=True)
  83. if self.loadbalancer:
  84. LOG.debug("tearDown lbass")
  85. lb_id = self.loadbalancer['id']
  86. self.delete_octavia_lb_resources(lb_id)
  87. cert_file = open(constants.CERT_FILE, "r")
  88. cert_content = cert_file.read()
  89. self.check_certificate_at_backend(should_present=False,
  90. cert_conent=cert_content)
  91. LOG.debug("tearDown lbaas exiting...")
  92. super(OctaviaRoundRobin, self).tearDown()
  93. def deploy_octavia_topology(self, no_of_servers=2,
  94. image_id=None, slaac=False):
  95. kwargs = {'name': "router_lbaas",
  96. 'external_gateway_info':
  97. {"network_id": CONF.network.public_network_id}}
  98. router_lbaas = self.cmgr_adm.routers_client.create_router(**kwargs)
  99. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  100. self.cmgr_adm.routers_client.delete_router,
  101. router_lbaas['router']['id'])
  102. networks_client = self.cmgr_adm.networks_client
  103. name = "network_lbaas_1"
  104. network_lbaas_1 = self.\
  105. create_topology_network(name,
  106. networks_client=networks_client)
  107. sec_rule_client = self.cmgr_adm.security_group_rules_client
  108. sec_client = self.cmgr_adm.security_groups_client
  109. kwargs = dict(tenant_id=network_lbaas_1['tenant_id'],
  110. security_group_rules_client=sec_rule_client,
  111. security_groups_client=sec_client)
  112. self.sg = self.create_topology_security_group(**kwargs)
  113. lbaas_rules = [dict(direction='ingress', protocol='tcp',
  114. port_range_min=constants.HTTP_PORT,
  115. port_range_max=constants.HTTP_PORT, ),
  116. dict(direction='ingress', protocol='tcp',
  117. port_range_min=443, port_range_max=443, )]
  118. t_id = network_lbaas_1['tenant_id']
  119. for rule in lbaas_rules:
  120. self.add_security_group_rule(self.sg, rule,
  121. secclient=sec_client,
  122. ruleclient=sec_rule_client,
  123. tenant_id=t_id)
  124. if slaac:
  125. address_cidr = CONF.network.project_network_v6_cidr
  126. address_prefixlen = CONF.network.project_network_v6_mask_bits
  127. if ((address_prefixlen >= 126)):
  128. msg = ("Subnet %s isn't large" % address_cidr)
  129. raise exceptions.InvalidConfiguration(msg)
  130. body = {'ip_version': 6, 'ipv6_ra_mode': 'slaac',
  131. 'ipv6_address_mode': 'slaac', 'cidr': '2001:db8::/64',
  132. "network_id": network_lbaas_1['id'],
  133. 'allocation_pools': [{
  134. 'start': str(address_cidr).split('/')[0] + '2',
  135. 'end': str(address_cidr).split('/')[0] + '70'}]}
  136. create_floating_ip = False
  137. else:
  138. body = {"network_id": network_lbaas_1['id'],
  139. "allocation_pools":
  140. [{"start": "2.0.0.2", "end": "2.0.0.254"}],
  141. "ip_version": 4, "cidr": "2.0.0.0/24"}
  142. create_floating_ip = True
  143. subnet_client = self.cmgr_adm.subnets_client
  144. subnet_lbaas = subnet_client.create_subnet(**body)
  145. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  146. subnet_client.delete_subnet,
  147. subnet_lbaas['subnet']['id'])
  148. self.cmgr_adm.routers_client.\
  149. add_router_interface(router_lbaas['router']['id'],
  150. subnet_id=subnet_lbaas['subnet']['id'])
  151. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  152. self.cmgr_adm.routers_client.remove_router_interface,
  153. router_lbaas['router']['id'],
  154. subnet_id=subnet_lbaas['subnet']['id'])
  155. for instance in range(0, no_of_servers):
  156. self.create_topology_instance(
  157. "server_lbaas_%s" % instance, [network_lbaas_1],
  158. security_groups=[{'name': self.sg['name']}],
  159. image_id=image_id, clients=self.cmgr_adm,
  160. create_floating_ip=create_floating_ip)
  161. return dict(router=router_lbaas, subnet=subnet_lbaas,
  162. network=network_lbaas_1)
  163. @decorators.attr(type='nsxv3')
  164. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a34')
  165. def test_create_verify_octavia_lb_with_vip_subnet_id_rr(self):
  166. """
  167. This testcase creates an octavia Loadbalancer with vip-subnet-ip
  168. option, and verifies the traffic on the loadbalancer vip
  169. """
  170. diction = self.deploy_octavia_topology()
  171. self.start_web_servers(constants.HTTP_PORT)
  172. subnet_id = diction['subnet']['subnet']['id']
  173. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  174. lb_algorithm="ROUND_ROBIN",
  175. vip_subnet_id=subnet_id)
  176. self.check_project_lbaas()
  177. @decorators.attr(type='nsxv3')
  178. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a34')
  179. def test_create_verify_octavia_lb_with_vip_net_id_rr(self):
  180. """
  181. This testcase creates an octavia Loadbalancer with vip-net-ip
  182. option, and verifies the traffic on the loadbalancer vip
  183. """
  184. diction = self.deploy_octavia_topology()
  185. self.start_web_servers(constants.HTTP_PORT)
  186. net_id = diction['network']['id']
  187. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  188. lb_algorithm="ROUND_ROBIN",
  189. vip_net_id=net_id)
  190. self.check_project_lbaas()
  191. @decorators.attr(type='nsxv3')
  192. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a34')
  193. def test_create_verify_octavia_lb_with_vip_net_id_LC(self):
  194. """
  195. This testcase creates an octavia Loadbalancer with vip-net-ip
  196. option, and verifies the traffic on the loadbalancer vip
  197. """
  198. diction = self.deploy_octavia_topology()
  199. self.start_web_servers(constants.HTTP_PORT)
  200. net_id = diction['network']['id']
  201. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  202. lb_algorithm="LEAST_CONNECTIONS",
  203. vip_net_id=net_id)
  204. self.check_project_lbaas()
  205. @decorators.attr(type='nsxv3')
  206. @decorators.idempotent_id('d6bd0657-6867-4b7a-8704-3844b11b1a34')
  207. def test_octavia_lb_vip_route_with_tenant_net(self):
  208. """
  209. This testcase creates an octavia Loadbalancer with tenant net
  210. and create floating ip for lb vip, and check advertised
  211. route at tier1 backend
  212. """
  213. diction = self.deploy_octavia_topology()
  214. self.start_web_servers(constants.HTTP_PORT)
  215. net_id = diction['network']['id']
  216. lb_dict = self.create_project_octavia(protocol_type="HTTP",
  217. protocol_port="80",
  218. lb_algorithm="LEAST_CONNECTIONS",
  219. vip_net_id=net_id)
  220. self.check_project_lbaas()
  221. vip_address = lb_dict['vip_address']
  222. vip_fip = lb_dict['vip_fip']
  223. router_state_1 = diction['router']['router']
  224. nsx_router_nat_rules = self.nsx.get_logical_router_nat_rule_ips(
  225. router_state_1['name'], router_state_1['id'])
  226. route_present = False
  227. for advertised_net in nsx_router_nat_rules['advertisedNetworks']:
  228. if len(advertised_net['networks']) > 0:
  229. if vip_address in advertised_net[
  230. 'networks'][0]['network'] and\
  231. advertised_net['networks'][
  232. 0]['advertiseRouteType'] == 'T1_LB_VIP' and\
  233. advertised_net['networks'][0]['advertiseAllow']:
  234. route_present = True
  235. self.assertEqual(True, route_present, 'Lb vip route is not advertised')
  236. kwargs = dict(port_id=None)
  237. self.cmgr_adm.floating_ips_client.\
  238. update_floatingip(vip_fip['id'],
  239. **kwargs)['floatingip']
  240. time.sleep(30)
  241. nsx_router_nat_rules = self.nsx.get_logical_router_nat_rule_ips(
  242. router_state_1['name'], router_state_1['id'])
  243. vip_address = vip_fip['fixed_ip_address']
  244. route_present = False
  245. for advertised_net in nsx_router_nat_rules['advertisedNetworks']:
  246. if len(advertised_net['networks']) > 0:
  247. if vip_address in advertised_net[
  248. 'networks'][0]['network'] and\
  249. advertised_net['networks'][
  250. 0]['advertiseRouteType'] == 'T1_LB_VIP' and\
  251. advertised_net['networks'][0]['advertiseAllow']:
  252. route_present = True
  253. self.assertEqual(False, route_present, 'Lb vip route is advertised')
  254. @decorators.attr(type='nsxv3')
  255. @decorators.idempotent_id('d6bd0657-7078-4b7a-8704-3844b11b1a34')
  256. def test_octavia_lb_vip_route_with_external_net(self):
  257. """
  258. This testcase creates an octavia Loadbalancer with external net
  259. and check lb vip route should get advertised at tier1 backend
  260. """
  261. diction = self.deploy_octavia_topology()
  262. self.start_web_servers(constants.HTTP_PORT)
  263. network = self.cmgr_adm.networks_client.show_network(
  264. CONF.network.public_network_id)['network']
  265. lb_dict = self.create_project_octavia(
  266. protocol_type="HTTP",
  267. protocol_port="80",
  268. lb_algorithm="LEAST_CONNECTIONS",
  269. external_subnet=network['subnets'][0],
  270. external=True)
  271. self.check_project_lbaas()
  272. vip_address = lb_dict['vip_address']
  273. router_state_1 = diction['router']['router']
  274. nsx_router_nat_rules = self.nsx.get_logical_router_nat_rule_ips(
  275. router_state_1['name'], router_state_1['id'])
  276. route_present = False
  277. for advertised_net in nsx_router_nat_rules['advertisedNetworks']:
  278. if len(advertised_net['networks']) > 0:
  279. if vip_address in advertised_net[
  280. 'networks'][0]['network'] and\
  281. advertised_net['networks'][
  282. 0]['advertiseRouteType'] == 'T1_LB_VIP' and\
  283. advertised_net['networks'][0]['advertiseAllow']:
  284. route_present = True
  285. self.assertEqual(True, route_present, 'Lb vip route is not advertised')
  286. @decorators.attr(type='nsxv3')
  287. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a34')
  288. def test_create_verify_octavia_lb_with_vip_subnet_id_LC(self):
  289. """
  290. This testcase creates an octavia Loadbalancer with vip-subnet-ip
  291. option, and verifies the traffic on the loadbalancer vip
  292. """
  293. diction = self.deploy_octavia_topology()
  294. self.start_web_servers(constants.HTTP_PORT)
  295. subnet_id = diction['subnet']['subnet']['id']
  296. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  297. lb_algorithm="LEAST_CONNECTIONS",
  298. vip_subnet_id=subnet_id)
  299. self.check_project_lbaas()
  300. @decorators.attr(type='nsxv3')
  301. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a34')
  302. def test_create_verify_octavia_lb_with_vip_subnet_id(self):
  303. """
  304. This testcase creates an octavia Loadbalancer with vip-subnet-ip
  305. option, and verifies the traffic on the loadbalancer vip
  306. """
  307. diction = self.deploy_octavia_topology()
  308. self.start_web_servers(constants.HTTP_PORT)
  309. subnet_id = diction['subnet']['subnet']['id']
  310. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  311. lb_algorithm="LEAST_CONNECTIONS",
  312. vip_subnet_id=subnet_id)
  313. self.check_project_lbaas()
  314. get_lb = self.octavia_admin_client.list_octavia_load_balancers()
  315. lb_id = get_lb['loadbalancers'][0]['id']
  316. stat = self.octavia_admin_client.\
  317. show_octavia_load_balancer_stats(lb_id)
  318. assert (stat['stats']['bytes_in'] == 0 and
  319. stat['stats']['bytes_out'] == 0)
  320. self.check_lbaas_project_weight_values(constants.NO_OF_VMS_2)
  321. stat = self.octavia_admin_client.\
  322. show_octavia_load_balancer_stats(lb_id)
  323. assert (stat['stats']['bytes_in'] >= 0 and
  324. stat['stats']['bytes_out'] >= 0)
  325. @decorators.attr(type='nsxv3')
  326. @decorators.idempotent_id('60e9ecaf-b8d6-48a9-b0d2-942e5bb38f38')
  327. def test_octavia_http_round_robin_with_session_persistence(self):
  328. """
  329. To verify the server count for LB pool with SOURCE_IP
  330. session persistence and ROUND_ROBIN lb-algorithm
  331. expected outcome is only one server responds to the
  332. client requests
  333. """
  334. diction = self.deploy_octavia_topology()
  335. self.start_web_servers(constants.HTTP_PORT)
  336. subnet_id = diction['subnet']['subnet']['id']
  337. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  338. lb_algorithm="ROUND_ROBIN",
  339. vip_subnet_id=subnet_id, persistence=True,
  340. persistence_type="SOURCE_IP")
  341. self.check_lbaas_project_weight_values(constants.NO_OF_VMS_2,
  342. hash_persistence=True)
  343. @decorators.attr(type='nsxv3')
  344. @decorators.idempotent_id('60e9ecaf-b8d6-48a9-b0d2-942e5bb38f38')
  345. def test_octavia_http_round_robin_with_net_id_session_persistence(self):
  346. """
  347. To verify the server count for LB pool with SOURCE_IP
  348. session persistence and ROUND_ROBIN lb-algorithm,
  349. expected outcome is only one server responds to the
  350. client requests.
  351. """
  352. diction = self.deploy_octavia_topology()
  353. self.start_web_servers(constants.HTTP_PORT)
  354. net_id = diction['network']['id']
  355. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  356. lb_algorithm="ROUND_ROBIN",
  357. vip_net_id=net_id, persistence=True,
  358. persistence_type="SOURCE_IP")
  359. self.check_lbaas_project_weight_values(constants.NO_OF_VMS_2,
  360. hash_persistence=True)
  361. @decorators.attr(type='nsxv3')
  362. @decorators.idempotent_id('c5ac8546-6768-4b7a-8704-3844b11b1a34')
  363. def test_create_verify_lb_rr_with_allowed_cidr_on_listener(self):
  364. """
  365. The Loadbalancer listener is created with allowed_cidrs specified
  366. """
  367. diction = self.deploy_octavia_topology()
  368. cidr_list = ['192.92.0.0/24', '192.94.0.0/16']
  369. if not CONF.nsxv3.ens:
  370. self.start_web_servers(constants.HTTP_PORT)
  371. subnet_id = diction['subnet']['subnet']['id']
  372. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  373. lb_algorithm="ROUND_ROBIN",
  374. vip_subnet_id=subnet_id,
  375. allowed_cidrs=cidr_list)
  376. self.check_project_lbaas()
  377. @decorators.attr(type='nsxv3')
  378. @decorators.idempotent_id('ca5c8546-6768-4b7a-8704-3844b11b1a34')
  379. def test_create_verify_lb_rr_with_allowed_cidr_0_0_0_0_on_listener(self):
  380. """
  381. The Loadbalancer listener is created with allowed_cidrs specified
  382. """
  383. diction = self.deploy_octavia_topology()
  384. cidr_list = ['0.0.0.0/0']
  385. if not CONF.nsxv3.ens:
  386. self.start_web_servers(constants.HTTP_PORT)
  387. subnet_id = diction['subnet']['subnet']['id']
  388. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  389. lb_algorithm="ROUND_ROBIN",
  390. vip_subnet_id=subnet_id,
  391. allowed_cidrs=cidr_list)
  392. self.check_project_lbaas()
  393. @decorators.attr(type='nsxv3')
  394. @decorators.idempotent_id('ca5c5468-6768-4b7a-8704-3844b11b1a34')
  395. def test_create_REJECT_l7policies_listeneres(self):
  396. """
  397. The Loadbalancer listener is created with allowed_cidrs specified
  398. """
  399. diction = self.deploy_octavia_topology()
  400. if not CONF.nsxv3.ens:
  401. self.start_web_servers(constants.HTTP_PORT)
  402. subnet_id = diction['subnet']['subnet']['id']
  403. self.create_project_octavia(protocol_type="HTTP",
  404. protocol_port="80",
  405. lb_algorithm="ROUND_ROBIN",
  406. vip_subnet_id=subnet_id,
  407. l7policy=True, action='REJECT')
  408. @decorators.attr(type='nsxv3')
  409. @decorators.idempotent_id('ca5c4368-6768-4b7a-8704-3844b11b1a34')
  410. def test_create_REDIRECT_TO_URL_l7policies_listeneres(self):
  411. """
  412. The Loadbalancer listener is created with redirect_url l7policy
  413. with no url specified.
  414. """
  415. diction = self.deploy_octavia_topology()
  416. if not CONF.nsxv3.ens:
  417. self.start_web_servers(constants.HTTP_PORT)
  418. subnet_id = diction['subnet']['subnet']['id']
  419. self.assertRaises(exceptions.BadRequest,
  420. self.create_project_octavia,
  421. protocol_type="HTTP",
  422. protocol_port="80",
  423. lb_algorithm="ROUND_ROBIN",
  424. vip_subnet_id=subnet_id,
  425. l7policy=True,
  426. action='REDIRECT_TO_URL')
  427. @decorators.attr(type='nsxv3')
  428. @decorators.idempotent_id('ca5c4368-6768-4b7a-8704-3844b11b1b34')
  429. def test_create_REDIRECT_TO_URL_url_l7policies_listeneres(self):
  430. """
  431. The Loadbalancer listener is created with redirect_url l7policy
  432. with url specified.
  433. """
  434. diction = self.deploy_octavia_topology()
  435. if not CONF.nsxv3.ens:
  436. self.start_web_servers(constants.HTTP_PORT)
  437. subnet_id = diction['subnet']['subnet']['id']
  438. self.create_project_octavia(protocol_type="HTTP",
  439. protocol_port="80",
  440. lb_algorithm="ROUND_ROBIN",
  441. vip_subnet_id=subnet_id,
  442. l7policy=True,
  443. action='REDIRECT_TO_URL',
  444. redirect_url='http://www.vmware.com')
  445. @decorators.attr(type='nsxv3')
  446. @decorators.idempotent_id('ca5c4368-6768-4a7b-8704-3844b11b1b34')
  447. def test_create_REDIRECT_TO_POOL_l7policies_listeneres(self):
  448. """
  449. The Loadbalancer listener is created with redirect_pool l7policy
  450. with url specified.
  451. """
  452. diction = self.deploy_octavia_topology()
  453. if not CONF.nsxv3.ens:
  454. self.start_web_servers(constants.HTTP_PORT)
  455. subnet_id = diction['subnet']['subnet']['id']
  456. lb = self.create_project_octavia(protocol_type="HTTP",
  457. protocol_port="80",
  458. lb_algorithm="ROUND_ROBIN",
  459. vip_subnet_id=subnet_id)
  460. listener = lb['listener_id']
  461. self.octavia_admin_l7policies_client.create_octavia_l7policies(
  462. listener_id=listener, action='REDIRECT_TO_POOL',
  463. redirect_pool_id=lb['pool_id'])
  464. self.octavia_admin_client.wait_for_load_balancer_status(lb['lb_id'])
  465. l7p = self.octavia_admin_l7policies_client.list_octavia_l7policies(
  466. lb['listener_id'])
  467. for i in l7p['l7policies']:
  468. if lb['listener_id'] == i['listener_id']:
  469. l7p_id = i['id']
  470. self.octavia_admin_l7policies_client.delete_octavia_l7policy(
  471. l7p_id)
  472. @decorators.attr(type='nsxv3')
  473. @decorators.idempotent_id('ca5c5468-6768-4a7a-8704-3844b11b1a34')
  474. def test_create_REJECT_l7policies_with_rules_REGEX_compare_type(self):
  475. """
  476. This testcase creates a l7policy to reject particular regex i.e
  477. regex rule is added to the l7policy.
  478. """
  479. diction = self.deploy_octavia_topology()
  480. if not CONF.nsxv3.ens:
  481. self.start_web_servers(constants.HTTP_PORT)
  482. subnet_id = diction['subnet']['subnet']['id']
  483. self.create_project_octavia(protocol_type="HTTP",
  484. protocol_port="80",
  485. lb_algorithm="ROUND_ROBIN",
  486. vip_subnet_id=subnet_id,
  487. l7policy=True, action='REJECT',
  488. compare_type='REGEX', type='PATH',
  489. value='.*', l7rule=True)
  490. @decorators.attr(type='nsxv3')
  491. @decorators.idempotent_id('ca5c5468-6768-4a7a-8704-3844b11b1a34')
  492. def test_create_REJECT_l7policies_with_rules_CONTAINS_compare_type(self):
  493. """
  494. This testcase creates a l7policy to reject particular regex i.e
  495. regex rule is added to the l7policy.
  496. """
  497. diction = self.deploy_octavia_topology()
  498. if not CONF.nsxv3.ens:
  499. self.start_web_servers(constants.HTTP_PORT)
  500. subnet_id = diction['subnet']['subnet']['id']
  501. self.create_project_octavia(protocol_type="HTTP",
  502. protocol_port="80",
  503. lb_algorithm="ROUND_ROBIN",
  504. vip_subnet_id=subnet_id,
  505. l7policy=True, action='REJECT',
  506. compare_type='CONTAINS', type='PATH',
  507. value='.*', l7rule=True)
  508. @decorators.attr(type='nsxv3')
  509. @decorators.idempotent_id('ca5c5468-6768-4a7a-8704-3844b11b1a34')
  510. def test_create_REJECT_l7policies_with_rules_ENDS_WITH_compare_type(self):
  511. """
  512. This testcase creates a l7policy to reject particular regex i.e
  513. regex rule is added to the l7policy.
  514. """
  515. diction = self.deploy_octavia_topology()
  516. if not CONF.nsxv3.ens:
  517. self.start_web_servers(constants.HTTP_PORT)
  518. subnet_id = diction['subnet']['subnet']['id']
  519. self.create_project_octavia(protocol_type="HTTP",
  520. protocol_port="80",
  521. lb_algorithm="ROUND_ROBIN",
  522. vip_subnet_id=subnet_id,
  523. l7policy=True, action='REJECT',
  524. compare_type='ENDS_WITH', type='PATH',
  525. value='*', l7rule=True)
  526. @decorators.attr(type='nsxv3')
  527. @decorators.idempotent_id('ca5c5468-6768-4a7a-8704-3844b11b1a34')
  528. def test_create_REJECT_l7policies_with_rules_STARTS_WITH_cmpr_type(self):
  529. """
  530. This testcase creates a l7policy to reject particular regex i.e
  531. regex rule is added to the l7policy.
  532. """
  533. diction = self.deploy_octavia_topology()
  534. if not CONF.nsxv3.ens:
  535. self.start_web_servers(constants.HTTP_PORT)
  536. subnet_id = diction['subnet']['subnet']['id']
  537. self.assertRaises(exceptions.BadRequest,
  538. self.create_project_octavia,
  539. protocol_type="HTTP",
  540. protocol_port="80",
  541. lb_algorithm="ROUND_ROBIN",
  542. vip_subnet_id=subnet_id,
  543. l7policy=True, action='REJECT',
  544. compare_type='STARTS_WITH', type='PATH',
  545. value='', l7rule=True)
  546. @decorators.attr(type='nsxv3')
  547. @decorators.idempotent_id('ca5c5468-6768-4a7a-8704-3844b11b1a34')
  548. def test_create_REJECT_l7policies_with_invert_enabled(self):
  549. """
  550. This testcase creates a l7policy to reject particular regex i.e
  551. regex rule is added to the l7policy.
  552. """
  553. diction = self.deploy_octavia_topology()
  554. if not CONF.nsxv3.ens:
  555. self.start_web_servers(constants.HTTP_PORT)
  556. subnet_id = diction['subnet']['subnet']['id']
  557. self.create_project_octavia(protocol_type="HTTP",
  558. protocol_port="80",
  559. lb_algorithm="ROUND_ROBIN",
  560. vip_subnet_id=subnet_id,
  561. l7policy=True, action='REJECT',
  562. invert=True)
  563. self.assertIn("KeyError", self.check_project_lbaas())
  564. @decorators.attr(type='nsxv3')
  565. @decorators.idempotent_id('74f022d6-a6ef-4458-96a7-541deadacf99')
  566. def test_octavia_http_traffic_with_barbican_secrets(self):
  567. """
  568. Create octavia loadbalancer with http traffic with barbican enabled.
  569. """
  570. diction = self.deploy_octavia_topology()
  571. subnet_id = diction['subnet']['subnet']['id']
  572. if not CONF.nsxv3.ens:
  573. self.start_web_servers(constants.HTTP_PORT)
  574. barbican_secrets = self.create_barbican_secret_conatainer(
  575. constants.CERT_FILE, constants.KEY_FILE)
  576. barbican_container = barbican_secrets['secret_container']
  577. self.create_project_octavia(protocol_type="HTTP",
  578. protocol_port="80",
  579. lb_algorithm="ROUND_ROBIN",
  580. vip_subnet_id=subnet_id,
  581. hm_type='HTTP',
  582. member_count=2,
  583. weight=5,
  584. pool_protocol='HTTP',
  585. pool_port='80',
  586. barbican_container=barbican_container,
  587. count=0, barbican=True,
  588. delay=self.hm_delay,
  589. max_retries=self.hm_max_retries,
  590. timeout=self.hm_timeout)
  591. self.check_lbaas_project_weight_values(barbican_http=True)
  592. @decorators.attr(type='nsxv3')
  593. @decorators.idempotent_id('74f022d6-a6ef-4458-96a7-541deadacf99')
  594. def test_octavia_https_traffic_with_barbican_secrets(self):
  595. """
  596. Create octavia loadbalancer with http traffic with barbican enabled.
  597. """
  598. diction = self.deploy_octavia_topology()
  599. subnet_id = diction['subnet']['subnet']['id']
  600. if not CONF.nsxv3.ens:
  601. self.start_web_servers(constants.HTTP_PORT)
  602. barbican_secrets = self.create_barbican_secret_conatainer(
  603. constants.CERT_FILE, constants.KEY_FILE)
  604. barbican_container = barbican_secrets['secret_container']
  605. self.create_project_octavia(protocol_type="TERMINATED_HTTPS",
  606. protocol_port="443",
  607. lb_algorithm="ROUND_ROBIN",
  608. vip_subnet_id=subnet_id,
  609. hm_type='HTTP',
  610. member_count=2,
  611. weight=5,
  612. pool_protocol='HTTP',
  613. pool_port='80',
  614. barbican_container=barbican_container,
  615. count=0, barbican=True,
  616. delay=self.hm_delay,
  617. max_retries=self.hm_max_retries,
  618. timeout=self.hm_timeout)
  619. self.check_lbaas_project_weight_values(HTTPS=True)
  620. @decorators.attr(type='nsxv3')
  621. @decorators.idempotent_id('d6bd0657-7078-5c8b-8704-3844b11b1a34')
  622. def test_octavia_multiple_listeners_with_secrets(self):
  623. """
  624. Create multiple terminated https protocol
  625. based listener with same loadbalancer
  626. """
  627. diction = self.deploy_octavia_topology()
  628. subnet_id = diction['subnet']['subnet']['id']
  629. if not CONF.nsxv3.ens:
  630. self.start_web_servers(constants.HTTP_PORT)
  631. barbican_secrets = self.create_barbican_secret_conatainer(
  632. constants.CERT_FILE, constants.KEY_FILE)
  633. barbican_container = barbican_secrets['secret_container']
  634. protocol_type = "TERMINATED_HTTPS"
  635. protocol_port = 443
  636. lb_name = data_utils.rand_name("tempest_lb")
  637. self.loadbalancer = self.\
  638. octavia_admin_client.\
  639. create_octavia_load_balancer(name=lb_name,
  640. vip_subnet_id=subnet_id
  641. )['loadbalancer']
  642. lb_id = self.loadbalancer['id']
  643. self.octavia_admin_client.wait_for_load_balancer_status(lb_id)
  644. for i in range(1, 20):
  645. tls_id = barbican_container["container_ref"]
  646. self.listener = self.octavia_admin_listener_client.\
  647. create_octavia_listener(loadbalancer_id=lb_id,
  648. protocol=protocol_type,
  649. protocol_port=protocol_port,
  650. name=lb_name,
  651. allowed_cidrs=None,
  652. default_tls_container_ref=tls_id
  653. )['listener']
  654. self.octavia_admin_client.wait_for_load_balancer_status(lb_id)
  655. protocol_port = protocol_port + 1
  656. @decorators.idempotent_id('d6bd0657-7078-5c8b-0815-3844b11b1a34')
  657. def test_octavia_create_listener_with_empty_secrets(self):
  658. """
  659. Try to create listener with terminated https
  660. protocol and empty secret , it should fail.
  661. """
  662. secret_name1 = data_utils.rand_name(name='tempest-cert-secret')
  663. kwargs = {"secret_type": constants.SECRET_TYPE,
  664. "algorithm": constants.ALGORITHM,
  665. "name": secret_name1}
  666. barbican_secret1 = self.create_barbican_secret(**kwargs)
  667. secret_name2 = data_utils.rand_name(name='tempest-key-secret')
  668. kwargs = {"secret_type": constants.SECRET_TYPE,
  669. "algorithm": constants.ALGORITHM,
  670. "name": secret_name2}
  671. barbican_secret2 = self.create_barbican_secret(**kwargs)
  672. container_name = data_utils.rand_name(name='tempest-container')
  673. kwargs = {"type": constants.CONTAINER_TYPE,
  674. "name": container_name,
  675. "secret_refs": [{"secret_ref":
  676. barbican_secret1['secret_ref'],
  677. "name": 'certificate'},
  678. {"secret_ref":
  679. barbican_secret2['secret_ref'],
  680. "name": 'private_key'}]}
  681. barbican_container = self.create_barbican_container(**kwargs)
  682. diction = self.deploy_octavia_topology()
  683. subnet_id = diction['subnet']['subnet']['id']
  684. protocol_type = "TERMINATED_HTTPS"
  685. protocol_port = 443
  686. lb_name = data_utils.rand_name("tempest_lb")
  687. self.loadbalancer = self.\
  688. octavia_admin_client.\
  689. create_octavia_load_balancer(name=lb_name,
  690. vip_subnet_id=subnet_id
  691. )['loadbalancer']
  692. lb_id = self.loadbalancer['id']
  693. self.octavia_admin_client.wait_for_load_balancer_status(lb_id)
  694. self.assertRaises(exceptions.BadRequest,
  695. self.octavia_admin_listener_client.
  696. create_octavia_listener,
  697. loadbalancer_id=lb_id,
  698. protocol=protocol_type,
  699. protocol_port=protocol_port,
  700. name=lb_name,
  701. allowed_cidrs=None,
  702. default_tls_container_ref=barbican_container[
  703. 'container_ref'])
  704. @decorators.attr(type='nsxv3')
  705. @decorators.idempotent_id('d6bd0657-7078-5c8b-0815-4055c21b1a34')
  706. def test_octavia_check_certificate_at_backend(self):
  707. """
  708. Create octavia loadbalancer with http traffic with barbican enabled.
  709. """
  710. diction = self.deploy_octavia_topology()
  711. subnet_id = diction['subnet']['subnet']['id']
  712. if not CONF.nsxv3.ens:
  713. self.start_web_servers(constants.HTTP_PORT)
  714. barbican_secrets = self.create_barbican_secret_conatainer(
  715. constants.CERT_FILE, constants.KEY_FILE)
  716. barbican_container = barbican_secrets['secret_container']
  717. self.create_project_octavia(
  718. protocol_type="TERMINATED_HTTPS",
  719. protocol_port="443",
  720. lb_algorithm="ROUND_ROBIN",
  721. vip_subnet_id=subnet_id,
  722. hm_type='HTTP',
  723. member_count=2,
  724. weight=5,
  725. pool_protocol='HTTP',
  726. pool_port='80',
  727. barbican_container=barbican_container,
  728. count=0, barbican=True, delay=self.hm_delay,
  729. max_retries=self.hm_max_retries, timeout=self.hm_timeout)
  730. self.check_lbaas_project_weight_values(HTTPS=True)
  731. cert_file = open(constants.CERT_FILE, "r")
  732. cert_content = cert_file.read()
  733. self.check_certificate_at_backend(cert_conent=cert_content.rstrip())
  734. @decorators.attr(type='nsxv3')
  735. @decorators.idempotent_id('d6bd0657-7078-5c8b-0815-4055c21c2b45')
  736. def test_octavia_create_lbaas_listener_with_invalid_container_uuid(self):
  737. """
  738. Create octavia loadbalancer with http traffic with barbican enabled.
  739. """
  740. diction = self.deploy_octavia_topology()
  741. subnet_id = diction['subnet']['subnet']['id']
  742. if not CONF.nsxv3.ens:
  743. self.start_web_servers(constants.HTTP_PORT)
  744. barbican_secrets = self.create_barbican_secret_conatainer(
  745. constants.CERT_FILE, constants.KEY_FILE)
  746. container_ref = barbican_secrets["secret_container"]['container_ref']\
  747. .split('/')
  748. container_ref.remove(container_ref[len(container_ref) - 1])
  749. container_ref.append(uuidutils.generate_uuid())
  750. container_ref = '/'.join(str(e) for e in container_ref)
  751. protocol_type = "TERMINATED_HTTPS"
  752. protocol_port = 443
  753. lb_name = data_utils.rand_name("tempest_lb")
  754. self.loadbalancer = self.\
  755. octavia_admin_client.\
  756. create_octavia_load_balancer(name=lb_name,
  757. vip_subnet_id=subnet_id
  758. )['loadbalancer']
  759. lb_id = self.loadbalancer['id']
  760. self.octavia_admin_client.wait_for_load_balancer_status(lb_id)
  761. self.assertRaises(exceptions.BadRequest,
  762. self.octavia_admin_listener_client.
  763. create_octavia_listener,
  764. loadbalancer_id=lb_id,
  765. protocol=protocol_type,
  766. protocol_port=protocol_port,
  767. name=lb_name,
  768. allowed_cidrs=None,
  769. default_tls_container_ref=container_ref)
  770. @decorators.attr(type='nsxv3')
  771. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a34')
  772. def test_create_verify_octavia_lb_with_vip_net_id_LC_hm_ping(self):
  773. """
  774. This testcase creates an octavia Loadbalancer with vip-net-ip
  775. option, and verifies the traffic on the loadbalancer vip
  776. """
  777. diction = self.deploy_octavia_topology()
  778. self.start_web_servers(constants.HTTP_PORT)
  779. net_id = diction['network']['id']
  780. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  781. lb_algorithm="LEAST_CONNECTIONS",
  782. vip_net_id=net_id, hm_type='PING',
  783. timeout=self.hm_timeout,
  784. max_retries=self.hm_max_retries,
  785. delay=self.hm_delay)
  786. self.check_project_lbaas()
  787. @decorators.attr(type='nsxv3')
  788. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a34')
  789. def test_create_verify_octavia_lb_with_vip_net_id_LC_hm_ping_https(self):
  790. """
  791. This testcase creates an octavia Loadbalancer with vip-net-ip
  792. option, and verifies the traffic on the loadbalancer vip
  793. """
  794. diction = self.deploy_octavia_topology()
  795. self.start_web_servers(constants.HTTP_PORT)
  796. net_id = diction['network']['id']
  797. self.create_project_octavia(protocol_type="HTTPS", protocol_port="80",
  798. lb_algorithm="LEAST_CONNECTIONS",
  799. vip_net_id=net_id, hm_type='PING',
  800. timeout=self.hm_timeout,
  801. max_retries=self.hm_max_retries,
  802. delay=self.hm_delay)
  803. self.check_project_lbaas()
  804. @decorators.attr(type='nsxv3')
  805. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a34')
  806. def test_create_verify_octavia_lb_with_vip_net_id_RR_hm_ping(self):
  807. """
  808. This testcase creates an octavia Loadbalancer with vip-net-ip
  809. option, and verifies the traffic on the loadbalancer vip
  810. """
  811. diction = self.deploy_octavia_topology()
  812. self.start_web_servers(constants.HTTP_PORT)
  813. net_id = diction['network']['id']
  814. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  815. lb_algorithm="ROUND_ROBIN",
  816. vip_net_id=net_id, hm_type='PING',
  817. timeout=self.hm_timeout,
  818. max_retries=self.hm_max_retries,
  819. delay=self.hm_delay)
  820. self.check_project_lbaas()
  821. @decorators.attr(type='nsxv3')
  822. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1a34')
  823. def test_create_verify_octavia_lb_with_vip_net_id_SOURCE_IP_hm_ping(self):
  824. """
  825. This testcase creates an octavia Loadbalancer with vip-net-ip
  826. option, and verifies the traffic on the loadbalancer vip
  827. """
  828. diction = self.deploy_octavia_topology()
  829. self.start_web_servers(constants.HTTP_PORT)
  830. net_id = diction['network']['id']
  831. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  832. lb_algorithm="ROUND_ROBIN",
  833. vip_net_id=net_id, hm_type='PING',
  834. timeout=self.hm_timeout,
  835. max_retries=self.hm_max_retries,
  836. delay=self.hm_delay)
  837. self.check_project_lbaas()
  838. @decorators.attr(type='nsxv3')
  839. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1b43')
  840. def test_verify_octavia_lb_vip_net_id_ROUND_ROBIN_default_pool(self):
  841. """
  842. This testcase is for verifying the loadbalancer with net-id and
  843. the pool is created using lb option and attached to a listener
  844. with default-pool option
  845. """
  846. diction = self.deploy_octavia_topology()
  847. self.start_web_servers(constants.HTTP_PORT)
  848. net_id = diction['network']['id']
  849. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  850. lb_algorithm="ROUND_ROBIN",
  851. vip_net_id=net_id, hm_type='PING',
  852. timeout=self.hm_timeout,
  853. max_retries=self.hm_max_retries,
  854. delay=self.hm_delay, default_pool=True)
  855. self.check_project_lbaas()
  856. @decorators.attr(type='nsxv3')
  857. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11a1b34')
  858. def test_verify_octavia_lb_vip_subnet_id_rr_default_pool(self):
  859. """
  860. This testcase is for verifying the loadbalancer with subnet-id and
  861. the pool is created using lb option and attached to a listener
  862. with default-pool option
  863. """
  864. diction = self.deploy_octavia_topology()
  865. self.start_web_servers(constants.HTTP_PORT)
  866. subnet_id = diction['subnet']['subnet']['id']
  867. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  868. lb_algorithm="ROUND_ROBIN",
  869. vip_subnet_id=subnet_id, hm_type='PING',
  870. timeout=self.hm_timeout,
  871. max_retries=self.hm_max_retries,
  872. delay=self.hm_delay, default_pool=True)
  873. self.check_project_lbaas()
  874. @decorators.attr(type='nsxv3')
  875. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3843a11b1a34')
  876. def test_verify_octavia_lb_port_id_rr_default_pool(self):
  877. """
  878. This testcase is for verifying the loadbalancer with port-id and
  879. the pool is created using lb option and attached to a listener
  880. with default-pool option
  881. """
  882. diction = self.deploy_octavia_topology()
  883. self.start_web_servers(constants.HTTP_PORT)
  884. net_id = diction['network']['id']
  885. port_id = self.cmgr_adm.ports_client.create_port(
  886. network_id=net_id)['port']['id']
  887. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  888. self.cmgr_adm.ports_client.delete_port, port_id)
  889. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  890. lb_algorithm="ROUND_ROBIN",
  891. vip_port_id=port_id, hm_type='PING',
  892. timeout=self.hm_timeout,
  893. max_retries=self.hm_max_retries,
  894. delay=self.hm_delay, default_pool=True)
  895. self.check_project_lbaas()
  896. @decorators.attr(type='nsxv3')
  897. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3843a11a2b34')
  898. def test_verify_octavia_lb_port_id_lc_default_pool(self):
  899. """
  900. This testcase is for verifying the loadbalancer with port-id and
  901. the pool is created using lb option and attached to a listener
  902. with default-pool option, lease connection algorithm
  903. """
  904. diction = self.deploy_octavia_topology()
  905. self.start_web_servers(constants.HTTP_PORT)
  906. net_id = diction['network']['id']
  907. port_id = self.cmgr_adm.ports_client.create_port(
  908. network_id=net_id)['port']['id']
  909. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  910. self.cmgr_adm.ports_client.delete_port, port_id)
  911. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  912. lb_algorithm="LEAST_CONNECTIONS",
  913. vip_port_id=port_id, hm_type='PING',
  914. timeout=self.hm_timeout,
  915. max_retries=self.hm_max_retries,
  916. delay=self.hm_delay, default_pool=True)
  917. self.check_project_lbaas()
  918. @decorators.attr(type='nsxv3')
  919. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3843a12b1a34')
  920. def test_verify_octavia_lb_port_id_source_ip_default_pool(self):
  921. """
  922. This testcase is for verifying the loadbalancer with port-id and
  923. the pool is created using lb option and attached to a listener
  924. with default-pool option, source_ip algorithm.
  925. """
  926. diction = self.deploy_octavia_topology()
  927. self.start_web_servers(constants.HTTP_PORT)
  928. net_id = diction['network']['id']
  929. port_id = self.cmgr_adm.ports_client.create_port(
  930. network_id=net_id)['port']['id']
  931. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  932. self.cmgr_adm.ports_client.delete_port, port_id)
  933. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  934. lb_algorithm="SOURCE_IP",
  935. vip_port_id=port_id, hm_type='PING',
  936. timeout=self.hm_timeout,
  937. max_retries=self.hm_max_retries,
  938. delay=self.hm_delay, default_pool=True)
  939. self.check_project_lbaas()
  940. @decorators.attr(type='nsxv3')
  941. @decorators.idempotent_id('c5ac8546-5677-4b7a-8704-3843a12b1a34')
  942. def test_verify_octavia_https_lb_port_id_source_ip_default_pool(self):
  943. """
  944. This testcase is for verifying the loadbalancer with port-id and
  945. the pool is created using lb option and attached to a listener
  946. with default-pool option, source_ip algorithm, https protocol.
  947. """
  948. diction = self.deploy_octavia_topology()
  949. self.start_web_servers(constants.HTTP_PORT)
  950. net_id = diction['network']['id']
  951. port_id = self.cmgr_adm.ports_client.create_port(
  952. network_id=net_id)['port']['id']
  953. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  954. self.cmgr_adm.ports_client.delete_port, port_id)
  955. self.create_project_octavia(protocol_type="HTTPS", protocol_port="80",
  956. lb_algorithm="SOURCE_IP",
  957. vip_port_id=port_id, hm_type='PING',
  958. timeout=self.hm_timeout,
  959. max_retries=self.hm_max_retries,
  960. delay=self.hm_delay, default_pool=True)
  961. self.check_project_lbaas()
  962. @decorators.attr(type='nsxv3')
  963. @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a34')
  964. def test_verify_octavia_https_lb_port_id_rr_default_pool(self):
  965. """
  966. This testcase is for verifying the loadbalancer with port-id and
  967. the pool is created using lb option and attached to a listener
  968. with default-pool option, https traffic
  969. """
  970. diction = self.deploy_octavia_topology()
  971. self.start_web_servers(constants.HTTP_PORT)
  972. net_id = diction['network']['id']
  973. port_id = self.cmgr_adm.ports_client.create_port(
  974. network_id=net_id)['port']['id']
  975. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  976. self.cmgr_adm.ports_client.delete_port, port_id)
  977. self.create_project_octavia(protocol_type="HTTPS", protocol_port="80",
  978. lb_algorithm="ROUND_ROBIN",
  979. vip_port_id=port_id, hm_type='PING',
  980. timeout=self.hm_timeout,
  981. max_retries=self.hm_max_retries,
  982. delay=self.hm_delay, default_pool=True)
  983. self.check_project_lbaas()
  984. @decorators.attr(type='nsxv3')
  985. @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a34')
  986. def test_verify_octavia_https_lb_port_id_lc_default_pool(self):
  987. """
  988. This testcase is for verifying the loadbalancer with port-id and
  989. the pool is created using lb option and attached to a listener
  990. with default-pool option,least connections https traffic
  991. """
  992. diction = self.deploy_octavia_topology()
  993. self.start_web_servers(constants.HTTP_PORT)
  994. net_id = diction['network']['id']
  995. port_id = self.cmgr_adm.ports_client.create_port(
  996. network_id=net_id)['port']['id']
  997. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  998. self.cmgr_adm.ports_client.delete_port, port_id)
  999. self.create_project_octavia(protocol_type="HTTPS", protocol_port="80",
  1000. lb_algorithm="LEAST_CONNECTIONS",
  1001. vip_port_id=port_id, hm_type='PING',
  1002. timeout=self.hm_timeout,
  1003. max_retries=self.hm_max_retries,
  1004. delay=self.hm_delay, default_pool=True)
  1005. self.check_project_lbaas()
  1006. @decorators.attr(type='nsxv3')
  1007. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b21b1a34')
  1008. def test_create_verify_octavia_lb_with_vip_net_id_qos_lc_hm_ping(self):
  1009. """
  1010. This testcase creates an octavia Loadbalancer with vip-net-ip
  1011. option, and verifies the traffic on the loadbalancer vip
  1012. """
  1013. diction = self.deploy_octavia_topology()
  1014. self.start_web_servers(constants.HTTP_PORT)
  1015. net_id = diction['network']['id']
  1016. policy = self.cmgr_adm.qos_client.create_qos_policy(
  1017. name='test-policy', description='test policy desc1',
  1018. shared=False)
  1019. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  1020. self.cmgr_adm.qos_client.delete_qos_policy,
  1021. policy['policy']['id'])
  1022. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  1023. lb_algorithm="LEAST_CONNECTIONS",
  1024. vip_net_id=net_id, hm_type='PING',
  1025. timeout=self.hm_timeout,
  1026. max_retries=self.hm_max_retries,
  1027. delay=self.hm_delay,
  1028. qos_policy_id=policy['policy']['id'])
  1029. self.check_project_lbaas()
  1030. @decorators.attr(type='nsxv3')
  1031. @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a34')
  1032. def test_verify_octavia_https_lb_port_id_lc_default_pool_qos(self):
  1033. """
  1034. This testcase is for verifying the loadbalancer with port-id and
  1035. the pool is created using lb option and attached to a listener
  1036. with default-pool option,least connections https traffic
  1037. """
  1038. diction = self.deploy_octavia_topology()
  1039. self.start_web_servers(constants.HTTP_PORT)
  1040. net_id = diction['network']['id']
  1041. policy = self.cmgr_adm.qos_client.create_qos_policy(
  1042. name='test-policy', description='test policy desc1',
  1043. shared=False)
  1044. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  1045. self.cmgr_adm.qos_client.delete_qos_policy,
  1046. policy['policy']['id'])
  1047. port_id = self.cmgr_adm.ports_client.create_port(
  1048. network_id=net_id)['port']['id']
  1049. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  1050. self.cmgr_adm.ports_client.delete_port, port_id)
  1051. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  1052. lb_algorithm="LEAST_CONNECTIONS",
  1053. vip_port_id=port_id, hm_type='PING',
  1054. timeout=self.hm_timeout,
  1055. max_retries=self.hm_max_retries,
  1056. delay=self.hm_delay, default_pool=True,
  1057. qos_policy_id=policy['policy']['id'])
  1058. self.check_project_lbaas()
  1059. @decorators.attr(type='nsxv3')
  1060. @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a23')
  1061. def test_verify_octavia_https_lb_port_id_rr_default_pool_qos(self):
  1062. """
  1063. This testcase is for verifying the loadbalancer with port-id and
  1064. the pool is created using lb option and attached to a listener
  1065. with default-pool option,round_robin https traffic
  1066. """
  1067. diction = self.deploy_octavia_topology()
  1068. self.start_web_servers(constants.HTTP_PORT)
  1069. net_id = diction['network']['id']
  1070. policy = self.cmgr_adm.qos_client.create_qos_policy(
  1071. name='test-policy', description='test policy desc1',
  1072. shared=False)
  1073. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  1074. self.cmgr_adm.qos_client.delete_qos_policy,
  1075. policy['policy']['id'])
  1076. port_id = self.cmgr_adm.ports_client.create_port(
  1077. network_id=net_id)['port']['id']
  1078. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  1079. self.cmgr_adm.ports_client.delete_port, port_id)
  1080. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  1081. lb_algorithm="ROUND_ROBIN",
  1082. vip_port_id=port_id, hm_type='PING',
  1083. timeout=self.hm_timeout,
  1084. max_retries=self.hm_max_retries,
  1085. delay=self.hm_delay, default_pool=True,
  1086. qos_policy_id=policy['policy']['id'])
  1087. self.check_project_lbaas()
  1088. @decorators.attr(type='nsxv3')
  1089. @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a24')
  1090. def test_verify_octavia_https_lb_port_id_source_ip_default_pool_qos(self):
  1091. """
  1092. This testcase is for verifying the loadbalancer with port-id and
  1093. the pool is created using lb option and attached to a listener
  1094. with default-pool option,SOURCE_IP https traffic
  1095. """
  1096. diction = self.deploy_octavia_topology()
  1097. self.start_web_servers(constants.HTTP_PORT)
  1098. net_id = diction['network']['id']
  1099. policy = self.cmgr_adm.qos_client.create_qos_policy(
  1100. name='test-policy', description='test policy desc1',
  1101. shared=False)
  1102. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  1103. self.cmgr_adm.qos_client.delete_qos_policy,
  1104. policy['policy']['id'])
  1105. port_id = self.cmgr_adm.ports_client.create_port(
  1106. network_id=net_id)['port']['id']
  1107. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  1108. self.cmgr_adm.ports_client.delete_port, port_id)
  1109. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  1110. lb_algorithm="SOURCE_IP",
  1111. vip_port_id=port_id, hm_type='PING',
  1112. timeout=self.hm_timeout,
  1113. max_retries=self.hm_max_retries,
  1114. delay=self.hm_delay, default_pool=True,
  1115. qos_policy_id=policy['policy']['id'])
  1116. self.check_project_lbaas()
  1117. @decorators.attr(type='nsxv3')
  1118. @decorators.idempotent_id('c5ac8546-5677-4b7a-8704-3843a12b1a98')
  1119. def test_verify_octavia_https_lb_port_id_source_ipv6_default_pool(self):
  1120. """
  1121. This testcase is for verifying the loadbalancer with port-id and
  1122. the pool is created using lb option and attached to a listener
  1123. with default-pool option, source_ip algorithm, https protocol.
  1124. """
  1125. diction = self.deploy_octavia_topology(slaac=True)
  1126. net_id = diction['network']['id']
  1127. port_id = self.cmgr_adm.ports_client.create_port(
  1128. network_id=net_id)['port']['id']
  1129. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  1130. self.cmgr_adm.ports_client.delete_port, port_id)
  1131. self.create_project_octavia(protocol_type="HTTPS", protocol_port="80",
  1132. lb_algorithm="SOURCE_IP",
  1133. vip_port_id=port_id, hm_type='PING',
  1134. timeout=self.hm_timeout,
  1135. max_retries=self.hm_max_retries,
  1136. delay=self.hm_delay, default_pool=True,
  1137. create_fip=False)
  1138. @decorators.attr(type='nsxv3')
  1139. @decorators.idempotent_id('c5ac8546-6867-4b7a-8704-3844b11b1b43')
  1140. def test_ipv6__verify_octavia_lb_vip_net_id_ROUND_ROBIN_default_pool(self):
  1141. """
  1142. This testcase is for verifying the loadbalancer with net-id and
  1143. the pool is created using lb option and attached to a listener
  1144. with default-pool option
  1145. """
  1146. diction = self.deploy_octavia_topology()
  1147. self.start_web_servers(constants.HTTP_PORT)
  1148. net_id = diction['network']['id']
  1149. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  1150. lb_algorithm="ROUND_ROBIN",
  1151. vip_net_id=net_id, hm_type='PING',
  1152. timeout=self.hm_timeout,
  1153. max_retries=self.hm_max_retries,
  1154. delay=self.hm_delay, default_pool=True,
  1155. fip_disassociate=True)
  1156. @decorators.attr(type='nsxv3')
  1157. @decorators.idempotent_id('c5ac8546-6867-4b7a-8544-3843a11b1a24')
  1158. def test_ipv6_verify_octavia_https_lb_port_id_source_ip_default_pool_qos(
  1159. self):
  1160. """
  1161. This testcase is for verifying the loadbalancer with port-id and
  1162. the pool is created using lb option and attached to a listener
  1163. with default-pool option,SOURCE_IP https traffic
  1164. """
  1165. diction = self.deploy_octavia_topology()
  1166. self.start_web_servers(constants.HTTP_PORT)
  1167. net_id = diction['network']['id']
  1168. policy = self.cmgr_adm.qos_client.create_qos_policy(
  1169. name='test-policy', description='test policy desc1',
  1170. shared=False)
  1171. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  1172. self.cmgr_adm.qos_client.delete_qos_policy,
  1173. policy['policy']['id'])
  1174. port_id = self.cmgr_adm.ports_client.create_port(
  1175. network_id=net_id)['port']['id']
  1176. self.addCleanup(test_utils.call_and_ignore_notfound_exc,
  1177. self.cmgr_adm.ports_client.delete_port, port_id)
  1178. self.create_project_octavia(protocol_type="HTTP", protocol_port="80",
  1179. lb_algorithm="SOURCE_IP",
  1180. vip_port_id=port_id, hm_type='PING',
  1181. timeout=self.hm_timeout,
  1182. max_retries=self.hm_max_retries,
  1183. delay=self.hm_delay, default_pool=True,
  1184. qos_policy_id=policy['policy']['id'],
  1185. fip_disassociate=True)
  1186. @decorators.attr(type='nsxv3')
  1187. @decorators.idempotent_id('ca5c5468-6768-4b7a-8704-3844b11b1a34')
  1188. def test_ipv6_create_REJECT_l7policies_listeneres(self):
  1189. """
  1190. The Loadbalancer listener is created with allowed_cidrs specified
  1191. """
  1192. diction = self.deploy_octavia_topology()
  1193. if not CONF.nsxv3.ens:
  1194. self.start_web_servers(constants.HTTP_PORT)
  1195. subnet_id = diction['subnet']['subnet']['id']
  1196. self.create_project_octavia(protocol_type="HTTP",
  1197. protocol_port="80",
  1198. lb_algorithm="ROUND_ROBIN",
  1199. vip_subnet_id=subnet_id,
  1200. l7policy=True, action='REJECT',
  1201. fip_disassociate=True)
  1202. @decorators.attr(type='nsxv3')
  1203. @decorators.idempotent_id('ca5c4368-6768-4b7a-8704-3844b11b1a34')
  1204. def test_ipv6_create_REDIRECT_TO_URL_l7policies_listeneres(self):
  1205. """
  1206. The Loadbalancer listener is created with redirect_url l7policy
  1207. with no url specified.
  1208. """
  1209. diction = self.deploy_octavia_topology()
  1210. if not CONF.nsxv3.ens:
  1211. self.start_web_servers(constants.HTTP_PORT)
  1212. subnet_id = diction['subnet']['subnet']['id']
  1213. self.assertRaises(exceptions.BadRequest,
  1214. self.create_project_octavia,
  1215. protocol_type="HTTP",
  1216. protocol_port="80",
  1217. lb_algorithm="ROUND_ROBIN",
  1218. vip_subnet_id=subnet_id,
  1219. l7policy=True,
  1220. action='REDIRECT_TO_URL',
  1221. fip_disassociate=True)