Skip to content

Commit

Permalink
test: added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Sep 30, 2024
1 parent 51b242f commit e8b7511
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

taskDictSimpleInputs = {1: {"TransformationID": 1, "InputData": ["a1", "a2", "a3"]}}

taskDictSimpleRuns = {1: {"TransformationID": 1, "RunNumber": ["123", "456", "789"]}}

taskDictNoInputs = {
1: {"TransformationID": 1, "a1": "aa1", "b1": "bb1", "Site": "MySite"},
2: {"TransformationID": 1, "a2": "aa2", "b2": "bb2"},
Expand Down Expand Up @@ -69,6 +71,11 @@
"Value": {"BulkJobObject": "", 1: {"TransformationID": 1, "InputData": ["a1", "a2", "a3"], "JobType": "User"}},
}

expectedBulkSimpleRuns = {
"OK": True,
"Value": {"BulkJobObject": "", 1: {"TransformationID": 1, "RunNmber": ["123", "456", "789"], "JobType": "User"}},
}

expectedBulk = {
"OK": True,
"Value": {
Expand All @@ -86,7 +93,8 @@
(taskDict, False, True, expected),
(taskDict, True, False, expectedBulk),
(taskDictSimple, True, True, expectedBulk),
(taskDictSimpleInputs, True, True, expectedBulkSimple),
# (taskDictSimpleInputs, True, True, expectedBulkSimple),
(taskDictSimpleRuns, True, True, expectedBulkSimpleRuns),
(taskDictNoInputs, True, False, expectedBulk),
(taskDictNoInputsNoSite, True, True, expectedBulk),
],
Expand Down
39 changes: 39 additions & 0 deletions src/DIRAC/tests/Utilities/testJobDefinitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,45 @@ def parametricJob():
J.setExecutable("exe-script.py", arguments=": testing %(args)s %(iargs)s", logFile="helloWorld_%n.log")
return endOfAllJobs(J)

def parametricJobInputData():
"""Creates a parametric job with 3 subjobs which are simple hello world jobs"""

J = baseToAllJobs("parametricJobInput")
try:
J.setInputSandbox([find_all("exe-script.py", rootPath, "DIRAC/tests/Workflow")[0]])
except IndexError:
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setParameterSequence("args", ["one", "two", "three"])
J.setParameterSequence("iargs", [1, 2, 3])
J.setParameterSequence("InputData", ["/lhcb/user/f/fstagni/test/1.txt",
"/lhcb/user/f/fstagni/test/2.txt",
"/lhcb/user/f/fstagni/test/3.txt"])
J.setInputDataPolicy("download")
J.setExecutable("exe-script.py", arguments=": testing %(args)s %(iargs)s", logFile="helloWorld_%n.log")
return endOfAllJobs(J)


def parametricJobRuns():
"""Creates a parametric job with 3 subjobs which are simple hello world jobs (added RunNumber)"""

J = baseToAllJobs("parametricJobRunNumber")
try:
J.setInputSandbox([find_all("exe-script.py", rootPath, "DIRAC/tests/Workflow")[0]])
except IndexError:
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setParameterSequence("args", ["one", "two", "three"])
J.setParameterSequence("iargs", [1, 2, 3])
J.setParameterSequence("RunNumber", [123, 456, 789])

J.setExecutable("exe-script.py", arguments=": testing %(args)s %(iargs)s", logFile="helloWorld_%n.log")
return endOfAllJobs(J)


def jobWithOutput():
"""Creates a job that uploads an output.
Expand Down
72 changes: 40 additions & 32 deletions tests/System/unitTestUserJobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,58 +33,66 @@ class submitSuccess(GridSubmissionTestCase):

def test_submit(self):
"""submit jobs defined in DIRAC.tests.Utilities.testJobDefinitions"""
res = helloWorld()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])
# res = helloWorld()
# self.assertTrue(res["OK"])
# jobsSubmittedList.append(res["Value"])

res = helloWorldCERN()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])
# res = helloWorldCERN()
# self.assertTrue(res["OK"])
# jobsSubmittedList.append(res["Value"])

res = helloWorldNCBJ()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])
# res = helloWorldNCBJ()
# self.assertTrue(res["OK"])
# jobsSubmittedList.append(res["Value"])

res = helloWorldGRIDKA()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])
# res = helloWorldGRIDKA()
# self.assertTrue(res["OK"])
# jobsSubmittedList.append(res["Value"])

res = helloWorldGRIF()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])
# res = helloWorldGRIF()
# self.assertTrue(res["OK"])
# jobsSubmittedList.append(res["Value"])

res = helloWorldSSHBatch()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])
# res = helloWorldSSHBatch()
# self.assertTrue(res["OK"])
# jobsSubmittedList.append(res["Value"])

res = mpJob()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])
# res = mpJob()
# self.assertTrue(res["OK"])
# jobsSubmittedList.append(res["Value"])

res = mp3Job()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])
# res = mp3Job()
# self.assertTrue(res["OK"])
# jobsSubmittedList.append(res["Value"])

res = min2max4Job()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])
# res = min2max4Job()
# self.assertTrue(res["OK"])
# jobsSubmittedList.append(res["Value"])

res = wholeNodeJob()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])
# res = wholeNodeJob()
# self.assertTrue(res["OK"])
# jobsSubmittedList.append(res["Value"])

res = parametricJob()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])

res = jobWithOutput()
res = parametricJobInputData()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])

res = jobWithOutputs()
res = parametricJobRuns()
self.assertTrue(res["OK"])
jobsSubmittedList.append(res["Value"])

# res = jobWithOutput()
# self.assertTrue(res["OK"])
# jobsSubmittedList.append(res["Value"])

# res = jobWithOutputs()
# self.assertTrue(res["OK"])
# jobsSubmittedList.append(res["Value"])

print(f"submitted {len(jobsSubmittedList)} jobs: {','.join(str(js) for js in jobsSubmittedList)}")


Expand Down

0 comments on commit e8b7511

Please sign in to comment.