Merge lp:~smoser/curtin/trunk.lp1649652 into lp:~curtin-dev/curtin/trunk

Proposed by Scott Moser
Status: Merged
Merged at revision: 441
Proposed branch: lp:~smoser/curtin/trunk.lp1649652
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 190 lines (+148/-1)
5 files modified
curtin/net/__init__.py (+1/-1)
examples/tests/network_static_routes.yaml (+27/-0)
tests/unittests/test_net.py (+47/-0)
tests/vmtests/test_network.py (+23/-0)
tests/vmtests/test_network_static_routes.py (+50/-0)
To merge this branch: bzr merge lp:~smoser/curtin/trunk.lp1649652
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Ryan Harper (community) Approve
Wesley Wiedenmeier (community) Needs Fixing
Review via email: mp+313474@code.launchpad.net

Commit message

add new lines after rendered static routes.

Static routes were being rendered in /etc/network/interfaces
without a trailing newline after the 'pre-down' line.

To post a comment you must log in.
Revision history for this message
Wesley Wiedenmeier (wesley-wiedenmeier) wrote :

The fix makes sense to me, it achieves the same formatting fix in the output as the user's patch.
There's a couple tox issues in the unittest, patch below fixes them:
http://paste.ubuntu.com/23656927/

review: Needs Fixing
lp:~smoser/curtin/trunk.lp1649652 updated
437. By Scott Moser

formatting fixes

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:437
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~smoser/curtin/trunk.lp1649652/+merge/313474/+edit-commit-message

https://jenkins.ubuntu.com/server/job/curtin-ci/284/
Executed test runs:
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=vm-amd64/284
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=vm-i386/284
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=vm-ppc64el/284
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=vm-s390x/284

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/curtin-ci/284/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ryan Harper (raharper) :
review: Approve
lp:~smoser/curtin/trunk.lp1649652 updated
438. By Scott Moser

merge with trunk

439. By Scott Moser

merge from rharper, adding a vmtest

440. By Scott Moser

fix to be a valid cidr

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'curtin/net/__init__.py'
--- curtin/net/__init__.py 2016-08-26 15:12:01 +0000
+++ curtin/net/__init__.py 2017-01-25 20:57:24 +0000
@@ -402,7 +402,7 @@
402 route_line += " %s %s" % (mapping[k], route[k])402 route_line += " %s %s" % (mapping[k], route[k])
403 content.append(up + route_line + or_true)403 content.append(up + route_line + or_true)
404 content.append(down + route_line + or_true)404 content.append(down + route_line + or_true)
405 return "\n".join(content)405 return "\n".join(content) + "\n"
406406
407407
408def iface_start_entry(iface):408def iface_start_entry(iface):
409409
=== added file 'examples/tests/network_static_routes.yaml'
--- examples/tests/network_static_routes.yaml 1970-01-01 00:00:00 +0000
+++ examples/tests/network_static_routes.yaml 2017-01-25 20:57:24 +0000
@@ -0,0 +1,27 @@
1# examples/tests/network_static_routes.yaml
2showtrace: true
3network:
4 version: 1
5 config:
6 - type: physical
7 name: interface0
8 mac_address: "52:54:00:12:34:00"
9 subnets:
10 - address: 172.23.31.42/26
11 gateway: 172.23.31.2
12 type: static
13 - type: route
14 id: 4
15 metric: 0
16 destination: 10.0.0.0/12
17 gateway: 172.23.31.1
18 - type: route
19 id: 5
20 metric: 0
21 destination: 192.168.0.0/16
22 gateway: 172.23.31.1
23 - type: route
24 id: 6
25 metric: 1
26 destination: 10.200.0.0/16
27 gateway: 172.23.31.1
028
=== modified file 'tests/unittests/test_net.py'
--- tests/unittests/test_net.py 2016-08-25 23:09:51 +0000
+++ tests/unittests/test_net.py 2017-01-25 20:57:24 +0000
@@ -654,5 +654,52 @@
654 self.assertEqual(sorted(ifaces.split('\n')),654 self.assertEqual(sorted(ifaces.split('\n')),
655 sorted(net_ifaces.split('\n')))655 sorted(net_ifaces.split('\n')))
656656
657 def test_routes_rendered(self):
658 # as reported in bug 1649652
659 conf = [
660 {'name': 'eth0', 'type': 'physical',
661 'subnets': [{
662 'address': '172.23.31.42/26',
663 'dns_nameservers': [], 'gateway': '172.23.31.2',
664 'type': 'static'}]},
665 {'type': 'route', 'id': 4,
666 'metric': 0, 'destination': '10.0.0.0/12',
667 'gateway': '172.23.31.1'},
668 {'type': 'route', 'id': 5,
669 'metric': 0, 'destination': '192.168.2.0/24',
670 'gateway': '172.23.31.1'},
671 {'type': 'route', 'id': 6,
672 'metric': 1, 'destination': '10.0.200.0/16',
673 'gateway': '172.23.31.1'},
674 ]
675
676 expected = [
677 'auto lo',
678 'iface lo inet loopback',
679 'auto eth0',
680 'iface eth0 inet static',
681 ' address 172.23.31.42/26',
682 ' gateway 172.23.31.2',
683 ('post-up route add -net 10.0.0.0 netmask 255.240.0.0 gw '
684 '172.23.31.1 metric 0 || true'),
685 ('pre-down route del -net 10.0.0.0 netmask 255.240.0.0 gw '
686 '172.23.31.1 metric 0 || true'),
687 ('post-up route add -net 192.168.2.0 netmask 255.255.255.0 gw '
688 '172.23.31.1 metric 0 || true'),
689 ('pre-down route del -net 192.168.2.0 netmask 255.255.255.0 gw '
690 '172.23.31.1 metric 0 || true'),
691 ('post-up route add -net 10.0.200.0 netmask 255.255.0.0 gw '
692 '172.23.31.1 metric 1 || true'),
693 ('pre-down route del -net 10.0.200.0 netmask 255.255.0.0 gw '
694 '172.23.31.1 metric 1 || true'),
695 'source /etc/network/interfaces.d/*.cfg',
696 ]
697
698 ns = network_state.NetworkState(version=1, config=conf)
699 ns.parse_config()
700 found = net.render_interfaces(ns.network_state).split('\n')
701 self.assertEqual(
702 sorted([line for line in expected if line]),
703 sorted([line for line in found if line]))
657704
658# vi: ts=4 expandtab syntax=python705# vi: ts=4 expandtab syntax=python
659706
=== modified file 'tests/vmtests/test_network.py'
--- tests/vmtests/test_network.py 2016-08-25 23:32:11 +0000
+++ tests/vmtests/test_network.py 2017-01-25 20:57:24 +0000
@@ -111,6 +111,29 @@
111 logger.debug('dns_line:%s', dns_line)111 logger.debug('dns_line:%s', dns_line)
112 self.assertTrue(dns_line in resolv_lines)112 self.assertTrue(dns_line in resolv_lines)
113113
114 def test_static_routes(self):
115 '''check routing table'''
116 network_state = self.get_network_state()
117 ip_route_show = self.load_collect_file("ip_route_show")
118 route_n = self.load_collect_file("route_n")
119
120 print("ip route show:\n%s" % ip_route_show)
121 print("route -n:\n%s" % route_n)
122 routes = network_state.get('routes')
123 for route in routes:
124 print('Checking static route: %s' % route)
125 destnet = (
126 ipaddress.IPv4Network("%s/%s" % (route.get('network'),
127 route.get('netmask'))))
128 route['destination'] = destnet.with_prefixlen
129 expected_string = (
130 "{destination} via {gateway} dev.*".format(**route))
131 if route.get('metric', 0) > 0:
132 expected_string += "metric {metric}".format(**route)
133 print('searching for: %s' % expected_string)
134 m = re.search(expected_string, ip_route_show, re.MULTILINE)
135 self.assertTrue(m is not None)
136
114 def test_ip_output(self):137 def test_ip_output(self):
115 '''check iproute2 'ip a' output with test input'''138 '''check iproute2 'ip a' output with test input'''
116 network_state = self.get_network_state()139 network_state = self.get_network_state()
117140
=== added file 'tests/vmtests/test_network_static_routes.py'
--- tests/vmtests/test_network_static_routes.py 1970-01-01 00:00:00 +0000
+++ tests/vmtests/test_network_static_routes.py 2017-01-25 20:57:24 +0000
@@ -0,0 +1,50 @@
1from .releases import base_vm_classes as relbase
2from .test_network import TestNetworkBaseTestsAbs
3
4
5class TestNetworkStaticRoutesAbs(TestNetworkBaseTestsAbs):
6 """ Static network routes testing with ipv4
7 """
8 conf_file = "examples/tests/network_static_routes.yaml"
9
10
11class PreciseHWETTestNetworkStaticRoutes(relbase.precise_hwe_t,
12 TestNetworkStaticRoutesAbs):
13 # FIXME: off due to hang at test: Starting execute cloud user/final scripts
14 __test__ = False
15
16
17class TrustyTestNetworkStaticRoutes(relbase.trusty,
18 TestNetworkStaticRoutesAbs):
19 __test__ = True
20
21
22class TrustyHWEUTestNetworkStaticRoutes(relbase.trusty_hwe_u,
23 TrustyTestNetworkStaticRoutes):
24 # Working, off by default to save test suite runtime, covered by
25 # TrustyTestNetworkStaticRoutes
26 __test__ = False
27
28
29class TrustyHWEVTestNetworkStaticRoutes(relbase.trusty_hwe_v,
30 TrustyTestNetworkStaticRoutes):
31 # Working, off by default to save test suite runtime, covered by
32 # TrustyTestNetworkStaticRoutes
33 __test__ = False
34
35
36class TrustyHWEWTestNetworkStaticRoutes(relbase.trusty_hwe_w,
37 TrustyTestNetworkStaticRoutes):
38 # Working, off by default to save test suite runtime, covered by
39 # TrustyTestNetworkStaticRoutes
40 __test__ = False
41
42
43class XenialTestNetworkStaticRoutes(relbase.xenial,
44 TestNetworkStaticRoutesAbs):
45 __test__ = True
46
47
48class YakketyTestNetworkStaticRoutes(relbase.yakkety,
49 TestNetworkStaticRoutesAbs):
50 __test__ = True

Subscribers

People subscribed via source and target branches