Exemplo n.º 1
0
        public virtual void TestAddQueueFailCases()
        {
            CapacityScheduler cs = (CapacityScheduler)rm.GetResourceScheduler();

            try
            {
                // Test invalid addition (adding non-zero size queue)
                ReservationQueue a1 = new ReservationQueue(cs, "a1", (PlanQueue)cs.GetQueue("a"));
                a1.SetEntitlement(new QueueEntitlement(A1Capacity / 100, 1f));
                cs.AddQueue(a1);
                NUnit.Framework.Assert.Fail();
            }
            catch (Exception)
            {
            }
            // expected
            // Test add one reservation dynamically and manually modify capacity
            ReservationQueue a1_1 = new ReservationQueue(cs, "a1", (PlanQueue)cs.GetQueue("a"
                                                                                          ));

            cs.AddQueue(a1_1);
            a1_1.SetEntitlement(new QueueEntitlement(A1Capacity / 100, 1f));
            // Test add another reservation queue and use setEntitlement to modify
            // capacity
            ReservationQueue a2 = new ReservationQueue(cs, "a2", (PlanQueue)cs.GetQueue("a"));

            cs.AddQueue(a2);
            try
            {
                // Test invalid entitlement (sum of queues exceed 100%)
                cs.SetEntitlement("a2", new QueueEntitlement(A2Capacity / 100 + 0.1f, 1.0f));
                NUnit.Framework.Assert.Fail();
            }
            catch (Exception)
            {
            }
            // expected
            cs.SetEntitlement("a2", new QueueEntitlement(A2Capacity / 100, 1.0f));
            // Verify all allocations match
            tcs.CheckQueueCapacities(cs, ACapacity, BCapacity);
            cs.Stop();
        }
Exemplo n.º 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();
        }
Exemplo n.º 3
0
        public virtual void TestRefreshQueuesWithReservations()
        {
            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));
            // Test add another reservation queue and use setEntitlement to modify
            // capacity
            ReservationQueue a2 = new ReservationQueue(cs, "a2", (PlanQueue)cs.GetQueue("a"));

            cs.AddQueue(a2);
            cs.SetEntitlement("a2", new QueueEntitlement(A2Capacity / 100, 1.0f));
            // Verify all allocations match
            tcs.CheckQueueCapacities(cs, ACapacity, BCapacity);
            // Reinitialize and verify all dynamic queued survived
            CapacitySchedulerConfiguration conf = cs.GetConfiguration();

            conf.SetCapacity(A, 80f);
            conf.SetCapacity(B, 20f);
            cs.Reinitialize(conf, rm.GetRMContext());
            tcs.CheckQueueCapacities(cs, 80f, 20f);
        }