How to use _get_ips_from_subnet method in tempest

Best Python code snippet using tempest_python

test_dhcp_ipv6.py

Source:test_dhcp_ipv6.py Github

copy

Full Screen

...73 for router in routers:74 if router['id'] in [r['id'] for r in self.routers]:75 self.client.delete_router(router['id'])76 self._remove_from_list_by_index(self.routers, router)77 def _get_ips_from_subnet(self, **kwargs):78 subnet = self.create_subnet(self.network, **kwargs)79 port_mac = data_utils.rand_mac_address()80 port = self.create_port(self.network, mac_address=port_mac)81 real_ip = next(iter(port['fixed_ips']), None)['ip_address']82 eui_ip = data_utils.get_ipv6_addr_by_EUI64(subnet['cidr'],83 port_mac).format()84 return real_ip, eui_ip85 @test.idempotent_id('e5517e62-6f16-430d-a672-f80875493d4c')86 def test_dhcpv6_stateless_eui64(self):87 """When subnets configured with RAs SLAAC (AOM=100) and DHCP stateless88 (AOM=110) both for radvd and dnsmasq, port shall receive IP address89 calculated from its MAC.90 """91 for ra_mode, add_mode in (92 ('slaac', 'slaac'),93 ('dhcpv6-stateless', 'dhcpv6-stateless'),94 ):95 kwargs = {'ipv6_ra_mode': ra_mode,96 'ipv6_address_mode': add_mode}97 real_ip, eui_ip = self._get_ips_from_subnet(**kwargs)98 self._clean_network()99 self.assertEqual(eui_ip, real_ip,100 ('Real port IP is %s, but shall be %s when '101 'ipv6_ra_mode=%s and ipv6_address_mode=%s') % (102 real_ip, eui_ip, ra_mode, add_mode))103 @test.idempotent_id('ae2f4a5d-03ff-4c42-a3b0-ce2fcb7ea832')104 def test_dhcpv6_stateless_no_ra(self):105 """When subnets configured with dnsmasq SLAAC and DHCP stateless106 and there is no radvd, port shall receive IP address calculated107 from its MAC and mask of subnet.108 """109 for ra_mode, add_mode in (110 (None, 'slaac'),111 (None, 'dhcpv6-stateless'),112 ):113 kwargs = {'ipv6_ra_mode': ra_mode,114 'ipv6_address_mode': add_mode}115 kwargs = {k: v for k, v in kwargs.iteritems() if v}116 real_ip, eui_ip = self._get_ips_from_subnet(**kwargs)117 self._clean_network()118 self.assertEqual(eui_ip, real_ip,119 ('Real port IP %s shall be equal to EUI-64 %s'120 'when ipv6_ra_mode=%s,ipv6_address_mode=%s') % (121 real_ip, eui_ip,122 ra_mode if ra_mode else "Off",123 add_mode if add_mode else "Off"))124 @test.idempotent_id('81f18ef6-95b5-4584-9966-10d480b7496a')125 def test_dhcpv6_invalid_options(self):126 """Different configurations for radvd and dnsmasq are not allowed"""127 for ra_mode, add_mode in (128 ('dhcpv6-stateless', 'dhcpv6-stateful'),129 ('dhcpv6-stateless', 'slaac'),130 ('slaac', 'dhcpv6-stateful'),131 ('dhcpv6-stateful', 'dhcpv6-stateless'),132 ('dhcpv6-stateful', 'slaac'),133 ('slaac', 'dhcpv6-stateless'),134 ):135 kwargs = {'ipv6_ra_mode': ra_mode,136 'ipv6_address_mode': add_mode}137 self.assertRaises(lib_exc.BadRequest,138 self.create_subnet,139 self.network,140 **kwargs)141 @test.idempotent_id('21635b6f-165a-4d42-bf49-7d195e47342f')142 def test_dhcpv6_stateless_no_ra_no_dhcp(self):143 """If no radvd option and no dnsmasq option is configured144 port shall receive IP from fixed IPs list of subnet.145 """146 real_ip, eui_ip = self._get_ips_from_subnet()147 self._clean_network()148 self.assertNotEqual(eui_ip, real_ip,149 ('Real port IP %s equal to EUI-64 %s when '150 'ipv6_ra_mode=Off and ipv6_address_mode=Off,'151 'but shall be taken from fixed IPs') % (152 real_ip, eui_ip))153 @test.idempotent_id('4544adf7-bb5f-4bdc-b769-b3e77026cef2')154 def test_dhcpv6_two_subnets(self):155 """When one IPv6 subnet configured with dnsmasq SLAAC or DHCP stateless156 and other IPv6 is with DHCP stateful, port shall receive EUI-64 IP157 addresses from first subnet and DHCP address from second one.158 Order of subnet creating should be unimportant.159 """160 for order in ("slaac_first", "dhcp_first"):...

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