Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(WMS): JobWrapper checks existence of executable in jobIDPath #7825

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
andresailer marked this conversation as resolved.
Show resolved Hide resolved
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
Loading