How to use _test_create_interface_by_port_id method in tempest

Best Python code snippet using tempest_python

test_attach_interfaces.py

Source:test_attach_interfaces.py Github

copy

Full Screen

...107 server['id'], iface['port_id'], 'ACTIVE')108 self._check_interface(iface, network_id=network_id)109 return iface110111 def _test_create_interface_by_port_id(self, server, ifs):112 network_id = ifs[0]['net_id']113 port = self.ports_client.create_port(network_id=network_id)114 port_id = port['port']['id']115 self.addCleanup(self.ports_client.delete_port, port_id)116 iface = self.client.create_interface(117 server['id'], port_id=port_id)['interfaceAttachment']118 iface = self.wait_for_interface_status(119 server['id'], iface['port_id'], 'ACTIVE')120 self._check_interface(iface, port_id=port_id)121 return iface122123 def _test_show_interface(self, server, ifs):124 iface = ifs[0]125 _iface = self.client.show_interface(126 server['id'], iface['port_id'])['interfaceAttachment']127 self._check_interface(iface, port_id=_iface['port_id'],128 network_id=_iface['net_id'],129 fixed_ip=_iface['fixed_ips'][0]['ip_address'],130 mac_addr=_iface['mac_addr'])131132 def _test_delete_interface(self, server, ifs):133 # NOTE(danms): delete not the first or last, but one in the middle134 iface = ifs[1]135 self.client.delete_interface(server['id'], iface['port_id'])136 _ifs = (self.client.list_interfaces(server['id'])137 ['interfaceAttachments'])138 start = int(time.time())139140 while len(ifs) == len(_ifs):141 time.sleep(self.build_interval)142 _ifs = (self.client.list_interfaces(server['id'])143 ['interfaceAttachments'])144 timed_out = int(time.time()) - start >= self.build_timeout145 if len(ifs) == len(_ifs) and timed_out:146 message = ('Failed to delete interface within '147 'the required time: %s sec.' % self.build_timeout)148 raise exceptions.TimeoutException(message)149150 self.assertNotIn(iface['port_id'], [i['port_id'] for i in _ifs])151 return _ifs152153 def _compare_iface_list(self, list1, list2):154 # NOTE(danms): port_state will likely have changed, so just155 # confirm the port_ids are the same at least156 list1 = [x['port_id'] for x in list1]157 list2 = [x['port_id'] for x in list2]158159 self.assertEqual(sorted(list1), sorted(list2))160161 @test.idempotent_id('73fe8f02-590d-4bf1-b184-e9ca81065051')162 @test.services('network')163 def test_create_list_show_delete_interfaces(self):164 server, ifs = self._create_server_get_interfaces()165 interface_count = len(ifs)166 self.assertTrue(interface_count > 0)167 self._check_interface(ifs[0])168169 try:170 iface = self._test_create_interface(server)171 except lib_exc.BadRequest as e:172 msg = ('Multiple possible networks found, use a Network ID to be '173 'more specific.')174 if not CONF.compute.fixed_network_name and e.message == msg:175 raise176 else:177 ifs.append(iface)178179 iface = self._test_create_interface_by_network_id(server, ifs)180 ifs.append(iface)181182 iface = self._test_create_interface_by_port_id(server, ifs)183 ifs.append(iface)184185 _ifs = (self.client.list_interfaces(server['id'])186 ['interfaceAttachments'])187 self._compare_iface_list(ifs, _ifs)188189 self._test_show_interface(server, ifs)190191 _ifs = self._test_delete_interface(server, ifs)192 self.assertEqual(len(ifs) - 1, len(_ifs))193194 @test.attr(type='smoke')195 @test.idempotent_id('c7e0e60b-ee45-43d0-abeb-8596fd42a2f9')196 @test.services('network') ...

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