/// <exception cref="System.Exception"/> private void VerifyClusterMetrics(int activeNodes, int appsSubmitted, int appsPending , int containersPending, int availableMB, int activeApplications) { int timeoutSecs = 0; QueueMetrics metrics = rm.GetResourceScheduler().GetRootQueueMetrics(); ClusterMetrics clusterMetrics = ClusterMetrics.GetMetrics(); bool isAllMetricAssertionDone = false; string message = null; while (timeoutSecs++ < 5) { try { // verify queue metrics AssertMetric("appsSubmitted", appsSubmitted, metrics.GetAppsSubmitted()); AssertMetric("appsPending", appsPending, metrics.GetAppsPending()); AssertMetric("containersPending", containersPending, metrics.GetPendingContainers ()); AssertMetric("availableMB", availableMB, metrics.GetAvailableMB()); AssertMetric("activeApplications", activeApplications, metrics.GetActiveApps()); // verify node metric AssertMetric("activeNodes", activeNodes, clusterMetrics.GetNumActiveNMs()); isAllMetricAssertionDone = true; break; } catch (Exception e) { message = e.Message; System.Console.Out.WriteLine("Waiting for metrics assertion to complete"); Sharpen.Thread.Sleep(1000); } } NUnit.Framework.Assert.IsTrue(message, isAllMetricAssertionDone); }