Exemple #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)
Exemple #2
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)
Exemple #3
0
    def test_checkJob(self):
        """test for DataRecoveryAgent checkJob No inputFiles............................................."""

        from DIRAC.TransformationSystem.Utilities.TransformationInfo import TransformationInfo

        tInfoMock = Mock(name="tInfoMock", spec=TransformationInfo)

        from DIRAC.TransformationSystem.Utilities.JobInfo import JobInfo

        # Test First option for MCGeneration
        tInfoMock.reset_mock()
        testJob = JobInfo(jobID=1234567,
                          status="Failed",
                          tID=123,
                          tType="MCGeneration")
        testJob.outputFiles = ["/my/stupid/file.lfn"]
        testJob.outputFileStatus = ["Exists"]

        self.dra.checkJob(testJob, tInfoMock)
        self.assertIn("setJobDone", tInfoMock.method_calls[0])
        self.assertEqual(self.dra.todo["NoInputFiles"][0]["Counter"], 1)
        self.assertEqual(self.dra.todo["NoInputFiles"][1]["Counter"], 0)

        # Test Second option for MCGeneration
        tInfoMock.reset_mock()
        testJob.status = "Done"
        testJob.outputFileStatus = ["Missing"]
        self.dra.checkJob(testJob, tInfoMock)
        self.assertIn("setJobFailed", tInfoMock.method_calls[0])
        self.assertEqual(self.dra.todo["NoInputFiles"][0]["Counter"], 1)
        self.assertEqual(self.dra.todo["NoInputFiles"][1]["Counter"], 1)

        # Test Second option for MCGeneration
        tInfoMock.reset_mock()
        testJob.status = "Done"
        testJob.outputFileStatus = ["Exists"]
        self.dra.checkJob(testJob, tInfoMock)
        self.assertEqual(tInfoMock.method_calls, [])
        self.assertEqual(self.dra.todo["NoInputFiles"][0]["Counter"], 1)
        self.assertEqual(self.dra.todo["NoInputFiles"][1]["Counter"], 1)