Merge lp:~james-page/charms/trusty/neutron-gateway/tox8-test-refactor into lp:~openstack-charmers-archive/charms/trusty/neutron-gateway/next

Proposed by James Page
Status: Merged
Merged at revision: 165
Proposed branch: lp:~james-page/charms/trusty/neutron-gateway/tox8-test-refactor
Merge into: lp:~openstack-charmers-archive/charms/trusty/neutron-gateway/next
Diff against target: 345 lines (+130/-60)
11 files modified
.bzrignore (+2/-0)
.testr.conf (+8/-0)
hooks/neutron_contexts.py (+2/-3)
hooks/neutron_hooks.py (+1/-1)
hooks/neutron_utils.py (+59/-22)
requirements.txt (+12/-0)
test-requirements.txt (+8/-0)
tox.ini (+29/-0)
unit_tests/test_actions_openstack_upgrade.py (+1/-0)
unit_tests/test_neutron_contexts.py (+1/-1)
unit_tests/test_neutron_utils.py (+7/-33)
To merge this branch: bzr merge lp:~james-page/charms/trusty/neutron-gateway/tox8-test-refactor
Reviewer Review Type Date Requested Status
Ryan Beisner (community) Approve
Review via email: mp+286933@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #1301 neutron-gateway-next for james-page mp286933
    LINT OK: passed

Build: http://10.245.162.36:8080/job/charm_lint_check/1301/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #1076 neutron-gateway-next for james-page mp286933
    UNIT OK: passed

Build: http://10.245.162.36:8080/job/charm_unit_test/1076/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #479 neutron-gateway-next for james-page mp286933
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/15182549/
Build: http://10.245.162.36:8080/job/charm_amulet_test/479/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #484 neutron-gateway-next for james-page mp286933
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/15186591/
Build: http://10.245.162.36:8080/job/charm_amulet_test/484/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

#recheck

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #1374 neutron-gateway-next for james-page mp286933
    LINT OK: passed

Build: http://10.245.162.36:8080/job/charm_lint_check/1374/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #1132 neutron-gateway-next for james-page mp286933
    UNIT OK: passed

Build: http://10.245.162.36:8080/job/charm_unit_test/1132/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #485 neutron-gateway-next for james-page mp286933
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/15186868/
Build: http://10.245.162.36:8080/job/charm_amulet_test/485/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

#recheck Drumroll...

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #1375 neutron-gateway-next for james-page mp286933
    LINT OK: passed

Build: http://10.245.162.36:8080/job/charm_lint_check/1375/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #1133 neutron-gateway-next for james-page mp286933
    UNIT OK: passed

Build: http://10.245.162.36:8080/job/charm_unit_test/1133/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #486 neutron-gateway-next for james-page mp286933
    AMULET OK: passed

Build: http://10.245.162.36:8080/job/charm_amulet_test/486/

Revision history for this message
Ryan Beisner (1chb1n) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2015-04-10 14:22:04 +0000
3+++ .bzrignore 2016-02-23 18:02:30 +0000
4@@ -1,3 +1,5 @@
5 bin
6 .coverage
7 tags
8+.tox
9+.testrepository
10
11=== added file '.testr.conf'
12--- .testr.conf 1970-01-01 00:00:00 +0000
13+++ .testr.conf 2016-02-23 18:02:30 +0000
14@@ -0,0 +1,8 @@
15+[DEFAULT]
16+test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
17+ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
18+ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
19+ ${PYTHON:-python} -m subunit.run discover -t ./ ./unit_tests $LISTOPT $IDOPTION
20+
21+test_id_option=--load-list $IDFILE
22+test_list_option=--list
23
24=== modified file 'hooks/neutron_contexts.py'
25--- hooks/neutron_contexts.py 2015-11-17 13:46:49 +0000
26+++ hooks/neutron_contexts.py 2016-02-23 18:02:30 +0000
27@@ -89,9 +89,8 @@
28
29 def core_plugin():
30 plugin = remap_plugin(config('plugin'))
31- if (get_os_codename_install_source(config('openstack-origin'))
32- >= 'icehouse'
33- and plugin == OVS):
34+ if (get_os_codename_install_source(config('openstack-origin')) >=
35+ 'icehouse' and plugin == OVS):
36 return NEUTRON_ML2_PLUGIN
37 else:
38 return CORE_PLUGIN[networking_name()][plugin]
39
40=== modified file 'hooks/neutron_hooks.py'
41--- hooks/neutron_hooks.py 2015-10-07 20:52:37 +0000
42+++ hooks/neutron_hooks.py 2016-02-23 18:02:30 +0000
43@@ -315,7 +315,7 @@
44 shortname="netns",
45 description='Network Namespace check {%s}' % current_unit,
46 check_cmd='check_status_file.py -f /var/lib/nagios/netns-check.txt'
47- )
48+ )
49 nrpe_setup.write()
50
51
52
53=== modified file 'hooks/neutron_utils.py'
54--- hooks/neutron_utils.py 2015-10-14 14:44:04 +0000
55+++ hooks/neutron_utils.py 2016-02-23 18:02:30 +0000
56@@ -567,22 +567,46 @@
57 },
58 }
59
60-
61-def register_configs():
62- ''' Register config files with their respective contexts. '''
63- release = get_os_codename_install_source(config('openstack-origin'))
64- configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
65- openstack_release=release)
66-
67- plugin = remap_plugin(config('plugin'))
68- name = networking_name()
69+SERVICE_RENAMES = {}
70+
71+
72+def remap_service(service_name):
73+ '''
74+ Remap service names based on openstack release to deal
75+ with changes to packaging
76+
77+ :param service_name: name of service to remap
78+ :returns: remapped service name or original value
79+ '''
80+ source = get_os_codename_install_source(config('openstack-origin'))
81+ for rename_source in SERVICE_RENAMES:
82+ if (source >= rename_source and
83+ service_name in SERVICE_RENAMES[rename_source]):
84+ service_name = SERVICE_RENAMES[rename_source][service_name]
85+ return service_name
86+
87+
88+def resolve_config_files(name, plugin, release):
89+ '''
90+ Resolve configuration files and contexts
91+
92+ :param name: neutron or quantum
93+ :param plugin: shortname of plugin e.g. ovs
94+ :param release: openstack release codename
95+ :returns: dict of configuration files, contexts
96+ and associated services
97+ '''
98+ config_files = deepcopy(CONFIG_FILES)
99 if plugin == 'ovs':
100 # NOTE: deal with switch to ML2 plugin for >= icehouse
101- drop_config = NEUTRON_ML2_PLUGIN_CONF
102+ drop_config = [NEUTRON_ML2_PLUGIN_CONF]
103 if release >= 'icehouse':
104- drop_config = NEUTRON_OVS_PLUGIN_CONF
105- if drop_config in CONFIG_FILES[name][plugin]:
106- CONFIG_FILES[name][plugin].pop(drop_config)
107+ # ovs -> ml2
108+ drop_config = [NEUTRON_OVS_PLUGIN_CONF]
109+
110+ for _config in drop_config:
111+ if _config in config_files[name][plugin]:
112+ config_files[name][plugin].pop(_config)
113
114 if is_relation_made('amqp-nova'):
115 amqp_nova_ctxt = context.AMQPContext(
116@@ -593,11 +617,22 @@
117 amqp_nova_ctxt = context.AMQPContext(
118 ssl_dir=NOVA_CONF_DIR,
119 rel_name='amqp')
120- CONFIG_FILES[name][plugin][NOVA_CONF][
121+ config_files[name][plugin][NOVA_CONF][
122 'hook_contexts'].append(amqp_nova_ctxt)
123- for conf in CONFIG_FILES[name][plugin]:
124+ return config_files
125+
126+
127+def register_configs():
128+ ''' Register config files with their respective contexts. '''
129+ release = get_os_codename_install_source(config('openstack-origin'))
130+ plugin = remap_plugin(config('plugin'))
131+ name = networking_name()
132+ config_files = resolve_config_files(name, plugin, release)
133+ configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
134+ openstack_release=release)
135+ for conf in config_files[name][plugin]:
136 configs.register(conf,
137- CONFIG_FILES[name][plugin][conf]['hook_contexts'])
138+ config_files[name][plugin][conf]['hook_contexts'])
139 return configs
140
141
142@@ -619,15 +654,17 @@
143 :returns: dict: A dictionary mapping config file to lists of services
144 that should be restarted when file changes.
145 '''
146+ release = get_os_codename_install_source(config('openstack-origin'))
147+ plugin = remap_plugin(config('plugin'))
148+ name = networking_name()
149+ config_files = resolve_config_files(name, plugin, release)
150 _map = {}
151- plugin = config('plugin')
152- name = networking_name()
153- for f, ctxt in CONFIG_FILES[name][plugin].iteritems():
154- svcs = []
155+ for f, ctxt in config_files[name][plugin].iteritems():
156+ svcs = set()
157 for svc in ctxt['services']:
158- svcs.append(svc)
159+ svcs.add(remap_service(svc))
160 if svcs:
161- _map[f] = svcs
162+ _map[f] = list(svcs)
163 return _map
164
165
166
167=== added file 'requirements.txt'
168--- requirements.txt 1970-01-01 00:00:00 +0000
169+++ requirements.txt 2016-02-23 18:02:30 +0000
170@@ -0,0 +1,12 @@
171+# The order of packages is significant, because pip processes them in the order
172+# of appearance. Changing the order has an impact on the overall integration
173+# process, which may cause wedges in the gate later.
174+PyYAML>=3.1.0
175+simplejson>=2.2.0
176+netifaces>=0.10.4
177+netaddr>=0.7.12,!=0.7.16
178+Jinja2>=2.6 # BSD License (3 clause)
179+six>=1.9.0
180+dnspython>=1.12.0
181+psutil>=1.1.1,<2.0.0
182+python-neutronclient>=2.6.0
183
184=== added file 'test-requirements.txt'
185--- test-requirements.txt 1970-01-01 00:00:00 +0000
186+++ test-requirements.txt 2016-02-23 18:02:30 +0000
187@@ -0,0 +1,8 @@
188+# The order of packages is significant, because pip processes them in the order
189+# of appearance. Changing the order has an impact on the overall integration
190+# process, which may cause wedges in the gate later.
191+coverage>=3.6
192+mock>=1.2
193+flake8>=2.2.4,<=2.4.1
194+os-testr>=0.4.1
195+charm-tools
196
197=== added file 'tox.ini'
198--- tox.ini 1970-01-01 00:00:00 +0000
199+++ tox.ini 2016-02-23 18:02:30 +0000
200@@ -0,0 +1,29 @@
201+[tox]
202+envlist = pep8,py27
203+skipsdist = True
204+
205+[testenv]
206+setenv = VIRTUAL_ENV={envdir}
207+ PYTHONHASHSEED=0
208+install_command =
209+ pip install --allow-unverified python-apt {opts} {packages}
210+commands = ostestr {posargs}
211+
212+[testenv:py27]
213+basepython = python2.7
214+deps = -r{toxinidir}/requirements.txt
215+ -r{toxinidir}/test-requirements.txt
216+
217+[testenv:pep8]
218+basepython = python2.7
219+deps = -r{toxinidir}/requirements.txt
220+ -r{toxinidir}/test-requirements.txt
221+commands = flake8 {posargs} hooks unit_tests tests actions
222+ charm proof
223+
224+[testenv:venv]
225+commands = {posargs}
226+
227+[flake8]
228+ignore = E402,E226
229+exclude = hooks/charmhelpers
230
231=== modified file 'unit_tests/test_actions_openstack_upgrade.py'
232--- unit_tests/test_actions_openstack_upgrade.py 2015-10-08 16:16:22 +0000
233+++ unit_tests/test_actions_openstack_upgrade.py 2016-02-23 18:02:30 +0000
234@@ -14,6 +14,7 @@
235 TO_PATCH = [
236 'do_openstack_upgrade',
237 'config_changed',
238+ 'get_common_package',
239 ]
240
241
242
243=== modified file 'unit_tests/test_neutron_contexts.py'
244--- unit_tests/test_neutron_contexts.py 2015-11-20 09:19:09 +0000
245+++ unit_tests/test_neutron_contexts.py 2016-02-23 18:02:30 +0000
246@@ -55,7 +55,7 @@
247 self.config.side_effect = self.test_config.get
248
249 @patch('neutron_contexts.NeutronAPIContext')
250- def test_no_ext_netid(self, _NeutronAPIContext):
251+ def test_no_ext_netid(self, _NeutronAPIContext):
252 _NeutronAPIContext.return_value = \
253 DummyNeutronAPIContext(return_value={'enable_dvr': False})
254 self.test_config.set('run-internal-router', 'none')
255
256=== modified file 'unit_tests/test_neutron_utils.py'
257--- unit_tests/test_neutron_utils.py 2015-09-28 11:18:48 +0000
258+++ unit_tests/test_neutron_utils.py 2016-02-23 18:02:30 +0000
259@@ -1,4 +1,4 @@
260-from mock import MagicMock, call, patch
261+from mock import MagicMock, call, patch, ANY
262 import collections
263 import charmhelpers.contrib.openstack.templating as templating
264
265@@ -287,11 +287,7 @@
266 neutron_utils.NEUTRON_OVS_PLUGIN_CONF,
267 neutron_utils.EXT_PORT_CONF]
268 for conf in confs:
269- configs.register.assert_any_call(
270- conf,
271- neutron_utils.CONFIG_FILES['neutron'][neutron_utils.OVS][conf]
272- ['hook_contexts']
273- )
274+ configs.register.assert_any_call(conf, ANY)
275
276 def test_register_configs_ovs_odl(self):
277 self.config.side_effect = self.test_config.get
278@@ -306,12 +302,7 @@
279 neutron_utils.NEUTRON_L3_AGENT_CONF,
280 neutron_utils.EXT_PORT_CONF]
281 for conf in confs:
282- configs.register.assert_any_call(
283- conf,
284- neutron_utils.CONFIG_FILES['neutron']
285- [neutron_utils.OVS_ODL][conf]
286- ['hook_contexts']
287- )
288+ configs.register.assert_any_call(conf, ANY)
289
290 def test_register_configs_amqp_nova(self):
291 self.config.return_value = 'ovs'
292@@ -325,11 +316,7 @@
293 neutron_utils.NEUTRON_OVS_PLUGIN_CONF,
294 neutron_utils.EXT_PORT_CONF]
295 for conf in confs:
296- configs.register.assert_any_call(
297- conf,
298- neutron_utils.CONFIG_FILES['neutron'][neutron_utils.OVS][conf]
299- ['hook_contexts']
300- )
301+ configs.register.assert_any_call(conf, ANY)
302
303 def test_restart_map_ovs(self):
304 self.config.return_value = 'ovs'
305@@ -411,11 +398,7 @@
306 neutron_utils.NOVA_CONF,
307 neutron_utils.NEUTRON_CONF]
308 for conf in confs:
309- configs.register.assert_any_call(
310- conf,
311- neutron_utils.CONFIG_FILES['neutron'][neutron_utils.NVP][conf]
312- ['hook_contexts']
313- )
314+ configs.register.assert_any_call(conf, ANY)
315
316 def test_register_configs_nsx(self):
317 self.config.return_value = 'nsx'
318@@ -425,11 +408,7 @@
319 neutron_utils.NOVA_CONF,
320 neutron_utils.NEUTRON_CONF]
321 for conf in confs:
322- configs.register.assert_any_call(
323- conf,
324- neutron_utils.CONFIG_FILES['neutron'][neutron_utils.NSX][conf]
325- ['hook_contexts']
326- )
327+ configs.register.assert_any_call(conf, ANY)
328
329 def test_stop_services_nvp(self):
330 self.config.return_value = 'nvp'
331@@ -482,13 +461,8 @@
332 neutron_utils.QUANTUM_L3_AGENT_CONF,
333 neutron_utils.QUANTUM_OVS_PLUGIN_CONF,
334 neutron_utils.EXT_PORT_CONF]
335- print configs.register.mock_calls
336 for conf in confs:
337- configs.register.assert_any_call(
338- conf,
339- neutron_utils.CONFIG_FILES['quantum'][neutron_utils.OVS][conf]
340- ['hook_contexts']
341- )
342+ configs.register.assert_any_call(conf, ANY)
343
344 def test_get_common_package_quantum(self):
345 self.get_os_codename_package.return_value = 'folsom'

Subscribers

People subscribed via source and target branches