Skip to content

Commit 1add080

Browse files
committed
Dev: unittests: Adjust unit test for previous commits
1 parent f497c52 commit 1add080

File tree

5 files changed

+283
-66
lines changed

5 files changed

+283
-66
lines changed

test/unittests/test_bootstrap.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,10 @@ def tearDownClass(cls):
520520
Global tearDown.
521521
"""
522522

523-
@mock.patch('crmsh.parallax.parallax_call')
524523
@mock.patch('crmsh.service_manager.ServiceManager.start_service')
525-
@mock.patch('crmsh.sbd.SBDTimeout.is_sbd_delay_start')
526-
@mock.patch('crmsh.service_manager.ServiceManager.service_is_enabled')
527-
@mock.patch('crmsh.utils.package_is_installed')
528-
def test_start_pacemaker(self, mock_installed, mock_enabled, mock_delay_start, mock_start, mock_parallax_call):
524+
@mock.patch('crmsh.sbd.SBDManager.unset_sbd_delay_start')
525+
def test_start_pacemaker(self, mock_unset_delay_start, mock_start):
529526
bootstrap._context = None
530-
mock_installed.return_value = True
531-
mock_enabled.return_value = True
532-
mock_delay_start.return_value = True
533527
node_list = ["node1", "node2", "node3", "node4", "node5", "node6"]
534528
bootstrap.start_pacemaker(node_list)
535529
mock_start.assert_has_calls([
@@ -541,11 +535,6 @@ def test_start_pacemaker(self, mock_installed, mock_enabled, mock_delay_start, m
541535
mock.call("corosync.service", remote_addr="node6"),
542536
mock.call("pacemaker.service", enable=False, node_list=node_list)
543537
])
544-
mock_parallax_call.assert_has_calls([
545-
mock.call(node_list, f'mkdir -p {sbd.SBDManager.SBD_SYSTEMD_DELAY_START_DISABLE_DIR}'),
546-
mock.call(node_list, f"echo -e '[Service]\nUnsetEnvironment=SBD_DELAY_START' > {sbd.SBDManager.SBD_SYSTEMD_DELAY_START_DISABLE_FILE}"),
547-
mock.call(node_list, "systemctl daemon-reload"),
548-
])
549538

550539
@mock.patch('crmsh.bootstrap.change_user_shell')
551540
@mock.patch('crmsh.bootstrap.configure_ssh_key')
@@ -1547,7 +1536,7 @@ def test_adjust_stonith_timeout_sbd(self, mock_is_active, mock_sbd_checker):
15471536
mock_sbd_checker_inst.check_and_fix = mock.Mock()
15481537
mock_is_active.return_value = True
15491538
bootstrap.adjust_stonith_timeout()
1550-
mock_sbd_checker.assert_called_once_with(quiet=True, fix=True, from_bootstrap=True)
1539+
mock_sbd_checker.assert_called_once_with(quiet=True, fix=True)
15511540

15521541
@mock.patch('crmsh.utils.set_property')
15531542
@mock.patch('crmsh.bootstrap.get_stonith_timeout_generally_expected')
@@ -1568,18 +1557,18 @@ def test_adjust_priority_in_rsc_defaults(self, mock_set):
15681557
bootstrap.adjust_priority_in_rsc_defaults(False)
15691558
mock_set.assert_called_once_with('priority', 0, property_type='rsc_defaults')
15701559

1571-
@mock.patch('crmsh.sh.ClusterShell.get_stdout_or_raise_error')
1572-
def test_adjust_priority_fencing_delay_no_fence_agent(self, mock_run):
1573-
mock_run.return_value = None
1574-
bootstrap.adjust_priority_fencing_delay(False)
1575-
mock_run.assert_called_once_with("crm configure show related:stonith")
1560+
@mock.patch('crmsh.utils.set_property')
1561+
@mock.patch('crmsh.utils.get_pcmk_delay_max_configured_value')
1562+
def test_adjust_priority_fencing_delay(self, mock_get_pcmk_delay, mock_set):
1563+
mock_get_pcmk_delay.return_value = 30
1564+
bootstrap.adjust_priority_fencing_delay(True)
1565+
mock_set.assert_called_once_with("priority-fencing-delay", 60, conditional=True)
15761566

15771567
@mock.patch('crmsh.utils.set_property')
1578-
@mock.patch('crmsh.sh.ClusterShell.get_stdout_or_raise_error')
1579-
def test_adjust_priority_fencing_delay_no_pcmk_delay(self, mock_run, mock_set):
1580-
mock_run.return_value = "data"
1568+
@mock.patch('crmsh.utils.get_pcmk_delay_max_configured_value')
1569+
def test_adjust_priority_fencing_delay_no_pcmk_delay(self, mock_get_pcmk_delay, mock_set):
1570+
mock_get_pcmk_delay.return_value = 0
15811571
bootstrap.adjust_priority_fencing_delay(False)
1582-
mock_run.assert_called_once_with("crm configure show related:stonith")
15831572
mock_set.assert_called_once_with("priority-fencing-delay", 0)
15841573

15851574
@mock.patch('crmsh.service_manager.ServiceManager.service_is_active')
@@ -1600,7 +1589,7 @@ def test_adjust_properties(self, mock_is_active, mock_2node_qdevice, mock_adj_pc
16001589
bootstrap.adjust_properties()
16011590
mock_is_active.assert_called_once_with("pacemaker.service")
16021591
mock_adj_pcmk.assert_called_once_with(True)
1603-
mock_adj_stonith.assert_called_once_with(with_sbd=False)
1592+
mock_adj_stonith.assert_called_once_with()
16041593
mock_adj_priority.assert_called_once_with(True)
16051594
mock_adj_fence.assert_called_once_with(True)
16061595

0 commit comments

Comments
 (0)