diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_distros/test_netconfig.py | 41 | ||||
-rw-r--r-- | tests/unittests/test_net.py | 4 |
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py index 562ee04a..d09e46af 100644 --- a/tests/unittests/test_distros/test_netconfig.py +++ b/tests/unittests/test_distros/test_netconfig.py @@ -15,6 +15,7 @@ from cloudinit.tests.helpers import ( FilesystemMockingTestCase, dir2dict) from cloudinit import subp from cloudinit import util +from cloudinit import safeyaml BASE_NET_CFG = ''' auto lo @@ -88,6 +89,24 @@ V1_NET_CFG = {'config': [{'name': 'eth0', 'type': 'physical'}], 'version': 1} +V1_NET_CFG_WITH_DUPS = """\ +# same value in interface specific dns and global dns +# should produce single entry in network file +version: 1 +config: + - type: physical + name: eth0 + subnets: + - type: static + address: 192.168.0.102/24 + dns_nameservers: [1.2.3.4] + dns_search: [test.com] + interface: eth0 + - type: nameserver + address: [1.2.3.4] + search: [test.com] +""" + V1_NET_CFG_OUTPUT = """\ # This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's @@ -867,6 +886,28 @@ class TestNetCfgDistroPhoton(TestNetCfgDistroBase): V2_NET_CFG, expected_cfgs.copy()) + def test_photon_network_config_v1_with_duplicates(self): + expected = """\ + [Match] + Name=eth0 + [Network] + DHCP=no + DNS=1.2.3.4 + Domains=test.com + [Address] + Address=192.168.0.102/24""" + + net_cfg = safeyaml.load(V1_NET_CFG_WITH_DUPS) + + expected = self.create_conf_dict(expected.splitlines()) + expected_cfgs = { + self.nwk_file_path('eth0'): expected, + } + + self._apply_and_verify(self.distro.apply_network_config, + net_cfg, + expected_cfgs.copy()) + def get_mode(path, target=None): return os.stat(subp.target_path(target, path)).st_mode & 0o777 diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index b2ddbf99..1aab51ee 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -825,10 +825,14 @@ NETWORK_CONFIGS = { [Match] Name=eth99 MACAddress=c0:d6:9f:2c:e8:80 + [Address] + Address=192.168.21.3/24 [Network] DHCP=ipv4 + Domains=barley.maas sach.maas Domains=wark.maas DNS=1.2.3.4 5.6.7.8 + DNS=8.8.8.8 8.8.4.4 [Route] Gateway=65.61.151.37 Destination=0.0.0.0/0 |