/// <exception cref="System.Exception"/> public virtual void TestRMAppSubmitMaxAppAttempts() { int[] globalMaxAppAttempts = new int[] { 10, 1 }; int[][] individualMaxAppAttempts = new int[][] { new int[] { 9, 10, 11, 0 }, new int[] { 1, 10, 0, -1 } }; int[][] expectedNums = new int[][] { new int[] { 9, 10, 10, 10 }, new int[] { 1, 1, 1, 1 } }; for (int i = 0; i < globalMaxAppAttempts.Length; ++i) { for (int j = 0; j < individualMaxAppAttempts.Length; ++j) { ResourceScheduler scheduler = MockResourceScheduler(); Configuration conf = new Configuration(); conf.SetInt(YarnConfiguration.RmAmMaxAttempts, globalMaxAppAttempts[i]); ApplicationMasterService masterService = new ApplicationMasterService(rmContext, scheduler); TestAppManager.TestRMAppManager appMonitor = new TestAppManager.TestRMAppManager( this, rmContext, new ClientToAMTokenSecretManagerInRM(), scheduler, masterService , new ApplicationACLsManager(conf), conf); ApplicationId appID = MockApps.NewAppID(i * 4 + j + 1); asContext.SetApplicationId(appID); if (individualMaxAppAttempts[i][j] != 0) { asContext.SetMaxAppAttempts(individualMaxAppAttempts[i][j]); } appMonitor.SubmitApplication(asContext, "test"); RMApp app = rmContext.GetRMApps()[appID]; NUnit.Framework.Assert.AreEqual("max application attempts doesn't match", expectedNums [i][j], app.GetMaxAppAttempts()); // wait for event to be processed int timeoutSecs = 0; while ((GetAppEventType() == RMAppEventType.Kill) && timeoutSecs++ < 20) { Sharpen.Thread.Sleep(1000); } SetAppEventType(RMAppEventType.Kill); } } }