First pass at tempest-lib based functional testing
Begin moving neutron CLI tests out of tempest and into this repo using tempest-lib. This patch adds the framework to run the functional tests, later patches will port the existing tempest tests. Change-Id: I1d168d7f255d08e7d7d0193b1d470b9c957c3ae8 Partila-Bug: #1429289
This commit is contained in:
0
neutronclient/tests/functional/__init__.py
Normal file
0
neutronclient/tests/functional/__init__.py
Normal file
44
neutronclient/tests/functional/base.py
Normal file
44
neutronclient/tests/functional/base.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
from tempest_lib.cli import base
|
||||||
|
|
||||||
|
|
||||||
|
class ClientTestBase(base.ClientTestBase):
|
||||||
|
"""This is a first pass at a simple read only python-neutronclient test.
|
||||||
|
This only exercises client commands that are read only.
|
||||||
|
|
||||||
|
This should test commands:
|
||||||
|
* as a regular user
|
||||||
|
* as a admin user
|
||||||
|
* with and without optional parameters
|
||||||
|
* initially just check return codes, and later test command outputs
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _get_clients(self):
|
||||||
|
cli_dir = os.environ.get(
|
||||||
|
'OS_NEUTRONCLIENT_EXEC_DIR',
|
||||||
|
os.path.join(os.path.abspath('.'), '.tox/functional/bin'))
|
||||||
|
|
||||||
|
return base.CLIClient(
|
||||||
|
username=os.environ.get('OS_USERNAME'),
|
||||||
|
password=os.environ.get('OS_PASSWORD'),
|
||||||
|
tenant_name=os.environ.get('OS_TENANT_NAME'),
|
||||||
|
uri=os.environ.get('OS_AUTH_URL'),
|
||||||
|
cli_dir=cli_dir)
|
||||||
|
|
||||||
|
def neutron(self, *args, **kwargs):
|
||||||
|
return self.clients.neutron(*args,
|
||||||
|
**kwargs)
|
47
neutronclient/tests/functional/test_readonly_neutron.py
Normal file
47
neutronclient/tests/functional/test_readonly_neutron.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# 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 tempest_lib import exceptions
|
||||||
|
|
||||||
|
from neutronclient.tests.functional import base
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleReadOnlyNeutronClientTest(base.ClientTestBase):
|
||||||
|
|
||||||
|
"""This is a first pass at a simple read only python-neutronclient test.
|
||||||
|
This only exercises client commands that are read only.
|
||||||
|
|
||||||
|
This should test commands:
|
||||||
|
* as a regular user
|
||||||
|
* as a admin user
|
||||||
|
* with and without optional parameters
|
||||||
|
* initially just check return codes, and later test command outputs
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test_admin_fake_action(self):
|
||||||
|
self.assertRaises(exceptions.CommandFailed,
|
||||||
|
self.neutron,
|
||||||
|
'this-does-neutron-exist')
|
||||||
|
|
||||||
|
# NOTE(mestery): Commands in order listed in 'neutron help'
|
||||||
|
|
||||||
|
# Optional arguments:
|
||||||
|
|
||||||
|
def test_admin_version(self):
|
||||||
|
self.neutron('', flags='--version')
|
||||||
|
|
||||||
|
def test_admin_debug_list(self):
|
||||||
|
self.neutron('net-list', flags='--debug')
|
||||||
|
|
||||||
|
def test_admin_timeout(self):
|
||||||
|
self.neutron('net-list', flags='--http-timeout %d' % 10)
|
@@ -16,3 +16,4 @@ requests-mock>=0.5.1 # Apache-2.0
|
|||||||
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
|
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
|
||||||
testrepository>=0.0.18
|
testrepository>=0.0.18
|
||||||
testtools>=0.9.36,!=1.2.0
|
testtools>=0.9.36,!=1.2.0
|
||||||
|
tempest-lib>=0.3.0
|
||||||
|
4
tox.ini
4
tox.ini
@@ -22,6 +22,10 @@ distribute = false
|
|||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
|
[testenv:functional]
|
||||||
|
setenv =
|
||||||
|
OS_TEST_PATH = ./neutronclient/tests/functional
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
commands = python setup.py testr --coverage --testr-args='{posargs}'
|
commands = python setup.py testr --coverage --testr-args='{posargs}'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user