Exemple #1
0
 /// <exception cref="System.Exception"/>
 public virtual void TestZKRMStateStoreRealZK()
 {
     TestZKRMStateStore.TestZKRMStateStoreTester zkTester = new TestZKRMStateStore.TestZKRMStateStoreTester
                                                                (this);
     TestRMAppStateStore(zkTester);
     TestRMDTSecretManagerStateStore(zkTester);
     TestCheckVersion(zkTester);
     TestEpoch(zkTester);
     TestAppDeletion(zkTester);
     TestDeleteStore(zkTester);
     TestAMRMTokenSecretManagerStateStore(zkTester);
 }
Exemple #2
0
        public virtual void TestNoAuthExceptionInNonHAMode()
        {
            TestZKRMStateStore.TestZKRMStateStoreTester zkTester = new TestZKRMStateStore.TestZKRMStateStoreTester
                                                                       (this);
            string    appRoot = zkTester.GetWorkingZNode() + "/ZKRMStateRoot/RMAppRoot";
            ZooKeeper zk      = Org.Mockito.Mockito.Spy(CreateClient());

            Org.Mockito.Mockito.DoThrow(new KeeperException.NoAuthException()).When(zk).Create
                (appRoot, null, RMZKUtils.GetZKAcls(new Configuration()), CreateMode.Persistent);
            try
            {
                zkTester.GetRMStateStore(zk);
                NUnit.Framework.Assert.Fail("Expected exception to be thrown");
            }
            catch (ServiceStateException e)
            {
                NUnit.Framework.Assert.IsNotNull(e.InnerException);
                NUnit.Framework.Assert.IsTrue("Expected NoAuthException", e.InnerException is KeeperException.NoAuthException
                                              );
            }
        }
Exemple #3
0
        public virtual void TestDuplicateRMAppDeletion()
        {
            TestZKRMStateStore.TestZKRMStateStoreTester zkTester = new TestZKRMStateStore.TestZKRMStateStoreTester
                                                                       (this);
            long         submitTime = Runtime.CurrentTimeMillis();
            long         startTime  = Runtime.CurrentTimeMillis() + 1234;
            RMStateStore store      = zkTester.GetRMStateStore();

            RMStateStoreTestBase.TestDispatcher dispatcher = new RMStateStoreTestBase.TestDispatcher
                                                                 ();
            store.SetRMDispatcher(dispatcher);
            ApplicationAttemptId attemptIdRemoved = ConverterUtils.ToApplicationAttemptId("appattempt_1352994193343_0002_000001"
                                                                                          );
            ApplicationId appIdRemoved = attemptIdRemoved.GetApplicationId();

            StoreApp(store, appIdRemoved, submitTime, startTime);
            StoreAttempt(store, attemptIdRemoved, "container_1352994193343_0002_01_000001", null
                         , null, dispatcher);
            ApplicationSubmissionContext context = new ApplicationSubmissionContextPBImpl();

            context.SetApplicationId(appIdRemoved);
            ApplicationStateData appStateRemoved = ApplicationStateData.NewInstance(submitTime
                                                                                    , startTime, context, "user1");

            appStateRemoved.attempts[attemptIdRemoved] = null;
            store.RemoveApplicationStateInternal(appStateRemoved);
            try
            {
                store.RemoveApplicationStateInternal(appStateRemoved);
            }
            catch (KeeperException.NoNodeException)
            {
                NUnit.Framework.Assert.Fail("NoNodeException should not happen.");
            }
            store.Close();
        }
Exemple #4
0
        public virtual void TestFencedState()
        {
            TestZKRMStateStore.TestZKRMStateStoreTester zkTester = new TestZKRMStateStore.TestZKRMStateStoreTester
                                                                       (this);
            RMStateStore store = zkTester.GetRMStateStore();

            // Move state to FENCED from ACTIVE
            store.UpdateFencedState();
            NUnit.Framework.Assert.AreEqual("RMStateStore should have been in fenced state",
                                            true, store.IsFencedState());
            long submitTime = Runtime.CurrentTimeMillis();
            long startTime  = submitTime + 1000;
            // Add a new app
            RMApp mockApp = Org.Mockito.Mockito.Mock <RMApp>();
            ApplicationSubmissionContext context = new ApplicationSubmissionContextPBImpl();

            Org.Mockito.Mockito.When(mockApp.GetSubmitTime()).ThenReturn(submitTime);
            Org.Mockito.Mockito.When(mockApp.GetStartTime()).ThenReturn(startTime);
            Org.Mockito.Mockito.When(mockApp.GetApplicationSubmissionContext()).ThenReturn(context
                                                                                           );
            Org.Mockito.Mockito.When(mockApp.GetUser()).ThenReturn("test");
            store.StoreNewApplication(mockApp);
            NUnit.Framework.Assert.AreEqual("RMStateStore should have been in fenced state",
                                            true, store.IsFencedState());
            // Add a new attempt
            ClientToAMTokenSecretManagerInRM clientToAMTokenMgr = new ClientToAMTokenSecretManagerInRM
                                                                      ();
            ApplicationAttemptId attemptId = ConverterUtils.ToApplicationAttemptId("appattempt_1234567894321_0001_000001"
                                                                                   );
            SecretKey           clientTokenMasterKey    = clientToAMTokenMgr.CreateMasterKey(attemptId);
            RMAppAttemptMetrics mockRmAppAttemptMetrics = Org.Mockito.Mockito.Mock <RMAppAttemptMetrics
                                                                                    >();
            Container container = new ContainerPBImpl();

            container.SetId(ConverterUtils.ToContainerId("container_1234567891234_0001_01_000001"
                                                         ));
            RMAppAttempt mockAttempt = Org.Mockito.Mockito.Mock <RMAppAttempt>();

            Org.Mockito.Mockito.When(mockAttempt.GetAppAttemptId()).ThenReturn(attemptId);
            Org.Mockito.Mockito.When(mockAttempt.GetMasterContainer()).ThenReturn(container);
            Org.Mockito.Mockito.When(mockAttempt.GetClientTokenMasterKey()).ThenReturn(clientTokenMasterKey
                                                                                       );
            Org.Mockito.Mockito.When(mockAttempt.GetRMAppAttemptMetrics()).ThenReturn(mockRmAppAttemptMetrics
                                                                                      );
            Org.Mockito.Mockito.When(mockRmAppAttemptMetrics.GetAggregateAppResourceUsage()).
            ThenReturn(new AggregateAppResourceUsage(0, 0));
            store.StoreNewApplicationAttempt(mockAttempt);
            NUnit.Framework.Assert.AreEqual("RMStateStore should have been in fenced state",
                                            true, store.IsFencedState());
            long finishTime = submitTime + 1000;
            // Update attempt
            ApplicationAttemptStateData newAttemptState = ApplicationAttemptStateData.NewInstance
                                                              (attemptId, container, store.GetCredentialsFromAppAttempt(mockAttempt), startTime
                                                              , RMAppAttemptState.Finished, "testUrl", "test", FinalApplicationStatus.Succeeded
                                                              , 100, finishTime, 0, 0);

            store.UpdateApplicationAttemptState(newAttemptState);
            NUnit.Framework.Assert.AreEqual("RMStateStore should have been in fenced state",
                                            true, store.IsFencedState());
            // Update app
            ApplicationStateData appState = ApplicationStateData.NewInstance(submitTime, startTime
                                                                             , context, "test");

            store.UpdateApplicationState(appState);
            NUnit.Framework.Assert.AreEqual("RMStateStore should have been in fenced state",
                                            true, store.IsFencedState());
            // Remove app
            store.RemoveApplication(mockApp);
            NUnit.Framework.Assert.AreEqual("RMStateStore should have been in fenced state",
                                            true, store.IsFencedState());
            // store RM delegation token;
            RMDelegationTokenIdentifier dtId1 = new RMDelegationTokenIdentifier(new Text("owner1"
                                                                                         ), new Text("renewer1"), new Text("realuser1"));
            long renewDate1 = Runtime.CurrentTimeMillis();

            dtId1.SetSequenceNumber(1111);
            store.StoreRMDelegationToken(dtId1, renewDate1);
            NUnit.Framework.Assert.AreEqual("RMStateStore should have been in fenced state",
                                            true, store.IsFencedState());
            store.UpdateRMDelegationToken(dtId1, renewDate1);
            NUnit.Framework.Assert.AreEqual("RMStateStore should have been in fenced state",
                                            true, store.IsFencedState());
            // remove delegation key;
            store.RemoveRMDelegationToken(dtId1);
            NUnit.Framework.Assert.AreEqual("RMStateStore should have been in fenced state",
                                            true, store.IsFencedState());
            // store delegation master key;
            DelegationKey key = new DelegationKey(1234, 4321, Sharpen.Runtime.GetBytesForString
                                                      ("keyBytes"));

            store.StoreRMDTMasterKey(key);
            NUnit.Framework.Assert.AreEqual("RMStateStore should have been in fenced state",
                                            true, store.IsFencedState());
            // remove delegation master key;
            store.RemoveRMDTMasterKey(key);
            NUnit.Framework.Assert.AreEqual("RMStateStore should have been in fenced state",
                                            true, store.IsFencedState());
            // store or update AMRMToken;
            store.StoreOrUpdateAMRMTokenSecretManager(null, false);
            NUnit.Framework.Assert.AreEqual("RMStateStore should have been in fenced state",
                                            true, store.IsFencedState());
            store.Close();
        }