summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2017-07-31 13:35:07 -0500
committerScott Moser <smoser@brickies.net>2017-08-01 12:31:06 -0400
commit56103567fbf486625cdf5bfe40eea5ddcb7e8e04 (patch)
tree15dd611d1b5120abf17d40a6e9743045ac420f6b /tests/unittests
parent512145cd16b0dfa0cbbe8a20d732e6f2d943b869 (diff)
downloadvyos-cloud-init-56103567fbf486625cdf5bfe40eea5ddcb7e8e04.tar.gz
vyos-cloud-init-56103567fbf486625cdf5bfe40eea5ddcb7e8e04.zip
sysconfig: Dont repeat header when rendering resolv.conf
The sysconfig renderer duplicates the cloud-init header string when rendering resolv.conf file. This leads to resolv.conf file growing with every reboot of a system. Fix this by checking for the header when loading content from existing file. Update one of the sysconfig unittests with multiple render calls to simulate the reboot to check that we don't repeat the header. LP: #1701420
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_net.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index e49abcc4..4653be1a 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -1683,6 +1683,9 @@ USERCTL=no
ns = network_state.parse_net_config_data(network_cfg,
skip_broken=False)
renderer = sysconfig.Renderer()
+ # render a multiple times to simulate reboots
+ renderer.render_network_state(ns, render_dir)
+ renderer.render_network_state(ns, render_dir)
renderer.render_network_state(ns, render_dir)
for fn, expected_content in os_sample.get('out_sysconfig', []):
with open(os.path.join(render_dir, fn)) as fh: