def test_getJobStatusBatchSystem(mocker):
    """Test Condor Batch System plugin getJobStatus"""
    patchPopen = mocker.patch("DIRAC.Resources.Computing.BatchSystems.Condor.subprocess.Popen")
    patchPopen.return_value.communicate.side_effect = [("\n".join(STATUS_LINES), ""), ("\n".join(HISTORY_LINES), "")]
    patchPopen.return_value.returncode = 0

    ret = Condor.Condor().getJobStatus(JobIDList=["123.0", "123.1", "123.2", "333.3"])

    expectedResults = {
        "123.0": "Done",
        "123.1": "Aborted",
        "123.2": "Unknown",  # HELD is treated as Unknown
        "333.3": "Unknown",
    }

    assert ret["Status"] == 0
    assert expectedResults == ret["Jobs"]
Example #2
0
  def test_getJobStatus(self):
    mock = Mock(side_effect=([(0, "\n".join(STATUS_LINES)),  # condor_q
                              (0, "\n".join(HISTORY_LINES))]))  # condor_history

    with patch(MODNAME + ".commands.getstatusoutput", new=mock):
      ret = Condor.Condor().getJobStatus(JobIDList=["123.0",
                                                    "123.1",
                                                    "123.2",
                                                    "333.3"])

    expectedResults = {"123.0": "Done",
                       "123.1": "Aborted",
                       "123.2": "Unknown",  # HELD is treated as Unknown
                       "333.3": "Unknown"}

    self.assertEqual(ret['Status'], 0)
    self.assertEqual(expectedResults, ret['Jobs'])