summaryrefslogtreecommitdiff
path: root/cloudinit/net/tests/test_dhcp.py
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2017-11-21 11:43:26 -0700
committerChad Smith <chad.smith@canonical.com>2017-11-21 11:43:26 -0700
commit5b974bbab161e6cd73751bf27b7741f6b0d19051 (patch)
treef634411a9b12b2e36ff8beefbec39dad21cd45ea /cloudinit/net/tests/test_dhcp.py
parentc9c7ff70f55ee024dd54336f07ba52acec1f6929 (diff)
parent7624348712b4502f0085d30c05b34dce3f2ceeae (diff)
downloadvyos-cloud-init-5b974bbab161e6cd73751bf27b7741f6b0d19051.tar.gz
vyos-cloud-init-5b974bbab161e6cd73751bf27b7741f6b0d19051.zip
merge from 7624348712b4502f0085d30c05b34dce3f2ceeae at 17.1-41-g76243487
Diffstat (limited to 'cloudinit/net/tests/test_dhcp.py')
-rw-r--r--cloudinit/net/tests/test_dhcp.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/cloudinit/net/tests/test_dhcp.py b/cloudinit/net/tests/test_dhcp.py
index 1c1f504a..3d8e15c0 100644
--- a/cloudinit/net/tests/test_dhcp.py
+++ b/cloudinit/net/tests/test_dhcp.py
@@ -2,6 +2,7 @@
import mock
import os
+import signal
from textwrap import dedent
from cloudinit.net.dhcp import (
@@ -114,8 +115,9 @@ class TestDHCPDiscoveryClean(CiTestCase):
self.assertEqual('eth9', call[0][1])
self.assertIn('/var/tmp/cloud-init/cloud-init-dhcp-', call[0][2])
+ @mock.patch('cloudinit.net.dhcp.os.kill')
@mock.patch('cloudinit.net.dhcp.util.subp')
- def test_dhcp_discovery_run_in_sandbox(self, m_subp):
+ def test_dhcp_discovery_run_in_sandbox(self, m_subp, m_kill):
"""dhcp_discovery brings up the interface and runs dhclient.
It also returns the parsed dhcp.leases file generated in the sandbox.
@@ -134,6 +136,10 @@ class TestDHCPDiscoveryClean(CiTestCase):
""")
lease_file = os.path.join(tmpdir, 'dhcp.leases')
write_file(lease_file, lease_content)
+ pid_file = os.path.join(tmpdir, 'dhclient.pid')
+ my_pid = 1
+ write_file(pid_file, "%d\n" % my_pid)
+
self.assertItemsEqual(
[{'interface': 'eth9', 'fixed-address': '192.168.2.74',
'subnet-mask': '255.255.255.0', 'routers': '192.168.2.1'}],
@@ -149,6 +155,7 @@ class TestDHCPDiscoveryClean(CiTestCase):
[os.path.join(tmpdir, 'dhclient'), '-1', '-v', '-lf',
lease_file, '-pf', os.path.join(tmpdir, 'dhclient.pid'),
'eth9', '-sf', '/bin/true'], capture=True)])
+ m_kill.assert_has_calls([mock.call(my_pid, signal.SIGKILL)])
class TestSystemdParseLeases(CiTestCase):