Skip to content

Commit ba3a1bc

Browse files
committed
Dev: unittests: Adjust unit test for previous commit
1 parent e849945 commit ba3a1bc

File tree

1 file changed

+0
-85
lines changed

1 file changed

+0
-85
lines changed

test/unittests/test_sbd.py

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,6 @@ class TestSBDTimeout(unittest.TestCase):
186186
"""
187187
Unitary tests for crmsh.sbd.SBDTimeout
188188
"""
189-
@patch('crmsh.sbd.SBDUtils.get_sbd_device_metadata')
190-
def test_get_sbd_msgwait_exception(self, mock_get_sbd_device_metadata):
191-
mock_get_sbd_device_metadata.return_value = {}
192-
with self.assertRaises(ValueError) as context:
193-
sbd.SBDTimeout.get_sbd_msgwait("/dev/sbd_device")
194-
self.assertTrue("Cannot get sbd msgwait for /dev/sbd_device" in str(context.exception))
195-
196-
@patch('crmsh.sbd.SBDUtils.get_sbd_device_metadata')
197-
def test_get_sbd_msgwait(self, mock_get_sbd_device_metadata):
198-
mock_get_sbd_device_metadata.return_value = {'msgwait': 10}
199-
result = sbd.SBDTimeout.get_sbd_msgwait("/dev/sbd_device")
200-
self.assertEqual(result, 10)
201-
202189
@patch('crmsh.sbd.SBDUtils.get_sbd_value_from_config')
203190
def test_get_sbd_watchdog_timeout_exception(self, mock_get_sbd_value_from_config):
204191
mock_get_sbd_value_from_config.return_value = None
@@ -246,78 +233,6 @@ def test_get_sbd_systemd_start_timeout(self, mock_cluster_shell, mock_get_system
246233
mock_cluster_shell.return_value.get_stdout_or_raise_error.assert_called_once_with(sbd.SBDTimeout.SHOW_SBD_START_TIMEOUT_CMD)
247234
mock_get_systemd_timeout_start_in_sec.assert_called_once_with("1min 30s")
248235

249-
@patch('crmsh.sbd.SBDTimeout.adjust_systemd_start_timeout')
250-
@patch('crmsh.sbd.SBDTimeout.adjust_stonith_timeout')
251-
@patch('crmsh.sbd.SBDTimeout.adjust_sbd_delay_start')
252-
@patch('crmsh.sbd.SBDTimeout._load_configurations')
253-
def test_adjust_sbd_timeout_related_cluster_configuration(self, mock_load_configurations, mock_adjust_sbd_delay_start, mock_adjust_stonith_timeout,
254-
mock_adjust_systemd_start_timeout):
255-
sbd.SBDTimeout.adjust_sbd_timeout_related_cluster_configuration()
256-
mock_load_configurations.assert_called_once()
257-
mock_adjust_sbd_delay_start.assert_called_once()
258-
mock_adjust_stonith_timeout.assert_called_once()
259-
mock_adjust_systemd_start_timeout.assert_called_once()
260-
261-
@patch('crmsh.sbd.SBDManager.update_sbd_configuration')
262-
def test_adjust_sbd_delay_start_return(self, mock_update_sbd_configuration):
263-
inst = sbd.SBDTimeout()
264-
inst.sbd_delay_start_value_expected = 100
265-
inst.sbd_delay_start_value_from_config = "100"
266-
inst.adjust_sbd_delay_start()
267-
mock_update_sbd_configuration.assert_not_called()
268-
269-
@patch('crmsh.sbd.SBDManager.update_sbd_configuration')
270-
def test_adjust_sbd_delay_start(self, mock_update_sbd_configuration):
271-
inst = sbd.SBDTimeout()
272-
inst.sbd_delay_start_value_expected = "no"
273-
inst.sbd_delay_start_value_from_config = 200
274-
inst.adjust_sbd_delay_start()
275-
mock_update_sbd_configuration.assert_called_once_with({'SBD_DELAY_START': 'no'})
276-
277-
@patch('crmsh.utils.set_property')
278-
def test_adjust_stonith_timeout(self, mock_set_property):
279-
inst = sbd.SBDTimeout()
280-
inst.get_stonith_timeout_expected = MagicMock(return_value=10)
281-
inst.adjust_stonith_timeout()
282-
mock_set_property.assert_called_once_with("stonith-timeout", 10)
283-
284-
@patch('crmsh.sbd.SBDTimeout.restore_systemd_start_timeout')
285-
@patch('crmsh.sbd.SBDTimeout.get_sbd_systemd_start_timeout')
286-
@patch('crmsh.sbd.SBDUtils.get_sbd_value_from_config')
287-
def test_adjust_systemd_start_timeout_no_delay_start(self, mock_get_sbd_value_from_config, mock_get_sbd_systemd_start_timeout, mock_restore_systemd_start_timeout):
288-
mock_get_sbd_value_from_config.return_value = "no"
289-
inst = sbd.SBDTimeout()
290-
inst.adjust_systemd_start_timeout()
291-
mock_get_sbd_value_from_config.assert_called_once_with("SBD_DELAY_START")
292-
mock_get_sbd_systemd_start_timeout.assert_not_called()
293-
294-
@patch('crmsh.sbd.SBDTimeout.restore_systemd_start_timeout')
295-
@patch('crmsh.sbd.SBDTimeout.get_sbd_systemd_start_timeout')
296-
@patch('crmsh.sbd.SBDUtils.get_sbd_value_from_config')
297-
def test_adjust_systemd_start_timeout_return(self, mock_get_sbd_value_from_config, mock_get_sbd_systemd_start_timeout, mock_restore_systemd_start_timeout):
298-
mock_get_sbd_value_from_config.return_value = "10"
299-
mock_get_sbd_systemd_start_timeout.return_value = 90
300-
inst = sbd.SBDTimeout()
301-
inst.adjust_systemd_start_timeout()
302-
mock_get_sbd_value_from_config.assert_called_once_with("SBD_DELAY_START")
303-
mock_get_sbd_systemd_start_timeout.assert_called_once()
304-
305-
@patch('crmsh.utils.cluster_run_cmd')
306-
@patch('crmsh.bootstrap.sync_path')
307-
@patch('crmsh.utils.str2file')
308-
@patch('crmsh.utils.mkdirp')
309-
@patch('crmsh.sbd.SBDTimeout.get_sbd_systemd_start_timeout')
310-
@patch('crmsh.sbd.SBDUtils.get_sbd_value_from_config')
311-
def test_adjust_systemd_start_timeout(self, mock_get_sbd_value_from_config, mock_get_sbd_systemd_start_timeout, mock_mkdirp, mock_str2file, mock_sync_file, mock_cluster_run_cmd):
312-
mock_get_sbd_value_from_config.return_value = "150"
313-
mock_get_sbd_systemd_start_timeout.return_value = 90
314-
inst = sbd.SBDTimeout()
315-
inst.adjust_systemd_start_timeout()
316-
mock_get_sbd_value_from_config.assert_called_once_with("SBD_DELAY_START")
317-
mock_get_sbd_systemd_start_timeout.assert_called_once()
318-
mock_mkdirp.assert_called_once_with(sbd.SBDManager.SBD_SYSTEMD_DELAY_START_DIR)
319-
mock_cluster_run_cmd.assert_called_once_with("systemctl daemon-reload")
320-
321236
@patch('crmsh.corosync.token_and_consensus_timeout')
322237
def test_get_sbd_delay_start_expected_diskbased(self, mock_token_and_consensus_timeout):
323238
inst = sbd.SBDTimeout()

0 commit comments

Comments
 (0)