Example #1
0
class TestCase(unittest.TestCase):
    
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.testNo = TestStatus.getTestSetup(1, 1, 2, 2)
        self.depth = TestStatus.getTestSetup(1, 2, 3, 5)
        self.jobTreeDir = os.path.join(os.getcwd(), "jobTree") #A directory for the job tree to be created in
        self.tempFileTreeDir = os.path.join(os.getcwd(), "tempFileTree") #Ensures that file tree is visible
        self.tempFileTree = TempFileTree(self.tempFileTreeDir) #A place to get temp files from
    
    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.tempFileTree.destroyTempFiles()
        system("rm -rf %s %s" % (self.jobTreeDir, self.tempFileTreeDir)) #Cleanup the job tree in case it hasn't already been cleaned up.
     
    def testJobTree_SingleMachine(self):
        testJobTree(self.testNo, self.depth, self.tempFileTree, self.jobTreeDir, "singleMachine")    
    
    def testJobTree_Parasol(self):
        if parasolIsInstalled():
            testJobTree(self.testNo, self.depth, self.tempFileTree, self.jobTreeDir, "parasol") 
    
    def testJobTree_gridengine(self):
        if gridEngineIsInstalled():
            testJobTree(self.testNo, self.depth, self.tempFileTree, self.jobTreeDir, "gridengine") 
Example #2
0
 def run(self):
     ##########################################
     #Setup a file tree.
     ##########################################
         
     tempFileTree = TempFileTree(os.path.join(self.getGlobalTempDir(), getRandomAlphaNumericString()))   
     
     fileTreeRootFile = tempFileTree.getTempFile()
 
     makeFileTree(fileTreeRootFile, \
                  self.depth, tempFileTree)
     
     treePointer = tempFileTree.getTempFile()
     
     makeTreePointer(fileTreeRootFile, treePointer)
     
     logger.info("We've set up the file tree")
     
     ##########################################
     #Issue the child and follow on jobs
     ##########################################
     
     self.addChildTarget(ChildTarget(treePointer))
     
     self.setFollowOnTarget(DestructFileTree(tempFileTree))
     
     logger.info("We've added the child target and finished SetupFileTree.run()")
Example #3
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.testNo = TestStatus.getTestSetup(1, 1, 2, 2)
     self.depth = TestStatus.getTestSetup(1, 2, 3, 5)
     self.jobTreeDir = os.path.join(os.getcwd(), "jobTree") #A directory for the job tree to be created in
     self.tempFileTreeDir = os.path.join(os.getcwd(), "tempFileTree") #Ensures that file tree is visible
     self.tempFileTree = TempFileTree(self.tempFileTreeDir) #A place to get temp files from
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.testNo = TestStatus.getTestSetup(1, 1, 5, 5)
     self.depth = TestStatus.getTestSetup(1, 2, 2, 3)
     self.jobTreeDir = os.getcwd() + "/jobTree" #A directory for the job tree to be created in
     self.tempFileTreeDir = os.path.join(os.getcwd(), "tempFileTree")
     self.tempFileTree = TempFileTree(self.tempFileTreeDir) #A place to get temp files from
     parasolRestart()
class TestCase(unittest.TestCase):
    
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.testNo = TestStatus.getTestSetup(1, 1, 5, 5)
        self.depth = TestStatus.getTestSetup(1, 2, 2, 3)
        self.jobTreeDir = os.getcwd() + "/jobTree" #A directory for the job tree to be created in
        self.tempFileTreeDir = os.path.join(os.getcwd(), "tempFileTree")
        self.tempFileTree = TempFileTree(self.tempFileTreeDir) #A place to get temp files from
        parasolRestart()
    
    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.tempFileTree.destroyTempFiles()
        parasolStop()
        parasolRestart()
        system("rm -rf %s %s" % (self.jobTreeDir, self.tempFileTreeDir)) #Cleanup the job tree in case it hasn't already been cleaned up.

    def testJobTree_Parasol(self):
        """Runs a test program using the job tree, whilst constantly restarting parasol
        by killing the nodes.
        """
        for test in xrange(self.testNo): #Does not run this test when doing short testing
            jobTreeCommand, fileTreeRootFile = setupJobTree(self.tempFileTree, self.jobTreeDir, 
                                                            "parasol", depth=self.depth)
            jobTreeCommand += " --rescueJobsFrequency 20"
            #Run the job
            parasolAndMasterKiller = ParasolAndMasterKiller()
            parasolAndMasterKiller.start()
            while True:
                while True:
                    process = subprocess.Popen(jobTreeCommand, shell=True)
                    sts = os.waitpid(process.pid, 0)
                    if sts[1] == 0:
                        logger.info("The job tree master ended, with an okay exit value (using parasol)")
                        break
                    else:
                        logger.info("The job tree master ended with an error exit value, restarting: %i" % sts[1])
                if checkEndStateOfJobTree(self.jobTreeDir): #Check the state of the job files
                    break
                
                jobTreeCommand = "jobTreeRun --jobTree %s --logDebug" % self.jobTreeDir
            checkFileTreeCounts(fileTreeRootFile)
            os.system("rm -rf %s" % self.jobTreeDir)
            parasolAndMasterKiller.stopKilling()
            logger.info("Test done okay")