@Test public void testSingleUserEasyFitPass() throws IOException, PlanningException { // generate allocation that easily fit within resource constraints int[] f = generateData(3600, (int) Math.ceil(0.2 * totCont)); assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), null, "u1", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil.generateAllocation(initTime, step, f), res, minAlloc))); }
@Test(expected = ResourceOverCommitException.class) public void testSingleFail() throws IOException, PlanningException { // generate allocation from single tenant that exceed capacity int[] f = generateData(3600, (int) (1.1 * totCont)); plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), null, "u1", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil .generateAllocation(initTime, step, f), res, minAlloc)); }
@Test public void testMultiTenantPass() throws IOException, PlanningException { // generate allocation from multiple tenants that barely fit in tot capacity int[] f = generateData(3600, (int) Math.ceil(0.25 * totCont)); for (int i = 0; i < 4; i++) { assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), null, "u" + i, "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil.generateAllocation(initTime, step, f), res, minAlloc))); } }
@Test(expected = ResourceOverCommitException.class) public void testMultiTenantFail() throws IOException, PlanningException { // generate allocation from multiple tenants that exceed tot capacity int[] f = generateData(3600, (int) Math.ceil(0.25 * totCont)); for (int i = 0; i < 5; i++) { assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), null, "u" + i, "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil.generateAllocation(initTime, step, f), res, minAlloc))); } } }
@Test public void testSingleUserBarelyFitPass() throws IOException, PlanningException { // generate allocation from single tenant that barely fit int[] f = generateData(3600, totCont); assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), null, "u1", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil.generateAllocation(initTime, step, f), res, minAlloc))); }
@Test(expected = MismatchedUserException.class) public void testUserMismatch() throws IOException, PlanningException { // generate allocation from single tenant that exceed capacity int[] f = generateData(3600, (int) (0.5 * totCont)); ReservationId rid = ReservationSystemTestUtil.getNewReservationId(); plan.addReservation(new InMemoryReservationAllocation(rid, null, "u1", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil .generateAllocation(initTime, step, f), res, minAlloc)); // trying to update a reservation with a mismatching user plan.updateReservation(new InMemoryReservationAllocation(rid, null, "u2", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil .generateAllocation(initTime, step, f), res, minAlloc)); }