Skip to content

Commit

Permalink
Migrate fragmentation test
Browse files Browse the repository at this point in the history
  • Loading branch information
href committed Nov 25, 2014
1 parent 79c9685 commit 13756ad
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions libres/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,3 +1014,30 @@ def test_quotas(scheduler):

other.extinguish_managed_records()
other.commit()


def test_fragmentation(scheduler):
start = datetime(2011, 1, 1, 15, 0)
end = datetime(2011, 1, 1, 16, 0)
daterange = (start, end)

allocation = scheduler.allocate(daterange, quota=3)[0]
reservation = scheduler.reserve(u'test@example.org', daterange)
slots = scheduler.approve_reservations(reservation)

assert all(True for s in slots if s.resource == scheduler.resource)

slots = scheduler.approve_reservations(
scheduler.reserve(u'test@example.org', daterange)
)
assert not any(False for s in slots if s.resource == scheduler.resource)

scheduler.remove_reservation(reservation)

slots = scheduler.approve_reservations(
scheduler.reserve(u'test@example.org', daterange)
)
assert all(True for s in slots if s.resource == scheduler.resource)

with pytest.raises(errors.AffectedReservationError):
scheduler.remove_allocation(allocation.id)

0 comments on commit 13756ad

Please sign in to comment.