diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..8c810ee7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,60 @@ +# Add patterns in here to exclude files created by tools integrated with this +# repository, such as test frameworks from the project's recommended workflow, +# rendered documentation and package builds. +# +# Don't add patterns to exclude files created by preferred personal tools +# (editors, IDEs, your operating system itself even). These should instead be +# maintained outside the repository, for example in a ~/.gitignore file added +# with: +# +# git config --global core.excludesfile '~/.gitignore' + +# Bytecompiled Python +*.py[cod] + +# C extensions +*.so + +# Packages +*.egg* +*.egg-info +dist +build +eggs +parts +sdist +develop-eggs +.installed.cfg +lib64 + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +cover/ +.coverage* +!.coveragerc +.tox +nosetests.xml +.testrepository +.stestr +.venv + +# Translations +*.mo + +etc/*.sample + +# Complexity +output/*.html +output/*/index.html + +# Sphinx +doc/build + +# pbr generates these +AUTHORS +ChangeLog + +# Files created by releasenotes build +releasenotes/build diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 00000000..f96576d2 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,114 @@ +# The format of this file isn't really documented; just use --generate-rcfile +[MASTER] +# Add to the black list. It should be a base name, not a +# path. You may set this option multiple times. +ignore=.git,tests + +[MESSAGES CONTROL] +# TODO: This list is copied from neutron, the options which do not need to be +# suppressed have been already removed, some of the remaining options will be +# removed by code adjustment. +disable= +# "F" Fatal errors that prevent further processing + import-error, +# "I" Informational noise +# "E" Error for important programming issues (likely bugs) + no-member, +# "W" Warnings for stylistic problems or minor programming issues + abstract-method, + arguments-differ, + attribute-defined-outside-init, + broad-except, + dangerous-default-value, + fixme, + global-statement, + no-init, + protected-access, + redefined-builtin, + redefined-outer-name, + signature-differs, + unused-argument, + unused-import, + unused-variable, + useless-super-delegation, +# "C" Coding convention violations + bad-continuation, + invalid-name, + len-as-condition, + misplaced-comparison-constant, + missing-docstring, + superfluous-parens, + ungrouped-imports, + wrong-import-order, +# "R" Refactor recommendations + duplicate-code, + no-else-return, + no-self-use, + too-few-public-methods, + too-many-ancestors, + too-many-arguments, + too-many-branches, + too-many-instance-attributes, + too-many-lines, + too-many-locals, + too-many-public-methods, + too-many-return-statements, + too-many-statements, + inconsistent-return-statements, + useless-object-inheritance, + too-many-nested-blocks, + too-many-boolean-expressions, + not-callable, +# new for python3 version of pylint + chained-comparison, + consider-using-dict-comprehension, + consider-using-in, + consider-using-set-comprehension, + unnecessary-pass, + useless-object-inheritance + + +[BASIC] +# Variable names can be 1 to 31 characters long, with lowercase and underscores +variable-rgx=[a-z_][a-z0-9_]{0,30}$ + +# Argument names can be 2 to 31 characters long, with lowercase and underscores +argument-rgx=[a-z_][a-z0-9_]{1,30}$ + +# Method names should be at least 3 characters long +# and be lowercased with underscores +method-rgx=([a-z_][a-z0-9_]{2,}|setUp|tearDown)$ + +# Module names matching +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Don't require docstrings on tests. +no-docstring-rgx=((__.*__)|([tT]est.*)|setUp|tearDown)$ + +[FORMAT] +# Maximum number of characters on a single line. +max-line-length=79 + +[VARIABLES] +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + +[CLASSES] +# List of interface methods to ignore, separated by a comma. +ignore-iface-methods= + +[IMPORTS] +# Deprecated modules which should not be used, separated by a comma +deprecated-modules= +# should use oslo_serialization.jsonutils + json + +[TYPECHECK] +# List of module names for which member attributes should not be checked +ignored-modules=six.moves,_MovedItems + +[REPORTS] +# Tells whether to display a full report or only the messages +reports=no + diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 00000000..dc62e666 --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=${OS_TEST_PATH:-./ovn_octavia_provider/tests/unit} +top_dir=./ diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 00000000..f3693cc6 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,13 @@ +If you would like to contribute to the development of OpenStack, +you must follow the steps in this page: +https://docs.openstack.org/infra/manual/developers.html + +Once those steps have been completed, changes to OpenStack +should be submitted for review via the Gerrit tool, following +the workflow documented at: +https://docs.openstack.org/infra/manual/developers.html#development-workflow + +Pull requests submitted through GitHub will be ignored. + +Bugs should be filed on Launchpad, not GitHub: +https://bugs.launchpad.net/neutron/+bugs?field.tag=ovn-octavia-provider diff --git a/HACKING.rst b/HACKING.rst new file mode 100644 index 00000000..5d718c1c --- /dev/null +++ b/HACKING.rst @@ -0,0 +1,17 @@ +ovn-octavia-provider Style Commandments +=============================================== + +Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/ + +Below you can find a list of checks specific to this repository. + +- [N322] Detect common errors with assert_called_once_with +- [N328] Detect wrong usage with assertEqual +- [N330] Use assertEqual(*empty*, observed) instead of + assertEqual(observed, *empty*) +- [N331] Detect wrong usage with assertTrue(isinstance()). +- [N332] Use assertEqual(expected_http_code, observed_http_code) instead of + assertEqual(observed_http_code, expected_http_code). +- [N343] Production code must not import from ovn_octavia_provider.tests.* +- [N344] Python 3: Do not use filter(lambda obj: test(obj), data). Replace it + with [obj for obj in data if test(obj)]. diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..68c771a0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,176 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..e8aa3f0b --- /dev/null +++ b/README.rst @@ -0,0 +1,25 @@ +=================================================================== +ovn-octavia-provider - OVN Provider driver for Octavia LoadBalancer +=================================================================== + +OVN provides virtual networking for Open vSwitch and is a component of the Open +vSwitch project. This project provides integration between OpenStack Octavia +and OVN. + +* Free software: Apache license +* Source: https://opendev.org/openstack/ovn-octavia-provider +* Bugs: https://bugs.launchpad.net/neutron/+bugs?field.tag=ovn-octavia-provider + +* Mailing list: + http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-discuss +* IRC: #openstack-neutron on Freenode. +* Docs: https://docs.openstack.org/ovn-octavia-provider/latest + +Team and repository tags +------------------------ + +.. image:: https://governance.openstack.org/tc/badges/ovn-octavia-provider.svg + :target: https://governance.openstack.org/tc/reference/tags/index.html + +* Release notes for the project can be found at: + https://docs.openstack.org/releasenotes/ovn-octavia-provider diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 00000000..e04f58da --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +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. +sphinx!=1.6.6,!=1.6.7,>=1.6.2,!=2.1.0 # BSD +sphinxcontrib-svg2pdfconverter>=0.1.0 # BSD +openstackdocstheme>=1.20.0 # Apache-2.0 +doc8>=0.6.0 # Apache-2.0 +oslotest>=3.2.0 # Apache-2.0 +reno>=2.5.0 # Apache-2.0 diff --git a/doc/source/_static/.placeholder b/doc/source/_static/.placeholder new file mode 100644 index 00000000..e69de29b diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 00000000..965b8697 --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- +# 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. + +import os +import sys + +sys.path.insert(0, os.path.abspath('../..')) +sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ---------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [ + 'sphinx.ext.autodoc', + 'openstackdocstheme', + 'oslo_config.sphinxext', + 'sphinxcontrib.rsvgconverter', +] + +# Project cross-reference roles +openstack_projects = [ + 'neutron', + 'octavia', +] + +# openstackdocstheme options +repository_name = 'openstack/ovn-octavia-provider' +bug_project = 'neutron' +bug_tag = 'ovn-octavia-provider' + +# autodoc generation is a bit aggressive and a nuisance when doing heavy +# text edit cycles. +# execute "export SPHINX_DEBUG=1" in your terminal to disable + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# If true, '()' will be appended to :func: etc. cross-reference text. +add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +add_module_names = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# -- Options for HTML output -------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +# html_theme_path = ["."] +# html_theme = '_theme' +html_static_path = ['_static'] +html_theme = 'openstackdocs' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'ovn-octavia-providerdoc' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto/manual]). +latex_documents = [ + ('index', + 'doc-ovn-octavia-provider.tex', + u'ovn-octavia-provider Documentation', + u'OpenStack Foundation', 'manual'), +] + +# Example configuration for intersphinx: refer to the Python standard library. +#intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 00000000..1b8181b2 --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,29 @@ +.. + Copyright 2011-2020 OpenStack Foundation + All Rights Reserved. + + 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. + +Welcome to OVN Octavia provider driver's documentation! +======================================================= + +.. We use different index pages for HTML and PDF documents for better TOC. + Please ensure to update pdf-index.rst when you update the index below. + +Search +------ + +* :ref:`OVN Octavia provider driver document search `: Search the + contents of this document. +* `OpenStack wide search `_: Search the wider + set of OpenStack documentation, including forums. diff --git a/doc/source/pdf-index.rst b/doc/source/pdf-index.rst new file mode 100644 index 00000000..24051487 --- /dev/null +++ b/doc/source/pdf-index.rst @@ -0,0 +1,21 @@ +:orphan: + +.. + Copyright 2011- OpenStack Foundation + All Rights Reserved. + + 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. + +.. toctree:: + :maxdepth: 2 + diff --git a/lower-constraints.txt b/lower-constraints.txt new file mode 100644 index 00000000..bf56817b --- /dev/null +++ b/lower-constraints.txt @@ -0,0 +1,152 @@ +alabaster==0.7.10 +alembic==0.8.10 +amqp==2.1.1 +appdirs==1.4.3 +asn1crypto==0.23.0 +astroid==2.1.0 +Babel==2.3.4 +beautifulsoup4==4.6.0 +cachetools==2.0.0 +cffi==1.7.0 +chardet==3.0.4 +cliff==2.8.0 +cmd2==0.8.0 +contextlib2==0.4.0 +coverage==4.0 +cryptography==2.1 +debtcollector==1.2.0 +decorator==3.4.0 +deprecation==1.0 +doc8==0.6.0 +docutils==0.11 +dogpile.cache==0.6.2 +dulwich==0.15.0 +eventlet==0.18.2 +extras==1.0.0 +fasteners==0.7.0 +fixtures==3.0.0 +flake8==2.6.2 +flake8-import-order==0.12 +future==0.16.0 +futurist==1.2.0 +greenlet==0.4.10 +hacking==1.1.0 +idna==2.6 +imagesize==0.7.1 +iso8601==0.1.11 +Jinja2==2.10 +jmespath==0.9.0 +jsonpatch==1.16 +jsonpointer==1.13 +jsonschema==2.6.0 +keystoneauth1==3.4.0 +keystonemiddleware==4.17.0 +kombu==4.0.0 +linecache2==1.0.0 +logilab-common==1.4.1 +logutils==0.3.5 +Mako==0.4.0 +MarkupSafe==1.0 +mccabe==0.2.1 +mock==2.0.0 +monotonic==0.6 +mox3==0.20.0 +msgpack-python==0.4.0 +munch==2.1.0 +netaddr==0.7.18 +netifaces==0.10.4 +neutron==13.0.0.0b2 +neutron-lib==1.28.0 +octavia-lib==1.3.1 +openstackdocstheme==1.20.0 +openstacksdk==0.11.2 +os-client-config==1.28.0 +os-service-types==1.2.0 +os-testr==1.0.0 +os-xenapi==0.3.1 +osc-lib==1.8.0 +oslo.cache==1.26.0 +oslo.concurrency==3.25.0 +oslo.config==5.2.0 +oslo.context==2.19.2 +oslo.i18n==3.15.3 +oslo.log==3.36.0 +oslo.messaging==5.29.0 +oslo.middleware==3.31.0 +oslo.policy==1.30.0 +oslo.privsep==1.23.0 +oslo.reports==1.18.0 +oslo.rootwrap==5.8.0 +oslo.serialization==2.18.0 +oslo.service==1.24.0 +oslo.utils==3.33.0 +oslo.versionedobjects==1.31.2 +oslotest==3.2.0 +osprofiler==1.4.0 +ovs==2.8.0 +ovsdbapp==0.17.0 +Paste==2.0.2 +PasteDeploy==1.5.0 +pbr==2.0.0 +pecan==1.0.0 +pep8==1.5.7 +pika==0.10.0 +pika-pool==0.1.3 +positional==1.2.1 +prettytable==0.7.2 +psutil==3.2.2 +pycadf==1.1.0 +pycodestyle==2.4.0 +pycparser==2.18 +pyflakes==0.8.1 +Pygments==2.2.0 +pyinotify==0.9.6 +pylint==2.2.0 +pyOpenSSL==17.1.0 +pyparsing==2.1.0 +pyperclip==1.5.27 +pyroute2==0.4.21 +python-dateutil==2.5.3 +python-designateclient==2.7.0 +python-editor==1.0.3 +python-keystoneclient==3.8.0 +python-mimeparse==1.6.0 +python-neutronclient==6.7.0 +python-novaclient==9.1.0 +python-subunit==1.0.0 +pytz==2013.6 +PyYAML==3.12 +reno==2.5.0 +repoze.lru==0.7 +requests==2.14.2 +requestsexceptions==1.2.0 +restructuredtext-lint==1.1.1 +rfc3986==0.3.1 +Routes==2.3.1 +ryu==4.14 +simplejson==3.5.1 +six==1.10.0 +snowballstemmer==1.2.1 +Sphinx==1.6.2 +sphinxcontrib-websupport==1.0.1 +SQLAlchemy==1.2.0 +sqlalchemy-migrate==0.11.0 +sqlparse==0.2.2 +statsd==3.2.1 +stestr==1.0.0 +stevedore==1.20.0 +Tempita==0.5.2 +tenacity==4.4.0 +testrepository==0.0.18 +testresources==2.0.0 +testscenarios==0.4 +testtools==2.2.0 +tooz==1.58.0 +tinyrpc==0.6 +traceback2==1.4.0 +unittest2==1.1.0 +vine==1.1.4 +waitress==1.1.0 +WebOb==1.7.1 +WebTest==2.0.27 +wrapt==1.7.0 diff --git a/ovn_octavia_provider/__init__.py b/ovn_octavia_provider/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ovn_octavia_provider/hacking/__init__.py b/ovn_octavia_provider/hacking/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ovn_octavia_provider/hacking/checks.py b/ovn_octavia_provider/hacking/checks.py new file mode 100644 index 00000000..cd76b221 --- /dev/null +++ b/ovn_octavia_provider/hacking/checks.py @@ -0,0 +1,180 @@ +# Copyright (c) 2014 OpenStack Foundation. +# +# 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. + +import re + + +def flake8ext(f): + """Decorator to indicate flake8 extension. + + This is borrowed from hacking.core.flake8ext(), but at now it is used + only for unit tests to know which are ovn_octavia_provider flake8 + extensions. + """ + f.name = __name__ + return f + + +# Guidelines for writing new hacking checks +# +# - Use only for OVN Octavia provider specific tests. OpenStack +# general tests should be submitted to the common 'hacking' module. +# - Pick numbers in the range N3xx. Find the current test with +# the highest allocated number and then pick the next value. +# - Keep the test method code in the source file ordered based +# on the N3xx value. +# - List the new rule in the top level HACKING.rst file +# - Add test cases for each new rule to +# ovn_octavia_provider/tests/unit/hacking/test_checks.py + + +unittest_imports_dot = re.compile(r"\bimport[\s]+unittest\b") +unittest_imports_from = re.compile(r"\bfrom[\s]+unittest\b") +filter_match = re.compile(r".*filter\(lambda ") + +tests_imports_dot = re.compile(r"\bimport[\s]+ovn_octavia_provider.tests\b") +tests_imports_from1 = re.compile(r"\bfrom[\s]+ovn_octavia_provider.tests\b") +tests_imports_from2 = re.compile( + r"\bfrom[\s]+ovn_octavia_provider[\s]+import[\s]+tests\b") + + +@flake8ext +def check_assert_called_once_with(logical_line, filename): + """Try to detect unintended calls of nonexistent mock methods like: + + assert_called_once + assertCalledOnceWith + assert_has_called + called_once_with + + N322 + """ + + if 'ovn_octavia_provider/tests/' in filename: + if '.assert_called_once_with(' in logical_line: + return + uncased_line = logical_line.lower().replace('_', '') + + check_calls = ['.assertcalledonce', '.calledoncewith'] + if any(x for x in check_calls if x in uncased_line): + msg = ("N322: Possible use of no-op mock method. " + "please use assert_called_once_with.") + yield (0, msg) + + if '.asserthascalled' in uncased_line: + msg = ("N322: Possible use of no-op mock method. " + "please use assert_has_calls.") + yield (0, msg) + + +@flake8ext +def check_asserttruefalse(logical_line, filename): + """N328 - Don't use assertEqual(True/False, observed).""" + + if 'ovn_octavia_provider/tests/' in filename: + if re.search(r"assertEqual\(\s*True,[^,]*(,[^,]*)?", logical_line): + msg = ("N328: Use assertTrue(observed) instead of " + "assertEqual(True, observed)") + yield (0, msg) + if re.search(r"assertEqual\([^,]*,\s*True(,[^,]*)?", logical_line): + msg = ("N328: Use assertTrue(observed) instead of " + "assertEqual(True, observed)") + yield (0, msg) + if re.search(r"assertEqual\(\s*False,[^,]*(,[^,]*)?", logical_line): + msg = ("N328: Use assertFalse(observed) instead of " + "assertEqual(False, observed)") + yield (0, msg) + if re.search(r"assertEqual\([^,]*,\s*False(,[^,]*)?", logical_line): + msg = ("N328: Use assertFalse(observed) instead of " + "assertEqual(False, observed)") + yield (0, msg) + + +@flake8ext +def check_assertempty(logical_line, filename): + """Enforce using assertEqual parameter ordering in case of empty objects. + + N330 + """ + + if 'ovn_octavia_provider/tests/' in filename: + msg = ("N330: Use assertEqual(*empty*, observed) instead of " + "assertEqual(observed, *empty*). *empty* contains " + "{}, [], (), set(), '', \"\"") + empties = r"(\[\s*\]|\{\s*\}|\(\s*\)|set\(\s*\)|'\s*'|\"\s*\")" + reg = r"assertEqual\(([^,]*,\s*)+?%s\)\s*$" % empties + if re.search(reg, logical_line): + yield (0, msg) + + +@flake8ext +def check_assertisinstance(logical_line, filename): + """N331 - Enforce using assertIsInstance.""" + + if 'ovn_octavia_provider/tests/' in filename: + if re.search(r"assertTrue\(\s*isinstance\(\s*[^,]*,\s*[^,]*\)\)", + logical_line): + msg = ("N331: Use assertIsInstance(observed, type) instead " + "of assertTrue(isinstance(observed, type))") + yield (0, msg) + + +@flake8ext +def check_assertequal_for_httpcode(logical_line, filename): + """N332 - Enforce correct oredering for httpcode in assertEqual.""" + + msg = ("N332: Use assertEqual(expected_http_code, observed_http_code) " + "instead of assertEqual(observed_http_code, expected_http_code)") + if 'ovn_octavia_provider/tests/' in filename: + if re.search(r"assertEqual\(\s*[^,]*,[^,]*HTTP[^\.]*\.code\s*\)", + logical_line): + yield (0, msg) + + +@flake8ext +def check_no_imports_from_tests(logical_line, filename): + """N343 - Production code must not import from ovn_octavia_provider.tests.* + + """ + + msg = ("N343 Production code must not import from " + "ovn_octavia_provider.tests.*") + + if 'ovn_octavia_provider/tests/' in filename: + return + + for regex in tests_imports_dot, tests_imports_from1, tests_imports_from2: + if re.match(regex, logical_line): + yield(0, msg) + + +@flake8ext +def check_python3_no_filter(logical_line): + """N344 - Use list comprehension instead of filter(lambda).""" + + msg = ("N344: Use list comprehension instead of " + "filter(lambda obj: test(obj), data) on python3.") + + if filter_match.match(logical_line): + yield(0, msg) + + +def factory(register): + register(check_assert_called_once_with) + register(check_asserttruefalse) + register(check_assertempty) + register(check_assertisinstance) + register(check_assertequal_for_httpcode) + register(check_no_imports_from_tests) + register(check_python3_no_filter) diff --git a/ovn_octavia_provider/tests/__init__.py b/ovn_octavia_provider/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ovn_octavia_provider/tests/functional/__init__.py b/ovn_octavia_provider/tests/functional/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ovn_octavia_provider/tests/functional/requirements.txt b/ovn_octavia_provider/tests/functional/requirements.txt new file mode 100644 index 00000000..f3c7e8e4 --- /dev/null +++ b/ovn_octavia_provider/tests/functional/requirements.txt @@ -0,0 +1,7 @@ +# Additional requirements for functional tests + +# 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. + +psutil>=1.1.1,<2.0.0 diff --git a/ovn_octavia_provider/tests/unit/__init__.py b/ovn_octavia_provider/tests/unit/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ovn_octavia_provider/tests/unit/test_hacking.py b/ovn_octavia_provider/tests/unit/test_hacking.py new file mode 100644 index 00000000..45af5d33 --- /dev/null +++ b/ovn_octavia_provider/tests/unit/test_hacking.py @@ -0,0 +1,21 @@ +# Copyright 2020 +# +# 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 oslotest import base + + +class NothingTestCase(base.BaseTestCase): + """Nothing test class""" + def test_nothing(self): + pass diff --git a/releasenotes/notes/new-repository-for-ovn-octavia-provider-driver-dd81c4414c529c4e.yaml b/releasenotes/notes/new-repository-for-ovn-octavia-provider-driver-dd81c4414c529c4e.yaml new file mode 100644 index 00000000..b02bffd1 --- /dev/null +++ b/releasenotes/notes/new-repository-for-ovn-octavia-provider-driver-dd81c4414c529c4e.yaml @@ -0,0 +1,8 @@ +--- +prelude: > + OVN Octavia provider driver has been created from the + networking-ovn repository. +upgrade: + - | + OVN Octavia Provider driver registers under the same entry point. + There is no action to be done from operator side. diff --git a/releasenotes/source/_static/.placeholder b/releasenotes/source/_static/.placeholder new file mode 100644 index 00000000..e69de29b diff --git a/releasenotes/source/_templates/.placeholder b/releasenotes/source/_templates/.placeholder new file mode 100644 index 00000000..e69de29b diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py new file mode 100644 index 00000000..f9a9b14d --- /dev/null +++ b/releasenotes/source/conf.py @@ -0,0 +1,257 @@ +# -*- coding: utf-8 -*- +# 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. + +# OVN Release Notes documentation build configuration file, created by +# sphinx-quickstart on Tue Nov 3 17:40:50 2015. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'openstackdocstheme', + 'reno.sphinxext', +] + +# openstackdocstheme options +repository_name = 'openstack/ovn-octavia-provider' +bug_project = 'neutron' +bug_tag = 'ovn-octavia-provider' + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +copyright = u'2020, Neutron Developers' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'openstackdocs' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'OVNOctaviaProviderReleaseNotesdoc' + + +# -- Options for LaTeX output --------------------------------------------- + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ('index', 'OVNOctaviaProviderReleaseNotes.tex', + u'OVN Octavia Provider Release Notes Documentation', + u'Neutron Developers', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'ovnoctaviaproviderreleasenotes', + u'OVN Octavia Provider Release Notes Documentation', + [u'Neutron Developers'], 1) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'OVNOctaviaProviderReleaseNotes', + u'OVN Octavia Provider Release Notes Documentation', + u'Neutron Developers', 'OVNOctaviaProviderReleaseNotes', + 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + +# -- Options for Internationalization output ------------------------------ +locale_dirs = ['locale/'] diff --git a/releasenotes/source/index.rst b/releasenotes/source/index.rst new file mode 100644 index 00000000..d227af60 --- /dev/null +++ b/releasenotes/source/index.rst @@ -0,0 +1,8 @@ +=================================== + OVN Octavia Provider Release Notes +=================================== + +.. toctree:: + :maxdepth: 1 + + unreleased diff --git a/releasenotes/source/unreleased.rst b/releasenotes/source/unreleased.rst new file mode 100644 index 00000000..bd360bab --- /dev/null +++ b/releasenotes/source/unreleased.rst @@ -0,0 +1,5 @@ +============================= + Current Series Release Notes +============================= + +.. release-notes:: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..385319fa --- /dev/null +++ b/requirements.txt @@ -0,0 +1,15 @@ +# 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. + +netaddr>=0.7.18 # BSD +neutron-lib>=1.28.0 # Apache-2.0 +oslo.config>=5.2.0 # Apache-2.0 +ovs>=2.8.0 # Apache-2.0 +ovsdbapp>=0.17.0 # Apache-2.0 +pbr!=2.1.0,>=2.0.0 # Apache-2.0 +tenacity>=4.4.0 # Apache-2.0 +Babel!=2.4.0,>=2.3.4 # BSD +neutron>=13.0.0.0b2 # Apache-2.0 +octavia-lib>=1.3.1 # Apache-2.0 +python-neutronclient>=6.7.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..962fa28b --- /dev/null +++ b/setup.cfg @@ -0,0 +1,27 @@ +[metadata] +name = ovn-octavia-provider +summary = OpenStack Octavia integration with OVN +description-file = + README.rst +author = OpenStack +author-email = openstack-discuss@lists.openstack.org +home-page = https://docs.openstack.org/ovn-octavia-provider/latest/ +python-requires = >=3.6 +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 :: 3 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + +[files] +packages = + ovn-octavia-provider + +[global] +setup-hooks = + pbr.hooks.setup_hook diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..566d8443 --- /dev/null +++ b/setup.py @@ -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>=2.0.0'], + pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..04342318 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,19 @@ +# 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>=1.1.0 # Apache-2.0 + +bandit!=1.6.0,>=1.1.0 # Apache-2.0 +coverage!=4.4,>=4.0 # Apache-2.0 +flake8-import-order==0.12 # LGPLv3 +python-subunit>=1.0.0 # Apache-2.0/BSD +oslotest>=3.2.0 # Apache-2.0 +os-testr>=1.0.0 # Apache-2.0 +astroid==2.1.0 # LGPLv2.1 +pylint==2.3.0 # GPLv2 +octavia-lib>=1.3.1 # Apache-2.0 +testresources>=2.0.0 # Apache-2.0/BSD +testscenarios>=0.4 # Apache-2.0/BSD +WebTest>=2.0.27 # MIT +testtools>=2.2.0 # MIT diff --git a/tools/check_unit_test_structure.sh b/tools/check_unit_test_structure.sh new file mode 100755 index 00000000..e642a725 --- /dev/null +++ b/tools/check_unit_test_structure.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# This script identifies the unit test modules that do not correspond +# directly with a module in the code tree. See TESTING.rst for the +# intended structure. + +repo_path=$(cd "$(dirname "$0")/.." && pwd) +base_test_path=ovn_octavia_provider/tests/unit +test_path=$repo_path/$base_test_path + +test_files=$(find ${test_path} -iname 'test_*.py') + +ignore_regexes=( + # Exceptional cases that should be skipped can be added here + # EXAMPLE: "^objects/test_objects.py$" +) + +error_count=0 +ignore_count=0 +total_count=0 +for test_file in ${test_files[@]}; do + relative_path=${test_file#$test_path/} + expected_path=$(dirname $repo_path/ovn_octavia_provider/$relative_path) + test_filename=$(basename "$test_file") + expected_filename=${test_filename#test_} + # Module filename (e.g. foo/bar.py -> foo/test_bar.py) + filename=$expected_path/$expected_filename + # Package dir (e.g. foo/ -> test_foo.py) + package_dir=${filename%.py} + if [ ! -f "$filename" ] && [ ! -d "$package_dir" ]; then + for ignore_regex in ${ignore_regexes[@]}; do + if [[ "$relative_path" =~ $ignore_regex ]]; then + ignore_count=$((ignore_count + 1)) + continue 2 + fi + done + echo "Unexpected test file: $base_test_path/$relative_path" + error_count=$((error_count + 1)) + fi + total_count=$((total_count + 1)) +done + +if [ "$ignore_count" -ne 0 ]; then + echo "$ignore_count unmatched test modules were ignored" +fi + +if [ "$error_count" -eq 0 ]; then + echo 'Success! All test modules match targets in the code tree.' + exit 0 +else + echo "Failure! $error_count of $total_count test modules do not match targets in the code tree." + exit 1 +fi diff --git a/tools/coding-checks.sh b/tools/coding-checks.sh new file mode 100755 index 00000000..18308d3d --- /dev/null +++ b/tools/coding-checks.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# This script is copied from neutron and adapted for networking-ovn. +set -eu + +usage () { + echo "Usage: $0 [OPTION]..." + echo "Run ovn_octavia_provider's coding check(s)" + echo "" + echo " -Y, --pylint [] Run pylint check on the entire ovn_octavia_provider module or just files changed in basecommit (e.g. HEAD~1)" + echo " -h, --help Print this usage message" + echo + exit 0 +} + +join_args() { + if [ -z "$scriptargs" ]; then + scriptargs="$opt" + else + scriptargs="$scriptargs $opt" + fi +} + +process_options () { + i=1 + while [ $i -le $# ]; do + eval opt=\$$i + case $opt in + -h|--help) usage;; + -Y|--pylint) pylint=1;; + *) join_args;; + esac + i=$((i+1)) + done +} + +run_pylint () { + local target="${scriptargs:-all}" + + if [ "$target" = "all" ]; then + files="ovn_octavia_provider" + else + case "$target" in + *HEAD~[0-9]*) files=$(git diff --diff-filter=AM --name-only $target -- "*.py");; + *) echo "$target is an unrecognized basecommit"; exit 1;; + esac + fi + + echo "Running pylint..." + echo "You can speed this up by running it on 'HEAD~[0-9]' (e.g. HEAD~1, this change only)..." + if [ -n "${files}" ]; then + pylint --rcfile=.pylintrc --output-format=colorized ${files} + else + echo "No python changes in this commit, pylint check not required." + exit 0 + fi +} + +scriptargs= +pylint=1 + +process_options $@ + +if [ $pylint -eq 1 ]; then + run_pylint + exit 0 +fi diff --git a/tools/pip_install_src_modules.sh b/tools/pip_install_src_modules.sh new file mode 100755 index 00000000..d2a89faf --- /dev/null +++ b/tools/pip_install_src_modules.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# For networking-ovn unit tests, you can define git repos containing modules +# that you want to use to override the requirements-based packages. +# +# Why, you ask? Because you made changes to neutron-lib, and you want +# run the unit tests together. E.g.: +# +# env TOX_ENV_SRC_MODULES="$HOME/src/neutron-lib" tox -e py37 + +toxinidir="$1" + +if [ -z "$TOX_ENV_SRC_MODULES" ]; then + exit 0 +fi + +for repo in $TOX_ENV_SRC_MODULES; do + d="${toxinidir}/${repo}" + if [ ! -d "$d" ]; then + echo "tox_env_src: error: no directory found at $d" + continue + fi + echo "tox_env_src: pip installing from $d" + pip install -e "$d" +done diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..6f33e1e7 --- /dev/null +++ b/tox.ini @@ -0,0 +1,145 @@ +[tox] +minversion = 3.1.0 +envlist = docs,py37,pep8 +skipsdist = True +ignore_basepython_conflict = True + +[testenv] +usedevelop = True +install_command = pip install {opts} {packages} +setenv = VIRTUAL_ENV={envdir} + OS_LOG_CAPTURE={env:OS_LOG_CAPTURE:true} + OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:true} + OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:true} + PYTHONWARNINGS=default::DeprecationWarning,ignore::DeprecationWarning:distutils,ignore::DeprecationWarning:site +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 + sh +passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY TOX_ENV_SRC_MODULES +commands = + {toxinidir}/tools/pip_install_src_modules.sh "{toxinidir}" + stestr run {posargs} + +[testenv:pep8] +envdir = {toxworkdir}/shared +commands = flake8 + {toxinidir}/tools/check_unit_test_structure.sh + {toxinidir}/tools/coding-checks.sh --pylint '{posargs}' + {[testenv:bandit]commands} + +[testenv:venv] +commands = {posargs} + +[testenv:functional] +setenv = + {[testenv]setenv} + OS_TEST_PATH=./ovn_octavia_provider/tests/functional + OS_TEST_TIMEOUT=240 +deps = {[testenv]deps} + -r{toxinidir}/ovn_octavia_provider/tests/functional/requirements.txt + +[testenv:dsvm] +# Fake job to define environment variables shared between dsvm jobs +setenv = OS_TEST_TIMEOUT=240 + OS_LOG_PATH={env:OS_LOG_PATH:/opt/stack/logs} +commands = false + +[testenv:dsvm-functional] +setenv = {[testenv:functional]setenv} + {[testenv:dsvm]setenv} +deps = {[testenv:functional]deps} +commands = + {toxinidir}/tools/ostestr_compat_shim.sh {posargs} + +[testenv:cover] +envdir = {toxworkdir}/shared +setenv = + {[testenv]setenv} + PYTHON=coverage run --source ovn_octavia_provider --parallel-mode +commands = + stestr run --no-subunit-trace {posargs} + coverage combine + coverage report --fail-under=75 --skip-covered + coverage html -d cover + coverage xml -o cover/coverage.xml + +[testenv:docs] +envdir = {toxworkdir}/docs +deps = + -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -r{toxinidir}/doc/requirements.txt + -r{toxinidir}/requirements.txt +commands = sphinx-build -W -b html doc/source doc/build/html + +[testenv:pdf-docs] +envdir = {toxworkdir}/docs +deps = {[testenv:docs]deps} +whitelist_externals = + make +commands = + sphinx-build -W -b latex doc/source doc/build/pdf + make -C doc/build/pdf + +[testenv:debug] +envdir = {toxworkdir}/shared +commands = oslo_debug_helper -t ovn_octavia_provider/tests {posargs} + +[testenv:releasenotes] +envdir = {toxworkdir}/docs +deps = -r{toxinidir}/doc/requirements.txt +commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html + +[doc8] +# File extensions to check +extensions = .rst + +[flake8] +# W504 line break after binary operator +ignore = W504 +# H106: Don't put vim configuration in source files +# H203: Use assertIs(Not)None to check for None +# H204: Use assert(Not)Equal to check for equality +# H205: Use assert(Greater|Less)(Equal) for comparison +# H904: Delay string interpolations at logging calls +enable-extensions=H106,H203,H204,H205,H904 +show-source = True +exclude=./.*,dist,doc,*egg*,build,releasenotes +import-order-style = pep8 + +[hacking] +import_exceptions = ovn_octavia_provider.i18n +local-check-factory = neutron_lib.hacking.checks.factory + +[testenv:lower-constraints] +deps = + -c{toxinidir}/lower-constraints.txt + -r{toxinidir}/test-requirements.txt + -r{toxinidir}/requirements.txt + +[testenv:requirements] +deps = + -egit+https://opendev.org/openstack/requirements#egg=openstack-requirements +whitelist_externals = sh +commands = + sh -c '{envdir}/src/openstack-requirements/playbooks/files/project-requirements-change.py --req {envdir}/src/openstack-requirements --local {toxinidir} master' + +[testenv:bandit] +envdir = {toxworkdir}/shared +deps = -r{toxinidir}/test-requirements.txt +commands = bandit -r ovn_octavia_provider -x tests -n5 + +[testenv:dev] +# run locally (not in the gate) using editable mode +# https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs +commands = + pip install -q -e "git+https://git.openstack.org/openstack/neutron#egg=neutron" + {[testenv]commands} + +[testenv:pep8-dev] +deps = + {[testenv]deps} +commands = + {[testenv:dev]commands} + {[testenv:pep8]commands} diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml new file mode 100644 index 00000000..33553738 --- /dev/null +++ b/zuul.d/project.yaml @@ -0,0 +1,19 @@ +- project: + templates: + - publish-openstack-docs-pti + - release-notes-jobs-python3 + - check-requirements + - openstack-python3-ussuri-jobs-neutron + - openstack-lower-constraints-jobs-neutron + check: + jobs: + - openstack-tox-cover: + required-projects: + - openstack/neutron + voting: false + gate: + jobs: + - openstack-tox-cover: + required-projects: + - openstack/neutron + voting: false