示例#1
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestQueueParsingWithMoveQueue()
        {
            YarnConfiguration conf = new YarnConfiguration();
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(conf);

            csConf.SetQueues("root", new string[] { "a" });
            csConf.SetQueues("root.a", new string[] { "x", "y" });
            csConf.SetCapacity("root.a", 100);
            csConf.SetCapacity("root.a.x", 50);
            csConf.SetCapacity("root.a.y", 50);
            CapacityScheduler capacityScheduler = new CapacityScheduler();
            RMContextImpl     rmContext         = new RMContextImpl(null, null, null, null, null, null, new
                                                                    RMContainerTokenSecretManager(csConf), new NMTokenSecretManagerInRM(csConf), new
                                                                    ClientToAMTokenSecretManagerInRM(), null);

            rmContext.SetNodeLabelManager(nodeLabelManager);
            capacityScheduler.SetConf(csConf);
            capacityScheduler.SetRMContext(rmContext);
            capacityScheduler.Init(csConf);
            capacityScheduler.Start();
            csConf.SetQueues("root", new string[] { "a", "x" });
            csConf.SetQueues("root.a", new string[] { "y" });
            csConf.SetCapacity("root.x", 50);
            csConf.SetCapacity("root.a", 50);
            csConf.SetCapacity("root.a.y", 100);
            capacityScheduler.Reinitialize(csConf, rmContext);
        }
示例#2
0
        public virtual void TestQueueParsing()
        {
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();

            SetupQueueConfiguration(csConf);
            YarnConfiguration conf = new YarnConfiguration(csConf);
            CapacityScheduler capacityScheduler = new CapacityScheduler();

            capacityScheduler.SetConf(conf);
            capacityScheduler.SetRMContext(TestUtils.GetMockRMContext());
            capacityScheduler.Init(conf);
            capacityScheduler.Start();
            capacityScheduler.Reinitialize(conf, TestUtils.GetMockRMContext());
            CSQueue a = capacityScheduler.GetQueue("a");

            NUnit.Framework.Assert.AreEqual(0.10, a.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual(0.15, a.GetAbsoluteMaximumCapacity(), Delta);
            CSQueue b1 = capacityScheduler.GetQueue("b1");

            NUnit.Framework.Assert.AreEqual(0.2 * 0.5, b1.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual("Parent B has no MAX_CAP", 0.85, b1.GetAbsoluteMaximumCapacity
                                                (), Delta);
            CSQueue c12 = capacityScheduler.GetQueue("c12");

            NUnit.Framework.Assert.AreEqual(0.7 * 0.5 * 0.45, c12.GetAbsoluteCapacity(), Delta
                                            );
            NUnit.Framework.Assert.AreEqual(0.7 * 0.55 * 0.7, c12.GetAbsoluteMaximumCapacity(
                                                ), Delta);
            ServiceOperations.StopQuietly(capacityScheduler);
        }
示例#3
0
        /// <summary>
        /// Test init a queue configuration, children's capacity for a given label
        /// doesn't equals to 100%.
        /// </summary>
        /// <remarks>
        /// Test init a queue configuration, children's capacity for a given label
        /// doesn't equals to 100%. This expect IllegalArgumentException thrown.
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestQueueParsingWithSumOfChildLabelCapacityNot100PercentWithWildCard
            ()
        {
            nodeLabelManager.AddToCluserNodeLabels(ImmutableSet.Of("red", "blue"));
            YarnConfiguration conf = new YarnConfiguration();
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(conf);

            SetupQueueConfigurationWithLabels(csConf);
            csConf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root + ".b.b3", "red", 24
                                      );
            csConf.SetAccessibleNodeLabels(CapacitySchedulerConfiguration.Root, ImmutableSet.
                                           Of(RMNodeLabelsManager.Any));
            csConf.SetAccessibleNodeLabels(CapacitySchedulerConfiguration.Root + ".b", ImmutableSet
                                           .Of(RMNodeLabelsManager.Any));
            CapacityScheduler capacityScheduler = new CapacityScheduler();
            RMContextImpl     rmContext         = new RMContextImpl(null, null, null, null, null, null, new
                                                                    RMContainerTokenSecretManager(csConf), new NMTokenSecretManagerInRM(csConf), new
                                                                    ClientToAMTokenSecretManagerInRM(), null);

            rmContext.SetNodeLabelManager(nodeLabelManager);
            capacityScheduler.SetConf(csConf);
            capacityScheduler.SetRMContext(rmContext);
            capacityScheduler.Init(csConf);
            capacityScheduler.Start();
            ServiceOperations.StopQuietly(capacityScheduler);
        }
示例#4
0
        public virtual void TestNestedQueueParsingShouldTrimSpaces()
        {
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();

            SetupNestedQueueConfigurationWithSpacesShouldBeTrimmed(csConf);
            YarnConfiguration conf = new YarnConfiguration(csConf);
            CapacityScheduler capacityScheduler = new CapacityScheduler();

            capacityScheduler.SetConf(conf);
            capacityScheduler.SetRMContext(TestUtils.GetMockRMContext());
            capacityScheduler.Init(conf);
            capacityScheduler.Start();
            capacityScheduler.Reinitialize(conf, TestUtils.GetMockRMContext());
            CSQueue a = capacityScheduler.GetQueue("a");

            NUnit.Framework.Assert.IsNotNull(a);
            NUnit.Framework.Assert.AreEqual(0.10, a.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual(0.15, a.GetAbsoluteMaximumCapacity(), Delta);
            CSQueue c = capacityScheduler.GetQueue("c");

            NUnit.Framework.Assert.IsNotNull(c);
            NUnit.Framework.Assert.AreEqual(0.70, c.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual(0.70, c.GetAbsoluteMaximumCapacity(), Delta);
            CSQueue a1 = capacityScheduler.GetQueue("a1");

            NUnit.Framework.Assert.IsNotNull(a1);
            NUnit.Framework.Assert.AreEqual(0.10 * 0.6, a1.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual(0.15, a1.GetAbsoluteMaximumCapacity(), Delta);
            CSQueue a2 = capacityScheduler.GetQueue("a2");

            NUnit.Framework.Assert.IsNotNull(a2);
            NUnit.Framework.Assert.AreEqual(0.10 * 0.4, a2.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual(0.15, a2.GetAbsoluteMaximumCapacity(), Delta);
        }
示例#5
0
        /// <exception cref="System.Exception"/>
        public virtual void TestMaxCapacity()
        {
            CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();

            conf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { "a", "b", "c" }
                           );
            string A = CapacitySchedulerConfiguration.Root + ".a";

            conf.SetCapacity(A, 50);
            conf.SetMaximumCapacity(A, 60);
            string B = CapacitySchedulerConfiguration.Root + ".b";

            conf.SetCapacity(B, 50);
            conf.SetMaximumCapacity(B, 45);
            // Should throw an exception
            bool fail = false;
            CapacityScheduler capacityScheduler;

            try
            {
                capacityScheduler = new CapacityScheduler();
                capacityScheduler.SetConf(new YarnConfiguration());
                capacityScheduler.Init(conf);
                capacityScheduler.Start();
                capacityScheduler.Reinitialize(conf, null);
            }
            catch (ArgumentException)
            {
                fail = true;
            }
            NUnit.Framework.Assert.IsTrue("Didn't throw IllegalArgumentException for wrong maxCap"
                                          , fail);
            conf.SetMaximumCapacity(B, 60);
            // Now this should work
            capacityScheduler = new CapacityScheduler();
            capacityScheduler.SetConf(new YarnConfiguration());
            capacityScheduler.Init(conf);
            capacityScheduler.Start();
            capacityScheduler.Reinitialize(conf, null);
            fail = false;
            try
            {
                LeafQueue a = (LeafQueue)capacityScheduler.GetQueue(A);
                a.SetMaxCapacity(45);
            }
            catch (ArgumentException)
            {
                fail = true;
            }
            NUnit.Framework.Assert.IsTrue("Didn't throw IllegalArgumentException for wrong "
                                          + "setMaxCap", fail);
            capacityScheduler.Stop();
        }
示例#6
0
        public virtual void TestCompareRMNodeAfterReconnect()
        {
            Configuration     yarnConf  = new YarnConfiguration();
            CapacityScheduler scheduler = new CapacityScheduler();

            scheduler.SetConf(yarnConf);
            ConfigurationProvider configurationProvider = ConfigurationProviderFactory.GetConfigurationProvider
                                                              (yarnConf);

            configurationProvider.Init(yarnConf);
            context.SetConfigurationProvider(configurationProvider);
            RMNodeLabelsManager nlm = new RMNodeLabelsManager();

            nlm.Init(yarnConf);
            nlm.Start();
            context.SetNodeLabelManager(nlm);
            scheduler.SetRMContext(context);
            scheduler.Init(yarnConf);
            scheduler.Start();
            dispatcher.Register(typeof(SchedulerEventType), scheduler);
            string   hostname1  = "localhost1";
            Resource capability = BuilderUtils.NewResource(4096, 4);
            RegisterNodeManagerRequest request1 = recordFactory.NewRecordInstance <RegisterNodeManagerRequest
                                                                                   >();
            NodeId nodeId1 = NodeId.NewInstance(hostname1, 0);

            request1.SetNodeId(nodeId1);
            request1.SetHttpPort(0);
            request1.SetResource(capability);
            resourceTrackerService.RegisterNodeManager(request1);
            NUnit.Framework.Assert.IsNotNull(context.GetRMNodes()[nodeId1]);
            // verify Scheduler and RMContext use same RMNode reference.
            NUnit.Framework.Assert.IsTrue(scheduler.GetSchedulerNode(nodeId1).GetRMNode() ==
                                          context.GetRMNodes()[nodeId1]);
            NUnit.Framework.Assert.AreEqual(context.GetRMNodes()[nodeId1].GetTotalCapability(
                                                ), capability);
            Resource capability1 = BuilderUtils.NewResource(2048, 2);

            request1.SetResource(capability1);
            resourceTrackerService.RegisterNodeManager(request1);
            NUnit.Framework.Assert.IsNotNull(context.GetRMNodes()[nodeId1]);
            // verify Scheduler and RMContext use same RMNode reference
            // after reconnect.
            NUnit.Framework.Assert.IsTrue(scheduler.GetSchedulerNode(nodeId1).GetRMNode() ==
                                          context.GetRMNodes()[nodeId1]);
            // verify RMNode's capability is changed.
            NUnit.Framework.Assert.AreEqual(context.GetRMNodes()[nodeId1].GetTotalCapability(
                                                ), capability1);
            nlm.Stop();
            scheduler.Stop();
        }
示例#7
0
        /// <exception cref="System.Exception"/>
        public virtual void TestRootQueueParsing()
        {
            CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();

            // non-100 percent value will throw IllegalArgumentException
            conf.SetCapacity(CapacitySchedulerConfiguration.Root, 90);
            CapacityScheduler capacityScheduler = new CapacityScheduler();

            capacityScheduler.SetConf(new YarnConfiguration());
            capacityScheduler.Init(conf);
            capacityScheduler.Start();
            capacityScheduler.Reinitialize(conf, null);
            ServiceOperations.StopQuietly(capacityScheduler);
        }
示例#8
0
        public virtual void TestQueueParsingWithUnusedLabels()
        {
            ImmutableSet <string> labels = ImmutableSet.Of("red", "blue");

            // Initialize a cluster with labels, but doesn't use them, reinitialize
            // shouldn't fail
            nodeLabelManager.AddToCluserNodeLabels(labels);
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();

            SetupQueueConfiguration(csConf);
            csConf.SetAccessibleNodeLabels(CapacitySchedulerConfiguration.Root, labels);
            YarnConfiguration conf = new YarnConfiguration(csConf);
            CapacityScheduler capacityScheduler = new CapacityScheduler();

            capacityScheduler.SetConf(conf);
            RMContextImpl rmContext = new RMContextImpl(null, null, null, null, null, null, new
                                                        RMContainerTokenSecretManager(csConf), new NMTokenSecretManagerInRM(csConf), new
                                                        ClientToAMTokenSecretManagerInRM(), null);

            rmContext.SetNodeLabelManager(nodeLabelManager);
            capacityScheduler.SetRMContext(rmContext);
            capacityScheduler.Init(conf);
            capacityScheduler.Start();
            capacityScheduler.Reinitialize(conf, rmContext);
            // check root queue's capacity by label -- they should be all zero
            CSQueue root = capacityScheduler.GetQueue(CapacitySchedulerConfiguration.Root);

            NUnit.Framework.Assert.AreEqual(0, root.GetQueueCapacities().GetCapacity("red"),
                                            Delta);
            NUnit.Framework.Assert.AreEqual(0, root.GetQueueCapacities().GetCapacity("blue"),
                                            Delta);
            CSQueue a = capacityScheduler.GetQueue("a");

            NUnit.Framework.Assert.AreEqual(0.10, a.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual(0.15, a.GetAbsoluteMaximumCapacity(), Delta);
            CSQueue b1 = capacityScheduler.GetQueue("b1");

            NUnit.Framework.Assert.AreEqual(0.2 * 0.5, b1.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual("Parent B has no MAX_CAP", 0.85, b1.GetAbsoluteMaximumCapacity
                                                (), Delta);
            CSQueue c12 = capacityScheduler.GetQueue("c12");

            NUnit.Framework.Assert.AreEqual(0.7 * 0.5 * 0.45, c12.GetAbsoluteCapacity(), Delta
                                            );
            NUnit.Framework.Assert.AreEqual(0.7 * 0.55 * 0.7, c12.GetAbsoluteMaximumCapacity(
                                                ), Delta);
            capacityScheduler.Stop();
        }
示例#9
0
        public virtual void SetUp()
        {
            CapacityScheduler spyCs = new CapacityScheduler();

            cs           = Org.Mockito.Mockito.Spy(spyCs);
            scheduler    = cs;
            rmContext    = TestUtils.GetMockRMContext();
            spyRMContext = Org.Mockito.Mockito.Spy(rmContext);
            ConcurrentMap <ApplicationId, RMApp> spyApps = Org.Mockito.Mockito.Spy(new ConcurrentHashMap
                                                                                   <ApplicationId, RMApp>());
            RMApp rmApp = Org.Mockito.Mockito.Mock <RMApp>();

            Org.Mockito.Mockito.When(rmApp.GetRMAppAttempt((ApplicationAttemptId)Matchers.Any
                                                               ())).ThenReturn(null);
            Org.Mockito.Mockito.DoReturn(rmApp).When(spyApps)[(ApplicationId)Matchers.Any()];
            Org.Mockito.Mockito.When(spyRMContext.GetRMApps()).ThenReturn(spyApps);
            Org.Mockito.Mockito.When(spyRMContext.GetScheduler()).ThenReturn(scheduler);
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();

            ReservationSystemTestUtil.SetupQueueConfiguration(csConf);
            cs.SetConf(csConf);
            csContext = Org.Mockito.Mockito.Mock <CapacitySchedulerContext>();
            Org.Mockito.Mockito.When(csContext.GetConfiguration()).ThenReturn(csConf);
            Org.Mockito.Mockito.When(csContext.GetConf()).ThenReturn(csConf);
            Org.Mockito.Mockito.When(csContext.GetMinimumResourceCapability()).ThenReturn(minAlloc
                                                                                          );
            Org.Mockito.Mockito.When(csContext.GetMaximumResourceCapability()).ThenReturn(maxAlloc
                                                                                          );
            Org.Mockito.Mockito.When(csContext.GetClusterResource()).ThenReturn(Resources.CreateResource
                                                                                    (100 * 16 * Gb, 100 * 32));
            Org.Mockito.Mockito.When(scheduler.GetClusterResource()).ThenReturn(Resources.CreateResource
                                                                                    (125 * Gb, 125));
            Org.Mockito.Mockito.When(csContext.GetResourceCalculator()).ThenReturn(new DefaultResourceCalculator
                                                                                       ());
            RMContainerTokenSecretManager containerTokenSecretManager = new RMContainerTokenSecretManager
                                                                            (csConf);

            containerTokenSecretManager.RollMasterKey();
            Org.Mockito.Mockito.When(csContext.GetContainerTokenSecretManager()).ThenReturn(containerTokenSecretManager
                                                                                            );
            cs.SetRMContext(spyRMContext);
            cs.Init(csConf);
            cs.Start();
            SetupPlanFollower();
        }
示例#10
0
        /// <exception cref="System.IO.IOException"/>
        public static CapacityScheduler MockCapacityScheduler()
        {
            // stolen from TestCapacityScheduler
            CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();

            SetupQueueConfiguration(conf);
            CapacityScheduler cs = new CapacityScheduler();

            cs.SetConf(new YarnConfiguration());
            RMContext rmContext = new RMContextImpl(null, null, null, null, null, null, new RMContainerTokenSecretManager
                                                        (conf), new NMTokenSecretManagerInRM(conf), new ClientToAMTokenSecretManagerInRM
                                                        (), null);

            rmContext.SetNodeLabelManager(new NullRMNodeLabelsManager());
            cs.SetRMContext(rmContext);
            cs.Init(conf);
            return(cs);
        }
示例#11
0
        public virtual void TestQueueParsingWithLabelsInherit()
        {
            nodeLabelManager.AddToCluserNodeLabels(ImmutableSet.Of("red", "blue"));
            YarnConfiguration conf = new YarnConfiguration();
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(conf);

            SetupQueueConfigurationWithLabelsInherit(csConf);
            CapacityScheduler capacityScheduler = new CapacityScheduler();
            RMContextImpl     rmContext         = new RMContextImpl(null, null, null, null, null, null, new
                                                                    RMContainerTokenSecretManager(csConf), new NMTokenSecretManagerInRM(csConf), new
                                                                    ClientToAMTokenSecretManagerInRM(), null);

            rmContext.SetNodeLabelManager(nodeLabelManager);
            capacityScheduler.SetConf(csConf);
            capacityScheduler.SetRMContext(rmContext);
            capacityScheduler.Init(csConf);
            capacityScheduler.Start();
            CheckQueueLabelsInheritConfig(capacityScheduler);
            ServiceOperations.StopQuietly(capacityScheduler);
        }
示例#12
0
        /// <summary>
        /// Test init a queue configuration, children's capacity for a given label
        /// doesn't equals to 100%.
        /// </summary>
        /// <remarks>
        /// Test init a queue configuration, children's capacity for a given label
        /// doesn't equals to 100%. This expect IllegalArgumentException thrown.
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestQueueParsingFailWhenSumOfChildrenNonLabeledCapacityNot100Percent
            ()
        {
            nodeLabelManager.AddToCluserNodeLabels(ImmutableSet.Of("red", "blue"));
            YarnConfiguration conf = new YarnConfiguration();
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(conf);

            SetupQueueConfiguration(csConf);
            csConf.SetCapacity(CapacitySchedulerConfiguration.Root + ".c.c2", 5);
            CapacityScheduler capacityScheduler = new CapacityScheduler();
            RMContextImpl     rmContext         = new RMContextImpl(null, null, null, null, null, null, new
                                                                    RMContainerTokenSecretManager(csConf), new NMTokenSecretManagerInRM(csConf), new
                                                                    ClientToAMTokenSecretManagerInRM(), null);

            rmContext.SetNodeLabelManager(nodeLabelManager);
            capacityScheduler.SetConf(csConf);
            capacityScheduler.SetRMContext(rmContext);
            capacityScheduler.Init(csConf);
            capacityScheduler.Start();
            ServiceOperations.StopQuietly(capacityScheduler);
        }
示例#13
0
        public virtual void TestQueueParsingWhenLabelsNotExist()
        {
            YarnConfiguration conf = new YarnConfiguration();
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(conf);

            SetupQueueConfigurationWithLabels(csConf);
            CapacityScheduler capacityScheduler = new CapacityScheduler();
            RMContextImpl     rmContext         = new RMContextImpl(null, null, null, null, null, null, new
                                                                    RMContainerTokenSecretManager(csConf), new NMTokenSecretManagerInRM(csConf), new
                                                                    ClientToAMTokenSecretManagerInRM(), null);
            RMNodeLabelsManager nodeLabelsManager = new NullRMNodeLabelsManager();

            nodeLabelsManager.Init(conf);
            nodeLabelsManager.Start();
            rmContext.SetNodeLabelManager(nodeLabelsManager);
            capacityScheduler.SetConf(csConf);
            capacityScheduler.SetRMContext(rmContext);
            capacityScheduler.Init(csConf);
            capacityScheduler.Start();
            ServiceOperations.StopQuietly(capacityScheduler);
            ServiceOperations.StopQuietly(nodeLabelsManager);
        }
        /// <exception cref="System.IO.IOException"/>
        public virtual CapacityScheduler MockCapacityScheduler(int numContainers)
        {
            // stolen from TestCapacityScheduler
            CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();

            SetupQueueConfiguration(conf);
            CapacityScheduler cs = Org.Mockito.Mockito.Spy(new CapacityScheduler());

            cs.SetConf(new YarnConfiguration());
            RMContext mockRmContext = CreateRMContext(conf);

            cs.SetRMContext(mockRmContext);
            try
            {
                cs.ServiceInit(conf);
            }
            catch (Exception e)
            {
                NUnit.Framework.Assert.Fail(e.Message);
            }
            InitializeRMContext(numContainers, cs, mockRmContext);
            return(cs);
        }
示例#15
0
        /// <exception cref="System.Exception"/>
        public virtual void TestQueueMapping()
        {
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();

            SetupQueueConfiguration(csConf);
            YarnConfiguration conf      = new YarnConfiguration(csConf);
            CapacityScheduler cs        = new CapacityScheduler();
            RMContext         rmContext = TestUtils.GetMockRMContext();

            cs.SetConf(conf);
            cs.SetRMContext(rmContext);
            cs.Init(conf);
            cs.Start();
            conf.SetClass(CommonConfigurationKeys.HadoopSecurityGroupMapping, typeof(SimpleGroupsMapping
                                                                                     ), typeof(GroupMappingServiceProvider));
            conf.Set(CapacitySchedulerConfiguration.EnableQueueMappingOverride, "true");
            // configuration parsing tests - negative test cases
            CheckInvalidQMapping(conf, cs, "x:a:b", "invalid specifier");
            CheckInvalidQMapping(conf, cs, "u:a", "no queue specified");
            CheckInvalidQMapping(conf, cs, "g:a", "no queue specified");
            CheckInvalidQMapping(conf, cs, "u:a:b,g:a", "multiple mappings with invalid mapping"
                                 );
            CheckInvalidQMapping(conf, cs, "u:a:b,g:a:d:e", "too many path segments");
            CheckInvalidQMapping(conf, cs, "u::", "empty source and queue");
            CheckInvalidQMapping(conf, cs, "u:", "missing source missing queue");
            CheckInvalidQMapping(conf, cs, "u:a:", "empty source missing q");
            // simple base case for mapping user to queue
            conf.Set(CapacitySchedulerConfiguration.QueueMapping, "u:a:" + Q1);
            cs.Reinitialize(conf, null);
            CheckQMapping("a", Q1, cs);
            // group mapping test
            conf.Set(CapacitySchedulerConfiguration.QueueMapping, "g:agroup:" + Q1);
            cs.Reinitialize(conf, null);
            CheckQMapping("a", Q1, cs);
            // %user tests
            conf.Set(CapacitySchedulerConfiguration.QueueMapping, "u:%user:"******"a", Q2, cs);
            conf.Set(CapacitySchedulerConfiguration.QueueMapping, "u:%user:%user");
            cs.Reinitialize(conf, null);
            CheckQMapping("a", "a", cs);
            // %primary_group tests
            conf.Set(CapacitySchedulerConfiguration.QueueMapping, "u:%user:%primary_group");
            cs.Reinitialize(conf, null);
            CheckQMapping("a", "agroup", cs);
            // non-primary group mapping
            conf.Set(CapacitySchedulerConfiguration.QueueMapping, "g:asubgroup1:" + Q1);
            cs.Reinitialize(conf, null);
            CheckQMapping("a", Q1, cs);
            // space trimming
            conf.Set(CapacitySchedulerConfiguration.QueueMapping, "    u : a : " + Q1);
            cs.Reinitialize(conf, null);
            CheckQMapping("a", Q1, cs);
            csConf = new CapacitySchedulerConfiguration();
            csConf.Set(YarnConfiguration.RmScheduler, typeof(CapacityScheduler).FullName);
            SetupQueueConfiguration(csConf);
            conf            = new YarnConfiguration(csConf);
            resourceManager = new MockRM(csConf);
            resourceManager.Start();
            conf.SetClass(CommonConfigurationKeys.HadoopSecurityGroupMapping, typeof(SimpleGroupsMapping
                                                                                     ), typeof(GroupMappingServiceProvider));
            conf.Set(CapacitySchedulerConfiguration.EnableQueueMappingOverride, "true");
            conf.Set(CapacitySchedulerConfiguration.QueueMapping, "u:user:"******"user", Q2, Q1);
            // toggle admin override and retry
            conf.SetBoolean(CapacitySchedulerConfiguration.EnableQueueMappingOverride, false);
            conf.Set(CapacitySchedulerConfiguration.QueueMapping, "u:user:"******"user", Q2, Q2);
            // ensure that if a user does not specify a Q, the user mapping is used
            CheckAppQueue(resourceManager, "user", null, Q1);
            conf.Set(CapacitySchedulerConfiguration.QueueMapping, "g:usergroup:" + Q2);
            SetupQueueConfiguration(csConf);
            resourceManager.GetResourceScheduler().Reinitialize(conf, null);
            // ensure that if a user does not specify a Q, the group mapping is used
            CheckAppQueue(resourceManager, "user", null, Q2);
            // if the mapping specifies a queue that does not exist, the job is rejected
            conf.Set(CapacitySchedulerConfiguration.QueueMapping, "u:user:non_existent_queue"
                     );
            SetupQueueConfiguration(csConf);
            bool fail = false;

            try
            {
                resourceManager.GetResourceScheduler().Reinitialize(conf, null);
            }
            catch (IOException)
            {
                fail = true;
            }
            NUnit.Framework.Assert.IsTrue("queue initialization failed for non-existent q", fail
                                          );
            resourceManager.Stop();
        }