How to use _verify_gateway_port method in tempest

Best Python code snippet using tempest_python

test_routers.py

Source:test_routers.py Github

copy

Full Screen

...97 return98 # Verify only keys passed in exp_ext_gw_info99 for k, v in exp_ext_gw_info.items():100 self.assertEqual(v, actual_ext_gw_info[k])101 def _verify_gateway_port(self, router_id):102 list_body = self.admin_ports_client.list_ports(103 network_id=CONF.network.public_network_id,104 device_id=router_id,105 device_owner="network:router_gateway")106 self.assertEqual(len(list_body['ports']), 1)107 gw_port = list_body['ports'][0]108 fixed_ips = gw_port['fixed_ips']109 self.assertNotEmpty(fixed_ips)110 # Assert that all of the IPs from the router gateway port111 # are allocated from a valid public subnet.112 public_net_body = self.admin_networks_client.show_network(113 CONF.network.public_network_id)114 public_subnet_ids = public_net_body['network']['subnets']115 for fixed_ip in fixed_ips:116 subnet_id = fixed_ip['subnet_id']117 self.assertIn(subnet_id, public_subnet_ids)118 @decorators.idempotent_id('6cc285d8-46bf-4f36-9b1a-783e3008ba79')119 @testtools.skipUnless(CONF.network.public_network_id,120 'The public_network_id option must be specified.')121 def test_update_router_set_gateway(self):122 router = self._create_router()123 self.routers_client.update_router(124 router['id'],125 external_gateway_info={126 'network_id': CONF.network.public_network_id})127 # Verify operation - router128 self._verify_router_gateway(129 router['id'],130 {'network_id': CONF.network.public_network_id})131 self._verify_gateway_port(router['id'])132 @decorators.idempotent_id('b386c111-3b21-466d-880c-5e72b01e1a33')133 @utils.requires_ext(extension='ext-gw-mode', service='network')134 @testtools.skipUnless(CONF.network.public_network_id,135 'The public_network_id option must be specified.')136 def test_update_router_set_gateway_with_snat_explicit(self):137 router = self._create_router()138 self.admin_routers_client.update_router(139 router['id'],140 external_gateway_info={141 'network_id': CONF.network.public_network_id,142 'enable_snat': True})143 self._verify_router_gateway(144 router['id'],145 {'network_id': CONF.network.public_network_id,146 'enable_snat': True})147 self._verify_gateway_port(router['id'])148 @decorators.idempotent_id('96536bc7-8262-4fb2-9967-5c46940fa279')149 @utils.requires_ext(extension='ext-gw-mode', service='network')150 @testtools.skipUnless(CONF.network.public_network_id,151 'The public_network_id option must be specified.')152 def test_update_router_set_gateway_without_snat(self):153 router = self._create_router()154 self.admin_routers_client.update_router(155 router['id'],156 external_gateway_info={157 'network_id': CONF.network.public_network_id,158 'enable_snat': False})159 self._verify_router_gateway(160 router['id'],161 {'network_id': CONF.network.public_network_id,162 'enable_snat': False})163 self._verify_gateway_port(router['id'])164 @decorators.idempotent_id('ad81b7ee-4f81-407b-a19c-17e623f763e8')165 @testtools.skipUnless(CONF.network.public_network_id,166 'The public_network_id option must be specified.')167 def test_update_router_unset_gateway(self):168 router = self._create_router(169 external_network_id=CONF.network.public_network_id)170 self.routers_client.update_router(router['id'],171 external_gateway_info={})172 self._verify_router_gateway(router['id'])173 # No gateway port expected174 list_body = self.admin_ports_client.list_ports(175 network_id=CONF.network.public_network_id,176 device_id=router['id'])177 self.assertFalse(list_body['ports'])178 @decorators.idempotent_id('f2faf994-97f4-410b-a831-9bc977b64374')179 @utils.requires_ext(extension='ext-gw-mode', service='network')180 @testtools.skipUnless(CONF.network.public_network_id,181 'The public_network_id option must be specified.')182 def test_update_router_reset_gateway_without_snat(self):183 router = self._create_router(184 external_network_id=CONF.network.public_network_id)185 self.admin_routers_client.update_router(186 router['id'],187 external_gateway_info={188 'network_id': CONF.network.public_network_id,189 'enable_snat': False})190 self._verify_router_gateway(191 router['id'],192 {'network_id': CONF.network.public_network_id,193 'enable_snat': False})194 self._verify_gateway_port(router['id'])195class RoutersIpV6AdminTest(RoutersAdminTest):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful