How to use _log_console_output_for_all_tenants method in tempest

Best Python code snippet using tempest_python

test_security_groups_basic_ops.py

Source:test_security_groups_basic_ops.py Github

copy

Full Screen

...400 ]401 server_ip = self._get_server_ip(tenant.access_point)402 subnet_id = tenant.subnet['id']403 self.assertIn((subnet_id, server_ip, mac_addr), port_detail_list)404 def _log_console_output_for_all_tenants(self):405 for tenant in self.tenants.values():406 client = tenant.manager.servers_client407 self._log_console_output(servers=tenant.servers, client=client)408 if tenant.access_point is not None:409 self._log_console_output(410 servers=[tenant.access_point], client=client)411 @decorators.idempotent_id('e79f879e-debb-440c-a7e4-efeda05b6848')412 @test.services('compute', 'network')413 def test_cross_tenant_traffic(self):414 if not self.credentials_provider.is_multi_tenant():415 raise self.skipException("No secondary tenant defined")416 try:417 # deploy new project418 self._deploy_tenant(self.alt_tenant)419 self._verify_network_details(self.alt_tenant)420 self._verify_mac_addr(self.alt_tenant)421 # cross tenant check422 source_tenant = self.primary_tenant423 dest_tenant = self.alt_tenant424 self._test_cross_tenant_block(source_tenant, dest_tenant)425 self._test_cross_tenant_allow(source_tenant, dest_tenant)426 except Exception:427 self._log_console_output_for_all_tenants()428 raise429 @decorators.idempotent_id('63163892-bbf6-4249-aa12-d5ea1f8f421b')430 @test.services('compute', 'network')431 def test_in_tenant_traffic(self):432 try:433 self._create_tenant_servers(self.primary_tenant, num=1)434 # in-tenant check435 self._test_in_tenant_block(self.primary_tenant)436 self._test_in_tenant_allow(self.primary_tenant)437 except Exception:438 self._log_console_output_for_all_tenants()439 raise440 @decorators.idempotent_id('f4d556d7-1526-42ad-bafb-6bebf48568f6')441 @decorators.attr(type='slow')442 @test.services('compute', 'network')443 def test_port_update_new_security_group(self):444 """Verifies the traffic after updating the vm port445 With new security group having appropriate rule.446 """447 new_tenant = self.primary_tenant448 # Create empty security group and add icmp rule in it449 new_sg = self._create_empty_security_group(450 namestart='secgroup_new-',451 tenant_id=new_tenant.creds.tenant_id,452 client=new_tenant.manager.security_groups_client)453 icmp_rule = dict(454 protocol='icmp',455 direction='ingress',456 )457 sec_group_rules_client = new_tenant.manager.security_group_rules_client458 self._create_security_group_rule(459 secgroup=new_sg,460 sec_group_rules_client=sec_group_rules_client,461 **icmp_rule)462 new_tenant.security_groups.update(new_sg=new_sg)463 # Create server with default security group464 name = 'server-{tenant}-gen-1'.format(465 tenant=new_tenant.creds.tenant_name466 )467 name = data_utils.rand_name(name)468 server = self._create_server(name, new_tenant,469 [new_tenant.security_groups['default']])470 # Check connectivity failure with default security group471 try:472 access_point_ssh = self._connect_to_access_point(new_tenant)473 self.check_remote_connectivity(source=access_point_ssh,474 dest=self._get_server_ip(server),475 should_succeed=False)476 server_id = server['id']477 port_id = self.os_admin.ports_client.list_ports(478 device_id=server_id)['ports'][0]['id']479 # update port with new security group and check connectivity480 self.ports_client.update_port(port_id, security_groups=[481 new_tenant.security_groups['new_sg']['id']])482 self.check_remote_connectivity(483 source=access_point_ssh,484 dest=self._get_server_ip(server))485 except Exception:486 self._log_console_output_for_all_tenants()487 raise488 @decorators.idempotent_id('d2f77418-fcc4-439d-b935-72eca704e293')489 @decorators.attr(type='slow')490 @test.services('compute', 'network')491 def test_multiple_security_groups(self):492 """Verify multiple security groups and checks that rules493 provided in the both the groups is applied onto VM494 """495 tenant = self.primary_tenant496 ip = self._get_server_ip(tenant.access_point,497 floating=self.floating_ip_access)498 ssh_login = CONF.validation.image_ssh_user499 private_key = tenant.keypair['private_key']500 self.check_vm_connectivity(ip,501 should_connect=False)502 ruleset = dict(503 protocol='icmp',504 direction='ingress'505 )506 self._create_security_group_rule(507 secgroup=tenant.security_groups['default'],508 **ruleset509 )510 # NOTE: Vm now has 2 security groups one with ssh rule(511 # already added in setUp() method),and other with icmp rule512 # (added in the above step).The check_vm_connectivity tests513 # -that vm ping test is successful514 # -ssh to vm is successful515 self.check_vm_connectivity(ip,516 username=ssh_login,517 private_key=private_key,518 should_connect=True)519 @decorators.attr(type='slow')520 @test.requires_ext(service='network', extension='port-security')521 @decorators.idempotent_id('7c811dcc-263b-49a3-92d2-1b4d8405f50c')522 @test.services('compute', 'network')523 def test_port_security_disable_security_group(self):524 """Verify the default security group rules is disabled."""525 new_tenant = self.primary_tenant526 # Create server527 name = 'server-{tenant}-gen-1'.format(528 tenant=new_tenant.creds.tenant_name529 )530 name = data_utils.rand_name(name)531 server = self._create_server(name, new_tenant,532 [new_tenant.security_groups['default']])533 access_point_ssh = self._connect_to_access_point(new_tenant)534 server_id = server['id']535 port_id = self.os_admin.ports_client.list_ports(536 device_id=server_id)['ports'][0]['id']537 # Flip the port's port security and check connectivity538 try:539 self.ports_client.update_port(port_id,540 port_security_enabled=True,541 security_groups=[])542 self.check_remote_connectivity(source=access_point_ssh,543 dest=self._get_server_ip(server),544 should_succeed=False)545 self.ports_client.update_port(port_id,546 port_security_enabled=False,547 security_groups=[])548 self.check_remote_connectivity(549 source=access_point_ssh,550 dest=self._get_server_ip(server))551 except Exception:552 self._log_console_output_for_all_tenants()553 raise554 @decorators.attr(type='slow')555 @test.requires_ext(service='network', extension='port-security')556 @decorators.idempotent_id('13ccf253-e5ad-424b-9c4a-97b88a026699')557 # TODO(mriedem): We shouldn't actually need to check this since neutron558 # disables the port_security extension by default, but the problem is nova559 # assumes port_security_enabled=True if it's not set on the network560 # resource, which will mean nova may attempt to apply a security group on561 # a port on that network which would fail. This is really a bug in nova.562 @testtools.skipUnless(563 CONF.network_feature_enabled.port_security,564 'Port security must be enabled.')565 @test.services('compute', 'network')566 def test_boot_into_disabled_port_security_network_without_secgroup(self):...

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