From 99f4140d1c5b1813c75790a8a99aae8fa84d13ee Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Mon, 25 Jan 2021 16:26:47 +0100 Subject: smoketest: dhcpv6: add client smoketests --- smoketest/scripts/cli/base_interfaces_test.py | 33 ++++++++++++++++++++++ smoketest/scripts/cli/test_interfaces_bonding.py | 1 + smoketest/scripts/cli/test_interfaces_bridge.py | 3 +- smoketest/scripts/cli/test_interfaces_ethernet.py | 1 + .../scripts/cli/test_interfaces_pseudo_ethernet.py | 1 + 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/smoketest/scripts/cli/base_interfaces_test.py b/smoketest/scripts/cli/base_interfaces_test.py index 6a68bcc26..8fa757967 100644 --- a/smoketest/scripts/cli/base_interfaces_test.py +++ b/smoketest/scripts/cli/base_interfaces_test.py @@ -59,6 +59,7 @@ class BasicInterfaceTest: _test_qinq = False _test_ipv6 = False _test_ipv6_pd = False + _test_ipv6_dhcpc6 = False _test_mirror = False _base_path = [] @@ -401,6 +402,38 @@ class BasicInterfaceTest: tmp = read_file(f'/proc/sys/net/ipv6/conf/{interface}/dad_transmits') self.assertEqual(dad_transmits, tmp) + def test_dhcpv6_clinet_options(self): + if not self._test_ipv6_dhcpc6: + self.skipTest('not supported') + + for interface in self._interfaces: + duid = '00:01:00:01:27:71:db:f0:' + read_file(f'/sys/class/net/{interface}/address') + path = self._base_path + [interface] + for option in self._options.get(interface, []): + self.session.set(path + option.split()) + + # Enable DHCPv6 client + self.session.set(path + ['address', 'dhcpv6']) + self.session.set(path + ['dhcpv6-options', 'rapid-commit']) + self.session.set(path + ['dhcpv6-options', 'parameters-only']) + self.session.set(path + ['dhcpv6-options', 'duid', duid]) + + self.session.commit() + + for interface in self._interfaces: + duid = '00:01:00:01:27:71:db:f0:' + read_file(f'/sys/class/net/{interface}/address') + dhcpc6_config = read_file(f'/run/dhcp6c/dhcp6c.{interface}.conf') + self.assertIn(f'interface {interface} ' + '{', dhcpc6_config) + self.assertIn(f' request domain-name-servers;', dhcpc6_config) + self.assertIn(f' request domain-name;', dhcpc6_config) + self.assertIn(f' information-only;', dhcpc6_config) + self.assertIn(f' send ia-na 0;', dhcpc6_config) + self.assertIn(f' send rapid-commit;', dhcpc6_config) + self.assertIn(f' send client-id {duid};', dhcpc6_config) + self.assertIn('};', dhcpc6_config) + + # Check for running process + self.assertTrue(process_named_running('dhcp6c')) def test_dhcpv6pd_auto_sla_id(self): if not self._test_ipv6_pd: diff --git a/smoketest/scripts/cli/test_interfaces_bonding.py b/smoketest/scripts/cli/test_interfaces_bonding.py index 560bfb92b..882d38760 100755 --- a/smoketest/scripts/cli/test_interfaces_bonding.py +++ b/smoketest/scripts/cli/test_interfaces_bonding.py @@ -29,6 +29,7 @@ class BondingInterfaceTest(BasicInterfaceTest.BaseTest): self._test_ip = True self._test_ipv6 = True self._test_ipv6_pd = True + self._test_ipv6_dhcpc6 = True self._test_mtu = True self._test_vlan = True self._test_qinq = True diff --git a/smoketest/scripts/cli/test_interfaces_bridge.py b/smoketest/scripts/cli/test_interfaces_bridge.py index 8f03290be..33c2e7dad 100755 --- a/smoketest/scripts/cli/test_interfaces_bridge.py +++ b/smoketest/scripts/cli/test_interfaces_bridge.py @@ -32,6 +32,7 @@ class BridgeInterfaceTest(BasicInterfaceTest.BaseTest): self._test_ip = True self._test_ipv6 = True self._test_ipv6_pd = True + self._test_ipv6_dhcpc6 = True self._test_vlan = True self._base_path = ['interfaces', 'bridge'] self._mirror_interfaces = ['dum21354'] @@ -198,7 +199,7 @@ class BridgeInterfaceTest(BasicInterfaceTest.BaseTest): for vif in vifs: # member interface must be assigned to the bridge self.assertTrue(os.path.exists(f'/sys/class/net/{interface}/lower_{member}.{vif}')) - + # delete all members for interface in self._interfaces: for member in self._members: diff --git a/smoketest/scripts/cli/test_interfaces_ethernet.py b/smoketest/scripts/cli/test_interfaces_ethernet.py index 9d896f690..6c6e66008 100755 --- a/smoketest/scripts/cli/test_interfaces_ethernet.py +++ b/smoketest/scripts/cli/test_interfaces_ethernet.py @@ -39,6 +39,7 @@ class EthernetInterfaceTest(BasicInterfaceTest.BaseTest): self._test_ip = True self._test_ipv6 = True self._test_ipv6_pd = True + self._test_ipv6_dhcpc6 = True self._test_mtu = True self._test_vlan = True self._test_qinq = True diff --git a/smoketest/scripts/cli/test_interfaces_pseudo_ethernet.py b/smoketest/scripts/cli/test_interfaces_pseudo_ethernet.py index 10bd7ca34..1a5debb79 100755 --- a/smoketest/scripts/cli/test_interfaces_pseudo_ethernet.py +++ b/smoketest/scripts/cli/test_interfaces_pseudo_ethernet.py @@ -23,6 +23,7 @@ class PEthInterfaceTest(BasicInterfaceTest.BaseTest): self._test_ip = True self._test_ipv6 = True self._test_ipv6_pd = True + self._test_ipv6_dhcpc6 = True self._test_mtu = True self._test_vlan = True self._test_qinq = True -- cgit v1.2.3