Example #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();
        }
Example #2
0
        public virtual void TestRemoveQueue()
        {
            CapacityScheduler cs = (CapacityScheduler)rm.GetResourceScheduler();
            // Test add one reservation dynamically and manually modify capacity
            ReservationQueue a1 = new ReservationQueue(cs, "a1", (PlanQueue)cs.GetQueue("a"));

            cs.AddQueue(a1);
            a1.SetEntitlement(new QueueEntitlement(A1Capacity / 100, 1f));
            // submit an app
            RMApp app = rm.SubmitApp(Gb, "test-move-1", "user_0", null, "a1");
            // check preconditions
            IList <ApplicationAttemptId> appsInA1 = cs.GetAppsInQueue("a1");

            NUnit.Framework.Assert.AreEqual(1, appsInA1.Count);
            try
            {
                cs.RemoveQueue("a1");
                NUnit.Framework.Assert.Fail();
            }
            catch (SchedulerDynamicEditException)
            {
            }
            // expected a1 contains applications
            // clear queue by killling all apps
            cs.KillAllAppsInQueue("a1");
            // wait for events of move to propagate
            rm.WaitForState(app.GetApplicationId(), RMAppState.Killed);
            try
            {
                cs.RemoveQueue("a1");
                NUnit.Framework.Assert.Fail();
            }
            catch (SchedulerDynamicEditException)
            {
            }
            // expected a1 is not zero capacity
            // set capacity to zero
            cs.SetEntitlement("a1", new QueueEntitlement(0f, 0f));
            cs.RemoveQueue("a1");
            NUnit.Framework.Assert.IsTrue(cs.GetQueue("a1") == null);
            rm.Stop();
        }