def test_active (self): reservation = Reservation({'name':"mine", 'start':100, 'duration':50}) for current_time in xrange(1, 100): assert not reservation.is_active(current_time) for current_time in xrange(100, 150): assert reservation.is_active(current_time) for current_time in xrange(151, 250): assert not reservation.is_active(current_time)
def test_overlaps_cyclic (self): reservation = Reservation({'name':"mine", 'start':100, 'duration':10, 'cycle':50, 'partitions':"ANL-R00-1024"}) assert not reservation.overlaps(partition=self.test_partition, start=0, duration=99) assert reservation.overlaps(partition=self.test_partition, start=0, duration=100) assert reservation.overlaps(partition=self.test_partition, start=99, duration=1) assert reservation.overlaps(partition=self.test_partition, start=99, duration=10) assert reservation.overlaps(partition=self.test_partition, start=101, duration=1) assert reservation.overlaps(partition=self.test_partition, start=109, duration=1) assert not reservation.overlaps(partition=self.test_partition, start=110, duration=39) assert reservation.overlaps(partition=self.test_partition, start=90, duration=100)
def test_overlaps (self): reservation = Reservation({'name':"mine", 'start':100, 'duration':50, 'partitions':"ANL-R00-1024"}) assert not reservation.overlaps(partition=self.test_partition, start=0, duration=99) assert reservation.overlaps(partition=self.test_partition, start=0, duration=100) assert reservation.overlaps(partition=self.test_partition, start=0, duration=151) assert reservation.overlaps(partition=self.test_partition, start=99, duration=1) assert reservation.overlaps(partition=self.test_partition, start=99, duration=50) assert reservation.overlaps(partition=self.test_partition, start=149, duration=1) assert not reservation.overlaps(partition=self.test_partition, start=150, duration=100) #check different partition than constructed reservation = Reservation({'name':"mine", 'start':100, 'duration':50, 'partitions':"anotherpartion"}) assert not reservation.overlaps(partition=self.test_partition, start=0, duration=100)
def test_is_over(self): reservation = Reservation({'name':"mine", 'start':100, 'duration':10, 'cycle':50}) assert not reservation.is_over() reservation = Reservation({'name':"mine", 'start':100, 'duration':10}) assert reservation.is_over() reservation = Reservation({'name':"mine", 'start':time.time(), 'duration':1000}) assert not reservation.is_over()
def test_update (self): reservation = Reservation({'name':"mine", 'start':100, 'duration':10}) try: reservation.update({'users':"newuser"}) except ComponentLookupError: cqm = QueueManager() reservation.update({'users':"newuser"}) assert reservation.users == "newuser" reservation = Reservation({'name':"mine", 'start':100, 'duration':10, 'users':"group"}) reservation.update({'users':"newuser"}) assert not reservation.users == "group" assert reservation.users == "newuser"
def test_job_within_reservation (self): # past reservation reservation = Reservation({'name':"mine", 'start':100, 'duration':3600, 'partitions':"ANLR00", 'queue':"default"}) j = Job(5, "default") assert not reservation.job_within_reservation(j) j = Job(70, "default") assert not reservation.job_within_reservation(j) # current reservation reservation = Reservation({'name':"mine", 'start':time.time(), 'duration':3600, 'partitions':"ANLR00", 'queue':"default"}) j = Job(5, "default") assert reservation.job_within_reservation(j) j = Job(70, "default") assert not reservation.job_within_reservation(j) # future reservation reservation = Reservation({'name':"mine", 'start':time.time() + 3600, 'duration':3600, 'partitions':"ANLR00", 'queue':"default"}) j = Job(5, "default") assert not reservation.job_within_reservation(j) j = Job(40, "default") assert not reservation.job_within_reservation(j) j = Job(70, "default") assert not reservation.job_within_reservation(j)
def test_active_cyclic (self): reservation = Reservation({'name':"mine", 'start':100, 'duration':10, 'cycle':50}) assert not reservation.is_active(99) assert reservation.is_active(100) assert reservation.is_active(109) assert not reservation.is_active(111) assert not reservation.is_active(149) assert reservation.is_active(150) assert reservation.is_active(159) assert not reservation.is_active(161)
def test_job_within_reservation_cyclic (self): reservation = Reservation({'name':"mine", 'start':time.time()-3000, 'duration':3600, 'cycle':4000, 'partitions':"ANLR00", 'queue':"default"}) # jobs ends inside the reservation j = Job(6, "default") assert reservation.job_within_reservation(j) # job ends in the "dead zone" j = Job(12, "default") assert not reservation.job_within_reservation(j) # job ends the next time the reservation is active j = Job(50, "default") assert not reservation.job_within_reservation(j) # job lasts longer than the reservation j = Job(100, "default") assert not reservation.job_within_reservation(j) # queue doesn't exist j = Job(0,"notaqueue") assert not reservation.job_within_reservation(j)