summaryrefslogtreecommitdiff
path: root/debian/patches/cpick-8c6878a-tests-fix-assumptions-that-expected-no-eth0-in-system
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/cpick-8c6878a-tests-fix-assumptions-that-expected-no-eth0-in-system')
-rw-r--r--debian/patches/cpick-8c6878a-tests-fix-assumptions-that-expected-no-eth0-in-system73
1 files changed, 73 insertions, 0 deletions
diff --git a/debian/patches/cpick-8c6878a-tests-fix-assumptions-that-expected-no-eth0-in-system b/debian/patches/cpick-8c6878a-tests-fix-assumptions-that-expected-no-eth0-in-system
new file mode 100644
index 00000000..2ec38217
--- /dev/null
+++ b/debian/patches/cpick-8c6878a-tests-fix-assumptions-that-expected-no-eth0-in-system
@@ -0,0 +1,73 @@
+commit 8c6878a04eff2fd75115b5f23faa2665cabb5ccd
+Author: Scott Moser <smoser@brickies.net>
+Date: Tue Nov 22 22:49:07 2016 -0500
+
+ 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
+
+--- 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(TempDi
+ 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(TempDi
+ 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']})