public static Map<ReservationInterval, Resource> generateAllocation( long startTime, long step, int[] alloc) { return generateAllocation(startTime, step, alloc, null); }
private ReservationAllocation createReservationAllocation(long startTime, long deadline, long step, int[] alloc, ReservationId id, Resource minAlloc) { Map<ReservationInterval, Resource> allocations = ReservationSystemTestUtil .generateAllocation(startTime, step, alloc); ResourceCalculator rs = mock(ResourceCalculator.class); ReservationDefinition definition = ReservationSystemTestUtil .createSimpleReservationDefinition(startTime, deadline, step); return new InMemoryReservationAllocation(id, definition, "user", ReservationSystemTestUtil.reservationQ, startTime, startTime + step, allocations, rs, minAlloc, false); }
@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)); }
@Test public void testSimplePass() throws IOException, PlanningException { // generate allocation that simply fit within all 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 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))); }
private void prepareBasicPlan() throws PlanningException { // insert in the reservation a couple of controlled reservations, to create // conditions for assignment that are non-empty int[] f = { 10, 10, 20, 20, 20, 10, 10 }; assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), null, "u1", "dedicated", 0L, 0L + f.length * step, ReservationSystemTestUtil .generateAllocation(0, step, f), res, minAlloc))); int[] f2 = { 5, 5, 5, 5, 5, 5, 5 }; Map<ReservationInterval, ReservationRequest> alloc = ReservationSystemTestUtil.generateAllocation(5000, step, f2); assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), null, "u1", "dedicated", 5000, 5000 + f2.length * step, alloc, res, minAlloc))); System.out.println("--------BEFORE AGENT----------"); System.out.println(plan.toString()); System.out.println(plan.toCumulativeString()); }
@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 public void testSimplePass2() throws IOException, PlanningException { // generate allocation from single tenant that exceed avg momentarily but // fit within // max instantanesou int[] f = generateData(3600, (int) Math.ceil(0.69 * 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(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(expected = PlanningQuotaException.class) public void testInstFail() throws IOException, PlanningException { // generate allocation that exceed the instantaneous cap single-show int[] f = generateData(3600, (int) Math.ceil(0.71 * totCont)); assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), null, "u1", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil.generateAllocation(initTime, step, f), res, minAlloc))); Assert.fail("should not have accepted this"); }
@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))); } }
private void addFixedAllocation(long start, long step, int[] f) throws PlanningException { ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition( start, start + f.length * step, f.length * step); assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), rDef, "user_fixed", "dedicated", start, start + f.length * step, ReservationSystemTestUtil.generateAllocation(start, step, f), res, minAlloc), false)); }
private void prepareBasicPlan() throws PlanningException { // insert in the reservation a couple of controlled reservations, to create // conditions for assignment that are non-empty int[] f = { 10, 10, 20, 20, 20, 10, 10 }; ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition( 0, 0 + f.length * step, f.length * step); assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), rDef, "u1", "dedicated", 0L, 0L + f.length * step, ReservationSystemTestUtil .generateAllocation(0, step, f), res, minAlloc), false)); int[] f2 = { 5, 5, 5, 5, 5, 5, 5 }; Map<ReservationInterval, Resource> alloc = ReservationSystemTestUtil.generateAllocation(5000, step, f2); assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), rDef, "u1", "dedicated", 5000, 5000 + f2.length * step, alloc, res, minAlloc), false)); System.out.println("--------BEFORE AGENT----------"); System.out.println(plan.toString()); System.out.println(plan.toCumulativeString()); }
@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 public void testInstFailBySum() throws IOException, PlanningException { // generate allocation that exceed the instantaneous cap by sum int[] f = generateData(3600, (int) Math.ceil(0.3 * totCont)); assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), null, "u1", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil.generateAllocation(initTime, step, f), res, minAlloc))); assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), null, "u1", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil.generateAllocation(initTime, step, f), res, minAlloc))); try { assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), null, "u1", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil.generateAllocation(initTime, step, f), res, minAlloc))); Assert.fail(); } catch (PlanningQuotaException p) { // expected } }
ReservationSystemTestUtil.getNewReservationId(), rDef, "u1", "dedicated", 30 * step, 30 * step + f.length * step, ReservationSystemTestUtil.generateAllocation(30 * step, step, f), res, minAlloc), false));
ReservationSystemTestUtil.getNewReservationId(), rDef, "u1", "dedicated", 30 * step, 30 * step + f.length * step, ReservationSystemTestUtil.generateAllocation(30 * step, step, f), res, minAlloc), false));
ReservationSystemTestUtil.getNewReservationId(), null, "u1", "dedicated", 30 * step, 30 * step + f.length * step, ReservationSystemTestUtil.generateAllocation(30 * step, step, f), res, minAlloc)));