diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-07-03 04:55:40 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-07-10 10:44:43 +0200 |
commit | e2d5aab32afa25d1bb54f4022213edd166199c50 (patch) | |
tree | e082b9a29cd71a790f8443f11bbdfaf15f491004 /test | |
parent | test-network: enable systemd-resolved.service (diff) | |
download | systemd-e2d5aab32afa25d1bb54f4022213edd166199c50.tar.xz systemd-e2d5aab32afa25d1bb54f4022213edd166199c50.zip |
test-network: add tests for UseDNS= in [DHCP] section
Diffstat (limited to 'test')
5 files changed, 123 insertions, 0 deletions
diff --git a/test/test-network/conf/dhcp-client-use-dns-ipv4-and-ra.network b/test/test-network/conf/dhcp-client-use-dns-ipv4-and-ra.network new file mode 100644 index 0000000000..ed5989555c --- /dev/null +++ b/test/test-network/conf/dhcp-client-use-dns-ipv4-and-ra.network @@ -0,0 +1,11 @@ +[Match] +Name=veth99 + +[Network] +DHCP=ipv4 + +[DHCP] +UseDNS=yes + +[IPv6AcceptRA] +UseDNS=yes diff --git a/test/test-network/conf/dhcp-client-use-dns-ipv4.network b/test/test-network/conf/dhcp-client-use-dns-ipv4.network new file mode 100644 index 0000000000..dbd0f7f3fe --- /dev/null +++ b/test/test-network/conf/dhcp-client-use-dns-ipv4.network @@ -0,0 +1,14 @@ +[Match] +Name=veth99 + +[Network] +DHCP=ipv4 + +[DHCPv4] +UseDNS=yes + +[DHCPv6] +UseDNS=no + +[IPv6AcceptRA] +UseDNS=no diff --git a/test/test-network/conf/dhcp-client-use-dns-no.network b/test/test-network/conf/dhcp-client-use-dns-no.network new file mode 100644 index 0000000000..891efdbe12 --- /dev/null +++ b/test/test-network/conf/dhcp-client-use-dns-no.network @@ -0,0 +1,11 @@ +[Match] +Name=veth99 + +[Network] +DHCP=yes + +[DHCP] +UseDNS=no + +[IPv6AcceptRA] +UseDNS=no diff --git a/test/test-network/conf/dhcp-client-use-dns-yes.network b/test/test-network/conf/dhcp-client-use-dns-yes.network new file mode 100644 index 0000000000..f38ffe36e3 --- /dev/null +++ b/test/test-network/conf/dhcp-client-use-dns-yes.network @@ -0,0 +1,11 @@ +[Match] +Name=veth99 + +[Network] +DHCP=yes + +[DHCP] +UseDNS=yes + +[IPv6AcceptRA] +UseDNS=no diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index e2b4aae6ef..2e6ac2896d 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -2153,6 +2153,10 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): 'dhcp-client-listen-port.network', 'dhcp-client-route-metric.network', 'dhcp-client-route-table.network', + 'dhcp-client-use-dns-ipv4-and-ra.network', + 'dhcp-client-use-dns-ipv4.network', + 'dhcp-client-use-dns-no.network', + 'dhcp-client-use-dns-yes.network', 'dhcp-client-use-routes-no.network', 'dhcp-client-vrf.network', 'dhcp-client-with-ipv4ll-fallback-with-dhcp-server.network', @@ -2674,6 +2678,78 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): self.assertRegex(output, f'default via 192.168.5.1 proto dhcp src {address2} metric 1024') self.assertRegex(output, f'192.168.5.1 proto dhcp scope link src {address2} metric 1024') + def test_dhcp_client_use_dns_yes(self): + copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-use-dns-yes.network') + + start_networkd() + wait_online(['veth-peer:carrier']) + start_dnsmasq('--dhcp-option=option:dns-server,192.168.5.1 --dhcp-option=option6:dns-server,[2600::1]') + wait_online(['veth99:routable', 'veth-peer:routable']) + + # link become 'routable' when at least one protocol provide an valid address. + self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4') + self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6') + + time.sleep(3) + output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env) + print(output) + self.assertRegex(output, '192.168.5.1') + self.assertRegex(output, '2600::1') + + def test_dhcp_client_use_dns_no(self): + copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-use-dns-no.network') + + start_networkd() + wait_online(['veth-peer:carrier']) + start_dnsmasq('--dhcp-option=option:dns-server,192.168.5.1 --dhcp-option=option6:dns-server,[2600::1]') + wait_online(['veth99:routable', 'veth-peer:routable']) + + # link become 'routable' when at least one protocol provide an valid address. + self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4') + self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6') + + time.sleep(3) + output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env) + print(output) + self.assertNotRegex(output, '192.168.5.1') + self.assertNotRegex(output, '2600::1') + + def test_dhcp_client_use_dns_ipv4(self): + copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-use-dns-ipv4.network') + + start_networkd() + wait_online(['veth-peer:carrier']) + start_dnsmasq('--dhcp-option=option:dns-server,192.168.5.1 --dhcp-option=option6:dns-server,[2600::1]') + wait_online(['veth99:routable', 'veth-peer:routable']) + + # link become 'routable' when at least one protocol provide an valid address. + self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4') + self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6') + + time.sleep(3) + output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env) + print(output) + self.assertRegex(output, '192.168.5.1') + self.assertNotRegex(output, '2600::1') + + def test_dhcp_client_use_dns_ipv4_and_ra(self): + copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-use-dns-ipv4-and-ra.network') + + start_networkd() + wait_online(['veth-peer:carrier']) + start_dnsmasq('--dhcp-option=option:dns-server,192.168.5.1 --dhcp-option=option6:dns-server,[2600::1]') + wait_online(['veth99:routable', 'veth-peer:routable']) + + # link become 'routable' when at least one protocol provide an valid address. + self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4') + self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6') + + time.sleep(3) + output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env) + print(output) + self.assertRegex(output, '192.168.5.1') + self.assertRegex(output, '2600::1') + if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--build-dir', help='Path to build dir', dest='build_dir') |