Merge lp:~james-page/charms/trusty/cinder/tox into lp:~openstack-charmers-archive/charms/trusty/cinder/next

Proposed by James Page on 2015-07-16
Status: Merged
Merged at revision: 134
Proposed branch: lp:~james-page/charms/trusty/cinder/tox
Merge into: lp:~openstack-charmers-archive/charms/trusty/cinder/next
Diff against target: 266 lines (+98/-64)
9 files modified
.bzrignore (+2/-0)
.testr.conf (+8/-0)
requirements.txt (+11/-0)
test-requirements.txt (+8/-0)
tox.ini (+29/-0)
unit_tests/test_actions_git_reinstall.py (+6/-17)
unit_tests/test_actions_openstack_upgrade.py (+7/-4)
unit_tests/test_cinder_hooks.py (+17/-25)
unit_tests/test_cluster_hooks.py (+10/-18)
To merge this branch: bzr merge lp:~james-page/charms/trusty/cinder/tox
Reviewer Review Type Date Requested Status
Corey Bryant Approve on 2015-11-03
James Page 2015-07-29 Resubmit on 2015-11-03
Billy Olsen 2015-07-16 Needs Information on 2015-07-29
Review via email: mp+265008@code.launchpad.net

Description of the Change

Support for execution of lint and tests using tox

To post a comment you must log in.
102. By James Page on 2015-07-16

Fixup lint target

charm_lint_check #6281 cinder-next for james-page mp265008
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/6281/

charm_unit_test #5913 cinder-next for james-page mp265008
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/5913/

103. By James Page on 2015-07-16

Switchover to using tox executing unit and lint tests

charm_unit_test #5914 cinder-next for james-page mp265008
    UNIT FAIL: unit-test missing

UNIT Results (max last 2 lines):
INFO:root:Search string not found in makefile target commands.
ERROR:root:No make target was executed.

Full unit test output: http://paste.ubuntu.com/11888272/
Build: http://10.245.162.77:8080/job/charm_unit_test/5914/

charm_lint_check #6282 cinder-next for james-page mp265008
    LINT FAIL: lint-test missing

LINT Results (max last 2 lines):
INFO:root:Search string not found in makefile target commands.
ERROR:root:No make target was executed.

Full lint test output: http://paste.ubuntu.com/11888273/
Build: http://10.245.162.77:8080/job/charm_lint_check/6282/

charm_amulet_test #5135 cinder-next for james-page mp265008
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/5135/

charm_amulet_test #5136 cinder-next for james-page mp265008
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/5136/

Billy Olsen (billy-olsen) wrote :

Code changes lgtm and I'd like to give it a thumbs up, but on my recently-reinstaled (aka cleanish) vivid system I get this --> http://paste.ubuntu.com/11957838/.

I suspect one of the dependencies might be slightly off ?? I'll spend more time looking at it next week since I don't think this is required for 15.07 release.

review: Needs Information
104. By James Page on 2015-09-10

Rebase

105. By James Page on 2015-09-14

Add a bit more patching when loading openstack_upgrade

charm_lint_check #9930 cinder-next for james-page mp265008
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/9930/

charm_unit_test #9149 cinder-next for james-page mp265008
    UNIT FAIL: unit-test failed

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

Full unit test output: http://paste.ubuntu.com/12407902/
Build: http://10.245.162.77:8080/job/charm_unit_test/9149/

106. By James Page on 2015-09-14

Tidy, fixup failing tests

charm_lint_check #9933 cinder-next for james-page mp265008
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/9933/

charm_unit_test #9152 cinder-next for james-page mp265008
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/9152/

107. By James Page on 2015-09-14

Use context helpers throughout

108. By James Page on 2015-09-14

Tidy lint

James Page (james-page) wrote :

I still see:

==============================
Failed 1 tests - output below:
==============================

unit_tests.test_cluster_hooks.TestClusterHooks.test_cluster_hook
----------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "/home/jamespage/src/charms/tox/cinder/.tox/py27-trusty/local/lib/python2.7/site-packages/mock.py", line 1201, in patched
        return func(*args, **keywargs)
      File "/home/jamespage/src/charms/tox/cinder/unit_tests/test_cluster_hooks.py", line 82, in test_cluster_hook
        self.assertEquals(ex, service.call_args_list)
      File "/usr/lib/python2.7/unittest/case.py", line 513, in assertEqual
        assertion_func(first, second, msg=msg)
      File "/usr/lib/python2.7/unittest/case.py", line 506, in _baseAssertEqual
        raise self.failureException(msg)
    AssertionError: [call('stop', 'cinder-api'), call('stop', 'cinder-volume'), call('stop', 'cinder-scheduler'), call('stop', 'haproxy'), call('stop', 'apache2'), call('start', 'cinder-api'), call('start', 'cinder-volume'), call('start', 'cinder-scheduler'), call('start', 'haproxy'), call('start', 'apache2')] != []

When run under tox (ok under make test); for the life of me I can't figure out how its working in the current codebase.

109. By James Page on 2015-09-14

Make sure that RESTART_MAP is patched consistently

James Page (james-page) wrote :

OK - figured that out - cinder_utils.restart_map was not being assigned a return value consistently across all import patching.

I don't really like the cross test implications of doing this outside of the test class.

charm_amulet_test #6415 cinder-next for james-page mp265008
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/6415/

James Page (james-page) :
review: Resubmit

charm_lint_check #9935 cinder-next for james-page mp265008
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/9935/

charm_unit_test #9153 cinder-next for james-page mp265008
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/9153/

charm_amulet_test #6417 cinder-next for james-page mp265008
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/6417/

charm_amulet_test #6418 cinder-next for james-page mp265008
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/6418/

110. By James Page on 2015-10-29

Rebase

charm_lint_check #12852 cinder-next for james-page mp265008
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/12852/

charm_unit_test #11932 cinder-next for james-page mp265008
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/11932/

charm_amulet_test #7645 cinder-next for james-page mp265008
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/7645/

111. By James Page on 2015-10-30

resync tox bits

charm_lint_check #12917 cinder-next for james-page mp265008
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/12917/

charm_unit_test #11997 cinder-next for james-page mp265008
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/11997/

charm_amulet_test #7660 cinder-next for james-page mp265008
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/7660/

Corey Bryant (corey.bryant) wrote :

It looks like this mp is missing (test-)requirements.txt files.

review: Needs Fixing
Corey Bryant (corey.bryant) wrote :

We probably want to also run flake8 against the actions/ directory.

112. By James Page on 2015-11-03

Add missing files, lint actions

James Page (james-page) wrote :

Missing files added and actions now being lint'ed

review: Resubmit
Corey Bryant (corey.bryant) wrote :

Looks good and tox tests run successfully.

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 2014-07-02 08:13:36 +0000
3+++ .bzrignore 2015-11-03 11:00:52 +0000
4@@ -1,2 +1,4 @@
5 bin
6 .coverage
7+.testrepository
8+.tox
9
10=== added file '.testr.conf'
11--- .testr.conf 1970-01-01 00:00:00 +0000
12+++ .testr.conf 2015-11-03 11:00:52 +0000
13@@ -0,0 +1,8 @@
14+[DEFAULT]
15+test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
16+ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
17+ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
18+ ${PYTHON:-python} -m subunit.run discover -t ./ ./unit_tests $LISTOPT $IDOPTION
19+
20+test_id_option=--load-list $IDFILE
21+test_list_option=--list
22
23=== added file 'requirements.txt'
24--- requirements.txt 1970-01-01 00:00:00 +0000
25+++ requirements.txt 2015-11-03 11:00:52 +0000
26@@ -0,0 +1,11 @@
27+# The order of packages is significant, because pip processes them in the order
28+# of appearance. Changing the order has an impact on the overall integration
29+# process, which may cause wedges in the gate later.
30+PyYAML>=3.1.0
31+simplejson>=2.2.0
32+netifaces>=0.10.4
33+netaddr>=0.7.12,!=0.7.16
34+Jinja2>=2.6 # BSD License (3 clause)
35+six>=1.9.0
36+dnspython>=1.12.0
37+psutil>=1.1.1,<2.0.0
38
39=== added file 'test-requirements.txt'
40--- test-requirements.txt 1970-01-01 00:00:00 +0000
41+++ test-requirements.txt 2015-11-03 11:00:52 +0000
42@@ -0,0 +1,8 @@
43+# The order of packages is significant, because pip processes them in the order
44+# of appearance. Changing the order has an impact on the overall integration
45+# process, which may cause wedges in the gate later.
46+coverage>=3.6
47+mock>=1.2
48+flake8>=2.2.4,<=2.4.1
49+os-testr>=0.4.1
50+charm-tools
51
52=== added file 'tox.ini'
53--- tox.ini 1970-01-01 00:00:00 +0000
54+++ tox.ini 2015-11-03 11:00:52 +0000
55@@ -0,0 +1,29 @@
56+[tox]
57+envlist = lint,py27
58+skipsdist = True
59+
60+[testenv]
61+setenv = VIRTUAL_ENV={envdir}
62+ PYTHONHASHSEED=0
63+install_command =
64+ pip install --allow-unverified python-apt {opts} {packages}
65+commands = ostestr {posargs}
66+
67+[testenv:py27]
68+basepython = python2.7
69+deps = -r{toxinidir}/requirements.txt
70+ -r{toxinidir}/test-requirements.txt
71+
72+[testenv:lint]
73+basepython = python2.7
74+deps = -r{toxinidir}/requirements.txt
75+ -r{toxinidir}/test-requirements.txt
76+commands = flake8 {posargs} hooks unit_tests tests actions
77+ charm proof
78+
79+[testenv:venv]
80+commands = {posargs}
81+
82+[flake8]
83+ignore = E402,E226
84+exclude = hooks/charmhelpers
85
86=== modified file 'unit_tests/test_actions_git_reinstall.py'
87--- unit_tests/test_actions_git_reinstall.py 2015-04-15 16:26:17 +0000
88+++ unit_tests/test_actions_git_reinstall.py 2015-11-03 11:00:52 +0000
89@@ -1,25 +1,14 @@
90-from mock import patch, MagicMock
91+from mock import patch
92 import os
93
94 os.environ['JUJU_UNIT_NAME'] = 'cinder'
95
96 from test_utils import RESTART_MAP
97-import cinder_utils as utils
98-
99-# Need to do some early patching to get the module loaded.
100-_restart_map = utils.restart_map
101-_register_configs = utils.register_configs
102-
103-utils.restart_map = MagicMock()
104-utils.restart_map.return_value = RESTART_MAP
105-utils.register_configs = MagicMock()
106-
107-import git_reinstall
108-
109-# Unpatch it now that its loaded.
110-utils.restart_map = _restart_map
111-utils.register_configs = _register_configs
112-
113+
114+with patch('cinder_utils.register_configs') as register_configs:
115+ with patch('cinder_utils.restart_map') as restart_map:
116+ restart_map.return_value = RESTART_MAP
117+ import git_reinstall
118
119 from test_utils import (
120 CharmTestCase
121
122=== modified file 'unit_tests/test_actions_openstack_upgrade.py'
123--- unit_tests/test_actions_openstack_upgrade.py 2015-09-22 21:03:02 +0000
124+++ unit_tests/test_actions_openstack_upgrade.py 2015-11-03 11:00:52 +0000
125@@ -3,13 +3,16 @@
126
127 os.environ['JUJU_UNIT_NAME'] = 'cinder'
128
129-with patch('cinder_utils.register_configs') as register_configs:
130- import openstack_upgrade
131-
132 from test_utils import (
133- CharmTestCase
134+ CharmTestCase,
135+ RESTART_MAP
136 )
137
138+with patch('cinder_utils.register_configs') as register_configs:
139+ with patch('cinder_utils.restart_map') as restart_map:
140+ restart_map.return_value = RESTART_MAP
141+ import openstack_upgrade
142+
143 TO_PATCH = [
144 'config_changed',
145 'do_openstack_upgrade',
146
147=== modified file 'unit_tests/test_cinder_hooks.py'
148--- unit_tests/test_cinder_hooks.py 2015-09-12 06:32:34 +0000
149+++ unit_tests/test_cinder_hooks.py 2015-11-03 11:00:52 +0000
150@@ -6,28 +6,18 @@
151 )
152 import yaml
153
154-import cinder_utils as utils
155 from test_utils import (
156 CharmTestCase,
157- RESTART_MAP
158+ RESTART_MAP,
159 )
160
161-# Need to do some early patching to get the module loaded.
162-_restart_map = utils.restart_map
163-_register_configs = utils.register_configs
164-
165-utils.restart_map = MagicMock()
166-utils.restart_map.return_value = RESTART_MAP
167-utils.register_configs = MagicMock()
168-
169-import cinder_hooks as hooks
170-hooks.hooks._config_save = False
171-
172-hooks.hooks._config_save = False
173-
174-# Unpatch it now that its loaded.
175-utils.restart_map = _restart_map
176-utils.register_configs = _register_configs
177+with patch('cinder_utils.register_configs') as register_configs:
178+ with patch('cinder_utils.restart_map') as restart_map:
179+ restart_map.return_value = RESTART_MAP
180+ import cinder_hooks as hooks
181+
182+hooks.hooks._config_save = False
183+import cinder_utils as utils
184
185 TO_PATCH = [
186 'check_call',
187@@ -366,9 +356,10 @@
188 self.CONFIGS.complete_contexts.return_value = ['https']
189 self.relation_ids.return_value = ['identity-service:0']
190 hooks.configure_https()
191- calls = [call('a2dissite', 'openstack_https_frontend'),
192- call('service', 'apache2', 'reload')]
193- self.check_call.assert_called_has_calls(calls)
194+ self.check_call.assert_called_with(['a2ensite',
195+ 'openstack_https_frontend'])
196+ self.service_reload.assert_called_with('apache2',
197+ restart_on_failure=True)
198 identity_joined.assert_called_with(rid='identity-service:0')
199
200 @patch.object(hooks, 'identity_joined')
201@@ -377,9 +368,10 @@
202 self.CONFIGS.complete_contexts.return_value = []
203 self.relation_ids.return_value = ['identity-service:0']
204 hooks.configure_https()
205- calls = [call('a2dissite', 'openstack_https_frontend'),
206- call('service', 'apache2', 'reload')]
207- self.check_call.assert_called_has_calls(calls)
208+ self.check_call.assert_called_with(['a2dissite',
209+ 'openstack_https_frontend'])
210+ self.service_reload.assert_called_with('apache2',
211+ restart_on_failure=True)
212 identity_joined.assert_called_with(rid='identity-service:0')
213
214 def test_image_service_changed(self):
215@@ -425,7 +417,7 @@
216 self.test_config.set('prefer-ipv6', True)
217 self.test_config.set('vip', 'dummy_vip')
218 hooks.hooks.execute(['hooks/shared-db-relation-joined'])
219- self.sync_db_with_multi_ipv6_addresses.assert_called_with_once(
220+ self.sync_db_with_multi_ipv6_addresses.assert_called_with(
221 'cinder', 'cinder')
222
223 def test_db_joined_with_postgresql(self):
224
225=== modified file 'unit_tests/test_cluster_hooks.py'
226--- unit_tests/test_cluster_hooks.py 2015-06-19 16:29:55 +0000
227+++ unit_tests/test_cluster_hooks.py 2015-11-03 11:00:52 +0000
228@@ -1,28 +1,20 @@
229 import os
230-from mock import MagicMock, patch, call
231-
232-os.environ['JUJU_UNIT_NAME'] = 'cinder'
233-import cinder_utils as utils
234-
235-# Need to do some early patching to get the module loaded.
236-# _restart_map = utils.restart_map
237-_register_configs = utils.register_configs
238-_service_enabled = utils.service_enabled
239-utils.register_configs = MagicMock()
240-utils.service_enabled = MagicMock()
241-
242-import cinder_hooks as hooks
243-hooks.hooks._config_save = False
244-
245-# Unpatch it now that its loaded.
246-utils.register_configs = _register_configs
247-utils.service_enabled = _service_enabled
248+from mock import patch, call
249
250 from test_utils import (
251 CharmTestCase,
252 RESTART_MAP,
253 )
254
255+os.environ['JUJU_UNIT_NAME'] = 'cinder'
256+
257+with patch('cinder_utils.register_configs') as register_configs:
258+ with patch('cinder_utils.restart_map') as restart_map:
259+ restart_map.return_value = RESTART_MAP
260+ import cinder_hooks as hooks
261+
262+hooks.hooks._config_save = False
263+
264 TO_PATCH = [
265 # cinder_utils
266 'determine_packages',

Subscribers

People subscribed via source and target branches