Example #1
0
 def test_enable_and_disable(self):
     sched = BGSched()
     assert sched.active
     sched.disable("crusher")
     assert not sched.active
     sched.enable("crusher")
     assert sched.active
 def __init__(self, *args, **kwargs):
     BGSched.__init__(self, *args, **kwargs)
     self.get_current_time = ComponentProxy("event-manager").get_current_time
     self.COMP_QUEUE_MANAGER = "cluster-queue-manager"
     self.COMP_SYSTEM = "cluster-system"
     self.queues = Cobalt.Components.bgsched.QueueDict(self.COMP_QUEUE_MANAGER)
     self.jobs = Cobalt.Components.bgsched.JobDict(self.COMP_QUEUE_MANAGER)
     self.running_job_walltime_prediction = False
Example #3
0
File: evsim.py Project: ido/cobalt
 def __init__(self, *args, **kwargs):
     BGSched.__init__(self, *args, **kwargs)
     self.get_current_time = ComponentProxy("event-manager").get_current_time
     self.COMP_QUEUE_MANAGER = "cluster-queue-manager"
     self.COMP_SYSTEM = "cluster-system"
     self.queues = Cobalt.Components.bgsched.QueueDict(self.COMP_QUEUE_MANAGER)
     self.jobs = Cobalt.Components.bgsched.JobDict(self.COMP_QUEUE_MANAGER)
     self.running_job_walltime_prediction = False
    def __init__(self, *args, **kwargs):
        BGSched.__init__(self, *args, **kwargs)

        self.get_current_time = ComponentProxy("event-manager").get_current_time

        predict_scheme = kwargs.get("predict", False)
        if predict_scheme:
            self.running_job_walltime_prediction = bool(int(predict_scheme[2]))
        else:
            self.running_job_walltime_prediction = False
Example #5
0
File: evsim.py Project: ido/cobalt
    def __init__(self, *args, **kwargs):
        BGSched.__init__(self, *args, **kwargs)

        self.get_current_time = ComponentProxy("event-manager").get_current_time

        predict_scheme = kwargs.get("predict", False)
        if predict_scheme:
            self.running_job_walltime_prediction = bool(int(predict_scheme[2]))
        else:
            self.running_job_walltime_prediction = False
Example #6
0
    def test_setstate_(self):
        sched = BGSched()
        assert sched.active

        res = Reservation({'name':"mine", 'start':0, 'duration':0})
        sched.__setstate__({'reservations':res, 'active':False})
        assert not sched.active 

        sched.__setstate__({'reservations':res})
        assert sched.active
Example #7
0
    def test_start_job(self):
        sched = BGSched()
        part = Partition({'name':"mine"})
        j = bgsched.Job({'jobid':1234})    

        try:
            sched._start_job(j, part)
        except ComponentLookupError:
            pass
             
        cqm = QueueManager()  
        sched._start_job(j, part)
        assert sched.assigned_partitions[part.name] < time.time()
        assert sched.started_jobs[j.jobid] < time.time()
Example #8
0
    def test_prioritycmp(self):
        sched = BGSched()
        q1 = Queue({'priority':2})      

        #prioriy is the same for both queues
        sched.queues['queue1'] = q1
        sched.queues['queue2'] = q1
        j1 = bgsched.Job({'queue':"queue1"})      
        j2 = bgsched.Job({'queue':"queue2"})
        
        assert sched.prioritycmp(j1, j2) == 0
    
        q1 = Queue({'priority':2}) 
        q2 = Queue({'priority':3})
        sched.queues['queue1'] = q1
        sched.queues['queue2'] = q2

        assert sched.prioritycmp(j1, j2) > 0
Example #9
0
 def test_sync_data(self): #|finish|
     sched = BGSched()
     sched.sync_data()
Example #10
0
    def test_check_reservations(self): #|finish|
        sched = BGSched()

        #if 'cycle' is not None
        r1 = Reservation({'name':"mine", 'start':100, 'duration':10, 'cycle':"50", 'partitions':"ANL-R00-1024"})
        sched.reservations['res1'] = r1
        r2 = Reservation({'name':"mine", 'start':100, 'duration':20, 'cycle':"50", 'partitions':"ANL-R01-1024"})
        sched.reservations['res2'] = r2

        p1 = Partition({'children':"blah", 'parents':"some", 'name':"mine"})
        sched.partitions['ANL-R00-1024'] = p1
        p2 = Partition({'children':"ANL-R01-1024", 'parents':"other", 'name':"mine"})
        sched.partitions['ANL-R01-1024'] = p2

        sched.check_reservations()
        
        #if 'cycle' is None
        r1 = Reservation({'name':"mine", 'start':100, 'duration':10, 'cycle':None, 'partitions':"ANL-R00-1024"})
        sched.reservations['res1'] = r1
        r2 = Reservation({'name':"mine", 'start':100, 'duration':10, 'cycle':None, 'partitions':"ANL-R01-1024"})
        sched.reservations['res2'] = r2

        sched.check_reservations()
Example #11
0
    def test_fifocmp(self):
        sched = BGSched()
        
        #job1.queue == job2.queue:  

        #test job1.nodes > job2 .nodes
        q1 = Queue({'policy':"largest-first"})
        sched.queues['queue1'] = q1
        j1 = bgsched.Job({'queue':"queue1", 'jobid':1234, 'index':2, 'nodes':8, 'walltime':8})
        j2 = bgsched.Job({'queue':"queue1", 'jobid':1234, 'index':2, 'nodes':4, 'walltime':4})
        assert sched.fifocmp(j1, j2) < 0

        #test job1.nodes < job2.nodes
        q1 = Queue({'policy':"smallest-first"})
        sched.queues['queue1'] = q1
        j1 = bgsched.Job({'queue':"queue1", 'jobid':1234, 'index':2, 'nodes':1, 'walltime':8})
        
        assert sched.fifocmp(j1, j2) < 0
        
        #test job1.walltime > job2.walltime
        q1 = Queue({'policy':"longest-first"})        
        sched.queues['queue1'] = q1        
        assert sched.fifocmp(j1, j2) < 0

        #test job1.walltime < job2.walltime
        q1 = Queue({'policy':"shortest-first"})
        sched.queues['queue1'] = q1
        j1 = bgsched.Job({'queue':"queue1", 'jobid':1234, 'index':2, 'nodes':1, 'walltime':1})   
        assert sched.fifocmp(j1, j2) < 0

        #test nested else
        j1 = bgsched.Job({'queue':"queue1", 'jobid':1234, 'index':2, 'nodes':4, 'walltime':4})    
        assert sched.fifocmp(j1, j2) == 0  #return index comparison test

        #job1.queue != job2.queue
        j1 = bgsched.Job({'queue':"queue1", 'jobid':1234, 'index':2, 'nodes':8, 'walltime':8})
        j2 = bgsched.Job({'queue':"diff", 'jobid':1234, 'index':2, 'nodes':4, 'walltime':4})
                
        assert sched.fifocmp(j1, j2) == 0  #return index comparison test
Example #12
0
 def test_get_sched_info(self):
     sched = BGSched()
     assert sched.get_sched_info() == {}
     sched.sched_info = {'im':"a", 'broken':"bgsched"}
     assert sched.get_sched_info() == {'im':"a", 'broken':"bgsched"}
Example #13
0
 def test_get_state(self):
     sched = BGSched()
     assert sched.__getstate__()['reservations'] == sched.reservations
     assert sched.__getstate__()['version'] == 1
     assert sched.__getstate__()['active'] == sched.active