Example #1
0
    def testCreation2(self):
        """
        creates a single task with N jobs
        """

        # log information
        logging.info("Test Creation 2: creating a task with %s jobs" % self.N)
        start = time()

        # create a session and db access
        session = SafeSession(dbInstance=self.dbInstance)
        db = TrackingDB(session)

        # create a task
        task = Task()
        task['name'] = 'task2'
        task['startDirectory'] = '/tmp/startdir'
        task['outputDirectory'] = '/tmp/outdir'
        task['globalSandbox'] = '/tmp/data_area'

        # create template for jobs
        template = {
            'inputFiles': ['a.txt', 'b.txt'],
            'executable': 'production.sh',
            'arguments': "-o c.txt",
            'outputFiles': ['c.txt'],
            'logFile': 'output.log'
        }

        # create list of N jobs
        jobs = []
        for index in range(1, self.N + 1):

            # set specific parameters
            template['name'] = 'job' + str(index)
            if index <= int(self.N / 2):
                template['logFile'] = 'output.log'
            else:
                template['logFile'] = 'useful.log'
            template['outputFiles'] = ['a.txt', 'b.txt']

            # add job to list
            jobs.append(Job(template))

        # add jobs to task
        task.addJobs(jobs)

        # save task (and jobs) in single transaction
        try:
            rows = task.save(db)
            session.commit()
        except TaskError, msg:
            self.fail("Error: " + str(msg))
Example #2
0
    def testCreation1(self):
        """
        creates a single task with 2 jobs
        """

        # log information
        print "Creation tests"
        logging.info("Test Creation 1: creating a task with two jobs")
        start = time()

        # create a session and db access
        session = SafeSession(dbInstance=self.dbInstance)
        db = TrackingDB(session)

        # create a task
        task = Task()
        task['name'] = 'task1'
        task['startDirectory'] = '/tmp/startdir'
        task['outputDirectory'] = '/tmp/output'
        task['globalSandbox'] = '/tmp/inputdata'

        # create first job
        job1 = Job()
        job1['name'] = 'job1'
        job1['executable'] = 'test.sh'
        job1['inputFiles'] = ['a.txt', 'b.txt']
        job1['outputFiles'] = ['c.txt']

        # create second job
        job2 = Job()
        job2['name'] = 'job2'
        job2['executable'] = 'production.sh'
        job2['arguments'] = "-o c.txt"

        # add jobs to task
        task.addJobs([job1, job2])

        # save task in single transaction
        try:
            rows = task.save(db)
            session.commit()
        except TaskError, msg:
            self.fail("Error: " + str(msg))
Example #3
0
    def testUpdate1(self):
        """
        updating task object
        """
        # log information
        logging.info("Test Updating 1: updating task object")
        start = time()

        # create a session and db access
        session = SafeSession(dbInstance=self.dbInstance)
        db = TrackingDB(session)

        # create template for task
        task = Task()
        task['name'] = 'task2'

        # load task
        try:
            task.load(db)
        except TaskError, msg:
            self.fail("Cannot load task: " + str(msg))
Example #4
0
    def testLoading4(self):
        """
        checking update of full output path for output files and input files
        """
        # log information
        logging.info("Test Loading 4: testing full path operations")
        start = time()

        # create a session and db access
        session = SafeSession(dbInstance=self.dbInstance)
        db = TrackingDB(session)

        # create template for task
        task = Task()
        task['name'] = 'task2'

        # load task
        try:
            task.load(db)
        except TaskError, msg:
            self.fail("Cannot load task: " + str(msg))
Example #5
0
    def testLoading3(self):
        """
        loading of a single job in the N jobs task
        """

        # log information
        logging.info("Test Loading 3: load of a single job in a %s jobs task" \
                     % self.N)
        start = time()

        # create a session and db access
        session = SafeSession(dbInstance=self.dbInstance)
        db = TrackingDB(session)

        # create template for task
        task = Task()
        task['name'] = 'task2'

        # create template for jobs with particular logFile
        job = Job()
        job['name'] = 'job1'

        # add to task template
        task.addJob(job)

        # load partial task (jobs with logFile 'output.log')
        try:
            task.load(db)
        except TaskError, msg:
            self.fail("Cannot load task: " + str(msg))
Example #6
0
    def testLoading1(self):
        """
        deep load of a task with 2 jobs and a task with N jobs
        """

        # log information
        print "\nLoading tests"
        logging.info("Test Loading 1: deep load of tasks with 2 and %s jobs" \
                     % self.N)
        start = time()

        # create a session and db access
        session = SafeSession(dbInstance=self.dbInstance)
        db = TrackingDB(session)

        # create template
        task = Task()
        task['name'] = 'task1'

        # load complete task
        try:
            task.load(db)
        except TaskError, msg:
            self.fail("Cannot load task: " + str(msg))
Example #7
0
    def testCreation3(self):
        """
        creating a running instance
        """

        # log information
        logging.info("Test Updating 1: updating task object")
        start = time()

        # create a session and db access
        session = SafeSession(dbInstance=self.dbInstance)
        db = TrackingDB(session)

        # create template for job
        task = Task({'name': 'task1'})
        job = Job({'name': 'job1'})
        task.addJob(job)

        # load information
        try:
            task.load(db)
        except TaskError, msg:
            self.fail("Cannot load task: " + str(msg))
Example #8
0
        self.assertEqual(task['startDirectory'], "/tmp/startdir")

        # check for two jobs
        self.assertEqual(len(task.jobs), 2)

        # check job names
        jobNames = set(['job' + str(index) for index in range(1, 3)])
        for job in task.jobs:
            if job['name'] in jobNames:
                jobNames.remove(job['name'])
            else:
                self.fail("Wrong job in task object")
        self.assertEqual(len(jobNames), 0)

        # get seconds task
        task = Task()
        task['name'] = 'task2'

        # load complete task
        try:
            task.load(db)
        except TaskError, msg:
            self.fail("Cannot load task: " + str(msg))

        # close session
        session.close()

        # check for task information
        self.assertEqual(task['outputDirectory'], "/tmp/outdir")

        # check for N jobs