Upgrade for stable/rocky branch

* Removed py36 env from 'tox.ini'.
    * Updated requirements.txt with relevant 'stable/rocky' branch
        libraries.
    * Updated test-requirements.txt with relevant 'stable/rocky' branch
        libraries.
    * Replaced 'mox' with 'mock' on unit tests.
    * Use stestr directly instead of ostestr to run UTs, as is done in 
        newer upstream branches.
    * Specify basepython as python2.7 for pep8, cover jobs, in case a 
        python3 version of tox is used.
    * Added 'flake8-import-order' and kept import-order-style as 'pep8'.
    * Added zuul jobs w.r.t. 'stable/rocky' release.
    * Removed '-U' option from toxenv install command, for stable/rocky
        & above branches compatibility.

Change-Id: I9161749fb2d8618b695815c095bdedae0251bb76
This commit is contained in:
Shyam Singh 2020-05-28 19:15:34 +05:30
parent ea11205cbc
commit 366ab2bfdb
7 changed files with 83 additions and 52 deletions

3
.stestr.conf Normal file
View File

@ -0,0 +1,3 @@
[DEFAULT]
test_path=${OS_TEST_PATH:-./gbpclient/tests/unit}
top_dir=./

View File

@ -3,19 +3,37 @@
templates:
- openstack-python-jobs
- publish-to-pypi
# REVISIT: In the jobs below, the required-projects clause is needed on
# the master branch to select the correct version of the requirements
# repository. Otherwise, the master version will be used. It can be
# eliminated on the stable branches, and on the master branch once this
# repository's master branch is based on the neutron repository's master
# branch.
check:
jobs:
- openstack-tox-pep8:
nodeset: ubuntu-xenial
required-projects:
- name: openstack/requirements
override-checkout: stable/rocky
- openstack-tox-py27:
nodeset: ubuntu-xenial
required-projects:
- name: openstack/requirements
override-checkout: stable/rocky
- openstack-tox-py35:
nodeset: ubuntu-xenial
required-projects:
- name: openstack/requirements
override-checkout: stable/rocky
gate:
jobs:
- openstack-tox-pep8:
nodeset: ubuntu-xenial
required-projects:
- name: openstack/requirements
override-checkout: stable/rocky
- openstack-tox-py27:
nodeset: ubuntu-xenial
required-projects:
- name: openstack/requirements
override-checkout: stable/rocky
- openstack-tox-py35:
nodeset: ubuntu-xenial
required-projects:
- name: openstack/requirements
override-checkout: stable/rocky

View File

@ -11,10 +11,11 @@
# under the License.
#
from mox3 import mox
import mock
import requests
from neutronclient.common import exceptions
from neutronclient.tests.unit import test_cli20 as neutron_test_cli20
import requests
from gbpclient import gbpshell
from gbpclient.v2_0 import client as gbpclient
@ -65,9 +66,6 @@ class CLITestV20Base(neutron_test_cli20.CLITestV20Base):
tenant_id=None, tags=None, admin_state_up=True,
extra_body=None, cmd_resource=None,
parent_id=None, **kwargs):
self.mox.StubOutWithMock(cmd, "get_client")
self.mox.StubOutWithMock(self.client.httpclient, "request")
cmd.get_client().MultipleTimes().AndReturn(self.client)
if not cmd_resource:
cmd_resource = resource
body = {resource: {}, }
@ -91,17 +89,26 @@ class CLITestV20Base(neutron_test_cli20.CLITestV20Base):
path = getattr(self.client, resource_plural + "_path")
if parent_id:
path = path % parent_id
mox_body = MyComparator(body, self.client)
self.client.httpclient.request(
end_url(path), 'POST',
body=mox_body,
headers=mox.ContainsKeyValue(
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr))
self.mox.ReplayAll()
mock_body = MyComparator(body, self.client)
cmd_parser = cmd.get_parser('create_' + resource)
gbpshell.run_command(cmd, cmd_parser, args)
self.mox.VerifyAll()
self.mox.UnsetStubs()
resp = (MyResp(200), resstr)
with mock.patch.object(
cmd, "get_client", return_value=self.client
) as mock_get_client, mock.patch.object(
self.client.httpclient, "request", return_value=resp
) as mock_request:
gbpshell.run_command(cmd, cmd_parser, args)
self.assert_mock_multiple_calls_with_same_arguments(
mock_get_client, mock.call(), None)
mock_request.assert_called_once_with(
end_url(path), 'POST',
body=mock_body,
headers=neutron_test_cli20.ContainsKeyValue(
{'X-Auth-Token': TOKEN}))
_str = self.fake_stdout.make_string()
self.assertIn(myid, _str)
if name:
@ -207,20 +214,19 @@ class CLITestV20ExceptionHandler(CLITestV20Base):
self.assertEqual(e.status_code, 599)
def test_connection_failed(self):
self.mox.StubOutWithMock(self.client.httpclient, 'request')
self.client.httpclient.auth_token = 'token'
excp = requests.exceptions.ConnectionError('Connection refused')
self.client.httpclient.request(
end_url('/test'), 'GET',
headers=mox.ContainsKeyValue('X-Auth-Token', 'token')
).AndRaise(requests.exceptions.ConnectionError('Connection refused'))
with mock.patch.object(self.client.httpclient, "request",
side_effect=excp) as mock_request:
error = self.assertRaises(exceptions.ConnectionFailed,
self.client.get, '/test')
self.mox.ReplayAll()
error = self.assertRaises(exceptions.ConnectionFailed,
self.client.get, '/test')
mock_request.assert_called_once_with(
end_url('/test'), 'GET',
body=None,
headers=neutron_test_cli20.ContainsKeyValue(
{'X-Auth-Token': 'token'}))
# NB: ConnectionFailed has no explicit status_code, so this
# tests that there is a fallback defined.
self.assertIsNotNone(error.status_code)
self.mox.VerifyAll()
self.mox.UnsetStubs()

View File

@ -2,7 +2,7 @@
# 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,!=2.1.0 # Apache-2.0
python-heatclient>=1.6.1
python-neutronclient>=6.3.0,<6.8
oslo.serialization>=2.18.0,!=2.19.1 # Apache-2.0
python-heatclient>=1.10.0 # Apache-2.0
python-neutronclient>=6.7.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
oslo.utils>=3.33.0 # Apache-2.0

View File

@ -36,3 +36,6 @@ source-dir = doc/source
[wheel]
universal = 1
[flake8]
import-order-style = pep8

View File

@ -1,19 +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.11,>=0.10.0
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
flake8-import-order==0.12 # LGPLv3
httpretty>=0.8.0,!=0.8.1,!=0.8.2,!=0.8.3
mox3>=0.20.0 # Apache-2.0
mock>=2.0.0 # BSD
oslotest>=3.2.0 # Apache-2.0
python-openstackclient>=3.12.0 # Apache-2.0
python-subunit>=1.0.0 # Apache-2.0/BSD
reno>=2.5.0 # Apache-2.0
requests-mock>=1.1.0 # Apache-2.0
sphinx!=1.6.6,>=1.6.2 # BSD
oslosphinx>=4.7.0 # Apache-2.0
stestr>=1.0.0 # Apache-2.0
testrepository>=0.0.18 # Apache-2.0/BSD
testtools>=2.2.0 # MIT
testscenarios>=0.4 # Apache-2.0/BSD

24
tox.ini
View File

@ -1,22 +1,23 @@
[tox]
envlist = py27,py33,py36,pypy,pep8
minversion = 1.6
envlist = py27,py35,pypy,pep8
minversion = 2.3.2
skipsdist = True
[testenv]
basepython = python3
setenv = VIRTUAL_ENV={envdir}
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ALL=C
usedevelop = True
install_command = pip install -U {opts} {packages}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = python setup.py testr --testr-args='{posargs}'
install_command = pip install {opts} {packages}
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/rocky}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = stestr run {posargs}
[testenv:pep8]
basepython = python3
basepython = python2.7
commands = flake8
distribute = false
@ -25,8 +26,11 @@ basepython = python3
commands = {posargs}
[testenv:cover]
basepython = python3
commands = python setup.py testr --coverage --testr-args='{posargs}'
basepython = python2.7
commands =
coverage erase
coverage run -m testtools.run
coverage report --include="*gbpclient*" --omit="*test*" --omit="*.tox*" --omit="*nfp*" -m
[testenv:docs]
basepython = python3