// Other stuff is verified in the regular web-services related tests /// <summary>Test to verify the following RM HA transitions to the following states.</summary> /// <remarks> /// Test to verify the following RM HA transitions to the following states. /// 1. Standby: Should be a no-op /// 2. Active: Active services should start /// 3. Active: Should be a no-op. /// While active, submit a couple of jobs /// 4. Standby: Active services should stop /// 5. Active: Active services should start /// 6. Stop the RM: All services should stop and RM should not be ready to /// become Active /// </remarks> /// <exception cref="System.Exception"/> public virtual void TestFailoverAndTransitions() { configuration.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); Configuration conf = new YarnConfiguration(configuration); rm = new MockRM(conf); rm.Init(conf); HAServiceProtocol.StateChangeRequestInfo requestInfo = new HAServiceProtocol.StateChangeRequestInfo (HAServiceProtocol.RequestSource.RequestByUser); NUnit.Framework.Assert.AreEqual(StateErr, HAServiceProtocol.HAServiceState.Initializing , rm.adminService.GetServiceStatus().GetState()); NUnit.Framework.Assert.IsFalse("RM is ready to become active before being started" , rm.adminService.GetServiceStatus().IsReadyToBecomeActive()); CheckMonitorHealth(); rm.Start(); CheckMonitorHealth(); CheckStandbyRMFunctionality(); VerifyClusterMetrics(0, 0, 0, 0, 0, 0); // 1. Transition to Standby - must be a no-op rm.adminService.TransitionToStandby(requestInfo); CheckMonitorHealth(); CheckStandbyRMFunctionality(); VerifyClusterMetrics(0, 0, 0, 0, 0, 0); // 2. Transition to active rm.adminService.TransitionToActive(requestInfo); CheckMonitorHealth(); CheckActiveRMFunctionality(); VerifyClusterMetrics(1, 1, 1, 1, 2048, 1); // 3. Transition to active - no-op rm.adminService.TransitionToActive(requestInfo); CheckMonitorHealth(); CheckActiveRMFunctionality(); VerifyClusterMetrics(1, 2, 2, 2, 2048, 2); // 4. Transition to standby rm.adminService.TransitionToStandby(requestInfo); CheckMonitorHealth(); CheckStandbyRMFunctionality(); VerifyClusterMetrics(0, 0, 0, 0, 0, 0); // 5. Transition to active to check Active->Standby->Active works rm.adminService.TransitionToActive(requestInfo); CheckMonitorHealth(); CheckActiveRMFunctionality(); VerifyClusterMetrics(1, 1, 1, 1, 2048, 1); // 6. Stop the RM. All services should stop and RM should not be ready to // become active rm.Stop(); NUnit.Framework.Assert.AreEqual(StateErr, HAServiceProtocol.HAServiceState.Stopping , rm.adminService.GetServiceStatus().GetState()); NUnit.Framework.Assert.IsFalse("RM is ready to become active even after it is stopped" , rm.adminService.GetServiceStatus().IsReadyToBecomeActive()); NUnit.Framework.Assert.IsFalse("Active RM services are started", rm.AreActiveServicesRunning ()); CheckMonitorHealth(); }