public virtual void TestGetRMDelegationTokenService()
        {
            string            defaultRMAddress = YarnConfiguration.DefaultRmAddress;
            YarnConfiguration conf             = new YarnConfiguration();
            // HA is not enabled
            Text tokenService = ClientRMProxy.GetRMDelegationTokenService(conf);

            string[] services = tokenService.ToString().Split(",");
            NUnit.Framework.Assert.AreEqual(1, services.Length);
            foreach (string service in services)
            {
                NUnit.Framework.Assert.IsTrue("Incorrect token service name", service.Contains(defaultRMAddress
                                                                                               ));
            }
            // HA is enabled
            conf.SetBoolean(YarnConfiguration.RmHaEnabled, true);
            conf.Set(YarnConfiguration.RmHaIds, "rm1,rm2");
            conf.Set(HAUtil.AddSuffix(YarnConfiguration.RmHostname, "rm1"), "0.0.0.0");
            conf.Set(HAUtil.AddSuffix(YarnConfiguration.RmHostname, "rm2"), "0.0.0.0");
            tokenService = ClientRMProxy.GetRMDelegationTokenService(conf);
            services     = tokenService.ToString().Split(",");
            NUnit.Framework.Assert.AreEqual(2, services.Length);
            foreach (string service_1 in services)
            {
                NUnit.Framework.Assert.IsTrue("Incorrect token service name", service_1.Contains(
                                                  defaultRMAddress));
            }
        }
Beispiel #2
0
        /// <exception cref="System.Exception"/>
        public virtual void TestCancelDelegationTokenOnHA()
        {
            CancelDelegationTokenRequest request = CancelDelegationTokenRequest.NewInstance(cluster
                                                                                            .CreateFakeToken());

            ClientRMProxy.CreateRMProxy <ApplicationClientProtocol>(this.conf).CancelDelegationToken
                (request);
        }
Beispiel #3
0
        /// <exception cref="System.Exception"/>
        public virtual void TestRenewDelegationTokenOnHA()
        {
            RenewDelegationTokenRequest request = RenewDelegationTokenRequest.NewInstance(cluster
                                                                                          .CreateFakeToken());
            long newExpirationTime = ClientRMProxy.CreateRMProxy <ApplicationClientProtocol>(this
                                                                                             .conf).RenewDelegationToken(request).GetNextExpirationTime();

            NUnit.Framework.Assert.AreEqual(newExpirationTime, cluster.CreateNextExpirationTime
                                                ());
        }
 public virtual void Initialize()
 {
     StartHACluster(0, false, false, true);
     attemptId = this.cluster.CreateFakeApplicationAttemptId();
     amClient  = ClientRMProxy.CreateRMProxy <ApplicationMasterProtocol>(this.conf);
     Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier> appToken = this.cluster
                                                                             .GetResourceManager().GetRMContext().GetAMRMTokenSecretManager().CreateAndGetAMRMToken
                                                                                 (attemptId);
     appToken.SetService(ClientRMProxy.GetAMRMTokenService(conf));
     UserGroupInformation.SetLoginUser(UserGroupInformation.CreateRemoteUser(UserGroupInformation
                                                                             .GetCurrentUser().GetUserName()));
     UserGroupInformation.GetCurrentUser().AddToken(appToken);
     SyncToken(appToken);
 }