Example #1
0
    def test_failHard(self,
                      infoCalls,
                      jID=666,
                      jStat="Done",
                      inFiles=None,
                      ofStat=["Exists"]):
        """Test the job.failHard function."""
        from DIRAC.TransformationSystem.Utilities.TransformationInfo import TransformationInfo
        from DIRAC.TransformationSystem.Utilities.JobInfo import JobInfo

        tInfoMock = Mock(name="tInfoMock", spec=TransformationInfo)
        tInfoMock.reset_mock()
        testJob = JobInfo(jobID=666,
                          status=jStat,
                          tID=123,
                          tType="MCSimulation")
        testJob.outputFiles = ["/my/stupid/file.lfn"]
        testJob.outputFileStatus = ofStat
        testJob.otherTasks = True
        testJob.inputFiles = inFiles
        testJob.inputFileExists = True
        testJob.fileStatus = "Processed"
        self.dra.inputFilesProcessed = set()
        self.dra._DataRecoveryAgent__failJobHard(testJob, tInfoMock)  # pylint: disable=protected-access, no-member
        gLogger.notice("Expecting calls", infoCalls)
        gLogger.notice("Called", tInfoMock.method_calls)
        assert len(infoCalls) == len(tInfoMock.method_calls)
        for index, infoCall in enumerate(infoCalls):
            self.assertIn(infoCall, tInfoMock.method_calls[index])
        if jStat == "Done":
            self.assertIn("Failing job %s" % jID, self.dra.notesToSend)
        else:
            self.assertNotIn("Failing job %s" % jID, self.dra.notesToSend)
Example #2
0
 def test__str__(self,
                 asserts,
                 assertNots,
                 trID=1234,
                 taID=5678,
                 otherTasks=False,
                 pendingRequest=False):
     jbi = JobInfo(jobID=123,
                   status="Failed",
                   tID=trID,
                   tType="MCReconstruction")
     jbi.pendingRequest = pendingRequest
     jbi.otherTasks = otherTasks
     gLogger.notice("otherTasks: ", jbi.otherTasks)
     jbi.taskID = taID
     jbi.inputFiles = ["inputFile"]
     jbi.inputFilesExist = [True]
     jbi.transFileStatus = ["Assigned"]
     jbi.outputFiles = ["outputFile"]
     jbi.errorCounts = [0]
     info = str(jbi)
     for assertStr in asserts:
         self.assertIn(assertStr, info)
     for assertStr in assertNots:
         self.assertNotIn(assertStr, info)
Example #3
0
 def test_checkJob_others_(self, counter, infoCalls, jID=1234567, jStat='Done', others=False,
                           inFiles=['/my/inputfile.lfn'], outFiles=['/my/stupid/file.lfn'],
                           ifStat=[], ofStat=['Exists'], ifProcessed=[],
                           tFiStat=['Processed'], errorCount=[]):
   from DIRAC.TransformationSystem.Utilities.TransformationInfo import TransformationInfo
   from DIRAC.TransformationSystem.Utilities.JobInfo import JobInfo
   tInfoMock = Mock(name="tInfoMock", spec=TransformationInfo)
   testJob = JobInfo(jobID=jID, status=jStat, tID=123, tType="MCSimulation")
   testJob.outputFiles = outFiles
   testJob.outputFileStatus = ofStat
   testJob.otherTasks = others
   testJob.inputFiles = inFiles
   testJob.inputFileStatus = ifStat
   testJob.transFileStatus = tFiStat
   testJob.errorCounts = errorCount
   self.dra.inputFilesProcessed = set(ifProcessed)
   self.dra.checkJob(testJob, tInfoMock)
   gLogger.notice('Testing counter', counter)
   gLogger.notice('Expecting calls', infoCalls)
   gLogger.notice('Called', tInfoMock.method_calls)
   assert len(infoCalls) == len(tInfoMock.method_calls)
   for index, infoCall in enumerate(infoCalls):
     self.assertIn(infoCall, tInfoMock.method_calls[index])
   for count in range(15):
     gLogger.notice('Checking Counter:', count)
     if count == counter:
       self.assertEqual(self.dra.todo['InputFiles'][count]['Counter'], 1)
     else:
       self.assertEqual(self.dra.todo['InputFiles'][count]['Counter'], 0)
   if 0 <= counter <= 2:
     assert set(testJob.inputFiles).issubset(self.dra.inputFilesProcessed)