diff options
author | gordon chung <gord@live.ca> | 2015-04-23 15:09:45 -0400 |
---|---|---|
committer | gordon chung <gord@live.ca> | 2015-06-23 15:45:18 +0000 |
commit | 6a3c77bb309984edfd68fd45aab3db13e65728cc (patch) | |
tree | 704bf7f8427554c9858a526faa1e5f6f34aadb37 /ceilometermiddleware/tests/test_swift.py | |
parent | a086aac03cd1948887ec1151a1b650c1ed94ead5 (diff) | |
download | ceilometermiddleware-6a3c77bb309984edfd68fd45aab3db13e65728cc.tar.gz |
add support to skip event/meter generation for certain projects
gnocchi is unuseable with swift backend because for every meter we
capture we are generating an event notification which creates 1+
meters, which creates 1+ event notifications, and so on. this will
flood the message queue and it will never catch up. by default, we
will configure system to ignore requests from gnocchi project.
DocImpact
Change-Id: I175c5d59529ebe51c8e5ccb379b54b05e9affe95
Diffstat (limited to 'ceilometermiddleware/tests/test_swift.py')
-rw-r--r-- | ceilometermiddleware/tests/test_swift.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ceilometermiddleware/tests/test_swift.py b/ceilometermiddleware/tests/test_swift.py index 2bb6e33..2599a34 100644 --- a/ceilometermiddleware/tests/test_swift.py +++ b/ceilometermiddleware/tests/test_swift.py @@ -328,3 +328,30 @@ class TestSwift(tests_base.TestCase): self.assertEqual(1, len(notify.call_args_list)) data = notify.call_args_list[0][0] self.assertEqual("account", data[2]['target']['id']) + + def test_ignore_requests_from_project(self): + app = swift.Swift(FakeApp(), {'ignore_projects': 'skip_proj'}) + + for proj_attr in ['HTTP_X_SERVICE_PROJECT_ID', 'HTTP_X_PROJECT_ID', + 'HTTP_X_TENANT_ID']: + for proj, calls in [('good', 1), ('skip_proj', 0)]: + req = FakeRequest('/1.0/CUSTOM_account/container/obj', + environ={'REQUEST_METHOD': 'GET', + proj_attr: proj}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(calls, len(notify.call_args_list)) + + def test_ignore_requests_from_multiple_projects(self): + app = swift.Swift(FakeApp(), {'ignore_projects': 'skip_proj, ignore'}) + + for proj_attr in ['HTTP_X_SERVICE_PROJECT_ID', 'HTTP_X_PROJECT_ID', + 'HTTP_X_TENANT_ID']: + for proj, calls in [('good', 1), ('skip_proj', 0), + ('also_good', 1), ('ignore', 0)]: + req = FakeRequest('/1.0/CUSTOM_account/container/obj', + environ={'REQUEST_METHOD': 'GET', + proj_attr: proj}) + with mock.patch('oslo.messaging.Notifier.info') as notify: + list(app(req.environ, self.start_response)) + self.assertEqual(calls, len(notify.call_args_list)) |