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.removeDeletedJobs() self.assertTrue(res["OK"], res.get("Message"))
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'])
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'])
def test_deleteJobOversizedSandbox(mocker, inputs, params, expected): """Testing JobCleaningAgent().deleteJobOversizedSandbox()""" mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.AgentModule.__init__" ) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.AgentModule.am_getOption", return_value=mockAM) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobDB", return_value=mockNone) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.ReqClient", return_value=mockNone) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobMonitoringClient", return_value=mockJMC) jobCleaningAgent = JobCleaningAgent() jobCleaningAgent.log = gLogger jobCleaningAgent.log.setLevel("DEBUG") jobCleaningAgent._AgentModule__configDefaults = mockAM jobCleaningAgent.initialize() mockJMC.getJobParameters.return_value = params result = jobCleaningAgent.deleteJobOversizedSandbox(inputs) assert result == expected
def test__getAllowedJobTypes(mocker, mockReplyInput, expected): """ Testing JobCleaningAgent()._getAllowedJobTypes() """ 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.getDistinctJobAttributes", 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._getAllowedJobTypes() assert result == expected
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.am_getOption", side_effect=mockAM) 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
def jca(mocker): 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.AgentModule.am_getOption", return_value=mockAM) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobDB.getDistinctJobAttributes", side_effect=mockReply) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobDB.selectJobs", side_effect=mockReply) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobDB.__init__", side_effect=mockNone) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.ReqClient", return_value=mockNone) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobMonitoringClient", return_value=mockJMC) jca = JobCleaningAgent() jca.log = gLogger jca.log.setLevel("DEBUG") jca._AgentModule__configDefaults = mockAM jca.initialize() return jca