Separate unit tests from fullstack tests

With this patch the tox command only runs the unit tests at
./fuxi/tests/unit folder. Another test job is added for fullstack
which is meant to be run only with a working devstack setup and
will run at the gate with tempest. You can run the tests there
for debugging with 'tox -e fullstack'

Change-Id: I2942ccfdf9a97dce331de9b27d9c485de3e112c3
Partial-Implements: blueprint fullstack-testing
This commit is contained in:
Hongbin Lu 2016-11-28 21:44:34 +00:00 committed by Hongbin Lu
parent db7497a070
commit 5b682e2333
19 changed files with 241 additions and 219 deletions

View File

@ -1,7 +1,4 @@
[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_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_LOG_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./fuxi/tests/unit} $LISTOPT $IDOPTION | cat
test_id_option=--load-list $IDFILE
test_list_option=--list

View File

@ -0,0 +1,19 @@
# 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 TestFuxi(base.BaseTestCase):
def test_something(self):
pass

View File

@ -12,7 +12,7 @@
from fuxi.common import mount
from fuxi import exceptions
from fuxi.tests import base
from fuxi.tests.unit import base
class FakeMounter(object):

View File

@ -16,7 +16,7 @@ from cinderclient import exceptions as cinder_exception
from fuxi.common import state_monitor
from fuxi import exceptions
from fuxi.tests import base, fake_client, fake_object
from fuxi.tests.unit import base, fake_client, fake_object
class TestStateMonitor(base.TestCase):
@ -45,7 +45,8 @@ class TestStateMonitor(base.TestCase):
fake_cinder_client = fake_client.FakeCinderClient()
fake_cinder_volume = fake_object.FakeCinderVolume(status='available')
with mock.patch('fuxi.tests.fake_client.FakeCinderClient.Volumes.get',
with mock.patch('fuxi.tests.unit.fake_client.FakeCinderClient.Volumes'
'.get',
side_effect=cinder_exception.ClientException(404)):
fake_state_monitor = state_monitor.StateMonitor(fake_cinder_client,
fake_cinder_volume,
@ -53,7 +54,8 @@ class TestStateMonitor(base.TestCase):
self.assertRaises(exceptions.TimeoutException,
fake_state_monitor.monitor_cinder_volume)
with mock.patch('fuxi.tests.fake_client.FakeCinderClient.Volumes.get',
with mock.patch('fuxi.tests.unit.fake_client.FakeCinderClient.Volumes'
'.get',
side_effect=cinder_exception.ClientException(404)):
fake_state_monitor = state_monitor.StateMonitor(fake_cinder_client,
fake_cinder_volume,

View File

@ -17,7 +17,7 @@ from fuxi.common import constants
from fuxi.common import state_monitor
from fuxi.connector.cloudconnector import openstack
from fuxi import utils
from fuxi.tests import base, fake_client, fake_object
from fuxi.tests.unit import base, fake_client, fake_object
from cinderclient import exceptions as cinder_exception
from novaclient import exceptions as nova_exception
@ -68,7 +68,7 @@ class TestCinderConnector(base.TestCase):
result = self.connector.disconnect_volume(fake_cinder_volume)
self.assertIsNone(result)
@mock.patch('fuxi.tests.fake_client.FakeCinderClient.Volumes.get',
@mock.patch('fuxi.tests.unit.fake_client.FakeCinderClient.Volumes.get',
side_effect=cinder_exception.ClientException(404))
@mock.patch.object(utils, 'execute')
@mock.patch.object(state_monitor.StateMonitor,
@ -80,7 +80,7 @@ class TestCinderConnector(base.TestCase):
self.connector.disconnect_volume,
fake_cinder_volume)
@mock.patch('fuxi.tests.fake_client.FakeNovaClient.Volumes'
@mock.patch('fuxi.tests.unit.fake_client.FakeNovaClient.Volumes'
'.delete_server_volume',
side_effect=nova_exception.ClientException(500))
@mock.patch.object(utils, 'get_instance_uuid', return_value='fake-123')

View File

@ -18,7 +18,7 @@ import sys
from fuxi.common import constants
from fuxi.connector import osbrickconnector
from fuxi.tests import base, fake_client, fake_object
from fuxi.tests.unit import base, fake_client, fake_object
from fuxi import utils
from cinderclient import exceptions as cinder_exception
@ -93,7 +93,7 @@ class TestCinderConnector(base.TestCase):
@mock.patch.object(osbrickconnector, 'brick_get_connector_properties',
mock_get_connector_properties)
@mock.patch.object(utils, 'execute')
@mock.patch('fuxi.tests.fake_client.FakeCinderClient.Volumes'
@mock.patch('fuxi.tests.unit.fake_client.FakeCinderClient.Volumes'
'.initialize_connection',
side_effect=cinder_exception.ClientException(500))
def test_disconnect_volume_no_connection_info(self, mock_execute,
@ -117,7 +117,7 @@ class TestCinderConnector(base.TestCase):
return_value={'driver_volume_type': 'fake_proto',
'data': {'path': '/dev/0'}})
@mock.patch.object(utils, 'execute')
@mock.patch('fuxi.tests.fake_client.FakeOSBrickConnector'
@mock.patch('fuxi.tests.unit.fake_client.FakeOSBrickConnector'
'.disconnect_volume',
side_effect=processutils.ProcessExecutionError())
def test_disconnect_volume_osbrick_disconnect_failed(self, mock_connector,
@ -136,7 +136,7 @@ class TestCinderConnector(base.TestCase):
self.connector.disconnect_volume,
fake_cinder_volume)
@mock.patch('fuxi.tests.fake_client.FakeCinderClient.Volumes.detach',
@mock.patch('fuxi.tests.unit.fake_client.FakeCinderClient.Volumes.detach',
side_effect=cinder_exception.ClientException(500))
@mock.patch.object(osbrickconnector, 'brick_get_connector',
return_value=fake_client.FakeOSBrickConnector())

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from fuxi.tests import fake_object
from fuxi.tests.unit import fake_object
from cinderclient import exceptions as cinder_exception

View File

@ -26,7 +26,7 @@ from fuxi import app
from fuxi.common import config
from fuxi.controllers import volume_providers_conf
from fuxi import exceptions
from fuxi.tests import base
from fuxi.tests.unit import base
from oslo_serialization import jsonutils

View File

@ -20,7 +20,7 @@ from fuxi.common import constants as consts
from fuxi.common import mount
from fuxi.common import state_monitor
from fuxi import exceptions
from fuxi.tests import base, fake_client, fake_object
from fuxi.tests.unit import base, fake_client, fake_object
from fuxi import utils
from fuxi.volumeprovider import cinder
@ -95,7 +95,7 @@ class TestCinder(base.TestCase):
@mock.patch.object(cinder.Cinder, '_get_docker_volume',
return_value=(fake_object.FakeCinderVolume(
status='unknown'), consts.UNKNOWN))
@mock.patch('fuxi.tests.fake_client.FakeCinderClient.Volumes.get',
@mock.patch('fuxi.tests.unit.fake_client.FakeCinderClient.Volumes.get',
side_effect=cinder_exception.ClientException(404))
def test_create_from_volume_id_with_volume_not_exist(self,
mocK_docker_volume,
@ -256,7 +256,7 @@ class TestCinder(base.TestCase):
@mock.patch.object(FakeCinderConnector,
'get_device_path',
mock_device_path_for_delete)
@mock.patch('fuxi.tests.fake_client.FakeCinderClient.Volumes.delete',
@mock.patch('fuxi.tests.unit.fake_client.FakeCinderClient.Volumes.delete',
side_effect=cinder_exception.ClientException(500))
def test_delete_failed(self, mock_execute, mock_delete):
fd, tmpfname = tempfile.mkstemp()
@ -311,7 +311,7 @@ class TestCinder(base.TestCase):
self.cinderprovider.list())
@mock.patch.object(cinder.Cinder, '_get_connector', mock_connector)
@mock.patch('fuxi.tests.fake_client.FakeCinderClient.Volumes.list',
@mock.patch('fuxi.tests.unit.fake_client.FakeCinderClient.Volumes.list',
side_effect=cinder_exception.ClientException(500))
def test_list_failed(self, mock_list):
self.assertRaises(cinder_exception.ClientException,

View File

@ -391,7 +391,7 @@ class Cinder(provider.Provider):
return False
else:
msg = _LE("Volume %(vol_name)s %(c_vol)s "
"state %(state) is invalid")
"state %(state)s is invalid")
LOG.error(msg, {'vol_name': docker_volume_name,
'c_vol': cinder_volume,
'state': state})

View File

@ -34,6 +34,10 @@ commands = oslo_debug_helper {posargs}
basepython = python3.4
commands = oslo_debug_helper {posargs}
[testenv:fullstack]
basepython = python2.7
setenv = OS_TEST_PATH=./fuxi/tests/fullstack
[flake8]
show-source = True
builtins = _