Exemple #1
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();
        }
Exemple #2
0
        public virtual void SetUp()
        {
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();
            YarnConfiguration conf = new YarnConfiguration();

            SetupQueueConfiguration(csConf);
            rmContext = TestUtils.GetMockRMContext();
            CapacitySchedulerContext csContext = Org.Mockito.Mockito.Mock <CapacitySchedulerContext
                                                                           >();

            Org.Mockito.Mockito.When(csContext.GetConfiguration()).ThenReturn(csConf);
            Org.Mockito.Mockito.When(csContext.GetConf()).ThenReturn(conf);
            Org.Mockito.Mockito.When(csContext.GetMinimumResourceCapability()).ThenReturn(Resources
                                                                                          .CreateResource(Gb, 1));
            Org.Mockito.Mockito.When(csContext.GetMaximumResourceCapability()).ThenReturn(Resources
                                                                                          .CreateResource(16 * Gb, 32));
            Org.Mockito.Mockito.When(csContext.GetClusterResource()).ThenReturn(Resources.CreateResource
                                                                                    (10 * 16 * Gb, 10 * 32));
            Org.Mockito.Mockito.When(csContext.GetApplicationComparator()).ThenReturn(CapacityScheduler
                                                                                      .applicationComparator);
            Org.Mockito.Mockito.When(csContext.GetQueueComparator()).ThenReturn(CapacityScheduler
                                                                                .queueComparator);
            Org.Mockito.Mockito.When(csContext.GetResourceCalculator()).ThenReturn(resourceCalculator
                                                                                   );
            Org.Mockito.Mockito.When(csContext.GetRMContext()).ThenReturn(rmContext);
            RMContainerTokenSecretManager containerTokenSecretManager = new RMContainerTokenSecretManager
                                                                            (conf);

            containerTokenSecretManager.RollMasterKey();
            Org.Mockito.Mockito.When(csContext.GetContainerTokenSecretManager()).ThenReturn(containerTokenSecretManager
                                                                                            );
            IDictionary <string, CSQueue> queues = new Dictionary <string, CSQueue>();
            CSQueue root = CapacityScheduler.ParseQueue(csContext, csConf, null, "root", queues
                                                        , queues, TestUtils.spyHook);

            queue = Org.Mockito.Mockito.Spy(new LeafQueue(csContext, A, root, null));
            // Stub out ACL checks
            Org.Mockito.Mockito.DoReturn(true).When(queue).HasAccess(Matchers.Any <QueueACL>()
                                                                     , Matchers.Any <UserGroupInformation>());
            // Some default values
            Org.Mockito.Mockito.DoReturn(100).When(queue).GetMaxApplications();
            Org.Mockito.Mockito.DoReturn(25).When(queue).GetMaxApplicationsPerUser();
        }