How to use _check_network_external_connectivity method in tempest

Best Python code snippet using tempest_python

test_dvr_basic_ops.py

Source:test_dvr_basic_ops.py Github

copy

Full Screen

...244 not p['device_owner'].endswith('dhcp')))245 self._check_server_connectivity(floating_ip,246 internal_ips,247 should_connect)248 def _check_network_external_connectivity(self):249 """250 ping public network default gateway to imply external connectivity251 """252 if not CONF.network.public_network_id:253 msg = 'public network not defined.'254 LOG.debug(msg)255 return256 # We ping the external IP from the instance using its floating IP257 # which is always IPv4, so we must only test connectivity to258 # external IPv4 IPs if the external network is dualstack.259 v4_subnets = [s for s in self._list_subnets(260 network_id=CONF.network.public_network_id) if s['ip_version'] == 4]261 self.assertEqual(1, len(v4_subnets),262 "Found %d IPv4 subnets" % len(v4_subnets))263 external_ips = [v4_subnets[0]['gateway_ip']]264 self._check_server_connectivity(self.floating_ip_tuple.floating_ip,265 external_ips)266 def _check_server_connectivity(self, floating_ip, address_list,267 should_connect=True):268 ip_address = floating_ip['floating_ip_address']269 private_key = self._get_server_key(self.floating_ip_tuple.server)270 # ssh_source = self._ssh_to_server(ip_address, private_key)271 ssh_source = self.get_remote_client(ip_address,272 private_key=private_key)273 for remote_ip in address_list:274 if should_connect:275 msg = "Timed out waiting for "276 "%s to become reachable" % remote_ip277 else:278 msg = "ip address %s is reachable" % remote_ip279 try:280 self.assertTrue(self._check_remote_connectivity281 (ssh_source, remote_ip, should_connect),282 msg)283 except Exception:284 LOG.debug("Unable to access {dest} via ssh to "285 "floating-ip {src}".format(dest=remote_ip,286 src=floating_ip))287 raise288 @decorators.idempotent_id('62eb50a8-45f3-4eec-acc4-f01cee10a011')289 @test.services('compute', 'network')290 def test_dvr_network_basic_ops(self):291 """292 For a freshly-booted VM with an IP address ("port") on a given293 network:294 - the Tempest host can ping the IP address. This implies, but295 does not guarantee (see the ssh check that follows), that the296 VM has been assigned the correct IP address and has297 connectivity to the Tempest host.298 - the Tempest host can perform key-based authentication to an299 ssh server hosted at the IP address. This check guarantees300 that the IP address is associated with the target VM.301 - the Tempest host can ssh into the VM via the IP address and302 successfully execute the following:303 - ping an external IP address, implying external connectivity.304 - ping an external hostname, implying that dns is correctly305 configured.306 - ping an internal IP address, implying connectivity to another307 VM on the same network.308 - detach the floating-ip from the VM and verify that it becomes309 unreachable310 - associate detached floating ip to a new VM and verify connectivity.311 VMs are created with unique keypair so connectivity also asserts that312 floating IP is associated with the new VM instead of the old one313 Verifies that floating IP status is updated correctly after each change314 """315 self._setup_network_and_servers(distributed=True)316 LOG.debug("Sleeping %ss after associate floating ip %s" %317 (FIP_OPS_TIMEOUT, self.floating_ip_tuple))318 self.check_public_network_connectivity(should_connect=True)319 self._check_network_internal_connectivity(network=self.network)320 self._check_network_external_connectivity()321 self._disassociate_floating_ips()322 LOG.debug("Sleeping %ss after disassociate floating ip %s" %323 (FIP_OPS_TIMEOUT, self.floating_ip_tuple))324 self.check_public_network_connectivity(should_connect=False,325 msg="after disassociate "326 "floating ip")327 self._reassociate_floating_ips()328 LOG.debug("Sleeping %ss after reassociate floating ip %s" %329 (FIP_OPS_TIMEOUT, self.floating_ip_tuple))330 self.check_public_network_connectivity(should_connect=True,331 msg="after re-associate "332 "floating ip")333 @decorators.idempotent_id('d99b62ec-28ce-44db-a195-edb74037a354')334 @test.services('compute', 'network')335 def test_dvr_connectivity_between_vms_on_different_networks(self):336 """337 For a freshly-booted VM with an IP address ("port") on a given338 network:339 - the Tempest host can ping the IP address.340 - the Tempest host can ssh into the VM via the IP address and341 successfully execute the following:342 - ping an external IP address, implying external connectivity.343 - ping an external hostname, implying that dns is correctly344 configured.345 - ping an internal IP address, implying connectivity to another346 VM on the same network.347 - Create another network on the same tenant with subnet, create348 an VM on the new network.349 - Ping the new VM from previous VM failed since the new network350 was not attached to router yet.351 - Attach the new network to the router, Ping the new VM from352 previous VM succeed.353 """354 self._setup_network_and_servers(distributed=True)355 LOG.debug("Sleeping %ss after associate floating ip %s" %356 (FIP_OPS_TIMEOUT, self.floating_ip_tuple))357 time.sleep(FIP_OPS_TIMEOUT)358 self.check_public_network_connectivity(should_connect=True)359 self._check_network_internal_connectivity(network=self.network)360 self._check_network_external_connectivity()361 self._create_new_network(create_gateway=True)362 name = data_utils.rand_name('server-smoke')363 self._create_server(name, self.new_net)364 self._check_network_internal_connectivity(network=self.new_net,365 should_connect=False)366 HELO.router_interface_add(self, self.router['id'],367 self.new_subnet['id'])368 self._check_network_internal_connectivity(network=self.new_net,369 should_connect=True)370 @decorators.idempotent_id('a73fd605-d55e-4151-b25e-41e7a7ff2258')371 @test.services('compute', 'network')372 def test_dvr_update_router_admin_state(self):373 """374 1. Check public connectivity before updating...

Full Screen

Full Screen

test_network_basic_ops.py

Source:test_network_basic_ops.py Github

copy

Full Screen

...238 self._list_ports(tenant_id=server['tenant_id'],239 network_id=network.id)240 if p['device_owner'].startswith('network'))241 self._check_server_connectivity(floating_ip, internal_ips)242 def _check_network_external_connectivity(self):243 """244 ping public network default gateway to imply external connectivity245 """246 if not CONF.network.public_network_id:247 msg = 'public network not defined.'248 LOG.info(msg)249 return250 subnet = self._list_subnets(251 network_id=CONF.network.public_network_id)252 self.assertEqual(1, len(subnet), "Found %d subnets" % len(subnet))253 external_ips = [subnet[0]['gateway_ip']]254 self._check_server_connectivity(self.floating_ip_tuple.floating_ip,255 external_ips)256 def _check_server_connectivity(self, floating_ip, address_list):257 ip_address = floating_ip.floating_ip_address258 private_key = self._get_server_key(self.floating_ip_tuple.server)259 ssh_source = self._ssh_to_server(ip_address, private_key)260 for remote_ip in address_list:261 try:262 self.assertTrue(self._check_remote_connectivity(ssh_source,263 remote_ip),264 "Timed out waiting for %s to become "265 "reachable" % remote_ip)266 except Exception:267 LOG.exception("Unable to access {dest} via ssh to "268 "floating-ip {src}".format(dest=remote_ip,269 src=floating_ip))270 debug.log_ip_ns()271 raise272 @test.attr(type='smoke')273 @test.services('compute', 'network')274 def test_network_basic_ops(self):275 """276 For a freshly-booted VM with an IP address ("port") on a given277 network:278 - the Tempest host can ping the IP address. This implies, but279 does not guarantee (see the ssh check that follows), that the280 VM has been assigned the correct IP address and has281 connectivity to the Tempest host.282 - the Tempest host can perform key-based authentication to an283 ssh server hosted at the IP address. This check guarantees284 that the IP address is associated with the target VM.285 - the Tempest host can ssh into the VM via the IP address and286 successfully execute the following:287 - ping an external IP address, implying external connectivity.288 - ping an external hostname, implying that dns is correctly289 configured.290 - ping an internal IP address, implying connectivity to another291 VM on the same network.292 - detach the floating-ip from the VM and verify that it becomes293 unreachable294 - associate detached floating ip to a new VM and verify connectivity.295 VMs are created with unique keypair so connectivity also asserts that296 floating IP is associated with the new VM instead of the old one297 """298 self._setup_network_and_servers()299 self._check_public_network_connectivity(should_connect=True)300 self._check_network_internal_connectivity(network=self.network)301 self._check_network_external_connectivity()302 self._disassociate_floating_ips()303 self._check_public_network_connectivity(should_connect=False,304 msg="after disassociate "305 "floating ip")306 self._reassociate_floating_ips()307 self._check_public_network_connectivity(should_connect=True,308 msg="after re-associate "309 "floating ip")310 @testtools.skipUnless(CONF.compute_feature_enabled.interface_attach,311 'NIC hotplug not available')312 @test.attr(type='smoke')313 @test.services('compute', 'network')314 def test_hotplug_nic(self):315 """...

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