Description: Fix testsuite Make sure testsuite output works with Pacemaker 2. Author: Valentin Vidic Last-Update: 2021-02-03 --- a/test/unittests/test_utils.py +++ b/test/unittests/test_utils.py @@ -34,12 +34,12 @@ mock_run.assert_called_once_with("crm_node -l") -@mock.patch("crmsh.sh.ShellUtils.get_stdout") +@mock.patch("crmsh.sh.ShellUtils.get_stdout_stderr") def test_package_is_installed_local(mock_run): - mock_run.return_value = (0, None) + mock_run.return_value = (0, None, None) res = utils.package_is_installed("crmsh") assert res is True - mock_run.assert_called_once_with("rpm -q --quiet crmsh") + mock_run.assert_called_once_with("dpkg-query --status crmsh") @mock.patch('crmsh.utils.detect_file') --- a/test/unittests/test_sbd.py +++ b/test/unittests/test_sbd.py @@ -512,9 +512,9 @@ self.sbd_inst._update_sbd_configuration() - mock_copy.assert_called_once_with("/usr/share/fillup-templates/sysconfig.sbd", "/etc/sysconfig/sbd") - mock_sysconfig.assert_called_once_with("/etc/sysconfig/sbd", SBD_WATCHDOG_DEV='/dev/watchdog', SBD_DEVICE='/dev/sdb1;/dev/sdc1', SBD_WATCHDOG_TIMEOUT="15") - mock_update.assert_called_once_with("/etc/sysconfig/sbd") + mock_copy.assert_called_once_with("/usr/share/fillup-templates/sysconfig.sbd", "/etc/default/sbd") + mock_sysconfig.assert_called_once_with("/etc/default/sbd", SBD_WATCHDOG_DEV='/dev/watchdog', SBD_DEVICE='/dev/sdb1;/dev/sdc1', SBD_WATCHDOG_TIMEOUT="15") + mock_update.assert_called_once_with("/etc/default/sbd") @mock.patch('crmsh.bootstrap.utils.parse_sysconfig') def test_get_sbd_device_from_config_none(self, mock_parse): @@ -525,7 +525,7 @@ res = self.sbd_inst._get_sbd_device_from_config() assert res == [] - mock_parse.assert_called_once_with("/etc/sysconfig/sbd") + mock_parse.assert_called_once_with("/etc/default/sbd") mock_parse_inst.get.assert_called_once_with("SBD_DEVICE") @mock.patch('crmsh.utils.re_split_string') @@ -539,7 +539,7 @@ res = self.sbd_inst._get_sbd_device_from_config() assert res == ["/dev/sdb1", "/dev/sdc1"] - mock_parse.assert_called_once_with("/etc/sysconfig/sbd") + mock_parse.assert_called_once_with("/etc/default/sbd") mock_parse_inst.get.assert_called_once_with("SBD_DEVICE") mock_split.assert_called_once_with(sbd.SBDManager.PARSE_RE, "/dev/sdb1;/dev/sdc1") @@ -712,7 +712,7 @@ mock_exists.return_value = False self.sbd_inst.join_sbd("alice", "node1") mock_package.assert_called_once_with("sbd") - mock_exists.assert_called_once_with("/etc/sysconfig/sbd") + mock_exists.assert_called_once_with("/etc/default/sbd") mock_invoke.assert_called_once_with("systemctl disable sbd.service") @mock.patch('crmsh.bootstrap.invoke') @@ -727,7 +727,7 @@ self.sbd_inst.join_sbd("alice", "node1") mock_package.assert_called_once_with("sbd") - mock_exists.assert_called_once_with("/etc/sysconfig/sbd") + mock_exists.assert_called_once_with("/etc/default/sbd") mock_invoke.assert_called_once_with("systemctl disable sbd.service") mock_enabled.assert_called_once_with("sbd.service", "node1") @@ -751,7 +751,7 @@ self.sbd_inst.join_sbd("alice", "node1") mock_package.assert_called_once_with("sbd") - mock_exists.assert_called_once_with("/etc/sysconfig/sbd") + mock_exists.assert_called_once_with("/etc/default/sbd") mock_invoke.assert_called_once_with("systemctl enable sbd.service") mock_get_device.assert_called_once_with() mock_verify.assert_called_once_with(["/dev/sdb1"], ["node1"]) @@ -781,7 +781,7 @@ self.sbd_inst.join_sbd("alice", "node1") mock_package.assert_called_once_with("sbd") - mock_exists.assert_called_once_with("/etc/sysconfig/sbd") + mock_exists.assert_called_once_with("/etc/default/sbd") mock_invoke.assert_called_once_with("systemctl enable sbd.service") mock_get_device.assert_called_once_with() mock_warn.assert_called_once_with("node1") --- a/test/unittests/test_ui_cluster.py +++ b/test/unittests/test_ui_cluster.py @@ -44,11 +44,13 @@ mock_qdevice_configured.return_value = False context_inst = mock.Mock() mock_parse_nodes.return_value = ["node1", "node2"] - mock_active.side_effect = [True, True] + mock_active.side_effect = [True, True, True, True] self.ui_cluster_inst.do_start(context_inst, "node1", "node2") mock_parse_nodes.assert_called_once_with(context_inst, "node1", "node2") mock_active.assert_has_calls([ + mock.call("corosync.service", remote_addr="node1"), mock.call("pacemaker.service", remote_addr="node1"), + mock.call("corosync.service", remote_addr="node2"), mock.call("pacemaker.service", remote_addr="node2") ]) mock_info.assert_has_calls([ @@ -67,12 +69,13 @@ context_inst = mock.Mock() mock_start_pacemaker.return_value = ["node1"] mock_parse_nodes.return_value = ["node1"] - mock_active.side_effect = [False, False] + mock_active.side_effect = [False, False, False] mock_qdevice_configured.return_value = True self.ui_cluster_inst.do_start(context_inst, "node1") mock_active.assert_has_calls([ + mock.call("corosync.service", remote_addr="node1"), mock.call("pacemaker.service", remote_addr="node1"), mock.call("corosync-qdevice.service", remote_addr="node1") ]) --- a/test/unittests/test_bootstrap.py +++ b/test/unittests/test_bootstrap.py @@ -1760,7 +1760,7 @@ bootstrap.rm_configuration_files() mock_run.assert_has_calls([ mock.call('rm -f file1 file2', None), - mock.call('cp /usr/share/fillup-templates/sysconfig.sbd /etc/sysconfig/sbd', None) + mock.call('cp /usr/share/fillup-templates/sysconfig.sbd /etc/default/sbd', None) ]) @mock.patch('crmsh.utils.get_iplist_from_name') --- a/test/cibtests/001.exp.xml +++ b/test/cibtests/001.exp.xml @@ -9,6 +9,9 @@ + + + --- a/test/cibtests/002.exp.xml +++ b/test/cibtests/002.exp.xml @@ -13,6 +13,11 @@ + + + + + --- a/test/cibtests/003.exp.xml +++ b/test/cibtests/003.exp.xml @@ -14,6 +14,11 @@ + + + + + --- a/test/cibtests/004.exp.xml +++ b/test/cibtests/004.exp.xml @@ -14,6 +14,11 @@ + + + + +