def test_check_sbd_no_conf(cls, mock_os_path_exists, mock_utils_msg_info, mock_run): """ Test no configuration file """ mock_os_path_exists.return_value = False check.check_sbd() mock_utils_msg_info.assert_called_with( "SBD configuration file {} not found.".format(config.SBD_CONF), to_stdout=False) mock_run.assert_called_once_with()
def test_check_sbd_not_configured(cls, mock_os_path_exists, mock_utils_parse_sysconf, mock_utils_msg_info, mock_run): """ Test SBD device not configured """ mock_os_path_exists.return_value = True mock_utils_parse_sysconf.return_value = {} check.check_sbd() mock_utils_msg_info.assert_called_with("SBD DEVICE not used.", to_stdout=False) mock_run.assert_called_once_with()
def test_check_sbd_exist_and_valid(cls, mock_os_path_exists, mock_utils_parse_sysconf, mock_find_hexdump, mock_msg_info, mock_is_valid_sbd, mock_run): """ Test configured SBD device exist and valid """ dev = "/dev/disk/by-id/scsi-SATA_ST2000LM007-1R81_WDZ5J42A" mock_os_path_exists.side_effect = [True, True, True] mock_utils_parse_sysconf.return_value = {"SBD_DEVICE": dev} mock_find_hexdump.return_value = (0, "/usr/bin/hexdump", None) mock_is_valid_sbd.return_value = True check.check_sbd() mock_msg_info.assert_called_with( "'{}' is a valid SBD device.".format(dev), to_stdout=False) mock_run.assert_called_once_with()
def test_check_sbd_exist_and_not_exist_has_can( cls, mock_os_path_exists, mock_utils_parse_sysconf, mock_find_hexdump, mock_msg_warn, mock_msg_info, mock_is_valid_sbd, mock_find_can_sbd, mock_run): """ Test configured SBD device not valid but has candidate """ dev = "/dev/disk/by-id/scsi-SATA_ST2000LM007-1R81_WDZ5J42A" candev = "/dev/disk/by-id/scsi-SATA_ST2037LM010-2R82_WDZ5J36B" mock_os_path_exists.side_effect = [True, False] mock_utils_parse_sysconf.return_value = {"SBD_DEVICE": dev} mock_find_hexdump.return_value = (0, "/usr/bin/hexdump", None) mock_is_valid_sbd.return_value = False mock_find_can_sbd.return_value = candev check.check_sbd() mock_msg_warn.assert_called_once_with( "SBD device '{}' is not exist.".format(dev), to_stdout=False) mock_msg_info.assert_called_with( "Found '{}' with SBD header exist.".format(candev), to_stdout=False) mock_run.assert_called_once_with()
def test_check_sbd_exist_and_not_valid_but_no_can( cls, mock_os_path_exists, mock_utils_parse_sysconf, mock_find_hexdump, mock_msg_warn, mock_is_valid_sbd, mock_find_can_sbd, mock_run): """ Test configured SBD device not valid and no candidate """ dev = "/dev/disk/by-id/scsi-SATA_ST2000LM007-1R81_WDZ5J42A" mock_os_path_exists.side_effect = [True, True, True] mock_utils_parse_sysconf.return_value = {"SBD_DEVICE": dev} mock_find_hexdump.return_value = (0, "/usr/bin/hexdump", None) mock_is_valid_sbd.return_value = False mock_find_can_sbd.return_value = "" check.check_sbd() mock_msg_warn.assert_has_calls([ mock.call("Device '{}' is not valid for SBD, may need initialize.". format(dev), to_stdout=False), mock.call("Fail to find a valid candidate SBD device.", to_stdout=False) ]) mock_run.assert_called_once_with()