summaryrefslogtreecommitdiff
path: root/novaclient/tests/unit/test_shell.py
diff options
context:
space:
mode:
authorBoris Pavlovic <boris@pavlovic.me>2015-12-08 14:17:45 +0300
committerTovin Seven <vinhnt@vn.fujitsu.com>2017-01-19 03:50:06 +0000
commit0fed79fd8fc84b6a1564fbb70655cdebc543381d (patch)
treec72143833e739305880b4ad0946b5f9fe57af468 /novaclient/tests/unit/test_shell.py
parentc732a5edce6e0b145b2c092607c126c111b2bfcd (diff)
downloadpython-novaclient-0fed79fd8fc84b6a1564fbb70655cdebc543381d.tar.gz
Add profiling support to novaclient
To be able to create profiling traces for Nova, client should be able to send special HTTP header that contains trace info. This patch is also important to be able to make cross project traces. (Typical case heat calls nova via python client, if profiler is initialized in heat, nova client will add extra header, that will be parsed by special osprofiler middleware in nova api.) Security considerations: trace information is signed by one of the HMAC keys that are set in nova.conf. So only person who knows HMAC key is able to send proper header. oslo-spec: https://review.openstack.org/#/c/103825/ Based on: https://review.openstack.org/#/c/105089/ Co-Authored-By: Dina Belova <dbelova@mirantis.com> Co-Authored-By: Roman Podoliaka <rpodolyaka@mirantis.com> Co-Authored-By: Tovin Seven <vinhnt@vn.fujitsu.com> Partially implements: blueprint osprofiler-support-in-nova Depends-On: I82d2badc8c1fcec27c3fce7c3c20e0f3b76414f1 Change-Id: I56ce4b547230e475854994c9d2249ef90e5b656c
Diffstat (limited to 'novaclient/tests/unit/test_shell.py')
-rw-r--r--novaclient/tests/unit/test_shell.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/novaclient/tests/unit/test_shell.py b/novaclient/tests/unit/test_shell.py
index 161b4547..5ccf09bb 100644
--- a/novaclient/tests/unit/test_shell.py
+++ b/novaclient/tests/unit/test_shell.py
@@ -655,6 +655,27 @@ class ShellTest(utils.TestCase):
exc = self.assertRaises(RuntimeError, self.shell, '--timings list')
self.assertEqual('Boom!', str(exc))
+ @requests_mock.Mocker()
+ def test_osprofiler(self, m_requests):
+ self.make_env()
+
+ def client(*args, **kwargs):
+ self.assertEqual('swordfish', kwargs['profile'])
+ with mock.patch('novaclient.client.Client', client):
+ # we are only interested in the fact Client is initialized properly
+ self.shell('list --profile swordfish', (0, 2))
+
+ @requests_mock.Mocker()
+ def test_osprofiler_not_installed(self, m_requests):
+ self.make_env()
+
+ # NOTE(rpodolyaka): osprofiler is in test-requirements, so we have to
+ # simulate its absence here
+ with mock.patch('novaclient.shell.osprofiler_profiler', None):
+ _, stderr = self.shell('list --profile swordfish', (0, 2))
+ self.assertIn('unrecognized arguments: --profile swordfish',
+ stderr)
+
@mock.patch('novaclient.shell.SecretsHelper.tenant_id',
return_value=True)
@mock.patch('novaclient.shell.SecretsHelper.auth_token',