Skip to content

Commit a9d3bbb

Browse files
committed
Dev: unittests: Adjust unit test for previous commit
1 parent 9e946fb commit a9d3bbb

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

test/unittests/test_bootstrap.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,25 +1804,29 @@ def test_get_cluster_node_ip(self, mock_get_values, mock_get_iplist):
18041804
mock_get_values.assert_called_once_with("nodelist.node.ring0_addr")
18051805
mock_get_iplist.assert_called_once_with('node1')
18061806

1807+
@mock.patch('crmsh.service_manager.ServiceManager.disable_service')
1808+
@mock.patch('crmsh.service_manager.ServiceManager.service_is_enabled')
18071809
@mock.patch('crmsh.utils.this_node')
18081810
@mock.patch('crmsh.service_manager.ServiceManager.stop_service')
18091811
@mock.patch('logging.Logger.info')
18101812
@mock.patch('crmsh.service_manager.ServiceManager.service_is_active')
1811-
def test_stop_services(self, mock_active, mock_status, mock_stop, mock_this_node):
1813+
def test_stop_and_disable_services(self, mock_active, mock_status, mock_stop, mock_this_node, mock_enabled, mock_disable):
18121814
mock_active.side_effect = [True, True, True, True]
1813-
mock_this_node.side_effect = ['node1', 'node1', 'node1', 'node1']
1814-
bootstrap.stop_services(bootstrap.SERVICES_STOP_LIST)
1815+
mock_enabled.side_effect = [True, True]
1816+
mock_this_node.side_effect = ['node1', 'node1', 'node1', 'node1', 'node1', 'node1']
1817+
bootstrap.stop_and_disable_services()
18151818
mock_active.assert_has_calls([
18161819
mock.call("corosync-qdevice.service", remote_addr=None),
18171820
mock.call("corosync.service", remote_addr=None),
18181821
mock.call("hawk.service", remote_addr=None),
18191822
mock.call("csync2.socket", remote_addr=None)
18201823
])
18211824
mock_status.assert_has_calls([
1822-
mock.call('Stopping the %s on %s', 'corosync-qdevice.service', 'node1'),
1823-
mock.call('Stopping the %s on %s', 'corosync.service', 'node1'),
1824-
mock.call('Stopping the %s on %s', 'hawk.service', 'node1'),
1825-
mock.call('Stopping the %s on %s', 'csync2.socket', 'node1')
1825+
mock.call('Stopping and disable %s on node %s', 'corosync.service', 'node1'),
1826+
mock.call('Stopping and disable %s on node %s', 'hawk.service', 'node1'),
1827+
mock.call('Stopping and disable %s on node %s', 'csync2.socket', 'node1'),
1828+
mock.call('Disable %s on node %s', 'pacemaker.service', 'node1'),
1829+
mock.call('Disable %s on node %s', 'sbd.service', 'node1'),
18261830
])
18271831
mock_stop.assert_has_calls([
18281832
mock.call("corosync-qdevice.service", disable=True, remote_addr=None),
@@ -1836,7 +1840,7 @@ def test_stop_services(self, mock_active, mock_status, mock_stop, mock_this_node
18361840
@mock.patch('crmsh.utils.fatal')
18371841
@mock.patch('crmsh.bootstrap.invoke')
18381842
@mock.patch('logging.Logger.info')
1839-
@mock.patch('crmsh.bootstrap.stop_services')
1843+
@mock.patch('crmsh.bootstrap.stop_and_disable_services')
18401844
@mock.patch('crmsh.bootstrap.get_cluster_node_ip')
18411845
@mock.patch('crmsh.xmlutil.CrmMonXmlParser')
18421846
def test_remove_node_from_cluster_rm_node_failed(self, mock_crm_mon_parser, mock_get_ip, mock_stop, mock_status, mock_invoke, mock_error, mock_rm_conf_files, mock_call_delnode):
@@ -1853,7 +1857,7 @@ def test_remove_node_from_cluster_rm_node_failed(self, mock_crm_mon_parser, mock
18531857

18541858
mock_get_ip.assert_called_once_with('node1')
18551859
mock_status.assert_called_once_with("Removing node %s from CIB", "node1")
1856-
mock_stop.assert_called_once_with(bootstrap.SERVICES_STOP_LIST, remote_addr="node1")
1860+
mock_stop.assert_called_once_with(remote_addr="node1")
18571861
mock_invoke.assert_not_called()
18581862
mock_call_delnode.assert_called_once_with("node1")
18591863
mock_error.assert_called_once_with("Failed to remove node1.")
@@ -1904,7 +1908,7 @@ def test_remove_node_from_cluster_rm_csync_failed(self, mock_crm_mon_parser, moc
19041908
@mock.patch('crmsh.bootstrap.invokerc')
19051909
@mock.patch('crmsh.bootstrap.invoke')
19061910
@mock.patch('logging.Logger.info')
1907-
@mock.patch('crmsh.bootstrap.stop_services')
1911+
@mock.patch('crmsh.bootstrap.stop_and_disable_services')
19081912
@mock.patch('crmsh.bootstrap.get_cluster_node_ip')
19091913
@mock.patch('crmsh.xmlutil.CrmMonXmlParser')
19101914
def test_remove_node_from_cluster_hostname(self, mock_crm_mon_parser, mock_get_ip, mock_stop, mock_status,
@@ -1928,7 +1932,7 @@ def test_remove_node_from_cluster_hostname(self, mock_crm_mon_parser, mock_get_i
19281932
mock.call("Removing node %s from CIB", "node1"),
19291933
mock.call("Propagating configuration changes across the remaining nodes")
19301934
])
1931-
mock_stop.assert_called_once_with(bootstrap.SERVICES_STOP_LIST, remote_addr="node1")
1935+
mock_stop.assert_called_once_with(remote_addr="node1")
19321936
mock_cal_delnode.assert_called_once_with("node1")
19331937
mock_invoke.assert_has_calls([
19341938
mock.call("corosync-cfgtool -R")

0 commit comments

Comments
 (0)