diff --git a/.gitignore b/.gitignore index faa9c1d6a827c06657529921a91fb0b1e493b11a..2571e6a47cd9173b33875336167cd7ff1d4366c4 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ ChangeLog .coverage cover/ .testrepository/ -doc/build/ \ No newline at end of file +doc/build/ +.stestr diff --git a/.gitreview b/.gitreview index 8ae1bcac54b43e97435a561d45ea92cc0f803fc6..1612ebedda715c6dcb6f24e9ca03b5af07d50a8f 100644 --- a/.gitreview +++ b/.gitreview @@ -1,4 +1,4 @@ [gerrit] -host=review.openstack.org +host=review.opendev.org port=29418 project=openstack/monasca-statsd.git diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 0000000000000000000000000000000000000000..ea359caed595ed86aecedfae327c7c6c468bb303 --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=./tests +top_dir=./ diff --git a/.testr.conf b/.testr.conf deleted file mode 100644 index 72195edbaf3328c737b6d7820d8fa3da3157c847..0000000000000000000000000000000000000000 --- a/.testr.conf +++ /dev/null @@ -1,9 +0,0 @@ -[DEFAULT] -test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ - OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ - OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \ - ${PYTHON:-python} -m subunit.run discover -t ./ $OS_TEST_PATH $LISTOPT $IDOPTION - -test_id_option=--load-list $IDFILE -test_list_option=--list -group_regex=tests(?:\.|_)([^_]+) \ No newline at end of file diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9b18ec8352a0375e35ede989215b88994455900b --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,10 @@ +- project: + templates: + - check-requirements + - openstack-cover-jobs + - openstack-lower-constraints-jobs + - openstack-python3-wallaby-jobs + check: + jobs: + - monasca-tempest-python3-influxdb: + voting: false diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000000000000000000000000000000000000..c860b7a7273f72dd23885ef12965f32ee4085489 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,19 @@ +The source repository for this project can be found at: + + https://opendev.org/openstack/monasca-statsd + +Pull requests submitted through GitHub are not monitored. + +To start contributing to OpenStack, follow the steps in the contribution guide +to set up and use Gerrit: + + https://docs.openstack.org/contributors/code-and-documentation/quick-start.html + +Bugs should be filed on Storyboard: + + https://storyboard.openstack.org/#!/project/872 + +For more specific information about contributing to this repository, see the +Monasca contributor guide: + + https://docs.openstack.org/monasca-api/latest/contributor/contributing.html diff --git a/README.md b/README.md deleted file mode 100644 index dd2c35530d47e844516cf713831732ca5dc5a7e3..0000000000000000000000000000000000000000 --- a/README.md +++ /dev/null @@ -1,95 +0,0 @@ -Team and repository tags -======================== - -[![Team and repository tags](https://governance.openstack.org/badges/monasca-statsd.svg)](https://governance.openstack.org/reference/tags/index.html) - - - -A Monasca-Statsd Python client. -================ - -Quick Start Guide ------------------ - -First install the library with `pip` or `easy_install` - - # Install in system python ... - sudo pip install monasca-statsd - - # .. or into a virtual env - pip install monasca-statsd - -Then start instrumenting your code: - -``` -# Import the module. -import monascastatsd as mstatsd - -# Create the connection -conn = mstatsd.Connection(host='localhost', port=8125) - -# Create the client with optional dimensions -client = mstatsd.Client(connection=conn, dimensions={'env': 'test'}) - -NOTE: You can also create a client without specifying the connection and it will create the client -with the default connection information for the monasca-agent statsd processor daemon -which uses host='localhost' and port=8125. - -client = mstatsd.Client(dimensions={'env': 'test'}) - -# Increment and decrement a counter. -counter = client.get_counter(name='page.views') - -counter.increment() -counter += 3 - -counter.decrement() -counter -= 3 - -# Record a gauge 50% of the time. -gauge = client.get_gauge('gauge', dimensions={'env': 'test'}) - -gauge.send('metric', 123.4, sample_rate=0.5) - -# Sample a histogram. -histogram = client.get_histogram('histogram', dimensions={'test': 'True'}) - -histogram.send('metric', 123.4, dimensions={'color': 'red'}) - -# Time a function call. -timer = client.get_timer() - -@timer.timed('page.render') -def render_page(): - # Render things ... - pass - -# Time a block of code. -timer = client.get_timer() - -with timer.time('t'): - # Do stuff - time.sleep(2) - -# Add dimensions to any metric. -histogram = client.get_histogram('my_hist') -histogram.send('query.time', 10, dimensions = {'version': '1.0', 'environment': 'dev'}) -``` -Repository -------------- - -The monasca-statsd code is located here: -[here](https://github.com/stackforge/monasca-statsd). - -Feedback --------- - -To suggest a feature, report a bug, or general discussion, head over -[here](https://bugs.launchpad.net/monasca). - - -License -------- - -See LICENSE file -Code was originally forked from Datadog's dogstatsd-python, hence the dual license. diff --git a/README.rst b/README.rst new file mode 100644 index 0000000000000000000000000000000000000000..2d6a32c2e185fc61209a9694d09a555d2724cb93 --- /dev/null +++ b/README.rst @@ -0,0 +1,92 @@ +Openstack Monasca Statsd +======================== + +.. image:: https://governance.openstack.org/tc/badges/monasca-statsd.svg + :target: https://governance.openstack.org/tc/reference/tags/index.html + +A Monasca-Statsd Python Client. +=============================== + +Quick Start Guide +----------------- + +First install the library with ``pip`` or ``easy_install``: + +:: + + # Install in system python ... + sudo pip install monasca-statsd + + # .. or into a virtual env + pip install monasca-statsd + +Then start instrumenting your code: + +:: + + # Import the module. + import monascastatsd as mstatsd + + # Create the connection + conn = mstatsd.Connection(host='localhost', port=8125) + + # Create the client with optional dimensions + client = mstatsd.Client(connection=conn, dimensions={'env': 'test'}) + + NOTE: You can also create a client without specifying the connection and it will create the client + with the default connection information for the monasca-agent statsd processor daemon + which uses host='localhost' and port=8125. + + client = mstatsd.Client(dimensions={'env': 'test'}) + + # Increment and decrement a counter. + counter = client.get_counter(name='page.views') + + counter.increment() + counter += 3 + + counter.decrement() + counter -= 3 + + # Record a gauge 50% of the time. + gauge = client.get_gauge('gauge', dimensions={'env': 'test'}) + + gauge.send('metric', 123.4, sample_rate=0.5) + + # Sample a histogram. + histogram = client.get_histogram('histogram', dimensions={'test': 'True'}) + + histogram.send('metric', 123.4, dimensions={'color': 'red'}) + + # Time a function call. + timer = client.get_timer() + + @timer.timed('page.render') + def render_page(): + # Render things ... + pass + + # Time a block of code. + timer = client.get_timer() + + with timer.time('t'): + # Do stuff + time.sleep(2) + + # Add dimensions to any metric. + histogram = client.get_histogram('my_hist') + histogram.send('query.time', 10, dimensions = {'version': '1.0', 'environment': 'dev'}) + +Feedback +-------- + +To suggest a feature, report a bug, or participate in the general +discussion, head over to `StoryBoard`_. + +License +------- + +See LICENSE file. Code was originally forked from Datadog’s +dogstatsd-python, hence the dual license. + +.. _StoryBoard: https://storyboard.openstack.org/#!/project/872 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000000000000000000000000000000000000..913d1dbde46753618158f14d8f45019833e1fa56 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,61 @@ +python-monasca-statsd (2.2.0-2) UNRELEASED; urgency=medium + + * Bump debhelper from old 10 to 13. + + Replace python_distutils buildsystem with pybuild. + * Set upstream metadata fields: Repository, Repository-Browse. + * Update standards version to 4.5.1, no changes needed. + + -- Debian Janitor Sat, 11 Sep 2021 06:04:39 -0000 + +python-monasca-statsd (2.2.0-1) unstable; urgency=medium + + * d/copyright: Add me to copyright file + * d/control: Add me to uploaders field + * New upstream version + + -- Michal Arbet Fri, 20 Aug 2021 12:29:29 +0200 + +python-monasca-statsd (2.1.0-2) unstable; urgency=medium + + * Uploading to unstable. + * Fixed debian/watch. + * Add a debian/salsa-ci.yml. + + -- Thomas Goirand Sat, 17 Oct 2020 16:45:51 +0200 + +python-monasca-statsd (2.1.0-1) experimental; urgency=medium + + [ Ondřej Nový ] + * Use debhelper-compat instead of debian/compat. + * Bump Standards-Version to 4.4.1. + + [ Thomas Goirand ] + * New upstream release. + * Removed python3-mock from build-depends. + + -- Thomas Goirand Tue, 08 Sep 2020 09:18:39 +0200 + +python-monasca-statsd (1.11.0-2) unstable; urgency=medium + + * Uploading to unstable. + + -- Thomas Goirand Tue, 16 Jul 2019 21:38:30 +0200 + +python-monasca-statsd (1.11.0-1) experimental; urgency=medium + + [ Ondřej Nový ] + * d/control: Set Vcs-* to salsa.debian.org + * d/copyright: Use https in Format + * d/control: Use team+openstack@tracker.debian.org as maintainer + + [ Thomas Goirand ] + * New upstream release. + * Removed Python 2 support. + + -- Thomas Goirand Wed, 27 Mar 2019 09:57:23 +0100 + +python-monasca-statsd (1.7.0-1) experimental; urgency=medium + + * Initial release. (Closes: #878750) + + -- Thomas Goirand Mon, 16 Oct 2017 14:48:04 +0200 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000000000000000000000000000000000000..978238b3e43a66e728fe9c26de08ee1c3e73ec55 --- /dev/null +++ b/debian/control @@ -0,0 +1,41 @@ +Source: python-monasca-statsd +Section: python +Priority: optional +Maintainer: Debian OpenStack +Uploaders: + Thomas Goirand , + Michal Arbet , +Build-Depends: + debhelper-compat (= 13), + dh-python, + openstack-pkg-tools, + python3-all, + python3-setuptools, +Build-Depends-Indep: + python3-coverage, + python3-hacking, + python3-oslotest, + python3-six, + python3-stestr, +Standards-Version: 4.5.1 +Vcs-Browser: https://salsa.debian.org/openstack-team/libs/python-monasca-statsd +Vcs-Git: https://salsa.debian.org/openstack-team/libs/python-monasca-statsd.git +Homepage: https://github.com/openstack/monasca-statsd + +Package: python3-monasca-statsd +Architecture: all +Depends: + python3-six, + ${misc:Depends}, + ${python3:Depends}, +Description: monasca statsd client - Python 3.x + Monasca is a highly scalable, performant, fault-tolerant + monitoring-as-a-service solution that integrates with OpenStack. It uses a + REST API for high-speed metrics processing and querying and has a streaming + alarm engine and notification engine. + . + This Python module provides a client to connect to Monasca's statsd REST API. + With this client, you can handle counters, gauge, get histograms, timers and + more. + . + This package contains the Python 3.x module. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000000000000000000000000000000000000..0cda7ba29e440fd9f519e4317be755104335f43d --- /dev/null +++ b/debian/copyright @@ -0,0 +1,52 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: monasca-statsd +Source: https://github.com/openstack/monasca-statsd + +Files: * +Copyright: (c) 2013, OpenStack Foundation + (c) 2014-2016, Hewlett Packard Enterprise Development LP + (c) 2012, Datadog +License: Apache-2-and-BSD-3-clause + +Files: debian/* +Copyright: (c) 2017, Thomas Goirand + (c) 2021, Michal Arbet +License: Apache-2-and-BSD-3-clause + +License: Apache-2-and-BSD-3-clause + 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. + . + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Datadog nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL DATADOG BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000000000000000000000000000000000000..470427504700eaf4bb0f0a684a284658d65cad1b --- /dev/null +++ b/debian/rules @@ -0,0 +1,21 @@ +#!/usr/bin/make -f + +UPSTREAM_GIT := https://github.com/openstack/monasca-statsd.git +include /usr/share/openstack-pkg-tools/pkgos.make + +%: + dh $@ --buildsystem=pybuild --with python3 + +override_dh_auto_clean: + rm -rf build + +override_dh_auto_build: + echo "Do nothing..." + +override_dh_auto_install: + pkgos-dh_auto_install --no-py2 + +override_dh_auto_test: +ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS))) + pkgos-dh_auto_test --no-py2 +endif diff --git a/debian/salsa-ci.yml b/debian/salsa-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..0c22dc4373420a05999d6f9bc2235f73fc0ffa14 --- /dev/null +++ b/debian/salsa-ci.yml @@ -0,0 +1,3 @@ +include: + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000000000000000000000000000000000000..163aaf8d82b6c54f23c45f32895dbdfdcc27b047 --- /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 0000000000000000000000000000000000000000..cb61fa5267b6ad8b3bbc2a612754b79dae466292 --- /dev/null +++ b/debian/source/options @@ -0,0 +1 @@ +extend-diff-ignore = "^[^/]*[.]egg-info/" diff --git a/debian/upstream/metadata b/debian/upstream/metadata new file mode 100644 index 0000000000000000000000000000000000000000..e955d473a031951ea8800eca80af550c7e7fab17 --- /dev/null +++ b/debian/upstream/metadata @@ -0,0 +1,3 @@ +--- +Repository: https://github.com/openstack/monasca-statsd.git +Repository-Browse: https://github.com/openstack/monasca-statsd diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000000000000000000000000000000000000..271b06a1a5121f107504d0b5f2690039f4f99827 --- /dev/null +++ b/debian/watch @@ -0,0 +1,3 @@ +version=3 +opts="uversionmangle=s/\.0rc/~rc/;s/\.0b1/~b1/;s/\.0b2/~b2/;s/\.0b3/~b3/" \ +https://github.com/openstack/monasca-statsd/tags .*/(\d[brc\d\.]+)\.tar\.gz diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..fb31f9f02ae92af972781fbb61de22b5c7ee80e3 --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1,3 @@ +sphinx!=1.6.6,!=1.6.7,>=1.6.5 # BSD +oslosphinx>=4.7.0 # Apache-2.0 +openstackdocstheme>=1.18.1 # Apache-2.0 diff --git a/doc/source/conf.py b/doc/source/conf.py index 20d22e9e059e83fdc67f493d92c9936ae0bd28c4..3e2e53a30307c35642e1e0148f5b530c5f124f91 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -172,12 +172,11 @@ html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local", - "-n1"] + "-n1"] try: - html_last_updated_fmt = subprocess.Popen( - git_cmd, stdout=subprocess.PIPE).communicate()[0].decode() + html_last_updated_fmt = subprocess.check_output(git_cmd).decode('utf-8') except Exception: warnings.warn('Cannot get last updated time from git repository. ' 'Not setting "html_last_updated_fmt".') diff --git a/lower-constraints.txt b/lower-constraints.txt new file mode 100644 index 0000000000000000000000000000000000000000..cc32fbc8d0437c1a192c3a8babe1d54dc45ccf82 --- /dev/null +++ b/lower-constraints.txt @@ -0,0 +1,44 @@ +alabaster==0.7.10 +appdirs==1.4.0 +Babel==2.3.4 +bandit==1.4.0 +coverage==4.0 +docutils==0.11 +dulwich==0.15.0 +extras==1.0.0 +fixtures==3.0.0 +future==0.16.0 +gitdb==0.6.4 +GitPython==1.0.1 +imagesize==0.7.1 +iso8601==0.1.11 +Jinja2==2.10 +keystoneauth1==3.4.0 +linecache2==1.0.0 +MarkupSafe==1.0 +mccabe==0.6.0 +mox3==0.20.0 +openstackdocstheme==1.18.1 +os-client-config==1.28.0 +os-testr==1.0.0 +oslosphinx==4.7.0 +oslotest==3.2.0 +pbr==2.0.0 +Pygments==2.2.0 +python-mimeparse==1.6.0 +python-subunit==1.0.0 +pytz==2013.6 +PyYAML==3.12 +requests==2.14.2 +requestsexceptions==1.2.0 +six==1.12.0 +smmap==0.9.0 +snowballstemmer==1.2.1 +Sphinx==1.6.5 +sphinxcontrib-websupport==1.0.1 +stestr==1.0.0 +stevedore==1.20.0 +testrepository==0.0.18 +testtools==2.2.0 +traceback2==1.4.0 +unittest2==1.1.0 diff --git a/releasenotes/notes/drop-py-2-7-c9e3758f73d5cf29.yaml b/releasenotes/notes/drop-py-2-7-c9e3758f73d5cf29.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d03534972223da02ed9fa4c1139639b8f1a4ac34 --- /dev/null +++ b/releasenotes/notes/drop-py-2-7-c9e3758f73d5cf29.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - | + Python 2.7 support has been dropped. Last release of monasca-statsd + to support python 2.7 is OpenStack Train. The minimum version of Python now + supported by monasca-statsd is Python 3.6. diff --git a/requirements.txt b/requirements.txt index 08c2a8868c7b797f14db8fb999b33f52aef4bb69..e6d6e1195a42c69218e6684acd27b9bca42d5ad3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -six>=1.9.0 # MIT +six>=1.12.0 # MIT diff --git a/setup.cfg b/setup.cfg index 9adc8375907fc66824a35a6f39e5b77288b1b1df..722f4e55b060850fa2e9c63c0d9791a6eff1e8f0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,9 +2,9 @@ name = monasca-statsd maintainer = monasca maintainer_email = monasca@lists.launchpad.net -description-file = README.md +description-file = README.rst summary = Monasca statsd Python client -home-page = https://github.com/openstack/monasca-statsd +home-page = https://opendev.org/openstack/monasca-statsd keywords= openstack monitoring @@ -12,28 +12,26 @@ keywords= license = Apache-2 include_package_data = True test_suite = nose.collector +python-requires = >=3.6 classifier = Development Status :: 5 - Production/Stable License :: OSI Approved :: Apache Software License Topic :: System :: Monitoring Programming Language :: Python - Programming Language :: Python :: 2.7 - Programming Language :: Python :: 3.5 + Programming Language :: Python :: Implementation :: CPython + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 [files] packages = monascastatsd -[global] -setup-hooks = - pbr.hooks.setup_hook - [pbr] autodoc_index_modules = True -[wheel] -universal = 1 - [egg_info] tag_build = tag_date = 0 diff --git a/setup.py b/setup.py index 566d84432eeda2c367f881c596d327a703beb79a..cd35c3c35bf1561bb136217711b0c9c163f4c796 100644 --- a/setup.py +++ b/setup.py @@ -13,17 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT import setuptools -# In python < 2.7.4, a lazy loading of package `pbr` will break -# setuptools if some other modules registered functions in `atexit`. -# solution from: http://bugs.python.org/issue15881#msg170215 -try: - import multiprocessing # noqa -except ImportError: - pass - setuptools.setup( setup_requires=['pbr>=2.0.0'], pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt index bec732ce4b406f8526632ea30c8ed020fd4c83eb..9cc0447baa5fb29306435eaa0635f7a38fd2722c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,13 +1,9 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 +hacking>=3.0.1,<3.1.0 # Apache-2.0 bandit>=1.1.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 -mock>=2.0 # BSD -sphinx!=1.6.1,>=1.5.1 # BSD -oslosphinx>=4.7.0 # Apache-2.0 -oslotest>=1.10.0 # Apache-2.0 -os-testr>=0.8.0 # Apache-2.0 +oslotest>=3.2.0 # Apache-2.0 +stestr>=1.0.0 # Apache-2.0 testrepository>=0.0.18 # Apache-2.0/BSD -openstackdocstheme>=1.5.0 # Apache-2.0 diff --git a/tests/test_monascastatsd.py b/tests/test_monascastatsd.py index cf9ea3a787d30862013c2b2d961c8568d33914ac..d8692c8915ea7ef3a06e6a8cfb7ec836a608e023 100644 --- a/tests/test_monascastatsd.py +++ b/tests/test_monascastatsd.py @@ -48,7 +48,7 @@ import unittest import monascastatsd as mstatsd -import mock +from unittest import mock import six from six.moves import range @@ -274,7 +274,8 @@ class TestMonascaStatsd(unittest.TestCase): timer.timing('timer', 123) self.client.connection.close_buffer() - self.assertEqual(six.b("site.views:123|g|#{'env': 'test'}\nsite.timer:123|g|#{'env': 'test'}"), + self.assertEqual(six.b("site.views:123|g|#{'env': 'test'}\n" + "site.timer:123|g|#{'env': 'test'}"), self.recv(gauge)) def test_context_manager(self): @@ -307,5 +308,6 @@ class TestMonascaStatsd(unittest.TestCase): b, delta) + if __name__ == '__main__': unittest.main() diff --git a/tools/tox_install.sh b/tools/tox_install.sh deleted file mode 100755 index 1adc0331f173358e986855b820d2b61094398ebc..0000000000000000000000000000000000000000 --- a/tools/tox_install.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash - -# Constraint file contains this package version pin that is in conflict -# with installing the package from source. We should replace the version pin in -# the constraints file before applying it for from-source installation. - -ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner -BRANCH_NAME=master -PACKAGE_NAME=monasca-statsd -requirements_installed=$(echo "import openstack_requirements" | python 2>/dev/null ; echo $?) - -set -e - -git config --global url.https://git.openstack.org/.insteadOf git://git.openstack.org/ - -CONSTRAINTS_FILE=$1 -shift - -install_cmd="pip install" -mydir=$(mktemp -dt "$PACKAGE_NAME-tox_install-XXXXXXX") -trap "rm -rf $mydir" EXIT -localfile=$mydir/upper-constraints.txt -if [[ $CONSTRAINTS_FILE != http* ]]; then - CONSTRAINTS_FILE=file://$CONSTRAINTS_FILE -fi -curl $CONSTRAINTS_FILE -k -o $localfile -install_cmd="$install_cmd -c$localfile" - -if [ $requirements_installed -eq 0 ]; then - echo "ALREADY INSTALLED" > /tmp/tox_install.txt - echo "Requirements already installed; using existing package" -elif [ -x "$ZUUL_CLONER" ]; then - echo "ZUUL CLONER" > /tmp/tox_install.txt - pushd $mydir - $ZUUL_CLONER --cache-dir \ - /opt/git \ - --branch $BRANCH_NAME \ - git://git.openstack.org \ - openstack/requirements - cd openstack/requirements - $install_cmd -e . - popd -else - echo "PIP HARDCODE" > /tmp/tox_install.txt - if [ -z "$REQUIREMENTS_PIP_LOCATION" ]; then - REQUIREMENTS_PIP_LOCATION="git+https://git.openstack.org/openstack/requirements@$BRANCH_NAME#egg=requirements" - fi - $install_cmd -U -e ${REQUIREMENTS_PIP_LOCATION} -fi - -# This is the main purpose of the script: Allow local installation of -# the current repo. It is listed in constraints file and thus any -# install will be constrained and we need to unconstrain it. -edit-constraints $localfile -- $PACKAGE_NAME "-e file://$PWD#egg=$PACKAGE_NAME" - -$install_cmd -U $* -exit $? diff --git a/tox.ini b/tox.ini index d9988d236deaf8894fa14f515253de5cc0d9fddf..a1b32e65594bc42814162cb195d31cdae9b8e9c3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,10 @@ [tox] -envlist = py{27,35},pep8,cover +envlist = py38,pep8,cover minversion = 2.5 skipsdist = True [testenv] -setenv = - VIRTUAL_ENV={envdir} - OS_TEST_PATH=tests - CLIENT_NAME=monasca-statsd +basepython = python3 passenv = http_proxy HTTP_PROXY https_proxy @@ -15,46 +12,35 @@ passenv = http_proxy no_proxy NO_PROXY usedevelop = True -install_command = - {toxinidir}/tools/tox_install.sh {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages} -deps = -r{toxinidir}/requirements.txt +install_command = pip install {opts} {packages} +deps = + -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt whitelist_externals = bash find rm commands = find . -type f -name "*.py[c|o]" -delete - -[testenv:py27] -basepython = python2.7 -deps = {[testenv]deps} -commands = - {[testenv]commands} - ostestr {posargs} - -[testenv:py35] -basepython = python3.5 -deps = {[testenv]deps} -commands = - {[testenv]commands} - ostestr {posargs} + stestr run {posargs} [testenv:cover] -basepython = python2.7 -deps = {[testenv]deps} +description = Calculates code coverage +setenv = + PYTHON=coverage run --source monascastatsd --parallel-mode commands = - {[testenv]commands} - coverage erase - python setup.py test --coverage --testr-args='{posargs}' --coverage-package-name=monascastatsd - coverage report + stestr run {posargs} + coverage combine + coverage html -d cover + coverage xml -o cover/coverage.xml [testenv:debug] -deps = {[testenv]deps} commands = - {[testenv]commands} oslo_debug_helper -t {toxinidir}/tests {posargs} [testenv:docs] +deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -r{toxinidir}/doc/requirements.txt commands = rm -rf doc/build python setup.py build_sphinx @@ -76,4 +62,10 @@ commands = {posargs} [flake8] show-source = True exclude=.venv,.git,.tox,dist,*egg,build,docs,cover -max-line-length = 120 +max-line-length = 100 + +[testenv:lower-constraints] +deps = + -c{toxinidir}/lower-constraints.txt + -r{toxinidir}/test-requirements.txt + -r{toxinidir}/requirements.txt