From e7773d0652306bb1c114300d5d1b4d811363690e Mon Sep 17 00:00:00 2001 From: Zhi Yan Liu Date: Mon, 25 Aug 2014 22:02:15 +0800 Subject: [PATCH 001/324] Adding a hits to notice operator when trace not found A wrong HMAC key provided in original calling will make osprofiler refuses to collect tracing data. This change updated hits output of command "trace show" when specified trace not found, to make operator awares this case. Change-Id: Ie9dbeb3d89c41cdba8a7f695c3460218204d5dbf Signed-off-by: Zhi Yan Liu --- osprofiler/cmd/commands.py | 6 ++++-- tests/cmd/test_shell.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/osprofiler/cmd/commands.py b/osprofiler/cmd/commands.py index 99a3acb..0700a90 100644 --- a/osprofiler/cmd/commands.py +++ b/osprofiler/cmd/commands.py @@ -59,9 +59,11 @@ class TraceCommands(BaseCommand): if not notifications: msg = ("Trace with UUID %s not found. " - "There are 2 possible reasons: \n" + "There are 3 possible reasons: \n" " 1) You are using not admin credentials\n" - " 2) You specified wrong trace id" % args.trace_id) + " 2) You specified wrong trace id\n" + " 3) You specified wrong HMAC Key in original calling" + % args.trace_id) raise exc.CommandError(msg) parsed_notifications = ceiloparser.parse_notifications(notifications) diff --git a/tests/cmd/test_shell.py b/tests/cmd/test_shell.py index ec2951f..91da766 100644 --- a/tests/cmd/test_shell.py +++ b/tests/cmd/test_shell.py @@ -155,9 +155,11 @@ class ShellTestCase(test.TestCase): mock_get.return_value = None fake_trace_id = "fake_id" - msg = ("Trace with UUID %s not found. There are 2 possible reasons: \n" + msg = ("Trace with UUID %s not found. There are 3 possible reasons: \n" " 1) You are using not admin credentials\n" - " 2) You specified wrong trace id" % fake_trace_id) + " 2) You specified wrong trace id\n" + " 3) You specified wrong HMAC Key in original calling" + % fake_trace_id) self._test_with_command_error("trace show %s" % fake_trace_id, msg) -- GitLab From db5a22cfbe4af7619be54a030f90a5dbfb84cd21 Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Sat, 16 Aug 2014 05:36:53 +0400 Subject: [PATCH 002/324] Imporve generated trace html Use indent (to make trace info human readble) Remove duplicated host column in modulal window Add duration in modal window Change-Id: I0549927952d903b0d46261cbe8f4c0bfa4dc2da9 --- osprofiler/cmd/commands.py | 2 +- osprofiler/cmd/template.html | 3 ++- tests/cmd/test_shell.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/osprofiler/cmd/commands.py b/osprofiler/cmd/commands.py index 99a3acb..01ea36e 100644 --- a/osprofiler/cmd/commands.py +++ b/osprofiler/cmd/commands.py @@ -72,7 +72,7 @@ class TraceCommands(BaseCommand): with open(os.path.join(os.path.dirname(__file__), "template.html")) as html_template: output = html_template.read().replace( - "$DATA", json.dumps(parsed_notifications)) + "$DATA", json.dumps(parsed_notifications, indent=2)) else: raise exc.CommandError("You should choose one of the following " "output-formats: --json or --html.") diff --git a/osprofiler/cmd/template.html b/osprofiler/cmd/template.html index a63f12d..1b2b532 100644 --- a/osprofiler/cmd/template.html +++ b/osprofiler/cmd/template.html @@ -154,11 +154,12 @@ }; }, metadata); + info["duration"] = info["finished"] - info["started"] info["metadata"] = "
" + JSON.stringify(metadata, "", 4) + "
" var trace_data = "
" columns = ["name", "project", "service", "host", "started", - "finished", "host", "metadata"]; + "finished", "duration", "metadata"]; for (var i = 0; i < columns.length; i++){ trace_data += "
" + columns[i] + "
"; trace_data += "
" + info[columns[i]] + "
"; diff --git a/tests/cmd/test_shell.py b/tests/cmd/test_shell.py index ec2951f..6d08e43 100644 --- a/tests/cmd/test_shell.py +++ b/tests/cmd/test_shell.py @@ -205,7 +205,7 @@ class ShellTestCase(test.TestCase): "spaceships, striking from a hidden" "base, have won their first victory" "against the evil Galactic Empire." - "\n" % json.dumps(notifications), + "\n" % json.dumps(notifications, indent=2), sys.stdout.getvalue()) @mock.patch("sys.stdout", six.StringIO()) -- GitLab From 643ced11d1965b9e9ff8f991ba8347d58c25558f Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Fri, 5 Sep 2014 09:50:51 +0800 Subject: [PATCH 003/324] Added initial debian folder. --- debian/changelog | 5 ++ debian/compat | 1 + debian/control | 94 +++++++++++++++++++++++++++ debian/copyright | 27 ++++++++ debian/gbp.conf | 9 +++ debian/patches/no-intersphinx.patch | 16 +++++ debian/patches/series | 1 + debian/python-osprofiler-doc.doc-base | 9 +++ debian/python-osprofiler.postinst | 12 ++++ debian/python-osprofiler.postrm | 12 ++++ debian/python-osprofiler.prerm | 12 ++++ debian/python3-osprofiler.postinst | 12 ++++ debian/python3-osprofiler.postrm | 12 ++++ debian/python3-osprofiler.prerm | 12 ++++ debian/rules | 59 +++++++++++++++++ debian/source/format | 1 + debian/source/options | 1 + debian/watch | 3 + 18 files changed, 298 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/gbp.conf create mode 100644 debian/patches/no-intersphinx.patch create mode 100644 debian/patches/series create mode 100644 debian/python-osprofiler-doc.doc-base create mode 100644 debian/python-osprofiler.postinst create mode 100644 debian/python-osprofiler.postrm create mode 100644 debian/python-osprofiler.prerm create mode 100644 debian/python3-osprofiler.postinst create mode 100644 debian/python3-osprofiler.postrm create mode 100644 debian/python3-osprofiler.prerm create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 debian/source/options create mode 100644 debian/watch diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..90dca10 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +python-osprofiler (0.3.0-1) unstable; urgency=medium + + * Initial release. (Closes: #760529) + + -- Thomas Goirand Fri, 05 Sep 2014 09:38:53 +0800 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..ca17ed5 --- /dev/null +++ b/debian/control @@ -0,0 +1,94 @@ +Source: python-osprofiler +Section: python +Priority: optional +Maintainer: PKG OpenStack +Uploaders: Thomas Goirand +Build-Depends: debhelper (>= 9), + openstack-pkg-tools, + python-all (>= 2.6.6-3~), + python-pbr, + python-setuptools, + python-six (>= 1.7.0), + python-sphinx, + python-webob (>= 1.2.3), + python3-all, + python3-pbr, + python3-setuptools +Build-Depends-Indep: python-hacking (>= 0.8.0), + python-mock (>= 1.0), + python-oslosphinx, + python-subunit (>= 0.0.18), + python-testtools (>= 0.9.34), + python3-mock (>= 1.0), + python3-subunit (>= 0.0.18), + python3-testtools (>= 0.9.34), + subunit (>= 0.0.18), + testrepository (>= 0.0.18) +Standards-Version: 3.9.5 +Vcs-Browser: http://anonscm.debian.org/gitweb/?p=openstack/python-osprofiler.git +Vcs-Git: git://anonscm.debian.org/openstack/python-osprofiler.git +Homepage: https://github.com/stackforge/osprofiler + +Package: python-osprofiler +Architecture: all +Pre-Depends: dpkg (>= 1.15.6~) +Depends: python-six (>= 1.7.0), + python-webob (>= 1.2.3), + ${misc:Depends}, + ${python:Depends} +Description: OpenStack Profiler Library - Python 2.x + OpenStack consists of multiple projects. Each project, in turn, is composed of + multiple services. To process some request, e.g. to boot a virtual machine, + OpenStack uses multiple services from different projects. In the case somethin + works too slowly, it's extremely complicated to understand what exactly goes + wrong and to locate the bottleneck. + . + To resolve this issue, a tiny but powerful library, osprofiler, has been + interoduced, and can be used by all OpenStack projects and their Python + clients. To be able to generate one trace per request, that goes through all + involved services, and builds a tree of calls (see an example + http://pavlovic.me/rally/profiler/). + . + This package contains the Python 2.x module. + +Package: python3-osprofiler +Architecture: all +Pre-Depends: dpkg (>= 1.15.6~) +Depends: python3-six (>= 1.7.0), + python3-webob (>= 1.2.3), + ${misc:Depends}, + ${python3:Depends} +Description: OpenStack Profiler Library - Python 3.x + OpenStack consists of multiple projects. Each project, in turn, is composed of + multiple services. To process some request, e.g. to boot a virtual machine, + OpenStack uses multiple services from different projects. In the case somethin + works too slowly, it's extremely complicated to understand what exactly goes + wrong and to locate the bottleneck. + . + To resolve this issue, a tiny but powerful library, osprofiler, has been + interoduced, and can be used by all OpenStack projects and their Python + clients. To be able to generate one trace per request, that goes through all + involved services, and builds a tree of calls (see an example + http://pavlovic.me/rally/profiler/). + . + This package contains the Python 3.x module. + +Package: python-osprofiler-doc +Section: doc +Architecture: all +Pre-Depends: dpkg (>= 1.15.6~) +Depends: ${misc:Depends}, ${sphinxdoc:Depends} +Description: OpenStack Profiler Library - doc + OpenStack consists of multiple projects. Each project, in turn, is composed of + multiple services. To process some request, e.g. to boot a virtual machine, + OpenStack uses multiple services from different projects. In the case somethin + works too slowly, it's extremely complicated to understand what exactly goes + wrong and to locate the bottleneck. + . + To resolve this issue, a tiny but powerful library, osprofiler, has been + interoduced, and can be used by all OpenStack projects and their Python + clients. To be able to generate one trace per request, that goes through all + involved services, and builds a tree of calls (see an example + http://pavlovic.me/rally/profiler/). + . + This package contains the documentation. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..7021eda --- /dev/null +++ b/debian/copyright @@ -0,0 +1,27 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: osprofiler +Source: git://github.com/stackforge/osprofiler.git + +Files: debian/* +Copyright: (c) 2014, Thomas Goirand +License: Apache-2 + +Files: * +Copyright: (c) 2013, OpenStack +License: Apache-2 + +License: Apache-2 + 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. + . + On Debian-based systems the full text of the Apache version 2.0 license + can be found in /usr/share/common-licenses/Apache-2.0. diff --git a/debian/gbp.conf b/debian/gbp.conf new file mode 100644 index 0000000..fd8ec27 --- /dev/null +++ b/debian/gbp.conf @@ -0,0 +1,9 @@ +[DEFAULT] +upstream-branch = master +debian-branch = debian/unstable +upstream-tag = %(version)s +compression = xz + +[git-buildpackage] +export-dir = ../build-area/ + diff --git a/debian/patches/no-intersphinx.patch b/debian/patches/no-intersphinx.patch new file mode 100644 index 0000000..fe72b46 --- /dev/null +++ b/debian/patches/no-intersphinx.patch @@ -0,0 +1,16 @@ +Description: No intersphinx + Avoid intersphinx so that there's no network access during build. +Author: Thomas Goirand +Forwarded: no +Last-Update: 2014-09-05 + +--- python-osprofiler-0.3.0.orig/doc/source/conf.py ++++ python-osprofiler-0.3.0/doc/source/conf.py +@@ -33,7 +33,6 @@ sys.path.extend([ + extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', +- 'sphinx.ext.intersphinx', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.ifconfig', diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..1813196 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +no-intersphinx.patch diff --git a/debian/python-osprofiler-doc.doc-base b/debian/python-osprofiler-doc.doc-base new file mode 100644 index 0000000..930aa64 --- /dev/null +++ b/debian/python-osprofiler-doc.doc-base @@ -0,0 +1,9 @@ +Document: python-osprofiler-doc +Title: osprofiler Documentation +Author: N/A +Abstract: Sphinx documentation for osprofiler +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/python-osprofiler-doc/html/index.html +Files: /usr/share/doc/python-osprofiler-doc/html/* diff --git a/debian/python-osprofiler.postinst b/debian/python-osprofiler.postinst new file mode 100644 index 0000000..041ed72 --- /dev/null +++ b/debian/python-osprofiler.postinst @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +if [ "$1" = "configure" ] ; then + update-alternatives --install /usr/bin/osprofiler osprofiler /usr/bin/python2-osprofiler 300 +fi + +#DEBHELPER# + +exit 0 + diff --git a/debian/python-osprofiler.postrm b/debian/python-osprofiler.postrm new file mode 100644 index 0000000..8789e9b --- /dev/null +++ b/debian/python-osprofiler.postrm @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +if [ "$1" = "remove" ] || [ "$1" = "disappear" ]; then + update-alternatives --remove osprofiler /usr/bin/python2-osprofiler +fi + +#DEBHELPER# + +exit 0 + diff --git a/debian/python-osprofiler.prerm b/debian/python-osprofiler.prerm new file mode 100644 index 0000000..b287c00 --- /dev/null +++ b/debian/python-osprofiler.prerm @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +if [ "$1" = "remove" ] ; then + update-alternatives --remove osprofiler /usr/bin/python2-osprofiler +fi + +#DEBHELPER# + +exit 0 + diff --git a/debian/python3-osprofiler.postinst b/debian/python3-osprofiler.postinst new file mode 100644 index 0000000..b916c20 --- /dev/null +++ b/debian/python3-osprofiler.postinst @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +if [ "$1" = "configure" ] ; then + update-alternatives --install /usr/bin/osprofiler osprofiler /usr/bin/python3-osprofiler 200 +fi + +#DEBHELPER# + +exit 0 + diff --git a/debian/python3-osprofiler.postrm b/debian/python3-osprofiler.postrm new file mode 100644 index 0000000..547310b --- /dev/null +++ b/debian/python3-osprofiler.postrm @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +if [ "$1" = "remove" ] || [ "$1" = "disappear" ]; then + update-alternatives --remove osprofiler /usr/bin/python3-osprofiler +fi + +#DEBHELPER# + +exit 0 + diff --git a/debian/python3-osprofiler.prerm b/debian/python3-osprofiler.prerm new file mode 100644 index 0000000..ab6f58a --- /dev/null +++ b/debian/python3-osprofiler.prerm @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +if [ "$1" = "remove" ] ; then + update-alternatives --remove osprofiler /usr/bin/python3-osprofiler +fi + +#DEBHELPER# + +exit 0 + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..acf1f47 --- /dev/null +++ b/debian/rules @@ -0,0 +1,59 @@ +#!/usr/bin/make -f + +PYTHONS:=$(shell pyversions -vr) +PYTHON3S:=$(shell py3versions -vr) + +UPSTREAM_GIT = git://github.com/stackforge/osprofiler.git +include /usr/share/openstack-pkg-tools/pkgos.make + +export OSLO_PACKAGE_VERSION=$(VERSION) + +%: + dh $@ --buildsystem=python_distutils --with python2,python3,sphinxdoc + +override_dh_install: + set -e && for pyvers in $(PYTHONS); do \ + python$$pyvers setup.py install --install-layout=deb \ + --root $(CURDIR)/debian/python-osprofiler; \ + done + set -e && for pyvers in $(PYTHON3S); do \ + python$$pyvers setup.py install --install-layout=deb \ + --root $(CURDIR)/debian/python3-osprofiler; \ + done + mv $(CURDIR)/debian/python-osprofiler/usr/bin/osprofiler $(CURDIR)/debian/python-osprofiler/usr/bin/python2-osprofiler + mv $(CURDIR)/debian/python3-osprofiler/usr/bin/osprofiler $(CURDIR)/debian/python3-osprofiler/usr/bin/python3-osprofiler + rm -rf $(CURDIR)/debian/python*-osprofiler/usr/lib/python*/dist-packages/*.pth + +override_dh_auto_test: +ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS))) + echo "===> Running tests" + set -ex ; for i in $(PYTHONS) $(PYTHON3S) ; do \ + PYMAJOR=`echo $$i | cut -d'.' -f1` ; \ + echo "===> Testing with python$$i (python$$PYMAJOR)" ; \ + rm -rf .testrepository ; \ + testr-python$$PYMAJOR init ; \ + TEMP_REZ=`mktemp -t` ; \ + PYTHONPATH=$(CURDIR) PYTHON=python$$i testr-python$$PYMAJOR run --subunit 'tests\.(?!.*OptsTestCase.test_entry_point.*)' | tee $$TEMP_REZ | subunit2pyunit ; \ + cat $$TEMP_REZ | subunit-filter -s --no-passthrough | subunit-stats ; \ + rm -f $$TEMP_REZ ; \ + testr-python$$PYMAJOR slowest ; \ + done +endif + +override_dh_clean: + dh_clean -O--buildsystem=python_distutils + rm -rf build + +override_dh_sphinxdoc: + sphinx-build -b html doc/source debian/python-osprofiler-doc/usr/share/doc/python-osprofiler-doc/html + dh_sphinxdoc -O--buildsystem=python_distutils + +# Commands not to run +override_dh_installcatalogs: +override_dh_installemacsen override_dh_installifupdown: +override_dh_installinfo override_dh_installmenu override_dh_installmime: +override_dh_installmodules override_dh_installlogcheck: +override_dh_installpam override_dh_installppp override_dh_installudev override_dh_installwm: +override_dh_installxfonts override_dh_gconf override_dh_icons override_dh_perl override_dh_usrlocal: +override_dh_installcron override_dh_installdebconf: +override_dh_installlogrotate override_dh_installgsettings: diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/source/options b/debian/source/options new file mode 100644 index 0000000..cb61fa5 --- /dev/null +++ b/debian/source/options @@ -0,0 +1 @@ +extend-diff-ignore = "^[^/]*[.]egg-info/" diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..2541266 --- /dev/null +++ b/debian/watch @@ -0,0 +1,3 @@ +version=3 +http://pypi.python.org/packages/source/o/osprofiler osprofiler-(.*).tar.gz + -- GitLab From 323dc4269b34c84919ed315b660a8381b3c9c2f2 Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Fri, 5 Sep 2014 02:12:18 +0000 Subject: [PATCH 004/324] Missing build-depends: python3-webob, python-six, python3-six --- debian/control | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index ca17ed5..559e723 100644 --- a/debian/control +++ b/debian/control @@ -8,20 +8,22 @@ Build-Depends: debhelper (>= 9), python-all (>= 2.6.6-3~), python-pbr, python-setuptools, - python-six (>= 1.7.0), python-sphinx, - python-webob (>= 1.2.3), python3-all, python3-pbr, python3-setuptools Build-Depends-Indep: python-hacking (>= 0.8.0), python-mock (>= 1.0), python-oslosphinx, + python-six (>= 1.7.0), python-subunit (>= 0.0.18), python-testtools (>= 0.9.34), + python-webob (>= 1.2.3), python3-mock (>= 1.0), + python3-six (>= 1.7.0), python3-subunit (>= 0.0.18), python3-testtools (>= 0.9.34), + python3-webob (>= 1.2.3), subunit (>= 0.0.18), testrepository (>= 0.0.18) Standards-Version: 3.9.5 -- GitLab From d92860e8db4fa08c29a8a25bb2d08be330c7e661 Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Fri, 5 Sep 2014 02:16:33 +0000 Subject: [PATCH 005/324] No unit tests in python 2.6, because it needs discover --- debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index acf1f47..ce07509 100755 --- a/debian/rules +++ b/debian/rules @@ -27,7 +27,7 @@ override_dh_install: override_dh_auto_test: ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS))) echo "===> Running tests" - set -ex ; for i in $(PYTHONS) $(PYTHON3S) ; do \ + set -ex ; for i in 2.7 $(PYTHON3S) ; do \ PYMAJOR=`echo $$i | cut -d'.' -f1` ; \ echo "===> Testing with python$$i (python$$PYMAJOR)" ; \ rm -rf .testrepository ; \ -- GitLab From 9720b7620ca39c97df2108b0b349cfe05e1a5fb2 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 8 Sep 2014 13:51:34 -0700 Subject: [PATCH 006/324] Rename doc environment to docs As per the governance resolution https://review.openstack.org/119875, projects should have a docs environment in their tox.ini testing interface. Rename the doc environment to docs. Change-Id: I32a8138934cd7b027dcbad0c3627b3554013494e --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index ce48b9e..ff8b4d7 100644 --- a/tox.ini +++ b/tox.ini @@ -25,7 +25,7 @@ commands = {posargs} [testenv:cover] commands = python setup.py testr --coverage --testr-args='{posargs}' -[testenv:doc] +[testenv:docs] changedir = doc/source commands = make html -- GitLab From c8c1869a893e7aa391b272c54ede8c475650ffc4 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Sat, 4 Oct 2014 20:50:35 +0200 Subject: [PATCH 007/324] Stop using intersphinx Remove intersphinx from the docs build as it triggers network calls that occasionally fail, and we don't really use intersphinx (links other sphinx documents out on the internet) This also removes the requirement for internet access during docs build. This can cause docs jobs to fail if the project errors out on warnings. Change-Id: I71e941e2a639641a662a163c682eb86d51de42fb Related-Bug: #1368910 --- doc/source/conf.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index fe3a691..cc18c90 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -33,7 +33,6 @@ sys.path.extend([ extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', - 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.ifconfig', @@ -257,7 +256,3 @@ texinfo_documents = [ # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'http://docs.python.org/': None} -- GitLab From 4d039c7861677456c14d44afdd528ae32f61ffbd Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Fri, 12 Jun 2015 11:19:17 +0200 Subject: [PATCH 008/324] Made build reproducible (Closes: #788503). Thanks to Juan Picca. --- debian/changelog | 6 ++++++ debian/rules | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 90dca10..b6dfefb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +python-osprofiler (0.3.0-2) unstable; urgency=medium + + * Made build reproducible (Closes: #788503). Thanks to Juan Picca. + + -- Thomas Goirand Fri, 12 Jun 2015 11:18:04 +0200 + python-osprofiler (0.3.0-1) unstable; urgency=medium * Initial release. (Closes: #760529) diff --git a/debian/rules b/debian/rules index ce07509..88d7a0f 100755 --- a/debian/rules +++ b/debian/rules @@ -1,5 +1,9 @@ #!/usr/bin/make -f +LAST_CHANGE = $(shell dpkg-parsechangelog -S Date) +BUILD_DATE = $(shell LC_ALL=C date -u "+%B %d, %Y" -d "$(LAST_CHANGE)") +SPHINXOPTS := -D html_last_updated_fmt="$(BUILD_DATE)" + PYTHONS:=$(shell pyversions -vr) PYTHON3S:=$(shell py3versions -vr) @@ -45,7 +49,7 @@ override_dh_clean: rm -rf build override_dh_sphinxdoc: - sphinx-build -b html doc/source debian/python-osprofiler-doc/usr/share/doc/python-osprofiler-doc/html + sphinx-build $(SPHINXOPTS) -b html doc/source debian/python-osprofiler-doc/usr/share/doc/python-osprofiler-doc/html dh_sphinxdoc -O--buildsystem=python_distutils # Commands not to run -- GitLab From 7b50105a0cafa964da47e7604b11caadb962ec32 Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Fri, 12 Jun 2015 09:19:45 +0000 Subject: [PATCH 009/324] Fixed gbp.conf --- debian/gbp.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/gbp.conf b/debian/gbp.conf index fd8ec27..10f9500 100644 --- a/debian/gbp.conf +++ b/debian/gbp.conf @@ -4,6 +4,6 @@ debian-branch = debian/unstable upstream-tag = %(version)s compression = xz -[git-buildpackage] +[buildpackage] export-dir = ../build-area/ -- GitLab From bc78823f299747ba1ff660953775a008d3581df0 Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Wed, 24 Jun 2015 11:58:57 -0700 Subject: [PATCH 010/324] Remove version from setup.cfg Pbr is calculating versions on it's own based on git tags. So we don't need to specify by hands in setup.cfg version Change-Id: Ia5b4859b662d98facf3c211ae813962bd07feef0 --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 91f497c..f719d74 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,5 @@ [metadata] name = osprofiler -version = 0.3.0 summary = OpenStack Profiler Library description-file = README.rst -- GitLab From c2e9a73b3f0ffac4ccc66b37086639dfe6a7d82b Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Mon, 17 Nov 2014 23:58:44 +0400 Subject: [PATCH 011/324] Various cleanups Change-Id: I311f694d2e2e92468d3345d0da3f550fffa560ee --- osprofiler/_utils.py | 12 +++--- osprofiler/cmd/template.html | 19 +-------- osprofiler/profiler.py | 12 +++--- osprofiler/web.py | 4 +- tests/cmd/test_shell.py | 74 ++++++++++++++++++------------------ 5 files changed, 52 insertions(+), 69 deletions(-) diff --git a/osprofiler/_utils.py b/osprofiler/_utils.py index 02fdcb8..f0c053b 100644 --- a/osprofiler/_utils.py +++ b/osprofiler/_utils.py @@ -61,7 +61,7 @@ def split(text, strip=True): return text.split(",") -def binary_encode(text, encoding='utf-8'): +def binary_encode(text, encoding="utf-8"): """Converts a string of into a binary type using given encoding. Does nothing if text not unicode string. @@ -74,7 +74,7 @@ def binary_encode(text, encoding='utf-8'): raise TypeError("Expected binary or string type") -def binary_decode(data, encoding='utf-8'): +def binary_decode(data, encoding="utf-8"): """Converts a binary type into a text type using given encoding. Does nothing if data is already unicode string. @@ -133,7 +133,7 @@ def signed_unpack(data, hmac_data, hmac_keys): try: contents = json.loads( binary_decode(base64.urlsafe_b64decode(data))) - contents['hmac_key'] = hmac_key + contents["hmac_key"] = hmac_key return contents except Exception: return None @@ -161,12 +161,12 @@ def import_modules_from_package(package): :param: package - Full package name. For example: rally.deploy.engines """ - path = [os.path.dirname(__file__), '..'] + package.split('.') + path = [os.path.dirname(__file__), ".."] + package.split(".") path = os.path.join(*path) for root, dirs, files in os.walk(path): for filename in files: - if filename.startswith('__') or not filename.endswith('.py'): + if filename.startswith("__") or not filename.endswith(".py"): continue new_package = ".".join(root.split(os.sep)).split("....")[1] - module_name = '%s.%s' % (new_package, filename[:-3]) + module_name = "%s.%s" % (new_package, filename[:-3]) __import__(module_name) diff --git a/osprofiler/cmd/template.html b/osprofiler/cmd/template.html index 1b2b532..369c498 100644 --- a/osprofiler/cmd/template.html +++ b/osprofiler/cmd/template.html @@ -10,27 +10,21 @@ - - - - - - + - + - +
- - - - - - - - - - -
LevelsDurationTypeProjectServiceHostDetails
-
+ + + + + + + + + + +
LevelsDurationTypeProjectServiceHostDetails
+
- - + -- GitLab From 221bb4f6b0a4c094f62fe4a6178d7c95e0365502 Mon Sep 17 00:00:00 2001 From: Vipin Balachandran Date: Thu, 24 Nov 2016 14:35:34 +0530 Subject: [PATCH 135/324] Error out for invalid trace ID There is no error message printed if the trace ID input to the 'trace show' command is invalid. Fixing this by checking for empty child nodes at the root of the trace result from driver. Change-Id: I8fc40356cffa98f5e9b9f6048b8fe422271f41f0 Closes-bug: #1644448 --- osprofiler/cmd/commands.py | 2 +- osprofiler/tests/cmd/test_shell.py | 43 +++++++++++++++++++----------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/osprofiler/cmd/commands.py b/osprofiler/cmd/commands.py index 60604d3..8b29c29 100644 --- a/osprofiler/cmd/commands.py +++ b/osprofiler/cmd/commands.py @@ -59,7 +59,7 @@ class TraceCommands(BaseCommand): trace = engine.get_report(args.trace) - if not trace: + if not trace or not trace.get("children"): msg = ("Trace with UUID %s not found. " "There are 3 possible reasons: \n" " 1) You are using not admin credentials\n" diff --git a/osprofiler/tests/cmd/test_shell.py b/osprofiler/tests/cmd/test_shell.py index f6316eb..c97c406 100644 --- a/osprofiler/tests/cmd/test_shell.py +++ b/osprofiler/tests/cmd/test_shell.py @@ -17,6 +17,7 @@ import json import os import sys +import ddt import mock import six @@ -25,6 +26,7 @@ from osprofiler import exc from osprofiler.tests import test +@ddt.ddt class ShellTestCase(test.TestCase): def setUp(self): super(ShellTestCase, self).setUp() @@ -145,14 +147,16 @@ class ShellTestCase(test.TestCase): @mock.patch("osprofiler.drivers.ceilometer.Ceilometer.get_report") def test_trace_show_no_selected_format(self, mock_get): - mock_get.return_value = "some_notificatios" + mock_get.return_value = self._create_mock_notifications() msg = ("You should choose one of the following output formats: " "json, html or dot.") self._test_with_command_error("trace show fake_id", msg) @mock.patch("osprofiler.drivers.ceilometer.Ceilometer.get_report") - def test_trace_show_trace_id_not_found(self, mock_get): - mock_get.return_value = None + @ddt.data(None, {"info": {"started": 0, "finished": 1, "name": "total"}, + "children": []}) + def test_trace_show_trace_id_not_found(self, notifications, mock_get): + mock_get.return_value = notifications fake_trace_id = "fake_id" msg = ("Trace with UUID %s not found. There are 3 possible reasons: \n" @@ -164,13 +168,28 @@ class ShellTestCase(test.TestCase): self._test_with_command_error("trace show %s" % fake_trace_id, msg) - @mock.patch("sys.stdout", six.StringIO()) - @mock.patch("osprofiler.drivers.ceilometer.Ceilometer.get_report") - def test_trace_show_in_json(self, mock_get): + def _create_mock_notifications(self): notifications = { "info": { - "started": 0, "finished": 0, "name": "total"}, "children": []} + "started": 0, + "finished": 1, + "name": "total" + }, + "children": [{ + "info": { + "started": 0, + "finished": 1, + "name": "total" + }, + "children": [] + }] + } + return notifications + @mock.patch("sys.stdout", six.StringIO()) + @mock.patch("osprofiler.drivers.ceilometer.Ceilometer.get_report") + def test_trace_show_in_json(self, mock_get): + notifications = self._create_mock_notifications() mock_get.return_value = notifications self.run_command("trace show fake_id --json") @@ -180,10 +199,7 @@ class ShellTestCase(test.TestCase): @mock.patch("sys.stdout", six.StringIO()) @mock.patch("osprofiler.drivers.ceilometer.Ceilometer.get_report") def test_trace_show_in_html(self, mock_get): - notifications = { - "info": { - "started": 0, "finished": 0, "name": "total"}, "children": []} - + notifications = self._create_mock_notifications() mock_get.return_value = notifications # NOTE(akurilin): to simplify assert statement, html-template should be @@ -211,10 +227,7 @@ class ShellTestCase(test.TestCase): @mock.patch("sys.stdout", six.StringIO()) @mock.patch("osprofiler.drivers.ceilometer.Ceilometer.get_report") def test_trace_show_write_to_file(self, mock_get): - notifications = { - "info": { - "started": 0, "finished": 0, "name": "total"}, "children": []} - + notifications = self._create_mock_notifications() mock_get.return_value = notifications with mock.patch("osprofiler.cmd.commands.open", -- GitLab From 291d8bd17bfc04be9274899a455e404538f65d51 Mon Sep 17 00:00:00 2001 From: Vipin Balachandran Date: Thu, 24 Nov 2016 15:04:26 +0530 Subject: [PATCH 136/324] Use oslo_utils.uuidutils.is_uuid_like Using oslo_utils.uuidutils.is_uuid_like() to check if the trace positional argument to "trace show" command is a trace ID or a file name containing the trace. Change-Id: I01c20beb2394805f29a1d7bdfa60ba6df5bac627 --- osprofiler/cmd/commands.py | 4 +++- osprofiler/tests/cmd/test_shell.py | 35 ++++++++++++++++++------------ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/osprofiler/cmd/commands.py b/osprofiler/cmd/commands.py index 60604d3..9628d9d 100644 --- a/osprofiler/cmd/commands.py +++ b/osprofiler/cmd/commands.py @@ -16,6 +16,8 @@ import json import os +from oslo_utils import uuidutils + from osprofiler.cmd import cliutils from osprofiler.drivers import base from osprofiler import exc @@ -49,7 +51,7 @@ class TraceCommands(BaseCommand): trace = None - if os.path.exists(args.trace): + if not uuidutils.is_uuid_like(args.trace): trace = json.load(open(args.trace)) else: try: diff --git a/osprofiler/tests/cmd/test_shell.py b/osprofiler/tests/cmd/test_shell.py index f6316eb..1f390a5 100644 --- a/osprofiler/tests/cmd/test_shell.py +++ b/osprofiler/tests/cmd/test_shell.py @@ -26,6 +26,9 @@ from osprofiler.tests import test class ShellTestCase(test.TestCase): + + TRACE_ID = "c598094d-bbee-40b6-b317-d76003b679d3" + def setUp(self): super(ShellTestCase, self).setUp() self.old_environment = os.environ.copy() @@ -63,6 +66,10 @@ class ShellTestCase(test.TestCase): super(ShellTestCase, self).tearDown() os.environ = self.old_environment + def _trace_show_cmd(self, format_=None): + cmd = "trace show %s" % self.TRACE_ID + return cmd if format_ is None else "%s --%s" % (cmd, format_) + @mock.patch("sys.stdout", six.StringIO()) @mock.patch("osprofiler.cmd.shell.OSProfilerShell") def test_shell_main(self, mock_shell): @@ -87,19 +94,19 @@ class ShellTestCase(test.TestCase): os.environ.pop("OS_USERNAME") msg = ("You must provide a username via either --os-username or " "via env[OS_USERNAME]") - self._test_with_command_error("trace show fake-uuid", msg) + self._test_with_command_error(self._trace_show_cmd(), msg) def test_password_is_not_presented(self): os.environ.pop("OS_PASSWORD") msg = ("You must provide a password via either --os-password or " "via env[OS_PASSWORD]") - self._test_with_command_error("trace show fake-uuid", msg) + self._test_with_command_error(self._trace_show_cmd(), msg) def test_auth_url(self): os.environ.pop("OS_AUTH_URL") msg = ("You must provide an auth url via either --os-auth-url or " "via env[OS_AUTH_URL]") - self._test_with_command_error("trace show fake-uuid", msg) + self._test_with_command_error(self._trace_show_cmd(), msg) def test_no_project_and_domain_set(self): os.environ.pop("OS_PROJECT_ID") @@ -114,7 +121,7 @@ class ShellTestCase(test.TestCase): "--os-user-domain-name or via env[OS_USER_DOMAIN_NAME] or a " "domain_id via either --os-user-domain-id or via " "env[OS_USER_DOMAIN_ID]") - self._test_with_command_error("trace show fake-uuid", msg) + self._test_with_command_error(self._trace_show_cmd(), msg) def test_trace_show_ceilometerclient_is_missed(self): sys.modules["ceilometerclient"] = None @@ -124,7 +131,7 @@ class ShellTestCase(test.TestCase): msg = ("To use this command, you should install " "'ceilometerclient' manually. Use command:\n " "'pip install python-ceilometerclient'.") - self._test_with_command_error("trace show fake-uuid", msg) + self._test_with_command_error(self._trace_show_cmd(), msg) def test_trace_show_unauthorized(self): class FakeHTTPUnauthorized(Exception): @@ -133,7 +140,7 @@ class ShellTestCase(test.TestCase): self.ceiloclient.client.get_client.side_effect = FakeHTTPUnauthorized msg = "Invalid OpenStack Identity credentials." - self._test_with_command_error("trace show fake_id", msg) + self._test_with_command_error(self._trace_show_cmd(), msg) def test_trace_show_unknown_error(self): class FakeException(Exception): @@ -141,28 +148,27 @@ class ShellTestCase(test.TestCase): self.ceiloclient.client.get_client.side_effect = FakeException msg = "Something has gone wrong. See ceilometer logs for more details" - self._test_with_command_error("trace show fake_id", msg) + self._test_with_command_error(self._trace_show_cmd(), msg) @mock.patch("osprofiler.drivers.ceilometer.Ceilometer.get_report") def test_trace_show_no_selected_format(self, mock_get): mock_get.return_value = "some_notificatios" msg = ("You should choose one of the following output formats: " "json, html or dot.") - self._test_with_command_error("trace show fake_id", msg) + self._test_with_command_error(self._trace_show_cmd(), msg) @mock.patch("osprofiler.drivers.ceilometer.Ceilometer.get_report") def test_trace_show_trace_id_not_found(self, mock_get): mock_get.return_value = None - fake_trace_id = "fake_id" msg = ("Trace with UUID %s not found. There are 3 possible reasons: \n" " 1) You are using not admin credentials\n" " 2) You specified wrong trace id\n" " 3) You specified wrong HMAC Key in original calling\n" " 4) Ceilometer didn't enable profiler notification topic" - % fake_trace_id) + % self.TRACE_ID) - self._test_with_command_error("trace show %s" % fake_trace_id, msg) + self._test_with_command_error(self._trace_show_cmd(), msg) @mock.patch("sys.stdout", six.StringIO()) @mock.patch("osprofiler.drivers.ceilometer.Ceilometer.get_report") @@ -173,7 +179,7 @@ class ShellTestCase(test.TestCase): mock_get.return_value = notifications - self.run_command("trace show fake_id --json") + self.run_command(self._trace_show_cmd(format_="json")) self.assertEqual("%s\n" % json.dumps(notifications, indent=2), sys.stdout.getvalue()) @@ -198,7 +204,7 @@ class ShellTestCase(test.TestCase): with mock.patch("osprofiler.cmd.commands.open", mock.mock_open(read_data=html_template), create=True): - self.run_command("trace show fake_id --html") + self.run_command(self._trace_show_cmd(format_="html")) self.assertEqual("A long time ago in a galaxy far, far away..." " some_data = %s" "It is a period of civil war. Rebel" @@ -219,7 +225,8 @@ class ShellTestCase(test.TestCase): with mock.patch("osprofiler.cmd.commands.open", mock.mock_open(), create=True) as mock_open: - self.run_command("trace show fake_id --json --out='/file'") + self.run_command("%s --out='/file'" % + self._trace_show_cmd(format_="json")) output = mock_open.return_value.__enter__.return_value output.write.assert_called_once_with(json.dumps(notifications, -- GitLab From cb6052de6fc654491f868709d22549388887acd8 Mon Sep 17 00:00:00 2001 From: Tovin Seven Date: Mon, 5 Dec 2016 11:33:37 +0700 Subject: [PATCH 137/324] Use uuidutils instead of uuid.uuid4() Openstack common has a wrapper for generating uuids. We should only use that function when generating uuids for consistency. Change-Id: Ia2ad4b3b683b6c432cb8629b5253dae8805af0e7 Closes-Bug: #1082248 --- osprofiler/profiler.py | 6 +++--- osprofiler/tests/test_profiler.py | 25 +++++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/osprofiler/profiler.py b/osprofiler/profiler.py index 5b4b499..4e501a6 100644 --- a/osprofiler/profiler.py +++ b/osprofiler/profiler.py @@ -19,9 +19,9 @@ import functools import inspect import socket import threading -import uuid from oslo_utils import reflection +from oslo_utils import uuidutils from osprofiler import notifier @@ -333,7 +333,7 @@ class _Profiler(object): connection_str=None, project=None, service=None): self.hmac_key = hmac_key if not base_id: - base_id = str(uuid.uuid4()) + base_id = str(uuidutils.generate_uuid()) self._trace_stack = collections.deque([base_id, parent_id or base_id]) self._name = collections.deque() self._host = socket.gethostname() @@ -376,7 +376,7 @@ class _Profiler(object): info["project"] = self._project info["service"] = self._service self._name.append(name) - self._trace_stack.append(str(uuid.uuid4())) + self._trace_stack.append(str(uuidutils.generate_uuid())) self._notify("%s-start" % name, info) def stop(self, info=None): diff --git a/osprofiler/tests/test_profiler.py b/osprofiler/tests/test_profiler.py index 87b3eea..195e298 100644 --- a/osprofiler/tests/test_profiler.py +++ b/osprofiler/tests/test_profiler.py @@ -66,32 +66,33 @@ class ProfilerTestCase(test.TestCase): prof = profiler._Profiler("secret", base_id="1", parent_id="2") self.assertEqual(prof.get_base_id(), "1") - @mock.patch("osprofiler.profiler.uuid.uuid4") - def test_profiler_get_parent_id(self, mock_uuid4): - mock_uuid4.return_value = "42" + @mock.patch("osprofiler.profiler.uuidutils.generate_uuid") + def test_profiler_get_parent_id(self, mock_generate_uuid): + mock_generate_uuid.return_value = "42" prof = profiler._Profiler("secret", base_id="1", parent_id="2") prof.start("test") self.assertEqual(prof.get_parent_id(), "2") - @mock.patch("osprofiler.profiler.uuid.uuid4") - def test_profiler_get_base_id_unset_case(self, mock_uuid4): - mock_uuid4.return_value = "42" + @mock.patch("osprofiler.profiler.uuidutils.generate_uuid") + def test_profiler_get_base_id_unset_case(self, mock_generate_uuid): + mock_generate_uuid.return_value = "42" prof = profiler._Profiler("secret") self.assertEqual(prof.get_base_id(), "42") self.assertEqual(prof.get_parent_id(), "42") - @mock.patch("osprofiler.profiler.uuid.uuid4") - def test_profiler_get_id(self, mock_uuid4): - mock_uuid4.return_value = "43" + @mock.patch("osprofiler.profiler.uuidutils.generate_uuid") + def test_profiler_get_id(self, mock_generate_uuid): + mock_generate_uuid.return_value = "43" prof = profiler._Profiler("secret") prof.start("test") self.assertEqual(prof.get_id(), "43") @mock.patch("osprofiler.profiler.datetime") - @mock.patch("osprofiler.profiler.uuid.uuid4") + @mock.patch("osprofiler.profiler.uuidutils.generate_uuid") @mock.patch("osprofiler.profiler.notifier.notify") - def test_profiler_start(self, mock_notify, mock_uuid4, mock_datetime): - mock_uuid4.return_value = "44" + def test_profiler_start(self, mock_notify, mock_generate_uuid, + mock_datetime): + mock_generate_uuid.return_value = "44" now = datetime.datetime.utcnow() mock_datetime.datetime.utcnow.return_value = now -- GitLab From 5fbbff1e02c5a38ce48663b6fbdb3f120fe263b2 Mon Sep 17 00:00:00 2001 From: Vipin Balachandran Date: Wed, 23 Nov 2016 13:07:14 +0530 Subject: [PATCH 138/324] Organize unit tests under tests/unit folder Moving all unit tests to tests/unit so that we can start writing functional tests for verifying notifier backends against osprofiler patches. Change-Id: I40a415df6e271f19c7b116471499d24eb45425db --- .testr.conf | 2 +- osprofiler/tests/{cmd => unit}/__init__.py | 0 .../tests/{doc => unit/cmd}/__init__.py | 0 osprofiler/tests/{ => unit}/cmd/test_shell.py | 0 .../tests/{drivers => unit/doc}/__init__.py | 0 osprofiler/tests/{ => unit}/doc/test_specs.py | 2 +- osprofiler/tests/unit/drivers/__init__.py | 0 .../tests/{ => unit}/drivers/test_base.py | 0 .../{ => unit}/drivers/test_ceilometer.py | 0 .../{ => unit}/drivers/test_elasticsearch.py | 0 .../{ => unit}/drivers/test_loginsight.py | 0 .../{ => unit}/drivers/test_messaging.py | 0 .../tests/{ => unit}/drivers/test_mongodb.py | 0 .../{ => unit}/drivers/test_redis_driver.py | 0 osprofiler/tests/{ => unit}/test_notifier.py | 0 osprofiler/tests/{ => unit}/test_opts.py | 0 osprofiler/tests/{ => unit}/test_profiler.py | 27 ++++++++++--------- .../tests/{ => unit}/test_sqlalchemy.py | 0 osprofiler/tests/{ => unit}/test_utils.py | 0 osprofiler/tests/{ => unit}/test_web.py | 0 20 files changed, 17 insertions(+), 14 deletions(-) rename osprofiler/tests/{cmd => unit}/__init__.py (100%) rename osprofiler/tests/{doc => unit/cmd}/__init__.py (100%) rename osprofiler/tests/{ => unit}/cmd/test_shell.py (100%) rename osprofiler/tests/{drivers => unit/doc}/__init__.py (100%) rename osprofiler/tests/{ => unit}/doc/test_specs.py (98%) create mode 100644 osprofiler/tests/unit/drivers/__init__.py rename osprofiler/tests/{ => unit}/drivers/test_base.py (100%) rename osprofiler/tests/{ => unit}/drivers/test_ceilometer.py (100%) rename osprofiler/tests/{ => unit}/drivers/test_elasticsearch.py (100%) rename osprofiler/tests/{ => unit}/drivers/test_loginsight.py (100%) rename osprofiler/tests/{ => unit}/drivers/test_messaging.py (100%) rename osprofiler/tests/{ => unit}/drivers/test_mongodb.py (100%) rename osprofiler/tests/{ => unit}/drivers/test_redis_driver.py (100%) rename osprofiler/tests/{ => unit}/test_notifier.py (100%) rename osprofiler/tests/{ => unit}/test_opts.py (100%) rename osprofiler/tests/{ => unit}/test_profiler.py (95%) rename osprofiler/tests/{ => unit}/test_sqlalchemy.py (100%) rename osprofiler/tests/{ => unit}/test_utils.py (100%) rename osprofiler/tests/{ => unit}/test_web.py (100%) diff --git a/.testr.conf b/.testr.conf index 27df784..ca3d5fa 100644 --- a/.testr.conf +++ b/.testr.conf @@ -1,4 +1,4 @@ [DEFAULT] -test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ ./osprofiler/tests $LISTOPT $IDOPTION +test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ ./osprofiler/tests/unit $LISTOPT $IDOPTION test_id_option=--load-list $IDFILE test_list_option=--list diff --git a/osprofiler/tests/cmd/__init__.py b/osprofiler/tests/unit/__init__.py similarity index 100% rename from osprofiler/tests/cmd/__init__.py rename to osprofiler/tests/unit/__init__.py diff --git a/osprofiler/tests/doc/__init__.py b/osprofiler/tests/unit/cmd/__init__.py similarity index 100% rename from osprofiler/tests/doc/__init__.py rename to osprofiler/tests/unit/cmd/__init__.py diff --git a/osprofiler/tests/cmd/test_shell.py b/osprofiler/tests/unit/cmd/test_shell.py similarity index 100% rename from osprofiler/tests/cmd/test_shell.py rename to osprofiler/tests/unit/cmd/test_shell.py diff --git a/osprofiler/tests/drivers/__init__.py b/osprofiler/tests/unit/doc/__init__.py similarity index 100% rename from osprofiler/tests/drivers/__init__.py rename to osprofiler/tests/unit/doc/__init__.py diff --git a/osprofiler/tests/doc/test_specs.py b/osprofiler/tests/unit/doc/test_specs.py similarity index 98% rename from osprofiler/tests/doc/test_specs.py rename to osprofiler/tests/unit/doc/test_specs.py index 39cabb5..fe2b867 100644 --- a/osprofiler/tests/doc/test_specs.py +++ b/osprofiler/tests/unit/doc/test_specs.py @@ -23,7 +23,7 @@ class TitlesTestCase(test.TestCase): specs_path = os.path.join( os.path.dirname(__file__), - os.pardir, os.pardir, os.pardir, + os.pardir, os.pardir, os.pardir, os.pardir, "doc", "specs") def _get_title(self, section_tree): diff --git a/osprofiler/tests/unit/drivers/__init__.py b/osprofiler/tests/unit/drivers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/osprofiler/tests/drivers/test_base.py b/osprofiler/tests/unit/drivers/test_base.py similarity index 100% rename from osprofiler/tests/drivers/test_base.py rename to osprofiler/tests/unit/drivers/test_base.py diff --git a/osprofiler/tests/drivers/test_ceilometer.py b/osprofiler/tests/unit/drivers/test_ceilometer.py similarity index 100% rename from osprofiler/tests/drivers/test_ceilometer.py rename to osprofiler/tests/unit/drivers/test_ceilometer.py diff --git a/osprofiler/tests/drivers/test_elasticsearch.py b/osprofiler/tests/unit/drivers/test_elasticsearch.py similarity index 100% rename from osprofiler/tests/drivers/test_elasticsearch.py rename to osprofiler/tests/unit/drivers/test_elasticsearch.py diff --git a/osprofiler/tests/drivers/test_loginsight.py b/osprofiler/tests/unit/drivers/test_loginsight.py similarity index 100% rename from osprofiler/tests/drivers/test_loginsight.py rename to osprofiler/tests/unit/drivers/test_loginsight.py diff --git a/osprofiler/tests/drivers/test_messaging.py b/osprofiler/tests/unit/drivers/test_messaging.py similarity index 100% rename from osprofiler/tests/drivers/test_messaging.py rename to osprofiler/tests/unit/drivers/test_messaging.py diff --git a/osprofiler/tests/drivers/test_mongodb.py b/osprofiler/tests/unit/drivers/test_mongodb.py similarity index 100% rename from osprofiler/tests/drivers/test_mongodb.py rename to osprofiler/tests/unit/drivers/test_mongodb.py diff --git a/osprofiler/tests/drivers/test_redis_driver.py b/osprofiler/tests/unit/drivers/test_redis_driver.py similarity index 100% rename from osprofiler/tests/drivers/test_redis_driver.py rename to osprofiler/tests/unit/drivers/test_redis_driver.py diff --git a/osprofiler/tests/test_notifier.py b/osprofiler/tests/unit/test_notifier.py similarity index 100% rename from osprofiler/tests/test_notifier.py rename to osprofiler/tests/unit/test_notifier.py diff --git a/osprofiler/tests/test_opts.py b/osprofiler/tests/unit/test_opts.py similarity index 100% rename from osprofiler/tests/test_opts.py rename to osprofiler/tests/unit/test_opts.py diff --git a/osprofiler/tests/test_profiler.py b/osprofiler/tests/unit/test_profiler.py similarity index 95% rename from osprofiler/tests/test_profiler.py rename to osprofiler/tests/unit/test_profiler.py index 195e298..6edd467 100644 --- a/osprofiler/tests/test_profiler.py +++ b/osprofiler/tests/unit/test_profiler.py @@ -202,7 +202,7 @@ class TraceDecoratorTestCase(test.TestCase): expected_info = { "info": "some_info", "function": { - "name": "osprofiler.tests.test_profiler.tracede_func", + "name": "osprofiler.tests.unit.test_profiler.tracede_func", "args": str((1,)), "kwargs": str({}) } @@ -216,7 +216,8 @@ class TraceDecoratorTestCase(test.TestCase): self.assertEqual((1, 2), trace_hide_args_func(1, i=2)) expected_info = { "function": { - "name": "osprofiler.tests.test_profiler.trace_hide_args_func" + "name": "osprofiler.tests.unit.test_profiler" + ".trace_hide_args_func" } } mock_start.assert_called_once_with("hide_args", info=expected_info) @@ -304,7 +305,7 @@ class TraceClsDecoratorTestCase(test.TestCase): expected_info = { "a": 10, "function": { - "name": ("osprofiler.tests.test_profiler" + "name": ("osprofiler.tests.unit.test_profiler" ".FakeTraceClassWithInfo.method1"), "args": str((fake_cls, 5, 15)), "kwargs": str({}) @@ -323,7 +324,7 @@ class TraceClsDecoratorTestCase(test.TestCase): expected_info = { "a": 10, "function": { - "name": ("osprofiler.tests.test_profiler" + "name": ("osprofiler.tests.unit.test_profiler" ".FakeTraceClassWithInfo.method3"), "args": str((fake_cls,)), "kwargs": str({"g": 5, "h": 10}) @@ -350,7 +351,7 @@ class TraceClsDecoratorTestCase(test.TestCase): expected_info = { "b": 20, "function": { - "name": ("osprofiler.tests.test_profiler" + "name": ("osprofiler.tests.unit.test_profiler" ".FakeTraceClassHideArgs.method1"), } } @@ -368,7 +369,7 @@ class TraceClsDecoratorTestCase(test.TestCase): expected_info = { "function": { - "name": ("osprofiler.tests.test_profiler" + "name": ("osprofiler.tests.unit.test_profiler" ".FakeTracePrivate._method"), "args": str((fake_cls, 5)), "kwargs": str({}) @@ -398,8 +399,10 @@ class TraceClsDecoratorTestCase(test.TestCase): # static and doesn't have reference to class # - and FakeTraceStatic.method4 in PY3 "name": - "osprofiler.tests.test_profiler.method4" if six.PY2 else - "osprofiler.tests.test_profiler.FakeTraceStatic.method4", + "osprofiler.tests.unit.test_profiler" + ".method4" if six.PY2 else + "osprofiler.tests.unit.test_profiler.FakeTraceStatic" + ".method4", "args": str((25,)), "kwargs": str({}) } @@ -482,7 +485,7 @@ class TraceWithMetaclassTestCase(test.TestCase): expected_info = { "a": 10, "function": { - "name": ("osprofiler.tests.test_profiler" + "name": ("osprofiler.tests.unit.test_profiler" ".FakeTraceWithMetaclassBase.method1"), "args": str((fake_cls, 5, 15)), "kwargs": str({}) @@ -501,7 +504,7 @@ class TraceWithMetaclassTestCase(test.TestCase): expected_info = { "a": 10, "function": { - "name": ("osprofiler.tests.test_profiler" + "name": ("osprofiler.tests.unit.test_profiler" ".FakeTraceWithMetaclassBase.method3"), "args": str((fake_cls,)), "kwargs": str({"g": 5, "h": 10}) @@ -528,7 +531,7 @@ class TraceWithMetaclassTestCase(test.TestCase): expected_info = { "b": 20, "function": { - "name": ("osprofiler.tests.test_profiler" + "name": ("osprofiler.tests.unit.test_profiler" ".FakeTraceWithMetaclassHideArgs.method5") } } @@ -546,7 +549,7 @@ class TraceWithMetaclassTestCase(test.TestCase): expected_info = { "function": { - "name": ("osprofiler.tests.test_profiler" + "name": ("osprofiler.tests.unit.test_profiler" ".FakeTraceWithMetaclassPrivate._new_private_method"), "args": str((fake_cls, 5)), "kwargs": str({}) diff --git a/osprofiler/tests/test_sqlalchemy.py b/osprofiler/tests/unit/test_sqlalchemy.py similarity index 100% rename from osprofiler/tests/test_sqlalchemy.py rename to osprofiler/tests/unit/test_sqlalchemy.py diff --git a/osprofiler/tests/test_utils.py b/osprofiler/tests/unit/test_utils.py similarity index 100% rename from osprofiler/tests/test_utils.py rename to osprofiler/tests/unit/test_utils.py diff --git a/osprofiler/tests/test_web.py b/osprofiler/tests/unit/test_web.py similarity index 100% rename from osprofiler/tests/test_web.py rename to osprofiler/tests/unit/test_web.py -- GitLab From f8cd42d11d5a328386e8682fb2d58601309dbc86 Mon Sep 17 00:00:00 2001 From: Vipin Balachandran Date: Thu, 8 Dec 2016 15:09:09 +0530 Subject: [PATCH 139/324] Pass oslo.messaging kwargs only for "messaging://" We need to pass oslo.messaging related arguments to notifier.create() only if the connection string starts with "messaging". Therefore removing those kwargs for other connection strings. Change-Id: Icb168ce6a456e5355aabbaf1283c30d3900a6ceb --- osprofiler/initializer.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/osprofiler/initializer.py b/osprofiler/initializer.py index 37d70b2..2921f30 100644 --- a/osprofiler/initializer.py +++ b/osprofiler/initializer.py @@ -30,14 +30,17 @@ def init_from_conf(conf, context, project, service, host): running on. """ connection_str = conf.profiler.connection_string + kwargs = {} + if connection_str.startswith("messaging"): + kwargs = {"messaging": oslo_messaging, + "transport": oslo_messaging.get_transport(conf)} _notifier = notifier.create( connection_str, - messaging=oslo_messaging, context=context, - transport=oslo_messaging.get_transport(conf), project=project, service=service, host=host, - conf=conf) + conf=conf, + **kwargs) notifier.set(_notifier) web.enable(conf.profiler.hmac_keys) -- GitLab From 33f85b2046e59deadc724eb28b7ce1b4487a5a5e Mon Sep 17 00:00:00 2001 From: Tovin Seven Date: Mon, 28 Nov 2016 14:21:39 +0700 Subject: [PATCH 140/324] Fix syntax in JS, JSON indent with 4 spaces template.html - Fix syntax: + Add a lot of semi-colons after statements/function expressions + Add a lot of brackets in for/if section - Change bracket notation -> dot notation (prefered in JS) - Change case in CSS colors - Change double quote to single quote - Add closing span tag commands.py - Indent json with 4 spaces Implements: blueprint update-html-template Change-Id: Idad248c3b3f9570045efb1495b69614a60e3f733 --- osprofiler/cmd/commands.py | 2 +- osprofiler/cmd/template.html | 82 +++++++++++++------------ osprofiler/tests/unit/cmd/test_shell.py | 2 +- 3 files changed, 45 insertions(+), 41 deletions(-) diff --git a/osprofiler/cmd/commands.py b/osprofiler/cmd/commands.py index 91d463a..27d3e5b 100644 --- a/osprofiler/cmd/commands.py +++ b/osprofiler/cmd/commands.py @@ -88,7 +88,7 @@ class TraceCommands(BaseCommand): with open(os.path.join(os.path.dirname(__file__), "template.html")) as html_template: output = html_template.read().replace( - "$DATA", json.dumps(trace, indent=2, + "$DATA", json.dumps(trace, indent=4, default=datetime_json_serialize)) elif args.use_dot: dot_graph = self._create_dot_graph(trace) diff --git a/osprofiler/cmd/template.html b/osprofiler/cmd/template.html index 1c35b79..7e8a653 100644 --- a/osprofiler/cmd/template.html +++ b/osprofiler/cmd/template.html @@ -3,7 +3,7 @@ @@ -16,14 +16,14 @@ } .trace tr:hover { - background-color: #D9EDF7!important; + background-color: #D9EDF7 !important; } .trace tr td { width: 14%; white-space: nowrap; padding: 2px; - border-right: 1px solid #eee; + border-right: 1px solid #EEE; } .trace tr td.details { @@ -48,7 +48,7 @@ width: 25px; margin: 0px; padding: 0px; - background-color: #c6eff3; + background-color: #C6EFF3; border-radius: 4px; font-size: 10px; } @@ -64,7 +64,7 @@
-
+