Exemplo n.º 1
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();
        }