Beispiel #1
0
        public virtual void TestMoveAppToPlanQueue()
        {
            CapacityScheduler scheduler = (CapacityScheduler)rm.GetResourceScheduler();
            // submit an app
            RMApp app = rm.SubmitApp(Gb, "test-move-1", "user_0", null, "b1");
            ApplicationAttemptId appAttemptId = rm.GetApplicationReport(app.GetApplicationId(
                                                                            )).GetCurrentApplicationAttemptId();
            // check preconditions
            IList <ApplicationAttemptId> appsInB1 = scheduler.GetAppsInQueue("b1");

            NUnit.Framework.Assert.AreEqual(1, appsInB1.Count);
            IList <ApplicationAttemptId> appsInB = scheduler.GetAppsInQueue("b");

            NUnit.Framework.Assert.AreEqual(1, appsInB.Count);
            NUnit.Framework.Assert.IsTrue(appsInB.Contains(appAttemptId));
            IList <ApplicationAttemptId> appsInA = scheduler.GetAppsInQueue("a");

            NUnit.Framework.Assert.IsTrue(appsInA.IsEmpty());
            string queue = scheduler.GetApplicationAttempt(appsInB1[0]).GetQueue().GetQueueName
                               ();

            NUnit.Framework.Assert.IsTrue(queue.Equals("b1"));
            IList <ApplicationAttemptId> appsInRoot = scheduler.GetAppsInQueue("root");

            NUnit.Framework.Assert.IsTrue(appsInRoot.Contains(appAttemptId));
            NUnit.Framework.Assert.AreEqual(1, appsInRoot.Count);
            // create the default reservation queue
            string           defQName = "a" + ReservationConstants.DefaultQueueSuffix;
            ReservationQueue defQ     = new ReservationQueue(scheduler, defQName, (PlanQueue)scheduler
                                                             .GetQueue("a"));

            scheduler.AddQueue(defQ);
            defQ.SetEntitlement(new QueueEntitlement(1f, 1f));
            IList <ApplicationAttemptId> appsInDefQ = scheduler.GetAppsInQueue(defQName);

            NUnit.Framework.Assert.IsTrue(appsInDefQ.IsEmpty());
            // now move the app to plan queue
            scheduler.MoveApplication(app.GetApplicationId(), "a");
            // check postconditions
            appsInDefQ = scheduler.GetAppsInQueue(defQName);
            NUnit.Framework.Assert.AreEqual(1, appsInDefQ.Count);
            queue = scheduler.GetApplicationAttempt(appsInDefQ[0]).GetQueue().GetQueueName();
            NUnit.Framework.Assert.IsTrue(queue.Equals(defQName));
            appsInA = scheduler.GetAppsInQueue("a");
            NUnit.Framework.Assert.IsTrue(appsInA.Contains(appAttemptId));
            NUnit.Framework.Assert.AreEqual(1, appsInA.Count);
            appsInRoot = scheduler.GetAppsInQueue("root");
            NUnit.Framework.Assert.IsTrue(appsInRoot.Contains(appAttemptId));
            NUnit.Framework.Assert.AreEqual(1, appsInRoot.Count);
            appsInB1 = scheduler.GetAppsInQueue("b1");
            NUnit.Framework.Assert.IsTrue(appsInB1.IsEmpty());
            appsInB = scheduler.GetAppsInQueue("b");
            NUnit.Framework.Assert.IsTrue(appsInB.IsEmpty());
            rm.Stop();
        }