示例#1
0
def test_removeJobsByStatus(mocker, conditions, mockReplyInput, expected):
    """ Testing JobCleaningAgent().removeJobsByStatus()
  """

    mockReply.return_value = mockReplyInput

    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.AgentModule.__init__"
    )
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.AgentModule._AgentModule__moduleProperties",
        side_effect=lambda x, y=None: y,
        create=True)
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobDB.selectJobs",
        side_effect=mockReply)
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.TaskQueueDB.__init__",
        side_effect=mockNone)
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobDB.__init__",
        side_effect=mockNone)
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobLoggingDB.__init__",
        side_effect=mockNone)

    jobCleaningAgent = JobCleaningAgent()
    jobCleaningAgent.log = gLogger
    jobCleaningAgent.log.setLevel('DEBUG')
    jobCleaningAgent._AgentModule__configDefaults = mockAM
    jobCleaningAgent.initialize()

    result = jobCleaningAgent.removeJobsByStatus(conditions)

    assert result == expected
示例#2
0
 def tearDown(self):
   """ use the JobCleaningAgent method to remove the jobs in status 'deleted' and 'Killed'
   """
   jca = JobCleaningAgent('WorkloadManagement/JobCleaningAgent',
                          'WorkloadManagement/JobCleaningAgent')
   jca.initialize()
   res = jca.removeJobsByStatus({'Status': ['Killed', 'Deleted']})
   self.assertTrue(res['OK'])
示例#3
0
 def tearDown(self):
   """ use the JobCleaningAgent method to remove the jobs in status 'deleted' and 'Killed'
   """
   jca = JobCleaningAgent('WorkloadManagement/JobCleaningAgent',
                          'WorkloadManagement/JobCleaningAgent')
   jca.initialize()
   res = jca.removeJobsByStatus({'Status': ['Killed', 'Deleted']})
   self.assertTrue(res['OK'])