Merge lp:~adam-collard/charms/trusty/swift-proxy/lib-in-python-package into lp:~openstack-charmers-archive/charms/trusty/swift-proxy/next
- Trusty Tahr (14.04)
- lib-in-python-package
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 107 |
Proposed branch: | lp:~adam-collard/charms/trusty/swift-proxy/lib-in-python-package |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/swift-proxy/next |
Diff against target: |
396 lines (+120/-52) 13 files modified
.coveragerc (+1/-0) Makefile (+3/-3) charm-helpers-hooks.yaml (+1/-1) charmhelpers/contrib/openstack/utils.py (+4/-0) charmhelpers/contrib/storage/linux/ceph.py (+2/-11) charmhelpers/core/kernel.py (+68/-0) hooks/swift_hooks.py (+1/-1) lib/swift_context.py (+7/-1) setup.cfg (+1/-1) unit_tests/__init__.py (+0/-2) unit_tests/test_swift_context.py (+7/-7) unit_tests/test_swift_hooks.py (+2/-1) unit_tests/test_swift_utils.py (+23/-24) |
To merge this branch: | bzr merge lp:~adam-collard/charms/trusty/swift-proxy/lib-in-python-package |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Glass (community) | Approve | ||
Landscape | Pending | ||
Review via email: mp+270304@code.launchpad.net |
Commit message
Description of the change
With the addition of actions to the OpenStack charms, there's a need to share code between actions and hooks. This branch moves library code to a top-level ./lib/ and then symlinks that into ./hooks/lib, likewise for charm-helpers.
This should be a plain refactor with no change in behaviour, but laying the ground for an actions/lib symlink and an actions/
(see https:/
- 110. By Adam Collard
-
Add explanatory comment
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #8781 swift-proxy-next for adam-collard mp270304
UNIT OK: passed
Chris Glass (tribaal) wrote : | # |
I think this looks good, small comment inline.
- 111. By Adam Collard
-
Add missing @property (tribaal's review)
Adam Collard (adam-collard) : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6311 swift-proxy-next for adam-collard mp270304
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
Preview Diff
1 | === modified file '.coveragerc' | |||
2 | --- .coveragerc 2013-11-18 11:16:28 +0000 | |||
3 | +++ .coveragerc 2015-09-07 14:15:28 +0000 | |||
4 | @@ -4,3 +4,4 @@ | |||
5 | 4 | if __name__ == .__main__.: | 4 | if __name__ == .__main__.: |
6 | 5 | include= | 5 | include= |
7 | 6 | hooks/swift_* | 6 | hooks/swift_* |
8 | 7 | lib/swift_* | ||
9 | 7 | 8 | ||
10 | === modified file 'Makefile' | |||
11 | --- Makefile 2015-04-16 21:32:07 +0000 | |||
12 | +++ Makefile 2015-09-07 14:15:28 +0000 | |||
13 | @@ -1,9 +1,7 @@ | |||
14 | 1 | #!/usr/bin/make | ||
15 | 2 | PYTHON := /usr/bin/env python | 1 | PYTHON := /usr/bin/env python |
16 | 3 | 2 | ||
17 | 4 | lint: | 3 | lint: |
20 | 5 | @flake8 --exclude hooks/charmhelpers --ignore=E125 hooks | 4 | @flake8 --exclude hooks unit_tests tests lib |
19 | 6 | @flake8 --exclude hooks/charmhelpers --ignore=E125 unit_tests tests | ||
21 | 7 | @charm proof | 5 | @charm proof |
22 | 8 | 6 | ||
23 | 9 | unit_test: | 7 | unit_test: |
24 | @@ -29,3 +27,5 @@ | |||
25 | 29 | publish: lint unit_test | 27 | publish: lint unit_test |
26 | 30 | bzr push lp:charms/swift-proxy | 28 | bzr push lp:charms/swift-proxy |
27 | 31 | bzr push lp:charms/trusty/swift-proxy | 29 | bzr push lp:charms/trusty/swift-proxy |
28 | 30 | |||
29 | 31 | .PHONY: lint unit_test test sync publish | ||
30 | 32 | 32 | ||
31 | === modified file 'charm-helpers-hooks.yaml' | |||
32 | --- charm-helpers-hooks.yaml 2015-07-31 13:11:02 +0000 | |||
33 | +++ charm-helpers-hooks.yaml 2015-09-07 14:15:28 +0000 | |||
34 | @@ -1,5 +1,5 @@ | |||
35 | 1 | branch: lp:charm-helpers | 1 | branch: lp:charm-helpers |
37 | 2 | destination: hooks/charmhelpers | 2 | destination: charmhelpers |
38 | 3 | include: | 3 | include: |
39 | 4 | - core | 4 | - core |
40 | 5 | - cli | 5 | - cli |
41 | 6 | 6 | ||
42 | === renamed directory 'hooks/charmhelpers' => 'charmhelpers' | |||
43 | === modified file 'charmhelpers/contrib/openstack/utils.py' | |||
44 | --- hooks/charmhelpers/contrib/openstack/utils.py 2015-09-03 09:41:22 +0000 | |||
45 | +++ charmhelpers/contrib/openstack/utils.py 2015-09-07 14:15:28 +0000 | |||
46 | @@ -114,6 +114,7 @@ | |||
47 | 114 | ('2.2.1', 'kilo'), | 114 | ('2.2.1', 'kilo'), |
48 | 115 | ('2.2.2', 'kilo'), | 115 | ('2.2.2', 'kilo'), |
49 | 116 | ('2.3.0', 'liberty'), | 116 | ('2.3.0', 'liberty'), |
50 | 117 | ('2.4.0', 'liberty'), | ||
51 | 117 | ]) | 118 | ]) |
52 | 118 | 119 | ||
53 | 119 | # >= Liberty version->codename mapping | 120 | # >= Liberty version->codename mapping |
54 | @@ -142,6 +143,9 @@ | |||
55 | 142 | 'glance-common': OrderedDict([ | 143 | 'glance-common': OrderedDict([ |
56 | 143 | ('11.0.0', 'liberty'), | 144 | ('11.0.0', 'liberty'), |
57 | 144 | ]), | 145 | ]), |
58 | 146 | 'openstack-dashboard': OrderedDict([ | ||
59 | 147 | ('8.0.0', 'liberty'), | ||
60 | 148 | ]), | ||
61 | 145 | } | 149 | } |
62 | 146 | 150 | ||
63 | 147 | DEFAULT_LOOPBACK_SIZE = '5G' | 151 | DEFAULT_LOOPBACK_SIZE = '5G' |
64 | 148 | 152 | ||
65 | === modified file 'charmhelpers/contrib/storage/linux/ceph.py' | |||
66 | --- hooks/charmhelpers/contrib/storage/linux/ceph.py 2015-07-29 10:47:50 +0000 | |||
67 | +++ charmhelpers/contrib/storage/linux/ceph.py 2015-09-07 14:15:28 +0000 | |||
68 | @@ -56,6 +56,8 @@ | |||
69 | 56 | apt_install, | 56 | apt_install, |
70 | 57 | ) | 57 | ) |
71 | 58 | 58 | ||
72 | 59 | from charmhelpers.core.kernel import modprobe | ||
73 | 60 | |||
74 | 59 | KEYRING = '/etc/ceph/ceph.client.{}.keyring' | 61 | KEYRING = '/etc/ceph/ceph.client.{}.keyring' |
75 | 60 | KEYFILE = '/etc/ceph/ceph.client.{}.key' | 62 | KEYFILE = '/etc/ceph/ceph.client.{}.key' |
76 | 61 | 63 | ||
77 | @@ -288,17 +290,6 @@ | |||
78 | 288 | os.chown(data_src_dst, uid, gid) | 290 | os.chown(data_src_dst, uid, gid) |
79 | 289 | 291 | ||
80 | 290 | 292 | ||
81 | 291 | # TODO: re-use | ||
82 | 292 | def modprobe(module): | ||
83 | 293 | """Load a kernel module and configure for auto-load on reboot.""" | ||
84 | 294 | log('Loading kernel module', level=INFO) | ||
85 | 295 | cmd = ['modprobe', module] | ||
86 | 296 | check_call(cmd) | ||
87 | 297 | with open('/etc/modules', 'r+') as modules: | ||
88 | 298 | if module not in modules.read(): | ||
89 | 299 | modules.write(module) | ||
90 | 300 | |||
91 | 301 | |||
92 | 302 | def copy_files(src, dst, symlinks=False, ignore=None): | 293 | def copy_files(src, dst, symlinks=False, ignore=None): |
93 | 303 | """Copy files from src to dst.""" | 294 | """Copy files from src to dst.""" |
94 | 304 | for item in os.listdir(src): | 295 | for item in os.listdir(src): |
95 | 305 | 296 | ||
96 | === added file 'charmhelpers/core/kernel.py' | |||
97 | --- charmhelpers/core/kernel.py 1970-01-01 00:00:00 +0000 | |||
98 | +++ charmhelpers/core/kernel.py 2015-09-07 14:15:28 +0000 | |||
99 | @@ -0,0 +1,68 @@ | |||
100 | 1 | #!/usr/bin/env python | ||
101 | 2 | # -*- coding: utf-8 -*- | ||
102 | 3 | |||
103 | 4 | # Copyright 2014-2015 Canonical Limited. | ||
104 | 5 | # | ||
105 | 6 | # This file is part of charm-helpers. | ||
106 | 7 | # | ||
107 | 8 | # charm-helpers is free software: you can redistribute it and/or modify | ||
108 | 9 | # it under the terms of the GNU Lesser General Public License version 3 as | ||
109 | 10 | # published by the Free Software Foundation. | ||
110 | 11 | # | ||
111 | 12 | # charm-helpers is distributed in the hope that it will be useful, | ||
112 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
113 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
114 | 15 | # GNU Lesser General Public License for more details. | ||
115 | 16 | # | ||
116 | 17 | # You should have received a copy of the GNU Lesser General Public License | ||
117 | 18 | # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. | ||
118 | 19 | |||
119 | 20 | __author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>" | ||
120 | 21 | |||
121 | 22 | from charmhelpers.core.hookenv import ( | ||
122 | 23 | log, | ||
123 | 24 | INFO | ||
124 | 25 | ) | ||
125 | 26 | |||
126 | 27 | from subprocess import check_call, check_output | ||
127 | 28 | import re | ||
128 | 29 | |||
129 | 30 | |||
130 | 31 | def modprobe(module, persist=True): | ||
131 | 32 | """Load a kernel module and configure for auto-load on reboot.""" | ||
132 | 33 | cmd = ['modprobe', module] | ||
133 | 34 | |||
134 | 35 | log('Loading kernel module %s' % module, level=INFO) | ||
135 | 36 | |||
136 | 37 | check_call(cmd) | ||
137 | 38 | if persist: | ||
138 | 39 | with open('/etc/modules', 'r+') as modules: | ||
139 | 40 | if module not in modules.read(): | ||
140 | 41 | modules.write(module) | ||
141 | 42 | |||
142 | 43 | |||
143 | 44 | def rmmod(module, force=False): | ||
144 | 45 | """Remove a module from the linux kernel""" | ||
145 | 46 | cmd = ['rmmod'] | ||
146 | 47 | if force: | ||
147 | 48 | cmd.append('-f') | ||
148 | 49 | cmd.append(module) | ||
149 | 50 | log('Removing kernel module %s' % module, level=INFO) | ||
150 | 51 | return check_call(cmd) | ||
151 | 52 | |||
152 | 53 | |||
153 | 54 | def lsmod(): | ||
154 | 55 | """Shows what kernel modules are currently loaded""" | ||
155 | 56 | return check_output(['lsmod'], | ||
156 | 57 | universal_newlines=True) | ||
157 | 58 | |||
158 | 59 | |||
159 | 60 | def is_module_loaded(module): | ||
160 | 61 | """Checks if a kernel module is already loaded""" | ||
161 | 62 | matches = re.findall('^%s[ ]+' % module, lsmod(), re.M) | ||
162 | 63 | return len(matches) > 0 | ||
163 | 64 | |||
164 | 65 | |||
165 | 66 | def update_initramfs(version='all'): | ||
166 | 67 | """Updates an initramfs image""" | ||
167 | 68 | return check_call(["update-initramfs", "-k", version, "-u"]) | ||
168 | 0 | 69 | ||
169 | === modified file 'hooks/swift_hooks.py' | |||
170 | --- hooks/swift_hooks.py 2015-05-11 08:04:17 +0000 | |||
171 | +++ hooks/swift_hooks.py 2015-09-07 14:15:28 +0000 | |||
172 | @@ -8,7 +8,7 @@ | |||
173 | 8 | CalledProcessError, | 8 | CalledProcessError, |
174 | 9 | ) | 9 | ) |
175 | 10 | 10 | ||
177 | 11 | from swift_utils import ( | 11 | from lib.swift_utils import ( |
178 | 12 | SwiftProxyCharmException, | 12 | SwiftProxyCharmException, |
179 | 13 | register_configs, | 13 | register_configs, |
180 | 14 | restart_map, | 14 | restart_map, |
181 | 15 | 15 | ||
182 | === added directory 'lib' | |||
183 | === added file 'lib/__init__.py' | |||
184 | === renamed file 'hooks/swift_context.py' => 'lib/swift_context.py' | |||
185 | --- hooks/swift_context.py 2015-04-13 22:57:02 +0000 | |||
186 | +++ lib/swift_context.py 2015-09-07 14:15:28 +0000 | |||
187 | @@ -50,9 +50,15 @@ | |||
188 | 50 | 50 | ||
189 | 51 | class ApacheSSLContext(SSLContext): | 51 | class ApacheSSLContext(SSLContext): |
190 | 52 | interfaces = ['https'] | 52 | interfaces = ['https'] |
191 | 53 | external_ports = [config('bind-port')] | ||
192 | 54 | service_namespace = 'swift' | 53 | service_namespace = 'swift' |
193 | 55 | 54 | ||
194 | 55 | # We make this a property so that we avoid import-time | ||
195 | 56 | # dependencies on config() | ||
196 | 57 | |||
197 | 58 | @property | ||
198 | 59 | def external_ports(self): | ||
199 | 60 | return [config('bind-port')] | ||
200 | 61 | |||
201 | 56 | 62 | ||
202 | 57 | class SwiftRingContext(OSContextGenerator): | 63 | class SwiftRingContext(OSContextGenerator): |
203 | 58 | 64 | ||
204 | 59 | 65 | ||
205 | === renamed file 'hooks/swift_utils.py' => 'lib/swift_utils.py' | |||
206 | === modified file 'setup.cfg' | |||
207 | --- setup.cfg 2013-11-18 11:16:28 +0000 | |||
208 | +++ setup.cfg 2015-09-07 14:15:28 +0000 | |||
209 | @@ -2,4 +2,4 @@ | |||
210 | 2 | verbosity=1 | 2 | verbosity=1 |
211 | 3 | with-coverage=1 | 3 | with-coverage=1 |
212 | 4 | cover-erase=1 | 4 | cover-erase=1 |
214 | 5 | cover-package=hooks | 5 | cover-package=lib,swift_hooks |
215 | 6 | 6 | ||
216 | === modified file 'unit_tests/__init__.py' | |||
217 | --- unit_tests/__init__.py 2013-11-18 11:16:28 +0000 | |||
218 | +++ unit_tests/__init__.py 2015-09-07 14:15:28 +0000 | |||
219 | @@ -1,2 +0,0 @@ | |||
220 | 1 | import sys | ||
221 | 2 | sys.path.append('hooks') | ||
222 | 3 | 0 | ||
223 | === modified file 'unit_tests/test_swift_context.py' | |||
224 | --- unit_tests/test_swift_context.py 2014-12-01 23:54:03 +0000 | |||
225 | +++ unit_tests/test_swift_context.py 2015-09-07 14:15:28 +0000 | |||
226 | @@ -6,12 +6,12 @@ | |||
227 | 6 | 6 | ||
228 | 7 | 7 | ||
229 | 8 | with mock.patch('charmhelpers.core.hookenv.config'): | 8 | with mock.patch('charmhelpers.core.hookenv.config'): |
231 | 9 | import swift_context | 9 | import lib.swift_context as swift_context |
232 | 10 | 10 | ||
233 | 11 | 11 | ||
234 | 12 | class SwiftContextTestCase(unittest.TestCase): | 12 | class SwiftContextTestCase(unittest.TestCase): |
235 | 13 | 13 | ||
237 | 14 | @mock.patch('swift_context.config') | 14 | @mock.patch('lib.swift_context.config') |
238 | 15 | def test_get_swift_hash_file(self, mock_config): | 15 | def test_get_swift_hash_file(self, mock_config): |
239 | 16 | expected = '##FILEHASH##' | 16 | expected = '##FILEHASH##' |
240 | 17 | with tempfile.NamedTemporaryFile() as tmpfile: | 17 | with tempfile.NamedTemporaryFile() as tmpfile: |
241 | @@ -24,7 +24,7 @@ | |||
242 | 24 | self.assertFalse(mock_config.called) | 24 | self.assertFalse(mock_config.called) |
243 | 25 | self.assertEqual(expected, hash) | 25 | self.assertEqual(expected, hash) |
244 | 26 | 26 | ||
246 | 27 | @mock.patch('swift_context.config') | 27 | @mock.patch('lib.swift_context.config') |
247 | 28 | def test_get_swift_hash_config(self, mock_config): | 28 | def test_get_swift_hash_config(self, mock_config): |
248 | 29 | expected = '##CFGHASH##' | 29 | expected = '##CFGHASH##' |
249 | 30 | mock_config.return_value = expected | 30 | mock_config.return_value = expected |
250 | @@ -38,8 +38,8 @@ | |||
251 | 38 | self.assertTrue(mock_config.called) | 38 | self.assertTrue(mock_config.called) |
252 | 39 | self.assertEqual(expected, hash) | 39 | self.assertEqual(expected, hash) |
253 | 40 | 40 | ||
256 | 41 | @mock.patch('swift_context.service_name') | 41 | @mock.patch('lib.swift_context.service_name') |
257 | 42 | @mock.patch('swift_context.config') | 42 | @mock.patch('lib.swift_context.config') |
258 | 43 | def test_get_swift_hash_env(self, mock_config, mock_service_name): | 43 | def test_get_swift_hash_env(self, mock_config, mock_service_name): |
259 | 44 | mock_config.return_value = None | 44 | mock_config.return_value = None |
260 | 45 | mock_service_name.return_value = "testsvc" | 45 | mock_service_name.return_value = "testsvc" |
261 | @@ -47,10 +47,10 @@ | |||
262 | 47 | swift_context.SWIFT_HASH_FILE = tmpfile | 47 | swift_context.SWIFT_HASH_FILE = tmpfile |
263 | 48 | with mock.patch('swift_context.os.environ.get') as mock_env_get: | 48 | with mock.patch('swift_context.os.environ.get') as mock_env_get: |
264 | 49 | mock_env_get.return_value = str(uuid.uuid4()) | 49 | mock_env_get.return_value = str(uuid.uuid4()) |
266 | 50 | hash = swift_context.get_swift_hash() | 50 | hash_ = swift_context.get_swift_hash() |
267 | 51 | mock_env_get.assert_called_with('JUJU_ENV_UUID') | 51 | mock_env_get.assert_called_with('JUJU_ENV_UUID') |
268 | 52 | 52 | ||
269 | 53 | with open(tmpfile, 'r') as fd: | 53 | with open(tmpfile, 'r') as fd: |
271 | 54 | self.assertEqual(hash, fd.read()) | 54 | self.assertEqual(hash_, fd.read()) |
272 | 55 | 55 | ||
273 | 56 | self.assertTrue(mock_config.called) | 56 | self.assertTrue(mock_config.called) |
274 | 57 | 57 | ||
275 | === modified file 'unit_tests/test_swift_hooks.py' | |||
276 | --- unit_tests/test_swift_hooks.py 2015-06-11 23:22:54 +0000 | |||
277 | +++ unit_tests/test_swift_hooks.py 2015-09-07 14:15:28 +0000 | |||
278 | @@ -1,8 +1,9 @@ | |||
279 | 1 | from mock import patch | 1 | from mock import patch |
280 | 2 | import sys | ||
281 | 2 | import unittest | 3 | import unittest |
282 | 3 | import uuid | 4 | import uuid |
283 | 4 | 5 | ||
285 | 5 | 6 | sys.path.append("hooks") | |
286 | 6 | with patch('charmhelpers.core.hookenv.log'): | 7 | with patch('charmhelpers.core.hookenv.log'): |
287 | 7 | import swift_hooks | 8 | import swift_hooks |
288 | 8 | 9 | ||
289 | 9 | 10 | ||
290 | === modified file 'unit_tests/test_swift_utils.py' | |||
291 | --- unit_tests/test_swift_utils.py 2014-12-18 11:58:28 +0000 | |||
292 | +++ unit_tests/test_swift_utils.py 2015-09-07 14:15:28 +0000 | |||
293 | @@ -5,9 +5,8 @@ | |||
294 | 5 | import uuid | 5 | import uuid |
295 | 6 | import unittest | 6 | import unittest |
296 | 7 | 7 | ||
297 | 8 | |||
298 | 9 | with mock.patch('charmhelpers.core.hookenv.config'): | 8 | with mock.patch('charmhelpers.core.hookenv.config'): |
300 | 10 | import swift_utils | 9 | import lib.swift_utils as swift_utils |
301 | 11 | 10 | ||
302 | 12 | 11 | ||
303 | 13 | def init_ring_paths(tmpdir): | 12 | def init_ring_paths(tmpdir): |
304 | @@ -21,16 +20,16 @@ | |||
305 | 21 | 20 | ||
306 | 22 | class SwiftUtilsTestCase(unittest.TestCase): | 21 | class SwiftUtilsTestCase(unittest.TestCase): |
307 | 23 | 22 | ||
318 | 24 | @mock.patch('swift_utils.get_broker_token') | 23 | @mock.patch('lib.swift_utils.get_broker_token') |
319 | 25 | @mock.patch('swift_utils.update_www_rings') | 24 | @mock.patch('lib.swift_utils.update_www_rings') |
320 | 26 | @mock.patch('swift_utils.get_builders_checksum') | 25 | @mock.patch('lib.swift_utils.get_builders_checksum') |
321 | 27 | @mock.patch('swift_utils.get_rings_checksum') | 26 | @mock.patch('lib.swift_utils.get_rings_checksum') |
322 | 28 | @mock.patch('swift_utils.balance_rings') | 27 | @mock.patch('lib.swift_utils.balance_rings') |
323 | 29 | @mock.patch('swift_utils.log') | 28 | @mock.patch('lib.swift_utils.log') |
324 | 30 | @mock.patch('swift_utils.os.path.exists') | 29 | @mock.patch('lib.swift_utils.os.path.exists') |
325 | 31 | @mock.patch('swift_utils.is_elected_leader') | 30 | @mock.patch('lib.swift_utils.is_elected_leader') |
326 | 32 | @mock.patch('swift_utils.get_min_part_hours') | 31 | @mock.patch('lib.swift_utils.get_min_part_hours') |
327 | 33 | @mock.patch('swift_utils.set_min_part_hours') | 32 | @mock.patch('lib.swift_utils.set_min_part_hours') |
328 | 34 | def test_update_rings(self, mock_set_min_hours, | 33 | def test_update_rings(self, mock_set_min_hours, |
329 | 35 | mock_get_min_hours, | 34 | mock_get_min_hours, |
330 | 36 | mock_is_elected_leader, mock_path_exists, | 35 | mock_is_elected_leader, mock_path_exists, |
331 | @@ -76,13 +75,13 @@ | |||
332 | 76 | self.assertTrue(mock_set_min_hours.called) | 75 | self.assertTrue(mock_set_min_hours.called) |
333 | 77 | self.assertTrue(mock_balance_rings.called) | 76 | self.assertTrue(mock_balance_rings.called) |
334 | 78 | 77 | ||
342 | 79 | @mock.patch('swift_utils.get_broker_token') | 78 | @mock.patch('lib.swift_utils.get_broker_token') |
343 | 80 | @mock.patch('swift_utils.balance_rings') | 79 | @mock.patch('lib.swift_utils.balance_rings') |
344 | 81 | @mock.patch('swift_utils.log') | 80 | @mock.patch('lib.swift_utils.log') |
345 | 82 | @mock.patch('swift_utils.is_elected_leader') | 81 | @mock.patch('lib.swift_utils.is_elected_leader') |
346 | 83 | @mock.patch('swift_utils.config') | 82 | @mock.patch('lib.swift_utils.config') |
347 | 84 | @mock.patch('swift_utils.update_www_rings') | 83 | @mock.patch('lib.swift_utils.update_www_rings') |
348 | 85 | @mock.patch('swift_utils.cluster_sync_rings') | 84 | @mock.patch('lib.swift_utils.cluster_sync_rings') |
349 | 86 | def test_sync_builders_and_rings_if_changed(self, mock_cluster_sync_rings, | 85 | def test_sync_builders_and_rings_if_changed(self, mock_cluster_sync_rings, |
350 | 87 | mock_update_www_rings, | 86 | mock_update_www_rings, |
351 | 88 | mock_config, | 87 | mock_config, |
352 | @@ -114,7 +113,7 @@ | |||
353 | 114 | self.assertTrue(mock_update_www_rings.called) | 113 | self.assertTrue(mock_update_www_rings.called) |
354 | 115 | self.assertTrue(mock_cluster_sync_rings.called) | 114 | self.assertTrue(mock_cluster_sync_rings.called) |
355 | 116 | 115 | ||
357 | 117 | @mock.patch('swift_utils.get_www_dir') | 116 | @mock.patch('lib.swift_utils.get_www_dir') |
358 | 118 | def test_mark_www_rings_deleted(self, mock_get_www_dir): | 117 | def test_mark_www_rings_deleted(self, mock_get_www_dir): |
359 | 119 | try: | 118 | try: |
360 | 120 | tmpdir = tempfile.mkdtemp() | 119 | tmpdir = tempfile.mkdtemp() |
361 | @@ -123,7 +122,7 @@ | |||
362 | 123 | finally: | 122 | finally: |
363 | 124 | shutil.rmtree(tmpdir) | 123 | shutil.rmtree(tmpdir) |
364 | 125 | 124 | ||
366 | 126 | @mock.patch('swift_utils.uuid') | 125 | @mock.patch('lib.swift_utils.uuid') |
367 | 127 | def test_cluster_rpc_stop_proxy_request(self, mock_uuid): | 126 | def test_cluster_rpc_stop_proxy_request(self, mock_uuid): |
368 | 128 | mock_uuid.uuid4.return_value = 'test-uuid' | 127 | mock_uuid.uuid4.return_value = 'test-uuid' |
369 | 129 | rpc = swift_utils.SwiftProxyClusterRPC() | 128 | rpc = swift_utils.SwiftProxyClusterRPC() |
370 | @@ -147,7 +146,7 @@ | |||
371 | 147 | 'stop-proxy-service-ack': None, | 146 | 'stop-proxy-service-ack': None, |
372 | 148 | 'sync-only-builders': None}, rq) | 147 | 'sync-only-builders': None}, rq) |
373 | 149 | 148 | ||
375 | 150 | @mock.patch('swift_utils.uuid') | 149 | @mock.patch('lib.swift_utils.uuid') |
376 | 151 | def test_cluster_rpc_stop_proxy_ack(self, mock_uuid): | 150 | def test_cluster_rpc_stop_proxy_ack(self, mock_uuid): |
377 | 152 | mock_uuid.uuid4.return_value = 'token2' | 151 | mock_uuid.uuid4.return_value = 'token2' |
378 | 153 | rpc = swift_utils.SwiftProxyClusterRPC() | 152 | rpc = swift_utils.SwiftProxyClusterRPC() |
379 | @@ -161,7 +160,7 @@ | |||
380 | 161 | 'stop-proxy-service-ack': 'token1', | 160 | 'stop-proxy-service-ack': 'token1', |
381 | 162 | 'sync-only-builders': None}, rq) | 161 | 'sync-only-builders': None}, rq) |
382 | 163 | 162 | ||
384 | 164 | @mock.patch('swift_utils.uuid') | 163 | @mock.patch('lib.swift_utils.uuid') |
385 | 165 | def test_cluster_rpc_sync_request(self, mock_uuid): | 164 | def test_cluster_rpc_sync_request(self, mock_uuid): |
386 | 166 | mock_uuid.uuid4.return_value = 'token2' | 165 | mock_uuid.uuid4.return_value = 'token2' |
387 | 167 | rpc = swift_utils.SwiftProxyClusterRPC() | 166 | rpc = swift_utils.SwiftProxyClusterRPC() |
388 | @@ -175,7 +174,7 @@ | |||
389 | 175 | 'stop-proxy-service-ack': None, | 174 | 'stop-proxy-service-ack': None, |
390 | 176 | 'sync-only-builders': None}, rq) | 175 | 'sync-only-builders': None}, rq) |
391 | 177 | 176 | ||
393 | 178 | @mock.patch('swift_utils.uuid') | 177 | @mock.patch('lib.swift_utils.uuid') |
394 | 179 | def test_cluster_rpc_notify_leader_changed(self, mock_uuid): | 178 | def test_cluster_rpc_notify_leader_changed(self, mock_uuid): |
395 | 180 | mock_uuid.uuid4.return_value = 'token1' | 179 | mock_uuid.uuid4.return_value = 'token1' |
396 | 181 | rpc = swift_utils.SwiftProxyClusterRPC() | 180 | rpc = swift_utils.SwiftProxyClusterRPC() |
charm_lint_check #9540 swift-proxy-next for adam-collard mp270304
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/9540/