From c808ea0a0cebcccf138ad5af680e357ef035ca41 Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Mon, 30 Sep 2024 13:21:06 +0200 Subject: [PATCH] test: added more tests --- .../Client/test/Test_Client_WorkflowTasks.py | 10 ++++- .../tests/Utilities/testJobDefinitions.py | 39 +++++++++++++++++++ tests/System/unitTestUserJobs.py | 8 ++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/DIRAC/TransformationSystem/Client/test/Test_Client_WorkflowTasks.py b/src/DIRAC/TransformationSystem/Client/test/Test_Client_WorkflowTasks.py index f29eea42e01..a77c39c4cee 100644 --- a/src/DIRAC/TransformationSystem/Client/test/Test_Client_WorkflowTasks.py +++ b/src/DIRAC/TransformationSystem/Client/test/Test_Client_WorkflowTasks.py @@ -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"}, @@ -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": { @@ -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), ], diff --git a/src/DIRAC/tests/Utilities/testJobDefinitions.py b/src/DIRAC/tests/Utilities/testJobDefinitions.py index 9fa9c9e47d2..29b5e1220a2 100644 --- a/src/DIRAC/tests/Utilities/testJobDefinitions.py +++ b/src/DIRAC/tests/Utilities/testJobDefinitions.py @@ -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. diff --git a/tests/System/unitTestUserJobs.py b/tests/System/unitTestUserJobs.py index c89ae99b058..a3584a74407 100644 --- a/tests/System/unitTestUserJobs.py +++ b/tests/System/unitTestUserJobs.py @@ -77,6 +77,14 @@ def test_submit(self): self.assertTrue(res["OK"]) jobsSubmittedList.append(res["Value"]) + res = parametricJobInputData() + self.assertTrue(res["OK"]) + jobsSubmittedList.append(res["Value"]) + + res = parametricJobRuns() + self.assertTrue(res["OK"]) + jobsSubmittedList.append(res["Value"]) + res = jobWithOutput() self.assertTrue(res["OK"]) jobsSubmittedList.append(res["Value"])