Skip to content

Commit

Permalink
fix: JobAgent check JobMonitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Dec 21, 2023
1 parent a007100 commit 7cbe5c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/DIRAC/WorkloadManagementSystem/Agent/JobAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ def _checkSubmittedJobs(self):
res = JobMonitoringClient().getJobsStatus(jobID)
if not res["OK"]:
return res
if res["Value"][jobID]["Status"] == JobStatus.RUNNING:
if res["Value"][int(jobID)]["Status"] == JobStatus.RUNNING:
self.jobReport.setJobStatus(status=JobStatus.FAILED, minorStatus="Payload failed")

# Do not keep running and do not overwrite the Payload error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from DIRAC.Resources.Computing.ComputingElementFactory import ComputingElementFactory
from DIRAC.Resources.Computing.test.Test_PoolComputingElement import badJobScript, jobScript
from DIRAC.WorkloadManagementSystem.Agent.JobAgent import JobAgent
from DIRAC.WorkloadManagementSystem.Client import JobStatus
from DIRAC.WorkloadManagementSystem.Client.JobReport import JobReport

gLogger.setLevel("DEBUG")
Expand Down Expand Up @@ -497,13 +498,20 @@ def test_submitAndCheckJob(mocker, localCE, job, expectedResult1, expectedResult
execFile.write(job)
os.chmod(jobName, 0o755)

jobID = "123"

mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobAgent.AgentModule.__init__")
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobAgent.JobAgent.am_stopExecution")
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobAgent.JobMonitoringClient", return_value=MagicMock())
mocker.patch(
"DIRAC.WorkloadManagementSystem.Agent.JobAgent.JobMonitoringClient.getJobsStatus",
return_value=S_OK({int(jobID): {"Status": JobStatus.RUNNING}}),
)
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobAgent.createJobWrapper", return_value=S_OK([jobName]))
mocker.patch("DIRAC.Core.Security.X509Chain.X509Chain.dumpAllToString", return_value=S_OK())

jobID = 123
mocker.patch(
"DIRAC.Resources.Computing.SingularityComputingElement.SingularityComputingElement._SingularityComputingElement__hasSingularity",
return_value=False,
)

jobAgent = JobAgent("JobAgent", "Test")
jobAgent.log = gLogger.getSubLogger("JobAgent")
Expand Down

0 comments on commit 7cbe5c3

Please sign in to comment.