stabilize set_host libvirt driver unit test
The test_set_host_enabled* unit tests are setting host state and asserting the result, but the libvirt driver connection handler also sets that in parallel in the unit test. Causing these test to be unstable. This patch mocks the connection handler to stabilize the tests. Change-Id: I68ed46d174bf151dbcb91568908c815584985a59
This commit is contained in:
parent
c501e23cb7
commit
b247e69923
|
@ -2082,6 +2082,9 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
|||
self.assertRaises(NotImplementedError,
|
||||
drvr.set_admin_password, instance, "123")
|
||||
|
||||
@mock.patch(
|
||||
'nova.virt.libvirt.driver.LibvirtDriver._handle_conn_event',
|
||||
new=mock.Mock())
|
||||
@mock.patch.object(objects.Service, 'save')
|
||||
@mock.patch.object(objects.Service, 'get_by_compute_host')
|
||||
def test_set_host_enabled_with_disable(self, mock_svc, mock_save):
|
||||
|
@ -2097,6 +2100,9 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
|||
self.assertTrue(svc.disabled)
|
||||
mock_save.assert_called_once_with()
|
||||
|
||||
@mock.patch(
|
||||
'nova.virt.libvirt.driver.LibvirtDriver._handle_conn_event',
|
||||
new=mock.Mock())
|
||||
@mock.patch.object(objects.Service, 'save')
|
||||
@mock.patch.object(objects.Service, 'get_by_compute_host')
|
||||
def test_set_host_enabled_with_enable(self, mock_svc, mock_save):
|
||||
|
@ -2113,6 +2119,9 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
|||
mock_save.assert_not_called()
|
||||
self.assertTrue(svc.disabled)
|
||||
|
||||
@mock.patch(
|
||||
'nova.virt.libvirt.driver.LibvirtDriver._handle_conn_event',
|
||||
new=mock.Mock())
|
||||
@mock.patch.object(objects.Service, 'save')
|
||||
@mock.patch.object(objects.Service, 'get_by_compute_host')
|
||||
def test_set_host_enabled_with_enable_state_enabled(self, mock_svc,
|
||||
|
@ -2128,6 +2137,9 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
|||
self.assertFalse(svc.disabled)
|
||||
mock_save.assert_not_called()
|
||||
|
||||
@mock.patch(
|
||||
'nova.virt.libvirt.driver.LibvirtDriver._handle_conn_event',
|
||||
new=mock.Mock())
|
||||
@mock.patch.object(objects.Service, 'save')
|
||||
@mock.patch.object(objects.Service, 'get_by_compute_host')
|
||||
def test_set_host_enabled_with_disable_state_disabled(self, mock_svc,
|
||||
|
|
Loading…
Reference in New Issue