Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        public virtual void TestRMConnectionRetry()
        {
            // verify the connection exception is thrown
            // if we haven't exhausted the retry interval
            ApplicationMasterProtocol mockScheduler = Org.Mockito.Mockito.Mock <ApplicationMasterProtocol
                                                                                >();

            Org.Mockito.Mockito.When(mockScheduler.Allocate(Matchers.IsA <AllocateRequest>()))
            .ThenThrow(RPCUtil.GetRemoteException(new IOException("forcefail")));
            Configuration           conf = new Configuration();
            LocalContainerAllocator lca  = new TestLocalContainerAllocator.StubbedLocalContainerAllocator
                                               (mockScheduler);

            lca.Init(conf);
            lca.Start();
            try
            {
                lca.Heartbeat();
                NUnit.Framework.Assert.Fail("heartbeat was supposed to throw");
            }
            catch (YarnException)
            {
            }
            finally
            {
                // YarnException is expected
                lca.Stop();
            }
            // verify YarnRuntimeException is thrown when the retry interval has expired
            conf.SetLong(MRJobConfig.MrAmToRmWaitIntervalMs, 0);
            lca = new TestLocalContainerAllocator.StubbedLocalContainerAllocator(mockScheduler
                                                                                 );
            lca.Init(conf);
            lca.Start();
            try
            {
                lca.Heartbeat();
                NUnit.Framework.Assert.Fail("heartbeat was supposed to throw");
            }
            catch (YarnRuntimeException)
            {
            }
            finally
            {
                // YarnRuntimeException is expected
                lca.Stop();
            }
        }