diff options
author | gordon chung <gord@live.ca> | 2015-01-20 18:14:51 -0500 |
---|---|---|
committer | gordon chung <gord@live.ca> | 2015-01-20 18:36:18 -0500 |
commit | 5a5dbbbee783e0dbfb089cb36523b1df41b76e72 (patch) | |
tree | 31ccbfef3128e4a651c2900bf1aaf7d6d3f2819e /ceilometermiddleware | |
parent | 2ca24af1fb92c85b6e7bf91a8a4cc5686d59bbc4 (diff) | |
download | ceilometermiddleware-5a5dbbbee783e0dbfb089cb36523b1df41b76e72.tar.gz |
initial checkin
Diffstat (limited to 'ceilometermiddleware')
-rw-r--r-- | ceilometermiddleware/__init__.py | 19 | ||||
-rw-r--r-- | ceilometermiddleware/__init__.pyc | bin | 0 -> 276 bytes | |||
-rw-r--r-- | ceilometermiddleware/swift.py | 225 | ||||
-rw-r--r-- | ceilometermiddleware/swift.pyc | bin | 0 -> 7443 bytes | |||
-rw-r--r-- | ceilometermiddleware/tests/__init__.py | 0 | ||||
-rw-r--r-- | ceilometermiddleware/tests/__init__.pyc | bin | 0 -> 125 bytes | |||
-rw-r--r-- | ceilometermiddleware/tests/base.py | 23 | ||||
-rw-r--r-- | ceilometermiddleware/tests/base.pyc | bin | 0 -> 437 bytes | |||
-rw-r--r-- | ceilometermiddleware/tests/test_swift.py | 330 | ||||
-rw-r--r-- | ceilometermiddleware/tests/test_swift.pyc | bin | 0 -> 14967 bytes |
10 files changed, 597 insertions, 0 deletions
diff --git a/ceilometermiddleware/__init__.py b/ceilometermiddleware/__init__.py new file mode 100644 index 0000000..f5cdc8c --- /dev/null +++ b/ceilometermiddleware/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import pbr.version + + +__version__ = pbr.version.VersionInfo( + 'ceilometermiddleware').version_string() diff --git a/ceilometermiddleware/__init__.pyc b/ceilometermiddleware/__init__.pyc Binary files differnew file mode 100644 index 0000000..1c4892f --- /dev/null +++ b/ceilometermiddleware/__init__.pyc diff --git a/ceilometermiddleware/swift.py b/ceilometermiddleware/swift.py new file mode 100644 index 0000000..8f27a1c --- /dev/null +++ b/ceilometermiddleware/swift.py @@ -0,0 +1,225 @@ +# +# Copyright 2012 eNovance <licensing@enovance.com> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Telemetry Middleware for Swift Proxy + +Configuration: +In /etc/swift/proxy-server.conf on the main pipeline add "ceilometer" just +before "proxy-server" and add the following filter in the file: +.. code-block:: python + [filter:ceilometer] + paste.filter_factory = ceilometermiddleware.swift:R + # Some optional configuration this allow to publish additional metadata + metadata_headers = X-TEST + # Set reseller prefix (defaults to "AUTH_" if not set) + reseller_prefix = AUTH_ +""" +import functools +import logging + +import oslo.messaging +from oslo_config import cfg +from oslo_context import context +from oslo_utils import timeutils +from pycadf import event as cadf_event +from pycadf import measurement as cadf_measurement +from pycadf import metric as cadf_metric +from pycadf import resource as cadf_resource +import six +import six.moves.urllib.parse as urlparse + +_LOG = logging.getLogger(__name__) + + +def _log_and_ignore_error(fn): + @functools.wraps(fn) + def wrapper(*args, **kwargs): + try: + return fn(*args, **kwargs) + except Exception as e: + _LOG.exception('An exception occurred processing ' + 'the API call: %s ', e) + return wrapper + + +class InputProxy(object): + """File-like object that counts bytes read. + + To be swapped in for wsgi.input for accounting purposes. + Borrowed from swift.common.utils. Duplicated here to avoid + dependency on swift package. + """ + def __init__(self, wsgi_input): + self.wsgi_input = wsgi_input + self.bytes_received = 0 + + def read(self, *args, **kwargs): + """Pass read request to the underlying file-like object + + Add bytes read to total. + """ + chunk = self.wsgi_input.read(*args, **kwargs) + self.bytes_received += len(chunk) + return chunk + + def readline(self, *args, **kwargs): + """Pass readline request to the underlying file-like object + + Add bytes read to total. + """ + line = self.wsgi_input.readline(*args, **kwargs) + self.bytes_received += len(line) + return line + + +class Swift(object): + """Swift middleware used for counting requests.""" + + def __init__(self, app, conf): + self._app = app + + self._notifier = oslo.messaging.Notifier( + oslo.messaging.get_transport(cfg.CONF), + publisher_id='ceilometermiddleware') + + self.metadata_headers = [h.strip().replace('-', '_').lower() + for h in conf.get( + "metadata_headers", + "").split(",") if h.strip()] + + self.reseller_prefix = conf.get('reseller_prefix', 'AUTH_') + if self.reseller_prefix and self.reseller_prefix[-1] != '_': + self.reseller_prefix += '_' + + def __call__(self, env, start_response): + start_response_args = [None] + input_proxy = InputProxy(env['wsgi.input']) + env['wsgi.input'] = input_proxy + + def my_start_response(status, headers, exc_info=None): + start_response_args[0] = (status, list(headers), exc_info) + + def iter_response(iterable): + iterator = iter(iterable) + try: + chunk = next(iterator) + while not chunk: + chunk = next(iterator) + except StopIteration: + chunk = '' + + if start_response_args[0]: + start_response(*start_response_args[0]) + bytes_sent = 0 + try: + while chunk: + bytes_sent += len(chunk) + yield chunk + chunk = next(iterator) + finally: + self.emit_event(env, input_proxy.bytes_received, bytes_sent) + + try: + iterable = self._app(env, my_start_response) + except Exception: + self.emit_event(env, input_proxy.bytes_received, 0, 'failure') + raise + else: + return iter_response(iterable) + + @_log_and_ignore_error + def emit_event(self, env, bytes_received, bytes_sent, outcome='success'): + path = urlparse.quote(env['PATH_INFO']) + method = env['REQUEST_METHOD'] + headers = {} + for header in env: + if header.startswith('HTTP_') and env[header]: + key = header[5:] + if isinstance(env[header], six.text_type): + headers[key] = env[header].encode('utf-8') + else: + headers[key] = str(env[header]) + + try: + container = obj = None + version, account, remainder = path.replace( + '/', '', 1).split('/', 2) + if not version or not account: + raise ValueError('Invalid path: %s' % path) + if remainder: + if '/' in remainder: + container, obj = remainder.split('/', 1) + else: + container = remainder + except ValueError: + return + + now = timeutils.utcnow().isoformat() + + resource_metadata = { + "path": path, + "version": version, + "container": container, + "object": obj, + } + + for header in self.metadata_headers: + if header.upper() in headers: + resource_metadata['http_header_%s' % header] = headers.get( + header.upper()) + + # build object store details + target = cadf_resource.Resource( + typeURI='service/storage/object', + id=account.partition(self.reseller_prefix)[2]) + target.metadata = resource_metadata + target.action = method.lower() + + # build user details + initiator = cadf_resource.Resource( + typeURI='service/security/account/user', + id=env.get('HTTP_X_USER_ID')) + initiator.project_id = env.get('HTTP_X_TENANT_ID') + + # build notification body + event = cadf_event.Event(eventTime=now, outcome=outcome, + initiator=initiator, target=target, + observer=cadf_resource.Resource(id='target')) + + # measurements + if bytes_received: + event.add_measurement(cadf_measurement.Measurement( + result=bytes_received, + metric=cadf_metric.Metric( + name='storage.objects.incoming.bytes', unit='B'))) + if bytes_sent: + event.add_measurement(cadf_measurement.Measurement( + result=bytes_sent, + metric=cadf_metric.Metric( + name='storage.objects.outgoing.bytes', unit='B'))) + + self._notifier.info(context.get_admin_context().to_dict(), + 'objectstore.http.request', event.as_dict()) + + +def filter_factory(global_conf, **local_conf): + conf = global_conf.copy() + conf.update(local_conf) + + def filter(app): + return Swift(app, conf) + return filter diff --git a/ceilometermiddleware/swift.pyc b/ceilometermiddleware/swift.pyc Binary files differnew file mode 100644 index 0000000..c8ce92e --- /dev/null +++ b/ceilometermiddleware/swift.pyc diff --git a/ceilometermiddleware/tests/__init__.py b/ceilometermiddleware/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ceilometermiddleware/tests/__init__.py diff --git a/ceilometermiddleware/tests/__init__.pyc b/ceilometermiddleware/tests/__init__.pyc Binary files differnew file mode 100644 index 0000000..3ce97fd --- /dev/null +++ b/ceilometermiddleware/tests/__init__.pyc diff --git a/ceilometermiddleware/tests/base.py b/ceilometermiddleware/tests/base.py new file mode 100644 index 0000000..1c30cdb --- /dev/null +++ b/ceilometermiddleware/tests/base.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +# Copyright 2010-2011 OpenStack Foundation +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslotest import base + + +class TestCase(base.BaseTestCase): + + """Test case base class for all unit tests.""" diff --git a/ceilometermiddleware/tests/base.pyc b/ceilometermiddleware/tests/base.pyc Binary files differnew file mode 100644 index 0000000..28ddfc3 --- /dev/null +++ b/ceilometermiddleware/tests/base.pyc diff --git a/ceilometermiddleware/tests/test_swift.py b/ceilometermiddleware/tests/test_swift.py new file mode 100644 index 0000000..adfd167 --- /dev/null +++ b/ceilometermiddleware/tests/test_swift.py @@ -0,0 +1,330 @@ +# +# Copyright 2012 eNovance <licensing@enovance.com> +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import mock +from oslo_config import cfg +from oslo_utils import timeutils +import six + +from ceilometermiddleware import swift +from ceilometermiddleware.tests import base as tests_base + + +class FakeApp(object): + def __init__(self, body=None): + self.body = body or ['This string is 28 bytes long'] + + def __call__(self, env, start_response): + yield + start_response('200 OK', [ + ('Content-Type', 'text/plain'), + ('Content-Length', str(sum(map(len, self.body)))) + ]) + while env['wsgi.input'].read(5): + pass + for line in self.body: + yield line + + +class FakeRequest(object): + """A bare bones request object + + The middleware will inspect this for request method, + wsgi.input and headers. + """ + + def __init__(self, path, environ=None, headers=None): + environ = environ or {} + headers = headers or {} + + environ['PATH_INFO'] = path + + if 'wsgi.input' not in environ: + environ['wsgi.input'] = six.moves.cStringIO('') + + for header, value in headers.iteritems(): + environ['HTTP_%s' % header.upper()] = value + self.environ = environ + + +@mock.patch('oslo.messaging.get_transport', mock.MagicMock()) +class TestSwift(tests_base.TestCase): + + def setUp(self): + super(TestSwift, self).setUp() + cfg.CONF([], project='ceilometermiddleware') + self.addCleanup(cfg.CONF.reset) + + @staticmethod + def start_response(*args): + pass + + def test_get(self): + app = swift.Swift(FakeApp(), {}) + req = FakeRequest('/1.0/account/container/obj', + environ={'REQUEST_METHOD': 'GET'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + resp = app(req.environ, self.start_response) + self.assertEqual(["This string is 28 bytes long"], list(resp)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual('objectstore.http.request', data[1]) + self.assertEqual(28, data[2]['measurements'][0]['result']) + self.assertEqual('storage.objects.outgoing.bytes', + data[2]['measurements'][0]['metric']['name']) + metadata = data[2]['target']['metadata'] + self.assertEqual('1.0', metadata['version']) + self.assertEqual('container', metadata['container']) + self.assertEqual('obj', metadata['object']) + self.assertEqual('get', data[2]['target']['action']) + + def test_put(self): + app = swift.Swift(FakeApp(body=['']), {}) + req = FakeRequest( + '/1.0/account/container/obj', + environ={'REQUEST_METHOD': 'PUT', + 'wsgi.input': + six.moves.cStringIO('some stuff')}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual('objectstore.http.request', data[1]) + self.assertEqual(10, data[2]['measurements'][0]['result']) + self.assertEqual('storage.objects.incoming.bytes', + data[2]['measurements'][0]['metric']['name']) + metadata = data[2]['target']['metadata'] + self.assertEqual('1.0', metadata['version']) + self.assertEqual('container', metadata['container']) + self.assertEqual('obj', metadata['object']) + self.assertEqual('put', data[2]['target']['action']) + + def test_post(self): + app = swift.Swift(FakeApp(body=['']), {}) + req = FakeRequest( + '/1.0/account/container/obj', + environ={'REQUEST_METHOD': 'POST', + 'wsgi.input': six.moves.cStringIO('some other stuff')}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual('objectstore.http.request', data[1]) + self.assertEqual(16, data[2]['measurements'][0]['result']) + self.assertEqual('storage.objects.incoming.bytes', + data[2]['measurements'][0]['metric']['name']) + metadata = data[2]['target']['metadata'] + self.assertEqual('1.0', metadata['version']) + self.assertEqual('container', metadata['container']) + self.assertEqual('obj', metadata['object']) + self.assertEqual('post', data[2]['target']['action']) + + def test_head(self): + app = swift.Swift(FakeApp(body=['']), {}) + req = FakeRequest('/1.0/account/container/obj', + environ={'REQUEST_METHOD': 'HEAD'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual('objectstore.http.request', data[1]) + self.assertIsNone(data[2].get('measurements')) + metadata = data[2]['target']['metadata'] + self.assertEqual('1.0', metadata['version']) + self.assertEqual('container', metadata['container']) + self.assertEqual('obj', metadata['object']) + self.assertEqual('head', data[2]['target']['action']) + + def test_bogus_request(self): + """Test even for arbitrary request method, this will still work.""" + app = swift.Swift(FakeApp(body=['']), {}) + req = FakeRequest('/1.0/account/container/obj', + environ={'REQUEST_METHOD': 'BOGUS'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual('objectstore.http.request', data[1]) + self.assertIsNone(data[2].get('measurements')) + metadata = data[2]['target']['metadata'] + self.assertEqual('1.0', metadata['version']) + self.assertEqual('container', metadata['container']) + self.assertEqual('obj', metadata['object']) + self.assertEqual('bogus', data[2]['target']['action']) + + def test_get_container(self): + app = swift.Swift(FakeApp(), {}) + req = FakeRequest('/1.0/account/container', + environ={'REQUEST_METHOD': 'GET'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual('objectstore.http.request', data[1]) + self.assertEqual(28, data[2]['measurements'][0]['result']) + self.assertEqual('storage.objects.outgoing.bytes', + data[2]['measurements'][0]['metric']['name']) + metadata = data[2]['target']['metadata'] + self.assertEqual('1.0', metadata['version']) + self.assertEqual('container', metadata['container']) + self.assertIsNone(metadata['object']) + self.assertEqual('get', data[2]['target']['action']) + + def test_no_metadata_headers(self): + app = swift.Swift(FakeApp(), {}) + req = FakeRequest('/1.0/account/container', + environ={'REQUEST_METHOD': 'GET'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual('objectstore.http.request', data[1]) + metadata = data[2]['target']['metadata'] + self.assertEqual('1.0', metadata['version']) + self.assertEqual('container', metadata['container']) + self.assertIsNone(metadata['object']) + self.assertEqual('get', data[2]['target']['action']) + http_headers = [k for k in metadata.keys() + if k.startswith('http_header_')] + self.assertEqual(0, len(http_headers)) + + def test_metadata_headers(self): + app = swift.Swift(FakeApp(), { + 'metadata_headers': 'X_VAR1, x-var2, x-var3, token' + }) + req = FakeRequest('/1.0/account/container', + environ={'REQUEST_METHOD': 'GET'}, + headers={'X_VAR1': 'value1', + 'X_VAR2': 'value2', + 'TOKEN': 'token'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual('objectstore.http.request', data[1]) + metadata = data[2]['target']['metadata'] + self.assertEqual('1.0', metadata['version']) + self.assertEqual('container', metadata['container']) + self.assertIsNone(metadata['object']) + self.assertEqual('get', data[2]['target']['action']) + http_headers = [k for k in metadata.keys() + if k.startswith('http_header_')] + self.assertEqual(3, len(http_headers)) + self.assertEqual('value1', metadata['http_header_x_var1']) + self.assertEqual('value2', metadata['http_header_x_var2']) + self.assertEqual('token', metadata['http_header_token']) + self.assertFalse('http_header_x_var3' in metadata) + + def test_metadata_headers_unicode(self): + app = swift.Swift(FakeApp(), { + 'metadata_headers': 'unicode' + }) + uni = u'\xef\xbd\xa1\xef\xbd\xa5' + req = FakeRequest('/1.0/account/container', + environ={'REQUEST_METHOD': 'GET'}, + headers={'UNICODE': uni}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual('objectstore.http.request', data[1]) + metadata = data[2]['target']['metadata'] + self.assertEqual('1.0', metadata['version']) + self.assertEqual('container', metadata['container']) + self.assertIsNone(metadata['object']) + self.assertEqual('get', data[2]['target']['action']) + http_headers = [k for k in metadata.keys() + if k.startswith('http_header_')] + self.assertEqual(1, len(http_headers)) + self.assertEqual(uni.encode('utf-8'), + metadata['http_header_unicode']) + + def test_metadata_headers_on_not_existing_header(self): + app = swift.Swift(FakeApp(), { + 'metadata_headers': 'x-var3' + }) + req = FakeRequest('/1.0/account/container', + environ={'REQUEST_METHOD': 'GET'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual('objectstore.http.request', data[1]) + metadata = data[2]['target']['metadata'] + self.assertEqual('1.0', metadata['version']) + self.assertEqual('container', metadata['container']) + self.assertIsNone(metadata['object']) + self.assertEqual('get', data[2]['target']['action']) + http_headers = [k for k in metadata.keys() + if k.startswith('http_header_')] + self.assertEqual(0, len(http_headers)) + + def test_bogus_path(self): + app = swift.Swift(FakeApp(), {}) + req = FakeRequest('/5.0//', + environ={'REQUEST_METHOD': 'GET'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(0, len(notify.call_args_list)) + + def test_missing_resource_id(self): + app = swift.Swift(FakeApp(), {}) + req = FakeRequest('/v1/', environ={'REQUEST_METHOD': 'GET'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(0, len(notify.call_args_list)) + + @mock.patch.object(timeutils, 'utcnow') + def test_emit_event_fail(self, mocked_time): + mocked_time.side_effect = Exception("a exception") + app = swift.Swift(FakeApp(body=["test"]), {}) + req = FakeRequest('/1.0/account/container', + environ={'REQUEST_METHOD': 'GET'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + resp = list(app(req.environ, self.start_response)) + self.assertEqual(0, len(notify.call_args_list)) + self.assertEqual(["test"], resp) + + def test_reseller_prefix(self): + app = swift.Swift(FakeApp(), {}) + req = FakeRequest('/1.0/AUTH_account/container/obj', + environ={'REQUEST_METHOD': 'GET'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual("account", data[2]['target']['id']) + + def test_custom_prefix(self): + app = swift.Swift(FakeApp(), {'reseller_prefix': 'CUSTOM_'}) + req = FakeRequest('/1.0/CUSTOM_account/container/obj', + environ={'REQUEST_METHOD': 'GET'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual("account", data[2]['target']['id']) + + def test_invalid_reseller_prefix(self): + # Custom reseller prefix set, but without trailing underscore + app = swift.Swift( + FakeApp(), {'reseller_prefix': 'CUSTOM'}) + req = FakeRequest('/1.0/CUSTOM_account/container/obj', + environ={'REQUEST_METHOD': 'GET'}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(1, len(notify.call_args_list)) + data = notify.call_args_list[0][0] + self.assertEqual("account", data[2]['target']['id']) diff --git a/ceilometermiddleware/tests/test_swift.pyc b/ceilometermiddleware/tests/test_swift.pyc Binary files differnew file mode 100644 index 0000000..101abb6 --- /dev/null +++ b/ceilometermiddleware/tests/test_swift.pyc |