Ejemplo n.º 1
0
    def testI(self):
         JobState.register("jobClassID10","Processing",8,2,"myWorkflowID")
         #retries=racer=0
         self.assertEqual(JobState.general("jobClassID10"),{'Retries': 0, 'CacheDirLocation': None, 'MaxRacers': 2, 'Racers': 0, 'State': 'register', 'MaxRetries': 8, 'JobType': 'Processing'})
         JobState.createFailure("jobClassID10")
         #retries=1, racer=0
         self.assertEqual(JobState.general("jobClassID10"),{'Retries': 1, 'CacheDirLocation': None, 'MaxRacers': 2, 'Racers': 0, 'State': 'register', 'MaxRetries': 8, 'JobType': 'Processing'})
         JobState.createFailure("jobClassID10")
         #retries=2, racer=0
         self.assertEqual(JobState.general("jobClassID10"),{'Retries': 2, 'CacheDirLocation': None, 'MaxRacers': 2, 'Racers': 0, 'State': 'register', 'MaxRetries': 8, 'JobType': 'Processing'})
         JobState.create("jobClassID10","cacheDir/location/10somewhere")
         #retries=2, racer=0
         self.assertEqual(JobState.general("jobClassID10"),{'Retries': 2, 'CacheDirLocation': 'cacheDir/location/10somewhere', 'MaxRacers': 2, 'Racers': 0, 'State': 'create', 'MaxRetries': 8, 'JobType': 'Processing'})
         JobState.inProgress("jobClassID10")
         #retries=2, racer=0
         self.assertEqual(JobState.general("jobClassID10"),{'Retries': 2, 'CacheDirLocation': 'cacheDir/location/10somewhere', 'MaxRacers': 2, 'Racers': 0, 'State': 'inProgress', 'MaxRetries': 8, 'JobType': 'Processing'})
         JobState.submitFailure("jobClassID10")
         #retries=3, racer=0
         self.assertEqual(JobState.general("jobClassID10"),{'Retries': 3, 'CacheDirLocation': 'cacheDir/location/10somewhere', 'MaxRacers': 2, 'Racers': 0, 'State': 'inProgress', 'MaxRetries': 8, 'JobType': 'Processing'})
         JobState.submit("jobClassID10")
         #retries=3, racer=1
         self.assertEqual(JobState.general("jobClassID10"),{'Retries': 3, 'CacheDirLocation': 'cacheDir/location/10somewhere', 'MaxRacers': 2, 'Racers': 1, 'State': 'inProgress', 'MaxRetries': 8, 'JobType': 'Processing'})
         JobState.submitFailure("jobClassID10")
         #retries=4, racer=1
         self.assertEqual(JobState.general("jobClassID10"),{'Retries': 4, 'CacheDirLocation': 'cacheDir/location/10somewhere', 'MaxRacers': 2, 'Racers': 1, 'State': 'inProgress', 'MaxRetries': 8, 'JobType': 'Processing'})
         JobState.submit("jobClassID10")
         #retries=4, racer=2
         self.assertEqual(JobState.general("jobClassID10"),{'Retries': 4, 'CacheDirLocation': 'cacheDir/location/10somewhere', 'MaxRacers': 2, 'Racers': 2, 'State': 'inProgress', 'MaxRetries': 8, 'JobType': 'Processing'})

         # on purpose we introduce an error:
         try:
             JobState.submit("jobClassID10")
         except ProdException, ex:
             print('>>>Test succeeded for exception 1/1 in testH of JobState_t.py\n')
Ejemplo n.º 2
0
    def testB(self):
        """change state test"""
        try:
         JobState.register("jobClassID2","Processing",2,1,"myWorkflowID")
         JobState.create("jobClassID2","cacheDir/location/2somewhere")
         JobState.inProgress("jobClassID2")

         # retries=racers=0
         self.assertEqual(JobState.general("jobClassID2"), {'Retries': 0, 'CacheDirLocation': 'cacheDir/location/2somewhere', 'MaxRacers': 1, 'Racers': 0, 'State': 'inProgress', 'MaxRetries': 2, 'JobType': 'Processing'})

         JobState.submit("jobClassID2")

         # retries0,=racers=1
         self.assertEqual(JobState.general("jobClassID2"),{'Retries': 0, 'CacheDirLocation': 'cacheDir/location/2somewhere', 'MaxRacers': 1, 'Racers': 1, 'State': 'inProgress', 'MaxRetries': 2, 'JobType': 'Processing'})

         JobState.runFailure("jobClassID2","jobInstanceID2.1",
              "some.location2.1","job/Report/Location2.1.xml")

         # retries= 1, racers=0
         self.assertEqual(JobState.general("jobClassID2"),
              {'CacheDirLocation': 'cacheDir/location/2somewhere', 
               'MaxRacers': 1, 'Racers': 0, 'State': 'inProgress', 
               'MaxRetries': 2, 'Retries': 1, 'JobType': 'Processing'})

         JobState.submit("jobClassID2")

         # retries= 1, racers=1
         self.assertEqual(JobState.general("jobClassID2"),{'Retries': 1L, 'CacheDirLocation': 'cacheDir/location/2somewhere', 'MaxRacers': 1L, 'Racers': 1L, 'State': 'inProgress', 'MaxRetries': 2L, 'JobType': 'Processing'})

        except StandardError, ex:
            msg = "Failed State Change TestB:\n"
            msg += str(ex)
            self.fail(msg)
Ejemplo n.º 3
0
    def testD(self):
        """change state test"""
        try:
         JobState.register("jobClassID4","Processing",6,2,"myWorkflowID")
         JobState.create("jobClassID4","cacheDir/location/4somewhere")
         JobState.inProgress("jobClassID4")

         # retries=racers=0
         self.assertEqual(JobState.general("jobClassID4"),{'Retries': 0L, 'CacheDirLocation': 'cacheDir/location/4somewhere', 'MaxRacers': 2L, 'Racers': 0L, 'State': 'inProgress', 'MaxRetries': 6L, 'JobType': 'Processing'})
Ejemplo n.º 4
0
 def testF(self):
     print("""\nSet the job cache (used for failure job cleanup)""")
     try:
         Session.set_database(dbConfig)
         Session.connect()
         Session.start_transaction()
         for i in xrange(0,self.failureJobSpecs):
             JobState.register("failureJobSpec"+str(i),"Processing",2,2)
             JobState.create("failureJobSpec"+str(i),self.location+"/failureJobSpecDir_"+str(i))
         Session.commit_all()
         Session.close_all()
     except StandardError, ex:
         msg = "Failed testB:\n"
         msg += str(ex)
         self.fail(msg)
Ejemplo n.º 5
0
    def testE(self):
        try:
         JobState.register("jobClassID5","Processing",2,2,"myWorkflowID")
         JobState.create("jobClassID5","cacheDir/location/5somewhere")
         JobState.inProgress("jobClassID5")
         JobState.submit("jobClassID5")

        # now introduce some failures until we have more failures
        # then retries (this raises an error)

         JobState.runFailure("jobClassID5","jobInstanceID5.1",
              "some.location5.1","job/Report/Location5.1.xml")
         try:
              JobState.runFailure("jobClassID5","jobInstanceID5.2",
                   "some.location5.1","job/Report/Location5.1.xml")
         except ProdException, ex:
              print('>>>Test succeeded for exception 1/1 in testE of JobState_t.py\n')
         JobState.finished("jobClassID5")
Ejemplo n.º 6
0
    def testC(self):
        """change state test"""
        try:
         JobState.register("jobClassID3","Merge",5,1,"myWorkflowID")
         JobState.create("jobClassID3","cacheDir/location/3somewhere")
         JobState.inProgress("jobClassID3")
         JobState.submit("jobClassID3")

         # try an illegal state transition:
         try:
              JobState.create("jobClassID3","cacheDir/location3somewhere")
         except ProdException, ex:
              print('>>>Test succeeded for  exception 1/3 in testC of JobState_t.py\n')
        # try to submit another job while the first one has not finished (we only are allowed one racer)
         try:
              JobState.submit("jobClassID3")
         except ProdException, ex:
              print('>>>Test succeeded for  exception 2/3 in testC of JobState_t.py\n')
Ejemplo n.º 7
0
    def testA(self):
        """change state test"""
        Session.set_database(dbConfig)
        Session.connect()
        Session.start_transaction()
        try:
         # illegal state transitions:
         try:
            JobState.create("jobClassID1","cacheDir/location/1somewhere")
         except ProdException, ex:
            print('>>>Test succeeded for exception 1/3 in testA of JobState_t.py\n')
         self.assertEqual(JobState.isRegistered("jobClassID1"),False)
         JobState.register("jobClassID1","Processing",3,1,"myWorkflowID")
         self.assertEqual(JobState.isRegistered("jobClassID1"),True)

         # register again (illegal):
         try:
             JobState.register("jobClassID1","Processing",3,1,"myWorkflowID")
             print('>>>Test ERROR \n')
         except ProdException, ex:
             print('>>>Test succeeded for exception 2/3 in testA of JobState_t.py\n')
Ejemplo n.º 8
0
 def testK(self):
     jobIDs=[]
     for i in xrange(0,20):
         JobState.register("jobClassID_0."+str(i),"Processing",30,1)
         JobState.register("jobClassID_1."+str(i),"Processing",30,1,"myWorkflowID1")
         JobState.register("jobClassID_2."+str(i),"Processing",30,1,"myWorkflowID2")
         JobState.register("jobClassID_3."+str(i),"Processing",30,1,"myWorkflowID3")
         jobIDs.append("jobClassID_1."+str(i))
         jobIDs.append("jobClassID_2."+str(i))
         jobIDs.append("jobClassID_3."+str(i))
     JobState.setMaxRetries(jobIDs,2)
     self.assertEqual(JobState.general("jobClassID_1.1")['MaxRetries'],2)
     JobState.setMaxRetries("jobClassID_1.1",3)
     self.assertEqual(JobState.general("jobClassID_1.1")['MaxRetries'],3)
     jobIDs=JobState.retrieveJobIDs("myWorkflowID1")
     self.assertEqual(len(jobIDs),20)
     jobIDs=JobState.retrieveJobIDs(["myWorkflowID1","myWorkflowID2","myWorkflowID3"])
     self.assertEqual(len(jobIDs),60)
     jobs=JobState.rangeGeneral(0,10)
     print(str(jobs))
Ejemplo n.º 9
0
 def testH(self):
      JobState.register("jobClassID7","Processing",8,2,"myWorkflowID")
      JobState.register("jobClassID8","Processing",8,2,"myWorkflowID")
      JobState.register("jobClassID9","Processing",8,2,"myWorkflowID")