def test_execute( self ):

    job = Job()

    job.setName( "helloWorld-test" )
    job.setExecutable( find_all( "helloWorld.py", '.', 'Integration' )[0],
                       arguments = "This is an argument",
                       logFile = "aLogFileForTest.txt" ,
                       parameters=[('executable', 'string', '', "Executable Script"),
                                   ('arguments', 'string', '', 'Arguments for executable Script'),
                                   ( 'applicationLog', 'string', '', "Log file name" ),
                                   ( 'someCustomOne', 'string', '', "boh" )],
                       paramValues = [( 'someCustomOne', 'aCustomValue' )] )
    job.setBannedSites( ['LCG.SiteA.com', 'DIRAC.SiteB.org'] )
    job.setOwner( 'ownerName' )
    job.setOwnerGroup( 'ownerGroup' )
    job.setName( 'jobName' )
    job.setJobGroup( 'jobGroup' )
    job.setType( 'jobType' )
    job.setDestination( 'DIRAC.someSite.ch' )
    job.setCPUTime( 12345 )
    job.setLogLevel( 'DEBUG' )

    res = job.runLocal( self.d )
    self.assertTrue( res['OK'] )
Exemple #2
0
    def test_execute(self):

        job = Job()

        job.setName("helloWorld-test")
        job.setExecutable(find_all("helloWorld.py", '.', 'Integration')[0],
                          arguments="This is an argument",
                          logFile="aLogFileForTest.txt",
                          parameters=[('executable', 'string', '',
                                       "Executable Script"),
                                      ('arguments', 'string', '',
                                       'Arguments for executable Script'),
                                      ('applicationLog', 'string', '',
                                       "Log file name"),
                                      ('someCustomOne', 'string', '', "boh")],
                          paramValues=[('someCustomOne', 'aCustomValue')])
        job.setBannedSites(['LCG.SiteA.com', 'DIRAC.SiteB.org'])
        job.setOwner('ownerName')
        job.setOwnerGroup('ownerGroup')
        job.setName('jobName')
        job.setJobGroup('jobGroup')
        job.setType('jobType')
        job.setDestination('DIRAC.someSite.ch')
        job.setCPUTime(12345)
        job.setLogLevel('DEBUG')

        res = job.runLocal(self.d)
        self.assertTrue(res['OK'])
Exemple #3
0
def test_basicJob():
    job = Job()

    job.setOwner('ownerName')
    job.setOwnerGroup('ownerGroup')
    job.setName('jobName')
    job.setJobGroup('jobGroup')
    job.setExecutable('someExe')
    job.setType('jobType')
    job.setDestination('ANY')

    xml = job._toXML()

    try:
        with open('./DIRAC/Interfaces/API/test/testWF.xml') as fd:
            expected = fd.read()
    except IOError:
        with open('./Interfaces/API/test/testWF.xml') as fd:
            expected = fd.read()

    assert xml == expected

    try:
        with open('./DIRAC/Interfaces/API/test/testWFSIO.jdl') as fd:
            expected = fd.read()
    except IOError:
        with open('./Interfaces/API/test/testWFSIO.jdl') as fd:
            expected = fd.read()

    jdlSIO = job._toJDL(jobDescriptionObject=StringIO.StringIO(job._toXML()))
    assert jdlSIO == expected
Exemple #4
0
def test_basicJob():
  job = Job()

  job.setOwner('ownerName')
  job.setOwnerGroup('ownerGroup')
  job.setName('jobName')
  job.setJobGroup('jobGroup')
  job.setExecutable('someExe')
  job.setType('jobType')
  job.setDestination('ANY')

  xml = job._toXML()

  try:
    with open('./DIRAC/Interfaces/API/test/testWF.xml') as fd:
      expected = fd.read()
  except IOError:
    with open('./Interfaces/API/test/testWF.xml') as fd:
      expected = fd.read()

  assert xml == expected

  try:
    with open('./DIRAC/Interfaces/API/test/testWFSIO.jdl') as fd:
      expected = fd.read()
  except IOError:
    with open('./Interfaces/API/test/testWFSIO.jdl') as fd:
      expected = fd.read()

  jdlSIO = job._toJDL(jobDescriptionObject=StringIO.StringIO(job._toXML()))
  assert jdlSIO == expected
Exemple #5
0
  def prepareTransformationTasks(self,transBody,taskDict,owner='',ownerGroup=''):
    if (not owner) or (not ownerGroup):
      res = getProxyInfo(False,False)
      if not res['OK']:
        return res
      proxyInfo = res['Value']
      owner = proxyInfo['username']
      ownerGroup = proxyInfo['group']

    oJob = Job(transBody)
    for taskNumber in sortList(taskDict.keys()):
      paramsDict = taskDict[taskNumber]
      transID = paramsDict['TransformationID']
      self.log.verbose('Setting job owner:group to %s:%s' % (owner,ownerGroup))
      oJob.setOwner(owner)
      oJob.setOwnerGroup(ownerGroup)
      transGroup = str(transID).zfill(8)
      self.log.verbose('Adding default transformation group of %s' % (transGroup))
      oJob.setJobGroup(transGroup)
      constructedName = str(transID).zfill(8)+'_'+str(taskNumber).zfill(8)
      self.log.verbose('Setting task name to %s' % constructedName)
      oJob.setName(constructedName)
      oJob._setParamValue('PRODUCTION_ID',str(transID).zfill(8))
      oJob._setParamValue('JOB_ID',str(taskNumber).zfill(8))
      inputData = None
      for paramName,paramValue in paramsDict.items():
        self.log.verbose('TransID: %s, TaskID: %s, ParamName: %s, ParamValue: %s' %(transID,taskNumber,paramName,paramValue))
        if paramName=='InputData':
          if paramValue:
            self.log.verbose('Setting input data to %s' %paramValue)
            oJob.setInputData(paramValue)
        elif paramName=='Site':
          if paramValue:
            self.log.verbose('Setting allocated site to: %s' %(paramValue))
            oJob.setDestination(paramValue)
        elif paramValue:
          self.log.verbose('Setting %s to %s' % (paramName,paramValue))
          oJob._addJDLParameter(paramName,paramValue)

      hospitalTrans = [int(x) for x in gConfig.getValue("/Operations/Hospital/Transformations",[])]
      if int(transID) in hospitalTrans:
        hospitalSite = gConfig.getValue("/Operations/Hospital/HospitalSite",'DIRAC.JobDebugger.ch')
        hospitalCEs = gConfig.getValue("/Operations/Hospital/HospitalCEs",[])
        oJob.setType('Hospital')
        oJob.setDestination(hospitalSite)
        oJob.setInputDataPolicy('download',dataScheduling=False)
        if hospitalCEs:
          oJob._addJDLParameter('GridRequiredCEs',hospitalCEs)        
      taskDict[taskNumber]['TaskObject'] = '' 
      res = self.getOutputData({'Job':oJob._toXML(),'TransformationID':transID,'TaskID':taskNumber,'InputData':inputData})
      if not res ['OK']:
        self.log.error("Failed to generate output data",res['Message'])
        continue
      for name,output in res['Value'].items():
        oJob._addJDLParameter(name,string.join(output,';'))
      taskDict[taskNumber]['TaskObject'] = Job(oJob._toXML())
    return S_OK(taskDict)
  def prepareTransformationTasks(self,transBody,taskDict,owner='',ownerGroup=''):
    if (not owner) or (not ownerGroup):
      res = getProxyInfo(False,False)
      if not res['OK']:
        return res
      proxyInfo = res['Value']
      owner = proxyInfo['username']
      ownerGroup = proxyInfo['group']

    oJob = Job(transBody)
    for taskNumber in sortList(taskDict.keys()):
      paramsDict = taskDict[taskNumber]
      transID = paramsDict['TransformationID']
      self.log.verbose('Setting job owner:group to %s:%s' % (owner,ownerGroup))
      oJob.setOwner(owner)
      oJob.setOwnerGroup(ownerGroup)
      transGroup = str(transID).zfill(8)
      self.log.verbose('Adding default transformation group of %s' % (transGroup))
      oJob.setJobGroup(transGroup)
      constructedName = str(transID).zfill(8)+'_'+str(taskNumber).zfill(8)
      self.log.verbose('Setting task name to %s' % constructedName)
      oJob.setName(constructedName)
      oJob._setParamValue('PRODUCTION_ID',str(transID).zfill(8))
      oJob._setParamValue('JOB_ID',str(taskNumber).zfill(8))
      inputData = None
      for paramName,paramValue in paramsDict.items():
        self.log.verbose('TransID: %s, TaskID: %s, ParamName: %s, ParamValue: %s' %(transID,taskNumber,paramName,paramValue))
        if paramName=='InputData':
          if paramValue:
            self.log.verbose('Setting input data to %s' %paramValue)
            oJob.setInputData(paramValue)
        elif paramName=='Site':
          if paramValue:
            self.log.verbose('Setting allocated site to: %s' %(paramValue))
            oJob.setDestination(paramValue)
        elif paramValue:
          self.log.verbose('Setting %s to %s' % (paramName,paramValue))
          oJob._addJDLParameter(paramName,paramValue)

      hospitalTrans = [int(x) for x in gConfig.getValue("/Operations/Hospital/Transformations",[])]
      if int(transID) in hospitalTrans:
        hospitalSite = gConfig.getValue("/Operations/Hospital/HospitalSite",'DIRAC.JobDebugger.ch')
        hospitalCEs = gConfig.getValue("/Operations/Hospital/HospitalCEs",[])
        oJob.setType('Hospital')
        oJob.setDestination(hospitalSite)
        oJob.setInputDataPolicy('download',dataScheduling=False)
        if hospitalCEs:
          oJob._addJDLParameter('GridRequiredCEs',hospitalCEs)        
      taskDict[taskNumber]['TaskObject'] = '' 
      res = self.getOutputData({'Job':oJob._toXML(),'TransformationID':transID,'TaskID':taskNumber,'InputData':inputData})
      if not res ['OK']:
        self.log.error("Failed to generate output data",res['Message'])
        continue
      for name,output in res['Value'].items():
        oJob._addJDLParameter(name,string.join(output,';'))
      taskDict[taskNumber]['TaskObject'] = Job(oJob._toXML())
    return S_OK(taskDict)
Exemple #7
0
    def test_execute(self):

        job = Job()
        job._siteSet = {"DIRAC.someSite.ch"}

        job.setName("helloWorld-test")
        job.setExecutable(
            self.helloWorld,
            arguments="This is an argument",
            logFile="aLogFileForTest.txt",
            parameters=[
                ("executable", "string", "", "Executable Script"),
                ("arguments", "string", "", "Arguments for executable Script"),
                ("applicationLog", "string", "", "Log file name"),
                ("someCustomOne", "string", "", "boh"),
            ],
            paramValues=[("someCustomOne", "aCustomValue")],
        )
        job.setBannedSites(["LCG.SiteA.com", "DIRAC.SiteB.org"])
        job.setOwner("ownerName")
        job.setOwnerGroup("ownerGroup")
        job.setName("jobName")
        job.setJobGroup("jobGroup")
        job.setType("jobType")
        job.setDestination("DIRAC.someSite.ch")
        job.setCPUTime(12345)
        job.setLogLevel("DEBUG")
        try:
            # This is the standard location in Jenkins
            job.setInputSandbox(
                find_all("pilot.cfg",
                         os.environ["WORKSPACE"] + "/PilotInstallDIR")[0])
        except (IndexError, KeyError):
            job.setInputSandbox(find_all("pilot.cfg", rootPath)[0])
        job.setConfigArgs("pilot.cfg")

        res = job.runLocal(self.d)
        self.assertTrue(res["OK"])
Exemple #8
0
def test_basicJob():
    job = Job()

    job.setOwner("ownerName")
    job.setOwnerGroup("ownerGroup")
    job.setName("jobName")
    job.setJobGroup("jobGroup")
    job.setExecutable("someExe")
    job.setType("jobType")
    job.setDestination("ANY")

    xml = job._toXML()

    with open(join(dirname(__file__), "testWF.xml")) as fd:
        expected = fd.read()

    assert xml == expected

    with open(join(dirname(__file__), "testWFSIO.jdl")) as fd:
        expected = fd.read()

    jdlSIO = job._toJDL(jobDescriptionObject=StringIO(job._toXML()))
    assert jdlSIO == expected
Exemple #9
0
    def test_execute(self):

        job = Job()
        job._siteSet = {'DIRAC.someSite.ch'}

        job.setName("helloWorld-test")
        job.setExecutable(self.helloWorld,
                          arguments="This is an argument",
                          logFile="aLogFileForTest.txt",
                          parameters=[('executable', 'string', '',
                                       "Executable Script"),
                                      ('arguments', 'string', '',
                                       'Arguments for executable Script'),
                                      ('applicationLog', 'string', '',
                                       "Log file name"),
                                      ('someCustomOne', 'string', '', "boh")],
                          paramValues=[('someCustomOne', 'aCustomValue')])
        job.setBannedSites(['LCG.SiteA.com', 'DIRAC.SiteB.org'])
        job.setOwner('ownerName')
        job.setOwnerGroup('ownerGroup')
        job.setName('jobName')
        job.setJobGroup('jobGroup')
        job.setType('jobType')
        job.setDestination('DIRAC.someSite.ch')
        job.setCPUTime(12345)
        job.setLogLevel('DEBUG')
        try:
            # This is the standard location in Jenkins
            job.setInputSandbox(
                find_all('pilot.cfg',
                         os.environ['WORKSPACE'] + '/PilotInstallDIR')[0])
        except (IndexError, KeyError):
            job.setInputSandbox(find_all('pilot.cfg', rootPath)[0])
        job.setConfigArgs('pilot.cfg')

        res = job.runLocal(self.d)
        self.assertTrue(res['OK'])