def test_activate_noiscsi_success(self, mock_util, mock_iscsilib): """ MPATH activate, no iscsi, success """ mock_iscsilib.is_iscsi_daemon_running.return_value = False mock_util.doexec.return_value = (0, "", "") self.mock_mpath_cli.is_working.side_effect = [False, False, True] mpath_dmp.activate() self.assertEqual(0, mock_util.pread2.call_count)
def test_activate_active_iscsi_success(self, mock_util, mock_iscsilib): """ MPATH activate, active iscsi, success """ mock_iscsilib.is_iscsi_daemon_running.return_value = True mock_iscsilib._checkAnyTGT.return_value = True mock_util.doexec.return_value = (0, "", "") self.mock_mpath_cli.is_working.side_effect = [False, False, True] mpath_dmp.activate() self.assertEqual(0, mock_iscsilib.restart_daemon.call_count)
def test_activate_noiscsi_start_mpath(self, mock_util, mock_iscsilib): """ MPATH activate, no iscsi, start mpath """ mock_iscsilib.is_iscsi_daemon_running.return_value = False mock_util.doexec.return_value = (1, "", "") self.mock_mpath_cli.is_working.side_effect = [False, False, True] mpath_dmp.activate() self.assertEqual(1, mock_util.pread2.call_count) mock_util.pread2.assert_called_once_with( ['service', 'multipathd', 'start'])
def test_activate_noiscsi_mpath_not_working(self, context, mock_util, mock_iscsilib): """ MPATH activate, mpath not running """ # Setup error codes context.setup_error_codes() mock_iscsilib.is_iscsi_daemon_running.return_value = False mock_util.doexec.return_value = (0, "", "") self.mock_mpath_cli.is_working.side_effect = [False] * 120 with self.assertRaises(SROSError) as soe: mpath_dmp.activate() self.assertEqual(430, soe.exception.errno)