Set up mistral-extra with the ability to run unit tests

Properly sets up the mistral-extra repository with packaging and testing
setup, in order to add gating in CI.

Change-Id: I204745785e63cc8b1ae47da5cc59eda6da18b722
Depends-On: I5e75914e500837babdeb358a76ec7d90c56f61ac
This commit is contained in:
Brad P. Crochet 2017-02-22 13:09:02 -05:00
parent 096e0face6
commit 5bee294596
14 changed files with 203 additions and 2 deletions

7
.coveragerc Normal file
View File

@ -0,0 +1,7 @@
[run]
branch = True
source = mistral_extra
[report]
ignore_errors = True

1
.gitignore vendored
View File

@ -27,6 +27,7 @@ pip-log.txt
.coverage .coverage
.tox .tox
nosetests.xml nosetests.xml
.testrepository
AUTHORS AUTHORS
# Translations # Translations

7
.testr.conf Normal file
View File

@ -0,0 +1,7 @@
[DEFAULT]
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list

View File

@ -27,14 +27,14 @@ def summ():
try: try:
args_list = flask.json.loads(args).get('arguments') args_list = flask.json.loads(args).get('arguments')
except: except Exception:
return (403, "Please, specify list of arguments in the request body" return (403, "Please, specify list of arguments in the request body"
" in form '{\"arguments\": [arg1, arg2, .., argN]}'") " in form '{\"arguments\": [arg1, arg2, .., argN]}'")
for a in args_list: for a in args_list:
try: try:
summ += int(a) summ += int(a)
except: except Exception:
return 403, "Sorry, need to use only integer arguments!" return 403, "Sorry, need to use only integer arguments!"
return flask.jsonify({'result': summ}) return flask.jsonify({'result': summ})

View File

View File

View File

View File

@ -0,0 +1,24 @@
# Copyright 2017 - Red Hat, Inc.
#
# 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 oslo_log import log as logging
from oslotest import base
LOG = logging.getLogger(__name__)
class BaseTest(base.BaseTestCase):
def setUp(self):
super(BaseTest, self).setUp()

View File

@ -0,0 +1,20 @@
# Copyright 2017 - Red Hat, Inc.
#
# 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 mistral_extra.tests.unit.base import BaseTest
class TestBase(BaseTest):
def test_base(self):
assert True

7
requirements.txt Normal file
View File

@ -0,0 +1,7 @@
# 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.
pbr>=2.0.0 # Apache-2.0
Babel>=2.3.4 # BSD
oslo.log>=3.11.0 # Apache-2.0

51
setup.cfg Normal file
View File

@ -0,0 +1,51 @@
[metadata]
name = mistral-extra
summary = Mistral OpenStack-specific bindings
description-file =
README.rst
license = Apache License, Version 2.0
author = OpenStack Mistral Team
author-email = openstack-dev@lists.openstack.org
home-page = http://docs.openstack.org/developer/mistral/
classifier =
Environment :: OpenStack
Intended Audience :: Information Technology
Intended Audience :: System Administrators
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
[files]
packages =
mistral-extra
[build_sphinx]
source-dir = doc/source
build-dir = doc/build
all_files = 1
[upload_sphinx]
upload-dir = doc/build/html
[compile_catalog]
directory = mistral-extra/locale
domain = mistral-extra
[update_catalog]
domain = mistral-extra
output_dir = mistral-extra/locale
input_file = mistral-extra/locale/mistral-extra.pot
[extract_messages]
keywords = _ gettext ngettext l_ lazy_gettext
mapping_file = babel.cfg
output_file = mistral-extra/locale/mistral-extra.pot
[build_releasenotes]
all_files = 1
build-dir = releasenotes/build
source-dir = releasenotes/source

29
setup.py Normal file
View File

@ -0,0 +1,29 @@
# 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.
# 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>=1.8'],
pbr=True)

16
test-requirements.txt Normal file
View File

@ -0,0 +1,16 @@
# 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
coverage>=4.0 # Apache-2.0
python-subunit>=0.0.18 # Apache-2.0/BSD
sphinx>=1.5.1 # BSD
oslosphinx>=4.7.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0
testrepository>=0.0.18 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD
testtools>=1.4.0 # MIT
# releasenotes
reno>=1.8.0 # Apache-2.0

39
tox.ini Normal file
View File

@ -0,0 +1,39 @@
[tox]
minversion = 2.0
envlist = py35,py27,pep8
skipsdist = True
[testenv]
usedevelop = True
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
commands = python setup.py test --slowest --testr-args='{posargs}'
[testenv:pep8]
commands = flake8 {posargs}
[testenv:venv]
commands = {posargs}
[testenv:cover]
commands = python setup.py test --coverage --testr-args='{posargs}'
[testenv:docs]
commands = python setup.py build_sphinx
[testenv:releasenotes]
commands =
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[testenv:debug]
commands = oslo_debug_helper {posargs}
[flake8]
# E123, E125 skipped as they are invalid PEP-8.
show-source = True
ignore = E123,E125
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build