Skip to content

Commit

Permalink
fix(WMS): JobWrapper checks existence of executable in jobIDPath
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Oct 11, 2024
1 parent c293d32 commit 9e7b6cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/DIRAC/WorkloadManagementSystem/JobWrapper/JobWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,10 @@ def __prepareCommand(self):
executable = shutil.which(executable) or executable

# Make the full path since . is not always in the PATH
executable = os.path.abspath(executable)
# self.jobIDPath is an absolute path, so we can use it directly
# if executable is an absolute path, self.jobIDPath is ignored
# Example: "/bin/ls" will be used as is
executable = str(self.jobIDPath / executable)
if not os.path.exists(executable):
self.__report(status=JobStatus.FAILED, minorStatus=JobMinorStatus.APP_NOT_FOUND, sendFlag=True)
return S_ERROR(f"Path to executable {executable} not found")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,17 @@ def test_preProcess_nonexistent_executable(setup_job_wrapper):
"""Test the pre process method of the JobWrapper class: nonexistent executable."""
jw = setup_job_wrapper({"Executable": "pippo"})

# Without a jobID
result = jw.preProcess()
assert not result["OK"]
assert result["Message"] == f"Path to executable {os.getcwd()}/pippo not found"

# With a jobID
jw.jobIDPath = jw.jobIDPath / "123"
result = jw.preProcess()
assert not result["OK"]
assert result["Message"] == f"Path to executable {os.getcwd()}/123/pippo not found"


def test_preProcess_dirac_jobexec(setup_job_wrapper):
"""Test the pre process method of the JobWrapper class: dirac-jobexec."""
Expand Down

0 comments on commit 9e7b6cb

Please sign in to comment.