diff options
author | Scott Moser <smoser@brickies.net> | 2016-11-22 22:49:07 -0500 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2016-11-22 22:53:39 -0500 |
commit | 8c6878a04eff2fd75115b5f23faa2665cabb5ccd (patch) | |
tree | 9787972abb75a005fc7cdae9bb9bd0cb2e062cf3 | |
parent | 6e92c5f2fccaad24afb89f79f260cb496fb8d67f (diff) | |
download | vyos-cloud-init-8c6878a04eff2fd75115b5f23faa2665cabb5ccd.tar.gz vyos-cloud-init-8c6878a04eff2fd75115b5f23faa2665cabb5ccd.zip |
tests: fix assumptions that expected no eth0 in system.
The previous commit added tests that would fail on any system that had
a nic named eth0 or eno1. The changes here supply the expected macs to
the function being tested so it does not query the system.
LP: #1644043
-rw-r--r-- | tests/unittests/test_net.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index 77e4013b..780e4ad6 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -662,25 +662,34 @@ class TestCmdlineConfigParsing(TestCase): class TestCmdlineReadKernelConfig(TempDirTestCase): + macs = { + 'eth0': '14:02:ec:42:48:00', + 'eno1': '14:02:ec:42:48:01', + } + def test_ip_cmdline_read_kernel_cmdline_ip(self): content = {'net-eth0.conf': DHCP_CONTENT_1} populate_dir(self.tmp, content) files = [os.path.join(self.tmp, k) for k in content.keys()] found = cmdline.read_kernel_cmdline_config( - files=files, cmdline='foo ip=dhcp') + files=files, cmdline='foo ip=dhcp', mac_addrs=self.macs) + exp1 = copy.deepcopy(DHCP_EXPECTED_1) + exp1['mac_address'] = self.macs['eth0'] self.assertEqual(found['version'], 1) - self.assertEqual(found['config'], [DHCP_EXPECTED_1]) + self.assertEqual(found['config'], [exp1]) def test_ip_cmdline_read_kernel_cmdline_ip6(self): content = {'net6-eno1.conf': DHCP6_CONTENT_1} populate_dir(self.tmp, content) files = [os.path.join(self.tmp, k) for k in content.keys()] found = cmdline.read_kernel_cmdline_config( - files=files, cmdline='foo ip6=dhcp root=/dev/sda') + files=files, cmdline='foo ip6=dhcp root=/dev/sda', + mac_addrs=self.macs) self.assertEqual( found, {'version': 1, 'config': [ {'type': 'physical', 'name': 'eno1', + 'mac_address': self.macs['eno1'], 'subnets': [ {'dns_nameservers': ['2001:67c:1562:8010::2:1'], 'control': 'manual', 'type': 'dhcp6', 'netmask': '64'}]}]}) @@ -691,7 +700,7 @@ class TestCmdlineReadKernelConfig(TempDirTestCase): populate_dir(self.tmp, content) files = [os.path.join(self.tmp, k) for k in content.keys()] found = cmdline.read_kernel_cmdline_config( - files=files, cmdline='foo root=/dev/sda') + files=files, cmdline='foo root=/dev/sda', mac_addrs=self.macs) self.assertEqual(found, None) def test_ip_cmdline_both_ip_ip6(self): @@ -700,9 +709,10 @@ class TestCmdlineReadKernelConfig(TempDirTestCase): populate_dir(self.tmp, content) files = [os.path.join(self.tmp, k) for k in sorted(content.keys())] found = cmdline.read_kernel_cmdline_config( - files=files, cmdline='foo ip=dhcp ip6=dhcp') + files=files, cmdline='foo ip=dhcp ip6=dhcp', mac_addrs=self.macs) eth0 = copy.deepcopy(DHCP_EXPECTED_1) + eth0['mac_address'] = self.macs['eth0'] eth0['subnets'].append( {'control': 'manual', 'type': 'dhcp6', 'netmask': '64', 'dns_nameservers': ['2001:67c:1562:8010::2:1']}) |