public virtual void TestOrder()
        {
            PrepareBasicPlan();
            // create a completely utilized segment around time 30
            int[] f = new int[] { 100, 100 };
            NUnit.Framework.Assert.IsTrue(plan.ToString(), plan.AddReservation(new InMemoryReservationAllocation
                                                                                   (ReservationSystemTestUtil.GetNewReservationId(), null, "u1", "dedicated", 30 *
                                                                                   step, 30 * step + f.Length * step, ReservationSystemTestUtil.GenerateAllocation(
                                                                                       30 * step, step, f), res, minAlloc)));
            // create a chain of 4 RR, mixing gang and non-gang
            ReservationDefinition rr = new ReservationDefinitionPBImpl();

            rr.SetArrival(0 * step);
            rr.SetDeadline(70 * step);
            ReservationRequests reqs = new ReservationRequestsPBImpl();

            reqs.SetInterpreter(ReservationRequestInterpreter.ROrder);
            ReservationRequest r = ReservationRequest.NewInstance(Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                                  .NewInstance(2048, 2), 10, 1, 10 * step);
            ReservationRequest r2 = ReservationRequest.NewInstance(Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                                   .NewInstance(1024, 1), 10, 10, 20 * step);
            IList <ReservationRequest> list = new AList <ReservationRequest>();

            list.AddItem(r);
            list.AddItem(r2);
            list.AddItem(r);
            list.AddItem(r2);
            reqs.SetReservationResources(list);
            rr.SetReservationRequests(reqs);
            // submit to agent
            ReservationId reservationID = ReservationSystemTestUtil.GetNewReservationId();

            agent.CreateReservation(reservationID, "u1", plan, rr);
            // validate
            NUnit.Framework.Assert.IsTrue("Agent-based allocation failed", reservationID != null
                                          );
            NUnit.Framework.Assert.IsTrue("Agent-based allocation failed", plan.GetAllReservations
                                              ().Count == 4);
            ReservationAllocation cs = plan.GetReservationById(reservationID);

            NUnit.Framework.Assert.IsTrue(cs.ToString(), Check(cs, 0 * step, 10 * step, 20, 1024
                                                               , 1));
            NUnit.Framework.Assert.IsTrue(cs.ToString(), Check(cs, 10 * step, 30 * step, 10,
                                                               1024, 1));
            NUnit.Framework.Assert.IsTrue(cs.ToString(), Check(cs, 40 * step, 50 * step, 20,
                                                               1024, 1));
            NUnit.Framework.Assert.IsTrue(cs.ToString(), Check(cs, 50 * step, 70 * step, 10,
                                                               1024, 1));
            System.Console.Out.WriteLine("--------AFTER ORDER ALLOCATION (queue: " + reservationID
                                         + ")----------");
            System.Console.Out.WriteLine(plan.ToString());
            System.Console.Out.WriteLine(plan.ToCumulativeString());
        }
        public virtual void TestAll()
        {
            PrepareBasicPlan();
            // create an ALL request
            ReservationDefinition rr = new ReservationDefinitionPBImpl();

            rr.SetArrival(100 * step);
            rr.SetDeadline(120 * step);
            ReservationRequests reqs = new ReservationRequestsPBImpl();

            reqs.SetInterpreter(ReservationRequestInterpreter.RAll);
            ReservationRequest r = ReservationRequest.NewInstance(Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                                  .NewInstance(1024, 1), 5, 5, 10 * step);
            ReservationRequest r2 = ReservationRequest.NewInstance(Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                                   .NewInstance(2048, 2), 10, 10, 20 * step);
            IList <ReservationRequest> list = new AList <ReservationRequest>();

            list.AddItem(r);
            list.AddItem(r2);
            reqs.SetReservationResources(list);
            rr.SetReservationRequests(reqs);
            // submit to agent
            ReservationId reservationID = ReservationSystemTestUtil.GetNewReservationId();

            agent.CreateReservation(reservationID, "u1", plan, rr);
            // validate results, we expect the second one to be accepted
            NUnit.Framework.Assert.IsTrue("Agent-based allocation failed", reservationID != null
                                          );
            NUnit.Framework.Assert.IsTrue("Agent-based allocation failed", plan.GetAllReservations
                                              ().Count == 3);
            ReservationAllocation cs = plan.GetReservationById(reservationID);

            NUnit.Framework.Assert.IsTrue(cs.ToString(), Check(cs, 100 * step, 110 * step, 20
                                                               , 1024, 1));
            NUnit.Framework.Assert.IsTrue(cs.ToString(), Check(cs, 110 * step, 120 * step, 25
                                                               , 1024, 1));
            System.Console.Out.WriteLine("--------AFTER ALL ALLOCATION (queue: " + reservationID
                                         + ")----------");
            System.Console.Out.WriteLine(plan.ToString());
            System.Console.Out.WriteLine(plan.ToCumulativeString());
        }