diff --git a/nova/tests/unit/scheduler/client/test_report.py b/nova/tests/unit/scheduler/client/test_report.py index 303c11d6d31a..02749db21cbd 100644 --- a/nova/tests/unit/scheduler/client/test_report.py +++ b/nova/tests/unit/scheduler/client/test_report.py @@ -325,6 +325,7 @@ class TestPutAllocations(SchedulerReportClientTestCase): expected_url, mock.ANY, version='1.28', global_request_id=self.context.global_id) + @mock.patch('time.sleep', new=mock.Mock()) @mock.patch('nova.scheduler.client.report.SchedulerReportClient.put') def test_put_allocations_retries_conflict(self, mock_put): failed = fake_requests.FakeResponse( @@ -3593,6 +3594,7 @@ class TestAllocations(SchedulerReportClientTestCase): uuids.rp1, six.text_type(ex)) + @mock.patch('time.sleep', new=mock.Mock()) @mock.patch("nova.scheduler.client.report.SchedulerReportClient.put") @mock.patch("nova.scheduler.client.report.SchedulerReportClient.get") def test_remove_res_from_alloc_retry_succeed( diff --git a/nova/tests/unit/test_utils.py b/nova/tests/unit/test_utils.py index baa873c8d228..81c30a1514d7 100644 --- a/nova/tests/unit/test_utils.py +++ b/nova/tests/unit/test_utils.py @@ -290,7 +290,7 @@ class TestCachedFile(test.NoDBTestCase): self.assertNotIn(filename, utils._FILE_CACHE) -class RootwrapDaemonTesetCase(test.NoDBTestCase): +class RootwrapDaemonTestCase(test.NoDBTestCase): @mock.patch('oslo_rootwrap.client.Client') def test_get_client(self, mock_client): mock_conf = mock.MagicMock() @@ -337,6 +337,7 @@ class RootwrapDaemonTesetCase(test.NoDBTestCase): daemon.client.execute = mock.Mock(return_value=(-2, None, None)) daemon.execute('b', 2, check_exit_code=[-2]) + @mock.patch('time.sleep', new=mock.Mock()) def test_execute_fail_with_retry(self): mock_conf = mock.MagicMock() daemon = utils.RootwrapDaemonHelper(mock_conf) @@ -349,6 +350,7 @@ class RootwrapDaemonTesetCase(test.NoDBTestCase): [mock.call(['b', '2'], None), mock.call(['b', '2'], None)]) + @mock.patch('time.sleep', new=mock.Mock()) @mock.patch('nova.utils.LOG.log') def test_execute_fail_and_logging(self, mock_log): mock_conf = mock.MagicMock() @@ -435,7 +437,8 @@ Exit code: -2''') daemon.client.execute.assert_called_once_with(['a', '1'], None) self.assertIn(expected_err, err) - def test_trycmd_fail_with_rety(self): + @mock.patch('time.sleep', new=mock.Mock()) + def test_trycmd_fail_with_retry(self): mock_conf = mock.MagicMock() daemon = utils.RootwrapDaemonHelper(mock_conf) daemon.client = mock.MagicMock() diff --git a/nova/tests/unit/virt/disk/mount/test_nbd.py b/nova/tests/unit/virt/disk/mount/test_nbd.py index 2baea9069670..7e48b73bf1bd 100644 --- a/nova/tests/unit/virt/disk/mount/test_nbd.py +++ b/nova/tests/unit/virt/disk/mount/test_nbd.py @@ -173,6 +173,7 @@ class NbdTestCase(test.NoDBTestCase): self.assertFalse(n._inner_get_dev()) self.assertTrue(n.error.endswith('did not show up')) + @mock.patch('time.sleep', new=mock.Mock()) @mock.patch('random.shuffle') @mock.patch('os.path.exists', side_effect=[True, False, False, False, False, True]) @@ -204,6 +205,7 @@ class NbdTestCase(test.NoDBTestCase): self.useFixture(fixtures.MonkeyPatch('nova.utils.execute', _fake_noop)) n.unget_dev() + @mock.patch('time.sleep', new=mock.Mock()) @mock.patch('random.shuffle') @mock.patch('os.path.exists', side_effect=[True, False, False, False, False, True]) diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 4160771989c7..0ae85b321b8c 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -19750,6 +19750,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase, TraitsComparisonMixin): mock_cleanup.assert_called_once_with( self.context, ins_ref, _fake_network_info(self, 1)) + @mock.patch('time.sleep', new=mock.Mock()) def test_cleanup_resize_same_host(self): CONF.set_override('policy_dirs', [], group='oslo_policy') ins_ref = self._create_instance({'host': CONF.host}) @@ -19771,6 +19772,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase, TraitsComparisonMixin): mock_get_path.assert_called_once_with(ins_ref) self.assertEqual(5, mock_rmtree.call_count) + @mock.patch('time.sleep', new=mock.Mock()) def test_cleanup_resize_not_same_host(self): CONF.set_override('policy_dirs', [], group='oslo_policy') host = 'not' + CONF.host @@ -19803,6 +19805,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase, TraitsComparisonMixin): mock_unplug.assert_called_once_with(ins_ref, fake_net) mock_unfilter.assert_called_once_with(ins_ref, fake_net) + @mock.patch('time.sleep', new=mock.Mock()) def test_cleanup_resize_not_same_host_volume_backed(self): """Tests cleaning up after a resize is confirmed with a volume-backed instance. The key point is that the instance base directory should not @@ -19839,6 +19842,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase, TraitsComparisonMixin): mock_unplug.assert_called_once_with(ins_ref, fake_net) mock_unfilter.assert_called_once_with(ins_ref, fake_net) + @mock.patch('time.sleep', new=mock.Mock()) def test_cleanup_resize_snap_backend(self): CONF.set_override('policy_dirs', [], group='oslo_policy') self.flags(images_type='rbd', group='libvirt') @@ -19863,6 +19867,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase, TraitsComparisonMixin): libvirt_utils.RESIZE_SNAPSHOT_NAME) self.assertEqual(5, mock_rmtree.call_count) + @mock.patch('time.sleep', new=mock.Mock()) def test_cleanup_resize_snap_backend_image_does_not_exist(self): CONF.set_override('policy_dirs', [], group='oslo_policy') ins_ref = self._create_instance({'host': CONF.host}) @@ -22347,6 +22352,7 @@ class LibvirtVolumeSnapshotTestCase(test.NoDBTestCase): self.c, instance, guest, self.volume_uuid, self.create_info['new_file']) + @mock.patch('time.sleep', new=mock.Mock()) @mock.patch.object(FakeVirtDomain, 'blockCommit') @mock.patch.object(FakeVirtDomain, 'blockRebase') @mock.patch.object(FakeVirtDomain, 'XMLDesc') @@ -22380,6 +22386,7 @@ class LibvirtVolumeSnapshotTestCase(test.NoDBTestCase): mock_commit.assert_not_called() fakelibvirt.__dict__.update({'VIR_DOMAIN_BLOCK_REBASE_RELATIVE': 8}) + @mock.patch('time.sleep', new=mock.Mock()) @mock.patch.object(FakeVirtDomain, 'blockCommit') @mock.patch.object(FakeVirtDomain, 'blockRebase') @mock.patch.object(FakeVirtDomain, 'XMLDesc') @@ -22510,6 +22517,7 @@ class LibvirtVolumeSnapshotTestCase(test.NoDBTestCase): snapshot_id, self.delete_info_1) self.assertIn('has not been fully tested', six.text_type(ex)) + @mock.patch('time.sleep', new=mock.Mock()) @mock.patch.object(host.Host, '_get_domain') @mock.patch.object(FakeVirtDomain, 'blockCommit') @mock.patch.object(FakeVirtDomain, 'blockRebase') @@ -22666,6 +22674,7 @@ class LibvirtVolumeSnapshotTestCase(test.NoDBTestCase): 'error_deleting') mock_get.assert_not_called() + @mock.patch('time.sleep', new=mock.Mock()) @mock.patch.object(host.Host, '_get_domain') @mock.patch('nova.virt.libvirt.guest.BlockDevice.is_job_complete') def test_volume_snapshot_delete_netdisk_1( @@ -22710,6 +22719,7 @@ class LibvirtVolumeSnapshotTestCase(test.NoDBTestCase): fakelibvirt.__dict__.update({'VIR_DOMAIN_BLOCK_REBASE_RELATIVE': 8}) + @mock.patch('time.sleep', new=mock.Mock()) @mock.patch.object(host.Host, '_get_domain') @mock.patch('nova.virt.libvirt.guest.BlockDevice.is_job_complete') def test_volume_snapshot_delete_netdisk_relative_1( @@ -22752,6 +22762,7 @@ class LibvirtVolumeSnapshotTestCase(test.NoDBTestCase): flags=fakelibvirt.VIR_DOMAIN_BLOCK_REBASE_RELATIVE) mock_commit.assert_not_called() + @mock.patch('time.sleep', new=mock.Mock()) @mock.patch.object(host.Host, '_get_domain') @mock.patch('nova.virt.libvirt.guest.BlockDevice.is_job_complete') def test_volume_snapshot_delete_netdisk_relative_2(