public virtual void TestAMRMTokenUpdate() { Configuration conf = new Configuration(); ApplicationAttemptId attemptId = ApplicationAttemptId.NewInstance(ApplicationId.NewInstance (1, 1), 1); AMRMTokenIdentifier oldTokenId = new AMRMTokenIdentifier(attemptId, 1); AMRMTokenIdentifier newTokenId = new AMRMTokenIdentifier(attemptId, 2); Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier> oldToken = new Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier>(oldTokenId.GetBytes(), Sharpen.Runtime.GetBytesForString("oldpassword" ), oldTokenId.GetKind(), new Text()); Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier> newToken = new Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier>(newTokenId.GetBytes(), Sharpen.Runtime.GetBytesForString("newpassword" ), newTokenId.GetKind(), new Text()); TestLocalContainerAllocator.MockScheduler scheduler = new TestLocalContainerAllocator.MockScheduler (); scheduler.amToken = newToken; LocalContainerAllocator lca = new TestLocalContainerAllocator.StubbedLocalContainerAllocator (scheduler); lca.Init(conf); lca.Start(); UserGroupInformation testUgi = UserGroupInformation.CreateUserForTesting("someuser" , new string[0]); testUgi.AddToken(oldToken); testUgi.DoAs(new _PrivilegedExceptionAction_144(lca)); lca.Close(); // verify there is only one AMRM token in the UGI and it matches the // updated token from the RM int tokenCount = 0; Org.Apache.Hadoop.Security.Token.Token <TokenIdentifier> ugiToken = null; foreach (Org.Apache.Hadoop.Security.Token.Token <TokenIdentifier> token in testUgi .GetTokens()) { if (AMRMTokenIdentifier.KindName.Equals(token.GetKind())) { ugiToken = token; ++tokenCount; } } NUnit.Framework.Assert.AreEqual("too many AMRM tokens", 1, tokenCount); Assert.AssertArrayEquals("token identifier not updated", newToken.GetIdentifier() , ugiToken.GetIdentifier()); Assert.AssertArrayEquals("token password not updated", newToken.GetPassword(), ugiToken .GetPassword()); NUnit.Framework.Assert.AreEqual("AMRM token service not updated", new Text(ClientRMProxy .GetAMRMTokenService(conf)), ugiToken.GetService()); }
public virtual void TestAllocResponseId() { ApplicationMasterProtocol scheduler = new TestLocalContainerAllocator.MockScheduler (); Configuration conf = new Configuration(); LocalContainerAllocator lca = new TestLocalContainerAllocator.StubbedLocalContainerAllocator (scheduler); lca.Init(conf); lca.Start(); // do two heartbeats to verify the response ID is being tracked lca.Heartbeat(); lca.Heartbeat(); lca.Close(); }