From fded752b167c62b888d8e13690c361ce1fad1f82 Mon Sep 17 00:00:00 2001 From: melanie witt Date: Tue, 6 Nov 2018 05:37:12 +0000 Subject: [PATCH] Use SleepFixture instead of mocking _ThreadingEvent.wait Recently, the _ThreadingEvent class in oslo.service was removed [1] and our unit test patching is preventing us from moving to a newer version of oslo.service [2]. We have patching of the _ThreadingEvent.wait method to bypass the sleep time in the looping call of RetryDecorator, which adds several seconds to the run time of unit tests. This changes things to use the new SleepFixture from oslo.service instead. Depends-On: https://review.openstack.org/616371 [1] I62e9f1a7cde8846be368fbec58b8e0825ce02079 [2] https://review.openstack.org/615676 Change-Id: I45dd7602068eb0ce1331cfefd5a0cf6418bc8e88 --- lower-constraints.txt | 2 +- nova/tests/unit/compute/test_compute_mgr.py | 2 ++ nova/tests/unit/virt/disk/mount/test_api.py | 6 ++++++ nova/tests/unit/virt/libvirt/test_guest.py | 4 ++++ requirements.txt | 2 +- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index 3a3831a274d3..c62d875c076a 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -89,7 +89,7 @@ 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.service==1.33.0 oslo.utils==3.37.0 oslo.versionedobjects==1.33.3 oslo.vmware==2.17.0 diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py index a9d0f70e8c17..c1b8f4154a11 100644 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -27,6 +27,7 @@ import netaddr from oslo_log import log as logging import oslo_messaging as messaging from oslo_serialization import jsonutils +from oslo_service import fixture as service_fixture from oslo_utils.fixture import uuidsentinel as uuids from oslo_utils import timeutils from oslo_utils import uuidutils @@ -6444,6 +6445,7 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase): """Tests that _try_deallocate_network will retry calling _deallocate_network on keystone ConnectFailure errors up to a limit. """ + self.useFixture(service_fixture.SleepFixture()) deallocate_network_mock.side_effect = \ keystone_exception.connection.ConnectFailure req_networks = objects.NetworkRequestList( diff --git a/nova/tests/unit/virt/disk/mount/test_api.py b/nova/tests/unit/virt/disk/mount/test_api.py index baaa81ae7d93..d2d040dd8495 100644 --- a/nova/tests/unit/virt/disk/mount/test_api.py +++ b/nova/tests/unit/virt/disk/mount/test_api.py @@ -13,6 +13,7 @@ # under the License. import mock +from oslo_service import fixture as service_fixture from nova import test from nova.virt.disk.mount import api @@ -29,6 +30,11 @@ MAP_PARTITION = "/dev/mapper/nullp77" class MountTestCase(test.NoDBTestCase): + def setUp(self): + super(MountTestCase, self).setUp() + # Make RetryDecorator not actually sleep on retries + self.useFixture(service_fixture.SleepFixture()) + def _test_map_dev(self, partition): mount = api.Mount(mock.sentinel.image, mock.sentinel.mount_dir) mount.device = ORIG_DEVICE diff --git a/nova/tests/unit/virt/libvirt/test_guest.py b/nova/tests/unit/virt/libvirt/test_guest.py index f0bba568a0c0..418092eee236 100644 --- a/nova/tests/unit/virt/libvirt/test_guest.py +++ b/nova/tests/unit/virt/libvirt/test_guest.py @@ -17,6 +17,7 @@ import sys import mock +from oslo_service import fixture as service_fixture from oslo_utils import encodeutils import six import testtools @@ -46,6 +47,9 @@ class GuestTestCase(test.NoDBTestCase): self.domain = mock.Mock(spec=fakelibvirt.virDomain) self.guest = libvirt_guest.Guest(self.domain) + # Make RetryDecorator not actually sleep on retries + self.useFixture(service_fixture.SleepFixture()) + def test_repr(self): self.domain.ID.return_value = 99 self.domain.UUIDString.return_value = "UUID" diff --git a/requirements.txt b/requirements.txt index 428a95c64ddd..9ce1b74e386a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -49,7 +49,7 @@ oslo.messaging>=6.3.0 # Apache-2.0 oslo.policy>=1.35.0 # Apache-2.0 oslo.privsep>=1.23.0 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 -oslo.service!=1.28.1,>=1.24.0 # Apache-2.0 +oslo.service>=1.33.0 # Apache-2.0 rfc3986>=0.3.1 # Apache-2.0 oslo.middleware>=3.31.0 # Apache-2.0 psutil>=3.2.2 # BSD