Merge lp:~raharper/curtin/trunk.test-vlan into lp:~curtin-dev/curtin/trunk

Proposed by Ryan Harper on 2016-04-05
Status: Merged
Merged at revision: 378
Proposed branch: lp:~raharper/curtin/trunk.test-vlan
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 236 lines (+167/-11)
4 files modified
curtin/net/__init__.py (+9/-10)
examples/tests/vlan_network.yaml (+81/-0)
tests/vmtests/__init__.py (+1/-0)
tests/vmtests/test_network.py (+76/-1)
To merge this branch: bzr merge lp:~raharper/curtin/trunk.test-vlan
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Needs Fixing on 2016-04-05
Scott Moser 2016-04-05 Pending
Review via email: mp+291023@code.launchpad.net

Commit Message

vmtests: add network vlan testing

- Utilize a real vlan configuration used in openstack deployments which on
  trusty sometimes triggers a bug/issue with ifupdown (lp:1565711)

- curtin/net now writes: network: {config: disabled} into
  /etc/cloud/cloud.cfg.d/curtin-disable-cloudinit-networking.cfg
  as in Xenial cloud-init network config device naming causes issues which
  prevent cloud-init from finding the data source and then bad things
  happen.

To post a comment you must log in.

FAILED: Continuous integration, rev:377
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/~raharper/curtin/trunk.test-vlan/+merge/291023/+edit-commit-message

https://server-team-jenkins.canonical.com/job/curtin-ci/201/
Executed test runs:
    None: https://server-team-jenkins.canonical.com/job/generic-update-mp/198/console

Click here to trigger a rebuild:
https://server-team-jenkins.canonical.com/job/curtin-ci/201/rebuild

review: Needs Fixing (continuous-integration)
lp:~raharper/curtin/trunk.test-vlan updated on 2016-04-06
373. By Ryan Harper on 2016-04-06

vmtests: enhance vlan testing on all releases

Enable vlan testing for all distros
Fix testcase logic for multiple vlan interfaces

Scott Moser (smoser) :
Ryan Harper (raharper) wrote :

On Wed, Apr 6, 2016 at 1:53 PM, Scott Moser <email address hidden> wrote:

>
>
> Diff comments:
>
> > === modified file 'curtin/net/__init__.py'
> > --- curtin/net/__init__.py 2016-03-31 14:27:52 +0000
> > +++ curtin/net/__init__.py 2016-04-06 16:25:28 +0000
> > @@ -444,4 +446,10 @@
> > LOG.info('Writing ' + netrules)
> > f.write(persistent_net_rules)
> >
> > + ccfg = os.path.sep.join((target, cloud_cfg_disable,))
>
> why not util.write_file() ?
>

Probably before I knew about it. Will convert them all.

>
> > + util.ensure_dir(os.path.dirname(ccfg))
> > + with open(ccfg, 'w+') as f:
> > + LOG.info('Writing ' + ccfg)
> > + f.write('network: {config: disabled}\n')
> > +
> > # vi: ts=4 expandtab syntax=python
>
>
> --
> https://code.launchpad.net/~raharper/curtin/trunk.test-vlan/+merge/291023
> You are the owner of lp:~raharper/curtin/trunk.test-vlan.
>

lp:~raharper/curtin/trunk.test-vlan updated on 2016-04-07
374. By Ryan Harper on 2016-04-07

use util.write_file for writing network configuration files

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'curtin/net/__init__.py'
2--- curtin/net/__init__.py 2016-03-31 14:27:52 +0000
3+++ curtin/net/__init__.py 2016-04-07 14:33:20 +0000
4@@ -429,19 +429,18 @@
5 def render_network_state(target, network_state):
6 eni = 'etc/network/interfaces'
7 netrules = 'etc/udev/rules.d/70-persistent-net.rules'
8+ cc = 'etc/cloud/cloud.cfg.d/curtin-disable-cloudinit-networking.cfg'
9
10 eni = os.path.sep.join((target, eni,))
11- util.ensure_dir(os.path.dirname(eni))
12- with open(eni, 'w+') as f:
13- LOG.info('Writing ' + eni)
14- f.write(render_interfaces(network_state))
15+ LOG.info('Writing ' + eni)
16+ util.write_file(eni, content=render_interfaces(network_state))
17
18 netrules = os.path.sep.join((target, netrules,))
19- util.ensure_dir(os.path.dirname(netrules))
20- persistent_net_rules = render_persistent_net(network_state)
21- if len(persistent_net_rules) > 0:
22- with open(netrules, 'w+') as f:
23- LOG.info('Writing ' + netrules)
24- f.write(persistent_net_rules)
25+ LOG.info('Writing ' + netrules)
26+ util.write_file(netrules, content=render_persistent_net(network_state))
27+
28+ cc_disable = os.path.sep.join((target, cc,))
29+ LOG.info('Writing ' + cc_disable)
30+ util.write_file(cc_disable, content='network: {config: disabled}\n')
31
32 # vi: ts=4 expandtab syntax=python
33
34=== added file 'examples/tests/vlan_network.yaml'
35--- examples/tests/vlan_network.yaml 1970-01-01 00:00:00 +0000
36+++ examples/tests/vlan_network.yaml 2016-04-07 14:33:20 +0000
37@@ -0,0 +1,81 @@
38+network:
39+ config:
40+ - id: eth0
41+ mac_address: d4:be:d9:a8:49:13
42+ mtu: 1500
43+ name: eth0
44+ subnets:
45+ - address: 10.245.168.16/21
46+ dns_nameservers:
47+ - 10.245.168.2
48+ gateway: 10.245.168.1
49+ type: static
50+ type: physical
51+ - id: eth1
52+ mac_address: d4:be:d9:a8:49:15
53+ mtu: 1500
54+ name: eth1
55+ subnets:
56+ - address: 10.245.188.2/24
57+ dns_nameservers: []
58+ type: static
59+ type: physical
60+ - id: eth2
61+ mac_address: d4:be:d9:a8:49:17
62+ mtu: 1500
63+ name: eth2
64+ subnets:
65+ - type: manual
66+ type: physical
67+ - id: eth3
68+ mac_address: d4:be:d9:a8:49:19
69+ mtu: 1500
70+ name: eth3
71+ subnets:
72+ - type: manual
73+ type: physical
74+ - id: eth1.2667
75+ mtu: 1500
76+ name: eth1.2667
77+ subnets:
78+ - address: 10.245.184.2/24
79+ dns_nameservers: []
80+ type: static
81+ type: vlan
82+ vlan_id: 2667
83+ vlan_link: eth1
84+ - id: eth1.2668
85+ mtu: 1500
86+ name: eth1.2668
87+ subnets:
88+ - address: 10.245.185.1/24
89+ dns_nameservers: []
90+ type: static
91+ type: vlan
92+ vlan_id: 2668
93+ vlan_link: eth1
94+ - id: eth1.2669
95+ mtu: 1500
96+ name: eth1.2669
97+ subnets:
98+ - address: 10.245.186.1/24
99+ dns_nameservers: []
100+ type: static
101+ type: vlan
102+ vlan_id: 2669
103+ vlan_link: eth1
104+ - id: eth1.2670
105+ mtu: 1500
106+ name: eth1.2670
107+ subnets:
108+ - address: 10.245.187.2/24
109+ dns_nameservers: []
110+ type: static
111+ type: vlan
112+ vlan_id: 2670
113+ vlan_link: eth1
114+ - address: 10.245.168.2
115+ search:
116+ - dellstack
117+ type: nameserver
118+ version: 1
119
120=== modified file 'tests/vmtests/__init__.py'
121--- tests/vmtests/__init__.py 2016-04-04 18:20:33 +0000
122+++ tests/vmtests/__init__.py 2016-04-07 14:33:20 +0000
123@@ -871,6 +871,7 @@
124 'password': 'passw0rd',
125 'chpasswd': {'expire': False},
126 'power_state': {'mode': 'poweroff'},
127+ 'network': {'config': 'disabled'},
128 }
129
130 ssh_keys, _err = util.subp(['tools/ssh-keys-list', 'cloud-config'],
131
132=== modified file 'tests/vmtests/test_network.py'
133--- tests/vmtests/test_network.py 2016-03-03 11:46:13 +0000
134+++ tests/vmtests/test_network.py 2016-04-07 14:33:20 +0000
135@@ -9,7 +9,7 @@
136
137
138 def iface_extract(input):
139- mo = re.search(r'^(?P<interface>\w+|\w+:\d+)\s+' +
140+ mo = re.search(r'^(?P<interface>\w+|\w+:\d+|\w+\.\d+)\s+' +
141 r'Link encap:(?P<link_encap>\S+)\s+' +
142 r'(HWaddr\s+(?P<mac_address>\S+))?' +
143 r'(\s+inet addr:(?P<address>\S+))?' +
144@@ -59,6 +59,7 @@
145 cp -av /etc/udev/rules.d/70-persistent-net.rules .
146 ip -o route show > ip_route_show
147 route -n > route_n
148+ cp -av /run/network ./run_network
149 """)]
150
151 def test_output_files_exist(self):
152@@ -237,6 +238,48 @@
153 conf_file = "examples/tests/basic_network_static.yaml"
154
155
156+class TestNetworkVlanAbs(TestNetworkAbs):
157+ conf_file = "examples/tests/vlan_network.yaml"
158+ collect_scripts = TestNetworkAbs.collect_scripts + [textwrap.dedent("""
159+ cd OUTPUT_COLLECT_D
160+ dpkg-query -W -f '${Status}' vlan > vlan_installed
161+ ip -d link show eth1.2667 > ip_link_show_eth1.2667
162+ ip -d link show eth1.2668 > ip_link_show_eth1.2668
163+ ip -d link show eth1.2669 > ip_link_show_eth1.2669
164+ ip -d link show eth1.2670 > ip_link_show_eth1.2670
165+ """)]
166+
167+ def get_vlans(self):
168+ network_state = self.get_network_state()
169+ logger.debug('get_vlans ns:\n{}'.format(
170+ yaml.dump(network_state, default_flow_style=False, indent=4)))
171+ interfaces = network_state.get('interfaces')
172+ return [iface for iface in interfaces.values()
173+ if iface['type'] == 'vlan']
174+
175+ def test_output_files_exist_vlan(self):
176+ link_files = ["ip_link_show_{}".format(vlan['name'])
177+ for vlan in self.get_vlans()]
178+ self.output_files_exist(["vlan_installed"] + link_files)
179+
180+ def test_vlan_installed(self):
181+ with open(os.path.join(self.td.collect, "vlan_installed")) as fp:
182+ status = fp.read().strip()
183+ logger.debug('vlan installed?: {}'.format(status))
184+ self.assertEqual('install ok installed', status)
185+
186+ def test_vlan_enabled(self):
187+
188+ # we must have at least one
189+ self.assertGreaterEqual(len(self.get_vlans()), 1)
190+
191+ # did they get configured?
192+ for vlan in self.get_vlans():
193+ link_file = "ip_link_show_" + vlan['name']
194+ vlan_msg = "vlan protocol 802.1Q id " + str(vlan['vlan_id'])
195+ self.check_file_regex(link_file, vlan_msg)
196+
197+
198 class PreciseHWETTestNetwork(relbase.precise_hwe_t, TestNetworkAbs):
199 # FIXME: off due to hang at test: Starting execute cloud user/final scripts
200 __test__ = False
201@@ -321,3 +364,35 @@
202 # over the net.ifnames to the installed system via '---' as the net
203 # config should take care of that.
204 extra_kern_args = "net.ifnames=0"
205+
206+
207+class PreciseTestNetworkVlan(relbase.precise, TestNetworkVlanAbs):
208+ __test__ = True
209+
210+ # precise ip -d link show output is different (of course)
211+ def test_vlan_enabled(self):
212+
213+ # we must have at least one
214+ self.assertGreaterEqual(len(self.get_vlans()), 1)
215+
216+ # did they get configured?
217+ for vlan in self.get_vlans():
218+ link_file = "ip_link_show_" + vlan['name']
219+ vlan_msg = "vlan id " + str(vlan['vlan_id'])
220+ self.check_file_regex(link_file, vlan_msg)
221+
222+
223+class TrustyTestNetworkVlan(relbase.trusty, TestNetworkVlanAbs):
224+ __test__ = True
225+
226+
227+class VividTestNetworkVlan(relbase.vivid, TestNetworkVlanAbs):
228+ __test__ = True
229+
230+
231+class WilyTestNetworkVlan(relbase.wily, TestNetworkVlanAbs):
232+ __test__ = True
233+
234+
235+class XenialTestNetworkVlan(relbase.xenial, TestNetworkVlanAbs):
236+ __test__ = True

Subscribers

People subscribed via source and target branches