コード例 #1
0
def test__getInputs(mocker, mockReplyInput, manifestOptions, expected):

    mockReply.return_value = mockReplyInput

    module_str = "DIRAC.WorkloadManagementSystem.Client.JobState.JobState.JobDB.getInputData"
    mocker.patch(module_str, side_effect=mockReply)
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Client.JobState.JobState.JobDB.__init__",
        side_effect=mockNone)
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Client.JobState.JobState.JobLoggingDB.__init__",
        side_effect=mockNone)
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Client.JobState.JobState.TaskQueueDB.__init__",
        side_effect=mockNone)

    inputData = InputData()
    js = CachedJobState(1)
    js.setAttribute('JobType', 'User')

    manifest = JobManifest()
    for varName, varValue in manifestOptions.iteritems():
        manifest.setOption(varName, varValue)

    js.setManifest(manifest)
    res = inputData._getInputs(js)
    assert res['OK'] is True
    assert res['Value'] == expected
コード例 #2
0
ファイル: Test_Executor.py プロジェクト: DIRACGrid/DIRAC
def test__getTagsFromManifest(manifestOptions, expected):
    manifest = JobManifest()
    for varName, varValue in manifestOptions.items():
        manifest.setOption(varName, varValue)

    js = JobScheduling()
    tagList = js._getTagsFromManifest(manifest)
    assert set(tagList) == set(expected)
コード例 #3
0
 def setManifest(self, manifest):
   if not isinstance(manifest, JobManifest):
     manifestStr = manifest
     manifest = JobManifest()
     result = manifest.load(manifestStr)
     if not result['OK']:
       return result
   manifestJDL = manifest.dumpAsJDL()
   return self.__retryFunction(5, JobState.__db.jobDB.setJobJDL, (self.__jid, manifestJDL))
コード例 #4
0
ファイル: JobState.py プロジェクト: DIRACGrid/DIRAC
 def getManifest(self, rawData=False):
     result = JobState.__db.jobDB.getJobJDL(self.__jid)
     if not result["OK"] or rawData:
         return result
     if not result["Value"]:
         return S_ERROR("No manifest for job %s" % self.__jid)
     manifest = JobManifest()
     result = manifest.loadJDL(result["Value"])
     if not result["OK"]:
         return result
     return S_OK(manifest)
コード例 #5
0
ファイル: CachedJobState.py プロジェクト: TaykYoku/DIRAC
 def setManifest(self, manifest):
     if not isinstance(manifest, JobManifest):
         jobManifest = JobManifest()
         result = jobManifest.load(str(manifest))
         if not result["OK"]:
             return result
         manifest = jobManifest
     manifest.setDirty()
     self.__manifest = manifest
     # self.__manifest.clearDirty()
     return S_OK()
コード例 #6
0
 def setManifest( self, manifest ):
   if not isinstance( manifest, JobManifest ):
     manifestStr = manifest
     manifest = JobManifest()
     result = manifest.load( manifestStr )
     if not result[ 'OK' ]:
       return result
   manifestJDL = manifest.dumpAsJDL()
   if self.localAccess:
     return self.__retryFunction( 5, self.__getDB().setJobJDL, ( self.__jid, manifestJDL ) )
   return self._getStoreClient().setManifest( self.__jid, manifestJDL )
コード例 #7
0
 def getManifest(self, rawData=False):
     result = self.__getDB().getJobJDL(self.__jid)
     if not result['OK'] or rawData:
         return result
     if not result['Value']:
         return S_ERROR("No manifest for job %s" % self.__jid)
     manifest = JobManifest()
     result = manifest.loadJDL(result['Value'])
     if not result['OK']:
         return result
     return S_OK(manifest)
コード例 #8
0
 def getManifest(self, rawData=False):
     if self.localAccess:
         result = self.__getDB().getJobJDL(self.__jid)
     else:
         result = self._getStoreClient().getManifest(self.__jid)
     if not result['OK'] or rawData:
         return result
     manifest = JobManifest()
     result = manifest.loadJDL(result['Value'])
     if not result['OK']:
         return result
     return S_OK(manifest)
コード例 #9
0
ファイル: CachedJobState.py プロジェクト: TaykYoku/DIRAC
 def deserialize(stub):
     dataTuple, _slen = DEncode.decode(stub.encode())
     if len(dataTuple) != 7:
         return S_ERROR("Invalid stub")
     # jid
     if not isinstance(dataTuple[0], int):
         return S_ERROR("Invalid stub 0")
     # cache
     if not isinstance(dataTuple[1], dict):
         return S_ERROR("Invalid stub 1")
     # trace
     if not isinstance(dataTuple[2], list):
         return S_ERROR("Invalid stub 2")
     # manifest
     if dataTuple[3] is not None and (
             not isinstance(dataTuple[3],
                            (tuple, list)) and len(dataTuple[3]) != 2):
         return S_ERROR("Invalid stub 3")
     # initstate
     if not isinstance(dataTuple[4], dict):
         return S_ERROR("Invalid stub 4")
     # Insert into TQ
     if not isinstance(dataTuple[5], bool):
         return S_ERROR("Invalid stub 5")
     # Dirty Keys
     if not isinstance(dataTuple[6], (tuple, list)):
         return S_ERROR("Invalid stub 6")
     cjs = CachedJobState(dataTuple[0], skipInitState=True)
     cjs.__cache = dataTuple[1]
     cjs.__jobLog = dataTuple[2]
     dt3 = dataTuple[3]
     if dataTuple[3]:
         manifest = JobManifest()
         result = manifest.loadCFG(dt3[0])
         if not result["OK"]:
             return result
         if dt3[1]:
             manifest.setDirty()
         else:
             manifest.clearDirty()
         cjs.__manifest = manifest
     cjs.__initState = dataTuple[4]
     cjs.__insertIntoTQ = dataTuple[5]
     cjs.__dirtyKeys = set(dataTuple[6])
     return S_OK(cjs)
コード例 #10
0
 def deserialize(stub):
     dataTuple, _slen = DEncode.decode(stub)
     if len(dataTuple) != 7:
         return S_ERROR("Invalid stub")
     #jid
     if type(dataTuple[0]) not in (types.IntType, types.LongType):
         return S_ERROR("Invalid stub 0")
     #cache
     if type(dataTuple[1]) != types.DictType:
         return S_ERROR("Invalid stub 1")
     #trace
     if type(dataTuple[2]) != types.ListType:
         return S_ERROR("Invalid stub 2")
     #manifest
     tdt3 = type(dataTuple[3])
     if tdt3 != types.NoneType and (tdt3 != types.TupleType
                                    and len(dataTuple[3]) != 2):
         return S_ERROR("Invalid stub 3")
     #initstate
     if type(dataTuple[4]) != types.DictType:
         return S_ERROR("Invalid stub 4")
     #Insert into TQ
     if type(dataTuple[5]) != types.BooleanType:
         return S_ERROR("Invalid stub 5")
     #Dirty Keys
     if type(dataTuple[6]) != types.TupleType:
         return S_ERROR("Invalid stub 6")
     cjs = CachedJobState(dataTuple[0], skipInitState=True)
     cjs.__cache = dataTuple[1]
     cjs.__jobLog = dataTuple[2]
     dt3 = dataTuple[3]
     if dataTuple[3]:
         manifest = JobManifest()
         result = manifest.loadCFG(dt3[0])
         if not result['OK']:
             return result
         if dt3[1]:
             manifest.setDirty()
         else:
             manifest.clearDirty()
         cjs.__manifest = manifest
     cjs.__initState = dataTuple[4]
     cjs.__insertIntoTQ = dataTuple[5]
     cjs.__dirtyKeys = set(dataTuple[6])
     return S_OK(cjs)
コード例 #11
0
ファイル: Test_Executor.py プロジェクト: DIRACGrid/DIRAC
def test__getInputSandbox(mocker, manifestOptions, expected):

    mocker.patch("DIRAC.WorkloadManagementSystem.Client.JobState.JobState.JobDB.__init__", side_effect=mockNone)
    mocker.patch("DIRAC.WorkloadManagementSystem.Client.JobState.JobState.JobLoggingDB.__init__", side_effect=mockNone)
    mocker.patch("DIRAC.WorkloadManagementSystem.Client.JobState.JobState.TaskQueueDB.__init__", side_effect=mockNone)

    inputData = InputData()
    js = CachedJobState(1)
    js.setAttribute("JobType", "User")

    manifest = JobManifest()
    for varName, varValue in manifestOptions.items():
        manifest.setOption(varName, varValue)

    js.setManifest(manifest)
    res = inputData._getInputSandbox(js)
    assert res["OK"] is True
    assert res["Value"] == expected