Пример #1
0
        public static void Setup()
        {
            RMStateStore store = RMStateStoreFactory.GetStore(conf);

            conf.SetBoolean(YarnConfiguration.YarnAclEnable, true);
            AccessControlList adminACL = new AccessControlList(string.Empty);

            adminACL.AddGroup(SuperGroup);
            conf.Set(YarnConfiguration.YarnAdminAcl, adminACL.GetAclString());
            resourceManager = new _MockRM_105(conf);
            new _Thread_127().Start();
            int waitCount = 0;

            while (resourceManager.GetServiceState() == Service.STATE.Inited && waitCount++ <
                   60)
            {
                Log.Info("Waiting for RM to start...");
                Sharpen.Thread.Sleep(1500);
            }
            if (resourceManager.GetServiceState() != Service.STATE.Started)
            {
                // RM could have failed.
                throw new IOException("ResourceManager failed to start. Final state is " + resourceManager
                                      .GetServiceState());
            }
            UserGroupInformation owner = UserGroupInformation.CreateRemoteUser(AppOwner);

            rmClient = owner.DoAs(new _PrivilegedExceptionAction_152());
        }
Пример #2
0
        /// <exception cref="System.Exception"/>
        private void VerifyAdministerQueueUserAccess()
        {
            isQueueUser = true;
            AccessControlList viewACL = new AccessControlList(string.Empty);

            viewACL.AddGroup(FriendlyGroup);
            AccessControlList modifyACL = new AccessControlList(string.Empty);

            modifyACL.AddUser(Friend);
            ApplicationId applicationId = SubmitAppAndGetAppId(viewACL, modifyACL);
            GetApplicationReportRequest appReportRequest = recordFactory.NewRecordInstance <GetApplicationReportRequest
                                                                                            >();

            appReportRequest.SetApplicationId(applicationId);
            KillApplicationRequest finishAppRequest = recordFactory.NewRecordInstance <KillApplicationRequest
                                                                                       >();

            finishAppRequest.SetApplicationId(applicationId);
            ApplicationClientProtocol administerQueueUserRmClient = GetRMClientForUser(QueueAdminUser
                                                                                       );

            // View as the administerQueueUserRmClient
            administerQueueUserRmClient.GetApplicationReport(appReportRequest);
            // List apps as administerQueueUserRmClient
            NUnit.Framework.Assert.AreEqual("App view by queue-admin-user should list the apps!!"
                                            , 5, administerQueueUserRmClient.GetApplications(recordFactory.NewRecordInstance
                                                                                             <GetApplicationsRequest>()).GetApplicationList().Count);
            // Kill app as the administerQueueUserRmClient
            administerQueueUserRmClient.ForceKillApplication(finishAppRequest);
            resourceManager.WaitForState(applicationId, RMAppState.Killed);
        }
Пример #3
0
        /// <exception cref="System.Exception"/>
        private void VerifyOwnerAccess()
        {
            AccessControlList viewACL = new AccessControlList(string.Empty);

            viewACL.AddGroup(FriendlyGroup);
            AccessControlList modifyACL = new AccessControlList(string.Empty);

            modifyACL.AddUser(Friend);
            ApplicationId applicationId = SubmitAppAndGetAppId(viewACL, modifyACL);
            GetApplicationReportRequest appReportRequest = recordFactory.NewRecordInstance <GetApplicationReportRequest
                                                                                            >();

            appReportRequest.SetApplicationId(applicationId);
            KillApplicationRequest finishAppRequest = recordFactory.NewRecordInstance <KillApplicationRequest
                                                                                       >();

            finishAppRequest.SetApplicationId(applicationId);
            // View as owner
            rmClient.GetApplicationReport(appReportRequest);
            // List apps as owner
            NUnit.Framework.Assert.AreEqual("App view by owner should list the apps!!", 1, rmClient
                                            .GetApplications(recordFactory.NewRecordInstance <GetApplicationsRequest>()).GetApplicationList
                                                ().Count);
            // Kill app as owner
            rmClient.ForceKillApplication(finishAppRequest);
            resourceManager.WaitForState(applicationId, RMAppState.Killed);
        }
Пример #4
0
        /// <exception cref="System.Exception"/>
        private void VerifyEnemyAccess()
        {
            AccessControlList viewACL = new AccessControlList(string.Empty);

            viewACL.AddGroup(FriendlyGroup);
            AccessControlList modifyACL = new AccessControlList(string.Empty);

            modifyACL.AddUser(Friend);
            ApplicationId applicationId = SubmitAppAndGetAppId(viewACL, modifyACL);
            GetApplicationReportRequest appReportRequest = recordFactory.NewRecordInstance <GetApplicationReportRequest
                                                                                            >();

            appReportRequest.SetApplicationId(applicationId);
            KillApplicationRequest finishAppRequest = recordFactory.NewRecordInstance <KillApplicationRequest
                                                                                       >();

            finishAppRequest.SetApplicationId(applicationId);
            ApplicationClientProtocol enemyRmClient = GetRMClientForUser(Enemy);
            // View as the enemy
            ApplicationReport appReport = enemyRmClient.GetApplicationReport(appReportRequest
                                                                             ).GetApplicationReport();

            VerifyEnemyAppReport(appReport);
            // List apps as enemy
            IList <ApplicationReport> appReports = enemyRmClient.GetApplications(recordFactory
                                                                                 .NewRecordInstance <GetApplicationsRequest>()).GetApplicationList();

            NUnit.Framework.Assert.AreEqual("App view by enemy should list the apps!!", 4, appReports
                                            .Count);
            foreach (ApplicationReport report in appReports)
            {
                VerifyEnemyAppReport(report);
            }
            // Kill app as the enemy
            try
            {
                enemyRmClient.ForceKillApplication(finishAppRequest);
                NUnit.Framework.Assert.Fail("App killing by the enemy should fail!!");
            }
            catch (YarnException e)
            {
                Log.Info("Got exception while killing app as the enemy", e);
                NUnit.Framework.Assert.IsTrue(e.Message.Contains("User enemy cannot perform operation MODIFY_APP on "
                                                                 + applicationId));
            }
            rmClient.ForceKillApplication(finishAppRequest);
        }