diff options
author | Scott Moser <smoser@brickies.net> | 2016-12-16 17:10:56 -0500 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2016-12-19 16:17:02 -0500 |
commit | 071563198530008651ef12c6039241086c5b60ad (patch) | |
tree | 9818021e53cb47679ea8110df66c1274daa5a6d1 | |
parent | c01129492f046fdf745b432b6035605c9c613655 (diff) | |
download | vyos-cloud-init-071563198530008651ef12c6039241086c5b60ad.tar.gz vyos-cloud-init-071563198530008651ef12c6039241086c5b60ad.zip |
network: add ENI unit test for statically rendered routes.
This just adds a unit test for a case found to be failing in curtin.
The issue was reported under bug 1649652.
-rwxr-xr-x | tests/unittests/test_net.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index 789c78b2..3242c19e 100755 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -769,6 +769,52 @@ class TestEniRoundTrip(TestCase): entry['expected_eni'].splitlines(), files['/etc/network/interfaces'].splitlines()) + def test_routes_rendered(self): + # as reported in bug 1649652 + conf = [ + {'name': 'eth0', 'type': 'physical', + 'subnets': [{ + 'address': '172.23.31.42/26', + 'dns_nameservers': [], 'gateway': '172.23.31.2', + 'type': 'static'}]}, + {'type': 'route', 'id': 4, + 'metric': 0, 'destination': '10.0.0.0/12', + 'gateway': '172.23.31.1'}, + {'type': 'route', 'id': 5, + 'metric': 0, 'destination': '192.168.2.0/16', + 'gateway': '172.23.31.1'}, + {'type': 'route', 'id': 6, + 'metric': 1, 'destination': '10.0.200.0/16', + 'gateway': '172.23.31.1'}, + ] + + files = self._render_and_read( + network_config={'config': conf, 'version': 1}) + expected = [ + 'auto lo', + 'iface lo inet loopback', + 'auto eth0', + 'iface eth0 inet static', + ' address 172.23.31.42/26', + ' gateway 172.23.31.2', + ('post-up route add -net 10.0.0.0 netmask 255.240.0.0 gw ' + '172.23.31.1 metric 0 || true'), + ('pre-down route del -net 10.0.0.0 netmask 255.240.0.0 gw ' + '172.23.31.1 metric 0 || true'), + ('post-up route add -net 192.168.2.0 netmask 255.255.0.0 gw ' + '172.23.31.1 metric 0 || true'), + ('pre-down route del -net 192.168.2.0 netmask 255.255.0.0 gw ' + '172.23.31.1 metric 0 || true'), + ('post-up route add -net 10.0.200.0 netmask 255.255.0.0 gw ' + '172.23.31.1 metric 1 || true'), + ('pre-down route del -net 10.0.200.0 netmask 255.255.0.0 gw ' + '172.23.31.1 metric 1 || true'), + ] + found = files['/etc/network/interfaces'].splitlines() + + self.assertEqual( + expected, [line for line in found if line]) + def _gzip_data(data): with io.BytesIO() as iobuf: |