How to use check_vm_connectivity method in tempest

Best Python code snippet using tempest_python

test_dpdk.py

Source:test_dpdk.py Github

copy

Full Screen

...101 (hosts[0], networks[1], None),102 (hosts[1], networks[1], None)]103 vms = self.create_vms(os_conn, hosts, networks, flavors[0], keypair,104 security_group, vms_param)105 network_checks.check_vm_connectivity(env, os_conn, vm_keypair=keypair)106 for vm in vms:107 self.check_vif_type_for_vm(vm, os_conn)108 act_size = self.get_instance_page_size(os_conn, vm)109 assert act_size == size, (110 "Unexpected package size. Should be {0} instead of {1}".format(111 size, act_size))112 final_conf = computes_configuration(env)113 exp_hosts_usage = [(hosts[0], 3), (hosts[1], 1)]114 for (host, nr_page) in exp_hosts_usage:115 exp_free = (initial_conf[host][size]['free'] -116 nr_page * flavors[0].ram * 1024 / size)117 assert exp_free == final_conf[host][size]['free']118 @pytest.mark.testrail_id('2984291',119 networks=dict(ipv6_ra_mode='slaac',120 ipv6_addr_mode='slaac',121 version=6))122 @pytest.mark.testrail_id('2994580',123 networks=dict(ipv6_ra_mode='dhcpv6-stateless',124 ipv6_addr_mode='dhcpv6-stateless',125 version=6))126 @pytest.mark.parametrize('networks',127 [dict(ipv6_ra_mode='slaac',128 ipv6_addr_mode='slaac', version=6),129 dict(ipv6_ra_mode='dhcpv6-stateless',130 ipv6_addr_mode='dhcpv6-stateless',131 version=6)],132 indirect=True)133 def test_ipv6_base_connectivity(self, env, os_conn, computes_with_dpdk_hp,134 networks, keypair, flavors,135 security_group_ipv6):136 """This test checks base connectivity between VMs with DPDK. Please137 note we're not able to count DPDK huge pages only.138 Steps:139 1. Create net1 with ipv6 subnet, net2 with ipv6 subnet and140 router1 with interfaces to both nets141 2. Create flavor for huge pages with 2048Mb ram, 1 vcpu and 1Gb142 disk143 3. Launch vm1, vm2, vm3 on compute-1 and vm4 on compute-2, vm1 and144 vm2 in net1, vm3 and vm4 in net2145 4. Check vms connectivity146 5. Check instance page size147 6. Check that neutron port has binding:vif_type = vhostuser148 7. Check that count of 2Mb huge pages is expected for each host149 """150 hosts = computes_with_dpdk_hp151 initial_conf = computes_configuration(env)152 size = self.prepare_flavor(initial_conf, flavors, hosts)153 vms_param = [(hosts[0], networks[0], None),154 (hosts[0], networks[0], None),155 (hosts[0], networks[1], None),156 (hosts[1], networks[1], None)]157 vms = self.create_vms(os_conn, hosts, networks, flavors[0], keypair,158 security_group_ipv6, vms_param)159 network_checks.check_vm_connectivity(env, os_conn, vm_keypair=keypair,160 version=6)161 for vm in vms:162 self.check_vif_type_for_vm(vm, os_conn)163 act_size = self.get_instance_page_size(os_conn, vm)164 assert act_size == size, (165 "Unexpected package size. Should be {0} instead of {1}".format(166 size, act_size))167 final_conf = computes_configuration(env)168 exp_hosts_usage = [(hosts[0], 3), (hosts[1], 1)]169 for (host, nr_page) in exp_hosts_usage:170 exp_free = (initial_conf[host][size]['free'] -171 nr_page * flavors[0].ram * 1024 / size)172 assert exp_free == final_conf[host][size]['free']173 @pytest.mark.testrail_id('2984292',174 networks=dict(ipv6_ra_mode='slaac',175 ipv6_addr_mode='slaac',176 version=10))177 @pytest.mark.testrail_id('2994582',178 networks=dict(ipv6_ra_mode='dhcpv6-stateless',179 ipv6_addr_mode='dhcpv6-stateless',180 version=10))181 @pytest.mark.parametrize('networks',182 [dict(ipv6_ra_mode='slaac',183 ipv6_addr_mode='slaac', version=10),184 dict(ipv6_ra_mode='dhcpv6-stateless',185 ipv6_addr_mode='dhcpv6-stateless',186 version=10)],187 indirect=True)188 def test_ipv6_ipv4_connectivity(self, env, os_conn, computes_with_dpdk_hp,189 networks, keypair, flavors,190 security_group_ipv6):191 """This test checks base connectivity between VMs with DPDK. Please192 note we're not able to count DPDK huge pages only.193 Steps:194 1. Create net1 with ipv6 and ipv4 subnets, net2 with ipv6 and ipv4195 subnets and router1 with interfaces to both nets196 2. Create flavor for huge pages with 2048Mb ram, 1 vcpu and 1Gb197 disk198 3. Launch vm1, vm2, vm3 on compute-1 and vm4 on compute-2, vm1 and199 vm2 in net1, vm3 and vm4 in net2200 4. Check vms connectivity201 5. Check instance page size202 6. Check that neutron port has binding:vif_type = vhostuser203 7. Check that count of 2Mb huge pages is expected for each host204 """205 hosts = computes_with_dpdk_hp206 initial_conf = computes_configuration(env)207 size = self.prepare_flavor(initial_conf, flavors, hosts)208 vms_param = [(hosts[0], networks[0], None),209 (hosts[0], networks[0], None),210 (hosts[0], networks[1], None),211 (hosts[1], networks[1], None)]212 vms = self.create_vms(os_conn, hosts, networks, flavors[0], keypair,213 security_group_ipv6, vms_param)214 network_checks.check_vm_connectivity(env, os_conn, vm_keypair=keypair,215 version=6)216 network_checks.check_vm_connectivity(env, os_conn, vm_keypair=keypair,217 version=4)218 for vm in vms:219 self.check_vif_type_for_vm(vm, os_conn)220 act_size = self.get_instance_page_size(os_conn, vm)221 assert act_size == size, (222 "Unexpected package size. Should be {0} instead of {1}".format(223 size, act_size))224 final_conf = computes_configuration(env)225 exp_hosts_usage = [(hosts[0], 3), (hosts[1], 1)]226 for (host, nr_page) in exp_hosts_usage:227 exp_free = (initial_conf[host][size]['free'] -228 nr_page * flavors[0].ram * 1024 / size)229 assert exp_free == final_conf[host][size]['free']230 @pytest.mark.testrail_id('838335')231 def test_vms_connectivity_after_cold_migration(self, env, os_conn,232 computes_with_dpdk_hp,233 flavors, networks, keypair,234 security_group):235 """This test checks connectivity between VMs with DPDK after cold236 migration. Please note we're not able to count DPDK huge pages only.237 Steps:238 1. Create net1 with subnet, net2 with subnet and router1 with239 interfaces to both nets240 2. Create flavor for huge pages with 2048Mb ram, 1 vcpu and 1Gb241 disk242 3. Launch vm1, vm2 on compute-1, vm3 - on compute-2, vm1 in net1,243 vm2 and vm3 in net2244 4. Migrate vm1 and check that vm moved to other compute with245 huge pages246 5. Check instance page size247 6. Check that neutron port has binding:vif_type = vhostuser248 7. Check vms connectivity249 """250 hosts = computes_with_dpdk_hp251 initial_conf = computes_configuration(env)252 self.prepare_flavor(initial_conf, flavors, hosts)253 vms_param = [(hosts[0], networks[0], None),254 (hosts[0], networks[1], None),255 (hosts[1], networks[1], None)]256 vms = self.create_vms(os_conn, hosts, networks, flavors[0], keypair,257 security_group, vms_param=vms_param)258 network_checks.check_vm_connectivity(env, os_conn, vm_keypair=keypair)259 vm0_new = self.migrate(os_conn, vms[0])260 vm0_host = getattr(os_conn.nova.servers.get(vm0_new),261 "OS-EXT-SRV-ATTR:host")262 assert vm0_host in hosts, ("Unexpected host {0},"263 "should be in {1}".format(vm0_host, hosts))264 assert vm0_host != hosts[0], ("New host is expected instead of {0}"265 "after cold migration".format(hosts[0]))266 network_checks.check_vm_connectivity(env, os_conn, vm_keypair=keypair)267 @pytest.mark.testrail_id('838337')268 def test_vms_connectivity_after_live_migration(self, env, os_conn,269 computes_with_dpdk_hp,270 flavors, networks, keypair,271 security_group):272 """This test checks connectivity between VMs with DPDK after live273 migration. Please note we're not able to count DPDK huge pages only.274 Steps:275 1. Create net1 with subnet, net2 with subnet and router1 with276 interfaces to both nets277 2. Create flavor for huge pages with 2048Mb ram, 1 vcpu and 1Gb278 disk279 3. Launch vm1, vm2 on compute-1, vm3 - on compute-2, vm1 in net1,280 vm2 and vm3 in net2281 4. Live migrate vm1 to compute2282 5. Check instance page size283 6. Check that neutron port has binding:vif_type = vhostuser284 7. Check that count of free 2Mb huge pages is expected one for285 each host286 8. Check vms connectivity287 """288 hosts = computes_with_dpdk_hp289 initial_conf = computes_configuration(env)290 size = self.prepare_flavor(initial_conf, flavors, hosts)291 vms_param = [(hosts[0], networks[0], None),292 (hosts[0], networks[1], None),293 (hosts[1], networks[1], None)]294 vms = self.create_vms(os_conn, hosts, networks, flavors[0], keypair,295 security_group, vms_param=vms_param)296 self.live_migrate(os_conn, vms[0], hosts[1])297 network_checks.check_vm_connectivity(env, os_conn, vm_keypair=keypair)298 final_conf = computes_configuration(env)299 exp_hosts_usage = [(hosts[0], 1), (hosts[1], 2)]300 for (host, nr_page) in exp_hosts_usage:301 exp_free = (initial_conf[host][size]['free'] -302 nr_page * flavors[0].ram * 1024 / size)303 assert exp_free == final_conf[host][size]['free']304 @pytest.mark.testrail_id('838336')305 def test_vms_connectivity_after_evacuation(self, env, os_conn, volume,306 computes_with_dpdk_hp, flavors,307 networks, keypair, devops_env,308 security_group):309 """This test checks connectivity between VMs with DPDK after310 evacuation. Please note we're not able to count DPDK huge pages only.311 Steps:312 1. Create net1 with subnet, net2 with subnet and router1 with313 interfaces to both nets314 2. Create flavor for huge pages with 2048Mb ram, 1 vcpu and 1Gb315 disk316 3. Launch vm1 (from not empty volume), vm2 on compute-1,317 vm3 - on compute-2, vm1 in net1, vm2 and vm3 in net2318 4. Kill compute2 and evacuate vm3319 5. Check vms connectivity320 6. Start compute2321 7. Check instance page size322 8. Check that neutron port has binding:vif_type = vhostuser323 9. Check that count of free 2Mb huge pages is expected one for324 each host325 """326 hosts = computes_with_dpdk_hp327 initial_conf = computes_configuration(env)328 size = self.prepare_flavor(initial_conf, flavors, hosts)329 vms_param = [(hosts[0], networks[0], {'vda': volume.id}),330 (hosts[0], networks[1], None),331 (hosts[1], networks[1], None)]332 vms = self.create_vms(os_conn, hosts, networks, flavors[0], keypair,333 security_group, vms_param=vms_param)334 network_checks.check_vm_connectivity(env, os_conn, vm_keypair=keypair)335 with self.change_compute_state_to_down(os_conn, devops_env, hosts[1]):336 vm_new = self.evacuate(os_conn, devops_env, vms[2])337 vm_new_host = getattr(os_conn.nova.servers.get(vm_new),338 "OS-EXT-SRV-ATTR:host")339 assert vm_new_host in hosts340 assert vm_new_host != hosts[1]341 os_conn.wait_servers_ssh_ready(vms)342 network_checks.check_vm_connectivity(env, os_conn,343 vm_keypair=keypair)344 final_conf = computes_configuration(env)345 exp_hosts_usage = [(hosts[0], 3), (hosts[1], 0)]346 for (host, nr_page) in exp_hosts_usage:347 exp_free = (initial_conf[host][size]['free'] -348 nr_page * flavors[0].ram * 1024 / size)349 assert exp_free == final_conf[host][size]['free']350 @pytest.mark.testrail_id('838332')351 def test_vms_connectivity_after_ovs_restart_on_computes(352 self, env, os_conn, computes_with_dpdk_hp, flavors, networks,353 keypair, security_group):354 """This test checks connectivity between VMs with DPDK after ovs355 restart on computes. Please note we're not able to count DPDK huge356 pages only.357 Steps:358 1. Create net1 with subnet, net2 with subnet and router1 with359 interfaces to both nets360 2. Create flavor for huge pages with 2048Mb ram, 1 vcpu and 1Gb361 disk362 3. Launch vm1, vm2, vm3 on compute-1 and vm4 on compute-2, vm1 and363 vm2 in net1, vm3 and vm4 in net2364 4. Check that neutron port has binding:vif_type = vhostuser365 5. Check instance page size366 6. Restart ovs on computes367 7. Check vms connectivity after ovs restart368 """369 hosts = computes_with_dpdk_hp370 initial_conf = computes_configuration(env)371 self.prepare_flavor(initial_conf, flavors, hosts)372 vms_param = [(hosts[0], networks[0], None),373 (hosts[0], networks[0], None),374 (hosts[0], networks[1], None),375 (hosts[1], networks[1], None)]376 self.create_vms(os_conn, hosts, networks, flavors[0], keypair,377 security_group, vms_param)378 network_checks.check_vm_connectivity(env, os_conn, vm_keypair=keypair)379 self.restart_ovs_on_computes(env, os_conn)380 network_checks.check_vm_connectivity(env, os_conn, vm_keypair=keypair)381 @pytest.mark.testrail_id('838333', restart_point='computes')382 @pytest.mark.testrail_id('838334', restart_point='controllers')383 @pytest.mark.parametrize('restart_point',384 ['computes', 'controllers'],385 ids=['computes', 'controllers'])386 def test_ssh_connection_after_ovs_restart(self, env, os_conn,387 computes_with_dpdk_hp, flavors,388 networks, security_group,389 keypair, restart_point):390 """This test checks ssh connection between VMs with DPDK after ovs391 restart on computes/controllers.392 Steps:393 1. Create net1 with subnet, net2 with subnet and router1 with394 interfaces to both nets395 2. Create flavor for huge pages with 2048Mb ram, 1 vcpu and 1Gb396 disk397 3. Launch vm1, vm2, vm3 on compute-1 and vm4 on compute-2, vm1 and398 vm2 in net1, vm3 and vm4 in net2399 4. Check that neutron port has binding:vif_type = vhostuser400 5. Check instance page size401 6. Open ssh connection to vm1 and vm4402 7. Restart ovs on computes/controllers403 8. Check that both ssh connections are still alive404 9. Check vms connectivity405 """406 hosts = computes_with_dpdk_hp407 initial_conf = computes_configuration(env)408 self.prepare_flavor(initial_conf, flavors, hosts)409 vms_param = [(hosts[0], networks[0], None),410 (hosts[0], networks[0], None),411 (hosts[0], networks[1], None),412 (hosts[1], networks[1], None)]413 vms = self.create_vms(os_conn, hosts, networks, flavors[0], keypair,414 security_group, vms_param)415 vm1_remote = os_conn.ssh_to_instance(env, vms[0], keypair)416 vm4_remote = os_conn.ssh_to_instance(env, vms[3], keypair)417 with vm1_remote, vm4_remote:418 if restart_point == 'computes':419 self.restart_ovs_on_computes(env, os_conn)420 elif restart_point == 'controllers':421 self.restart_ovs_on_controllers(env, os_conn)422 vm1_remote.check_call("uname")423 vm4_remote.check_call("uname")...

Full Screen

Full Screen

test_baremetal_multitenancy.py

Source:test_baremetal_multitenancy.py Github

copy

Full Screen

...85 )86 floating_ip1 = self.create_floating_ip(87 instance1,88 )['floating_ip_address']89 self.check_vm_connectivity(ip_address=floating_ip1,90 private_key=keypair['private_key'])91 # Boot instance in the alt tenant network and ensure there is no92 # L2 connectivity between instances of the different tenants93 alt_keypair = self.create_keypair(self.alt_manager.keypairs_client)94 alt_network, alt_subnet, alt_router = self.create_tenant_network(95 self.alt_manager, tenant_cidr)96 alt_instance, alt_node = self.boot_instance(97 keypair=alt_keypair,98 clients=self.alt_manager,99 net_id=alt_network['id'],100 fixed_ip=fixed_ip2101 )102 alt_floating_ip = self.create_floating_ip(103 alt_instance,104 client=self.alt_manager.floating_ips_client105 )['floating_ip_address']106 self.check_vm_connectivity(ip_address=alt_floating_ip,107 private_key=alt_keypair['private_key'])108 self.verify_l3_connectivity(109 alt_floating_ip,110 alt_keypair['private_key'],111 fixed_ip1,112 conn_expected=False113 )114 self.verify_l3_connectivity(115 floating_ip1,116 keypair['private_key'],117 fixed_ip2,118 conn_expected=False119 )120 self.verify_l3_connectivity(...

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