/// <exception cref="System.Exception"/>
        public virtual void TestMoveTooLate()
        {
            // Submit application
            Application   application = new Application("user1", resourceManager);
            ApplicationId appId       = application.GetApplicationId();

            application.Submit();
            ClientRMService clientRMService = resourceManager.GetClientRMService();

            // Kill the application
            clientRMService.ForceKillApplication(KillApplicationRequest.NewInstance(appId));
            RMApp rmApp = resourceManager.GetRMContext().GetRMApps()[appId];

            // wait until it's dead
            while (rmApp.GetState() != RMAppState.Killed)
            {
                Sharpen.Thread.Sleep(100);
            }
            try
            {
                clientRMService.MoveApplicationAcrossQueues(MoveApplicationAcrossQueuesRequest.NewInstance
                                                                (appId, "newqueue"));
                NUnit.Framework.Assert.Fail("Should have hit exception");
            }
            catch (YarnException ex)
            {
                NUnit.Framework.Assert.AreEqual(typeof(YarnException), ex.GetType());
                NUnit.Framework.Assert.AreEqual("App in KILLED state cannot be moved.", ex.Message
                                                );
            }
        }
Example #2
0
        public static ClientRMService MockClientRMService(RMContext rmContext)
        {
            ClientRMService           clientRMService = Org.Mockito.Mockito.Mock <ClientRMService>();
            IList <ApplicationReport> appReports      = new AList <ApplicationReport>();

            foreach (RMApp app in rmContext.GetRMApps().Values)
            {
                ApplicationReport appReport = ApplicationReport.NewInstance(app.GetApplicationId(
                                                                                ), (ApplicationAttemptId)null, app.GetUser(), app.GetQueue(), app.GetName(), (string
                                                                                                                                                              )null, 0, (Token)null, app.CreateApplicationState(), app.GetDiagnostics().ToString
                                                                                (), (string)null, app.GetStartTime(), app.GetFinishTime(), app.GetFinalApplicationStatus
                                                                                (), (ApplicationResourceUsageReport)null, app.GetTrackingUrl(), app.GetProgress(
                                                                                ), app.GetApplicationType(), (Token)null);
                appReports.AddItem(appReport);
            }
            GetApplicationsResponse response = Org.Mockito.Mockito.Mock <GetApplicationsResponse
                                                                         >();

            Org.Mockito.Mockito.When(response.GetApplicationList()).ThenReturn(appReports);
            try
            {
                Org.Mockito.Mockito.When(clientRMService.GetApplications(Matchers.Any <GetApplicationsRequest
                                                                                       >())).ThenReturn(response);
            }
            catch (YarnException)
            {
                NUnit.Framework.Assert.Fail("Exception is not expteced.");
            }
            return(clientRMService);
        }
        public virtual void TestMoveRejectedByScheduler()
        {
            failMove = true;
            // Submit application
            Application application = new Application("user1", resourceManager);

            application.Submit();
            // Wait for app to be accepted
            RMApp app = resourceManager.rmContext.GetRMApps()[application.GetApplicationId()];

            while (app.GetState() != RMAppState.Accepted)
            {
                Sharpen.Thread.Sleep(100);
            }
            ClientRMService clientRMService = resourceManager.GetClientRMService();

            try
            {
                // FIFO scheduler does not support moves
                clientRMService.MoveApplicationAcrossQueues(MoveApplicationAcrossQueuesRequest.NewInstance
                                                                (application.GetApplicationId(), "newqueue"));
                NUnit.Framework.Assert.Fail("Should have hit exception");
            }
            catch (YarnException ex)
            {
                NUnit.Framework.Assert.AreEqual("Move not supported", ex.InnerException.Message);
            }
        }
        /// <exception cref="System.IO.IOException"/>
        private static ResourceManager MockRmWithApps(RMContext rmContext)
        {
            ResourceManager   rm = Org.Mockito.Mockito.Mock <ResourceManager>();
            ResourceScheduler rs = MockFairSchedulerWithoutApps(rmContext);
            ClientRMService   clientRMService = MockClientRMService(rmContext);

            Org.Mockito.Mockito.When(rm.GetResourceScheduler()).ThenReturn(rs);
            Org.Mockito.Mockito.When(rm.GetRMContext()).ThenReturn(rmContext);
            Org.Mockito.Mockito.When(rm.GetClientRMService()).ThenReturn(clientRMService);
            return(rm);
        }
        public virtual void TestStartupFailure()
        {
            Configuration          conf = new Configuration();
            DelegationTokenRenewer delegationTokenRenewer = new DelegationTokenRenewer();
            RMContext       mockContext         = Org.Mockito.Mockito.Mock <RMContext>();
            ClientRMService mockClientRMService = Org.Mockito.Mockito.Mock <ClientRMService>();

            Org.Mockito.Mockito.When(mockContext.GetClientRMService()).ThenReturn(mockClientRMService
                                                                                  );
            delegationTokenRenewer.SetRMContext(mockContext);
            delegationTokenRenewer.Init(conf);
            delegationTokenRenewer.Stop();
        }
Example #6
0
        /// <exception cref="System.IO.IOException"/>
        public static ResourceManager MockRm(RMContext rmContext)
        {
            ResourceManager        rm              = Org.Mockito.Mockito.Mock <ResourceManager>();
            ResourceScheduler      rs              = MockCapacityScheduler();
            ApplicationACLsManager aclMgr          = MockAppACLsManager();
            ClientRMService        clientRMService = MockClientRMService(rmContext);

            Org.Mockito.Mockito.When(rm.GetResourceScheduler()).ThenReturn(rs);
            Org.Mockito.Mockito.When(rm.GetRMContext()).ThenReturn(rmContext);
            Org.Mockito.Mockito.When(rm.GetApplicationACLsManager()).ThenReturn(aclMgr);
            Org.Mockito.Mockito.When(rm.GetClientRMService()).ThenReturn(clientRMService);
            return(rm);
        }
        /// <exception cref="System.Exception"/>
        public virtual void TestMoveSuccessful()
        {
            MockRM rm1 = new MockRM(conf);

            rm1.Start();
            RMApp           app             = rm1.SubmitApp(1024);
            ClientRMService clientRMService = rm1.GetClientRMService();

            // FIFO scheduler does not support moves
            clientRMService.MoveApplicationAcrossQueues(MoveApplicationAcrossQueuesRequest.NewInstance
                                                            (app.GetApplicationId(), "newqueue"));
            RMApp rmApp = rm1.GetRMContext().GetRMApps()[app.GetApplicationId()];

            NUnit.Framework.Assert.AreEqual("newqueue", rmApp.GetQueue());
            rm1.Stop();
        }
        public virtual void TestMoveRejectedByPermissions()
        {
            failMove = true;
            // Submit application
            Application application = new Application("user1", resourceManager);

            application.Submit();
            ClientRMService clientRMService = resourceManager.GetClientRMService();

            try
            {
                UserGroupInformation.CreateRemoteUser("otheruser").DoAs(new _PrivilegedExceptionAction_151
                                                                            (clientRMService, application));
                NUnit.Framework.Assert.Fail("Should have hit exception");
            }
            catch (Exception ex)
            {
                NUnit.Framework.Assert.AreEqual(typeof(AccessControlException), ex.InnerException
                                                .InnerException.GetType());
            }
        }
Example #9
0
        public virtual void TestAppsRace()
        {
            // mock up an RM that returns app reports for apps that don't exist
            // in the RMApps list
            ApplicationId     appId      = ApplicationId.NewInstance(1, 1);
            ApplicationReport mockReport = Org.Mockito.Mockito.Mock <ApplicationReport>();

            Org.Mockito.Mockito.When(mockReport.GetApplicationId()).ThenReturn(appId);
            GetApplicationsResponse mockAppsResponse = Org.Mockito.Mockito.Mock <GetApplicationsResponse
                                                                                 >();

            Org.Mockito.Mockito.When(mockAppsResponse.GetApplicationList()).ThenReturn(Arrays
                                                                                       .AsList(new ApplicationReport[] { mockReport }));
            ClientRMService mockClientSvc = Org.Mockito.Mockito.Mock <ClientRMService>();

            Org.Mockito.Mockito.When(mockClientSvc.GetApplications(Matchers.IsA <GetApplicationsRequest
                                                                                 >(), Matchers.AnyBoolean())).ThenReturn(mockAppsResponse);
            ResourceManager mockRM    = Org.Mockito.Mockito.Mock <ResourceManager>();
            RMContextImpl   rmContext = new RMContextImpl(null, null, null, null, null, null, null
                                                          , null, null, null);

            Org.Mockito.Mockito.When(mockRM.GetRMContext()).ThenReturn(rmContext);
            Org.Mockito.Mockito.When(mockRM.GetClientRMService()).ThenReturn(mockClientSvc);
            RMWebServices webSvc = new RMWebServices(mockRM, new Configuration(), Org.Mockito.Mockito.Mock
                                                     <HttpServletResponse>());
            ICollection <string> emptySet = Collections.UnmodifiableSet(Collections.EmptySet <string
                                                                                              >());
            // verify we don't get any apps when querying
            HttpServletRequest mockHsr  = Org.Mockito.Mockito.Mock <HttpServletRequest>();
            AppsInfo           appsInfo = webSvc.GetApps(mockHsr, null, emptySet, null, null, null, null
                                                         , null, null, null, null, emptySet, emptySet);

            NUnit.Framework.Assert.IsTrue(appsInfo.GetApps().IsEmpty());
            // verify we don't get an NPE when specifying a final status query
            appsInfo = webSvc.GetApps(mockHsr, null, emptySet, "FAILED", null, null, null, null
                                      , null, null, null, emptySet, emptySet);
            NUnit.Framework.Assert.IsTrue(appsInfo.GetApps().IsEmpty());
        }
Example #10
0
 public virtual void SetClientRMService(ClientRMService clientRMService)
 {
     activeServiceContext.SetClientRMService(clientRMService);
 }
 public _PrivilegedExceptionAction_151(ClientRMService clientRMService, Application
                                       application)
 {
     this.clientRMService = clientRMService;
     this.application     = application;
 }
 public virtual void SetClientRMService(ClientRMService clientRMService)
 {
     this.clientRMService = clientRMService;
 }