Esempio n. 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") 
Esempio n. 2
0
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")