Fixes zuul issues
Some issues were not caught during the initial mock autospec patch which was added to compute_hyperv, and now they're causing some unit tests to fail. This patch fixes those issues. Secondly, the docs job relies on tools/tox_install.sh to install nova, but it is not passing the required arguments, causing it to fail. This patch updates the script so it can properly execute. Change-Id: I91cbadb2a05ee4880c3fa761696818ec95c40df2 (cherry picked from commit48bb0d6b41
) tests: uses oslotest as the test base oslotest's base will add mock.patch.stopall, so we don't have to. Change-Id: If13a465000648dfbf1e229a3b8d765e8b3204db4 (cherry picked from commit8dd2910195
)
This commit is contained in:
parent
74daeb2219
commit
68897c48e6
|
@ -34,10 +34,10 @@ from nova.tests.unit import conf_fixture
|
|||
from nova.tests.unit import policy_fixture
|
||||
from oslo_log.fixture import logging_error as log_fixture
|
||||
from oslo_log import log as logging
|
||||
from oslotest import base
|
||||
from oslotest import mock_fixture
|
||||
from oslotest import moxstubout
|
||||
import six
|
||||
import testtools
|
||||
|
||||
import compute_hyperv.nova.conf
|
||||
|
||||
|
@ -78,7 +78,7 @@ _patch_mock_to_raise_for_invalid_assert_calls()
|
|||
mock_fixture.patch_mock_module()
|
||||
|
||||
|
||||
class NoDBTestCase(testtools.TestCase):
|
||||
class NoDBTestCase(base.BaseTestCase):
|
||||
"""Test case base class for all unit tests.
|
||||
|
||||
Due to the slowness of DB access, please consider deriving from
|
||||
|
|
|
@ -18,6 +18,7 @@ import mock
|
|||
from nova.compute import power_state
|
||||
from nova.compute import task_states
|
||||
from nova.compute import vm_states
|
||||
from nova.network.neutronv2 import api as network_api
|
||||
from nova import objects
|
||||
from os_win import exceptions as os_win_exc
|
||||
|
||||
|
@ -35,7 +36,7 @@ class ClusterOpsTestCase(test_base.HyperVBaseTestCase):
|
|||
|
||||
_autospec_classes = [
|
||||
clusterops.hostops.HostOps,
|
||||
clusterops.network.API,
|
||||
network_api.API,
|
||||
clusterops.vmops.VMOps,
|
||||
clusterops.serialconsoleops.SerialConsoleOps,
|
||||
]
|
||||
|
|
|
@ -30,9 +30,9 @@ class HyperVBaseTestCase(test.NoDBTestCase):
|
|||
|
||||
utilsfactory_patcher = mock.patch.object(utilsfactory, '_get_class')
|
||||
utilsfactory_patcher.start()
|
||||
self.addCleanup(utilsfactory_patcher.stop)
|
||||
|
||||
self._patch_autospec_classes()
|
||||
self.addCleanup(mock.patch.stopall)
|
||||
|
||||
def _patch_autospec_classes(self):
|
||||
for class_type in self._autospec_classes:
|
||||
|
@ -41,6 +41,7 @@ class HyperVBaseTestCase(test.NoDBTestCase):
|
|||
'.'.join([class_type.__module__, class_type.__name__]),
|
||||
mocked_class)
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
|
||||
class MonotonicTestCase(test.NoDBTestCase):
|
||||
|
|
|
@ -22,6 +22,7 @@ import sys
|
|||
|
||||
import mock
|
||||
from nova import exception
|
||||
from nova.image import api
|
||||
from nova import safe_utils
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.virt import driver as base_driver
|
||||
|
@ -43,8 +44,8 @@ class HyperVDriverTestCase(test_base.HyperVBaseTestCase):
|
|||
driver.rdpconsoleops.RDPConsoleOps,
|
||||
driver.serialconsoleops.SerialConsoleOps,
|
||||
driver.imagecache.ImageCache,
|
||||
driver.image.API,
|
||||
driver.pathutils.PathUtils,
|
||||
api.API,
|
||||
]
|
||||
|
||||
FAKE_WIN_2008R2_VERSION = '6.0.0'
|
||||
|
|
|
@ -531,7 +531,7 @@ class MigrationOpsTestCase(test_base.HyperVBaseTestCase):
|
|||
mock.call(root_device_path, mock_vhd_info,
|
||||
mock_instance.flavor.root_gb * units.Gi))
|
||||
else:
|
||||
self.assertFalse(self._pathutils.lookup_root_vhd.called)
|
||||
self.assertFalse(self._pathutils.lookup_root_vhd_path.called)
|
||||
|
||||
mock_check_resize_vhd.assert_has_calls(expected_check_resize)
|
||||
self._vhdutils.get_vhd_info.assert_has_calls(
|
||||
|
|
|
@ -32,9 +32,9 @@ class SerialConsoleHandlerTestCase(test_base.HyperVBaseTestCase):
|
|||
def setUp(self):
|
||||
super(SerialConsoleHandlerTestCase, self).setUp()
|
||||
|
||||
pathutils.PathUtils.return_value.mock_get_log_paths.return_value = [
|
||||
mock.sentinel.log_path]
|
||||
|
||||
mock_get_vm_console_logs = (
|
||||
pathutils.PathUtils.return_value.get_vm_console_log_paths)
|
||||
mock_get_vm_console_logs.return_value = [mock.sentinel.log_path]
|
||||
self._consolehandler = serialconsolehandler.SerialConsoleHandler(
|
||||
mock.sentinel.instance_name)
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class SnapshotOpsTestCase(test_base.HyperVBaseTestCase):
|
|||
mock.sentinel.PATH, 'rb')
|
||||
glance_image_service.update.assert_called_once_with(
|
||||
self.context, mock.sentinel.IMAGE_ID, image_metadata,
|
||||
self._snapshotops._pathutils.open().__enter__(),
|
||||
self._snapshotops._pathutils.open.return_value.__enter__(),
|
||||
purge_props=False)
|
||||
|
||||
@mock.patch('compute_hyperv.nova.snapshotops.SnapshotOps'
|
||||
|
|
|
@ -52,5 +52,5 @@ shift
|
|||
|
||||
install_project nova
|
||||
|
||||
$install_cmd -U $*
|
||||
$install_cmd -U .
|
||||
exit $?
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -17,7 +17,7 @@ setenv = VIRTUAL_ENV={envdir}
|
|||
LANGUAGE=en_US
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
-egit+https://github.com/openstack/nova#egg=nova
|
||||
-egit+https://github.com/openstack/nova@stable/queens#egg=nova
|
||||
commands =
|
||||
find . -type f -name "*.pyc" -delete
|
||||
python setup.py testr --slowest --testr-args='{posargs}'
|
||||
|
|
Loading…
Reference in New Issue